# h248.cnf
# H.248 conformation file

#.MODULE_IMPORT

#.EXPORTS

#.PDU

#.NO_EMIT
MtpAddress
PkgdName
ErrorCode
PropertyID
SignalName
SigParameterName
SigParamValue
EventName
EventParameterName
EventParamValue
ContextID
EventParamValueV1
SigParamValueV1

#.TYPE_RENAME
IndAudMediaDescriptor/streams			IndAudMediaDescriptorStreams
ActionRequest/contextId					ContextId
ActionReply/contextId					ContextId
StatisticsParameter/statName			StatName
StatisticsParameter/statValue			StatValue
PropertyParm/propertyName				PropertyName
EventParameter/extraInfo				EventPar_extraInfo
PropertyParm/extraInfo					PropParm_extraInfo
ContextRequest/iepscallind				Iepscallind_BOOL

#.FIELD_RENAME
IP4Address/address		iP4Address
IP6Address/address		iP6Address
ContextAttrAuditRequest/emergency	cAAREmergency
ContextAttrAuditRequest/priority	cAARPriority
SecondRequestedEvent/eventAction	secondaryEventAction
TerminationStateDescriptor/eventBufferControl	tSEventBufferControl
SecondEventsDescriptor/eventList	secondaryEventList
IndAudEventBufferDescriptor/eventName	iAEBDEventName
TerminationID/id			terminationId
IndAudStreamParms/localControlDescriptor iASPLocalControlDescriptor
IndAudStreamParms/localDescriptor	iASPLocalDescriptor
LocalControlDescriptor/propertyParms lCDpropertyParms
TerminationStateDescriptor/propertyParms tSDpropertyParms
MediaDescriptor/streams/oneStream	mediaDescriptorOneStream
MediaDescriptor/streams/multiStream	mediaDescriptorMultiStream
MediaDescriptor/streams/multiStream/_item	mediaDescriptorMultiStream_item
DomainName/name				domName
IndAudEventsDescriptor/pkgdName		iAEDPkgdName
IndAudLocalRemoteDescriptor/propGrps	iAPropertyGroup
IndAudLocalControlDescriptor/propertyParms	indAudPropertyParms
IndAudTerminationStateDescriptor/propertyParms	indAudPropertyParms
IndAudLocalControlDescriptor/reserveGroup	iALCDReserveGroup
IndAudLocalControlDescriptor/reserveValue	iALCDReserveValue
IndAudLocalControlDescriptor/streamMode		iALCDStreamMode
IndAudStreamDescriptor/streamParms		indAudStreamParms
IndAudMediaDescriptor/termStateDescr		indAudTerminationStateDescriptor
IndAudSignal/signalName				iASignalName
IndAudSeqSigList/signalList			iASignalList
IndAudSignalsDescriptor/signal			indAudSignal
IndAudSignalsDescriptor/seqSigList		indAudSeqSigList
IndAudTerminationStateDescriptor/serviceState	iATSDServiceState
IndAudStreamParms/remoteDescriptor		iASPRemoteDescriptor
PropertyParm/value				propertyParamValue
IndAudMediaDescriptor/streams			indAudMediaDescriptorStreams
AmmRequest/terminationID			terminationIDList
AmmsReply/terminationID			terminationIDList
AmmDescriptor/statisticsDescriptor	aDstatisticsDescriptor
AuditReturnParameter/statisticsDescriptor	aRPstatisticsDescriptor
StreamParms/statisticsDescriptor				sPstatisticsDescriptor
SubtractRequest/terminationID			terminationIDList
NotifyRequest/terminationID			terminationIDList
NotifyReply/terminationID			terminationIDList
ServiceChangeRequest/terminationID			terminationIDList
ServiceChangeReply/terminationID			terminationIDList
IndAudStatisticsDescriptor/statName		iAStatName
EventParameter/extraInfo				eventPar_extraInfo
PropertyParm/extraInfo					propParm_extraInfo
ContextRequest/iepscallind				iepscallind_BOOL
TransactionRequest/transactionId	transactionId
SegmentReply/transactionId			seg_rep_transactionId
TransactionReply/transactionId		trep_transactionId
TransactionPending/transactionId	tpend_transactionId
EventParameterV1/value		event_param_value
SigParameterV1/value		sig_param_value
AuditReplyV1/auditResult	audit_result

#.FIELD_ATTR
IP4Address/address                  ABBREV=iP4Address
IP6Address/address                  ABBREV=iP6Address
TransactionRequest/transactionId    ABBREV=transactionRequest.transactionId
SegmentReply/transactionId          ABBREV=segmentreply.transactionId
TransactionReply/transactionId      ABBREV=transactionreply.transactionId
TransactionPending/transactionId    ABBREV=transactionpending.transactionId
DomainName/name                     ABBREV=domainname
TerminationID/id                    ABBREV=terminationId
PropertyParm/value                  ABBREV=propertyParamValue
EventParameterV1/value              ABBREV=event_param_value
SigParameterV1/value                ABBREV=sig_param_value

#.FN_HDR Message
    curr_info.msg = gcp_msg(actx->pinfo,tvb_raw_offset(tvb),keep_persistent_data);
#.END

#.FN_FTR Message
    col_add_str(actx->pinfo->cinfo, COL_INFO, gcp_msg_to_str(curr_info.msg,actx->pinfo->pool,keep_persistent_data));

    if (keep_persistent_data)
        gcp_analyze_msg(h248_tree, actx->pinfo, tvb, curr_info.msg, &h248_arrel, &ei_h248_errored_command);
#.END

#.FN_BODY Message/version VAL_PTR = &h248_version
	%(DEFAULT_BODY)s
#.END

#.FN_BODY TransactionRequest/transactionId
    uint32_t trx_id = 0;
	offset = dissect_h248_trx_id(implicit_tag, actx->pinfo, tree, tvb, offset, &trx_id);
    curr_info.trx = gcp_trx(curr_info.msg, trx_id, GCP_TRX_REQUEST, actx->pinfo, keep_persistent_data);
    error_code = 0;
#.END

#.FN_BODY TransactionPending/transactionId
    uint32_t trx_id = 0;
	offset = dissect_h248_trx_id(implicit_tag, actx->pinfo, tree, tvb, offset, &trx_id);
    curr_info.trx = gcp_trx(curr_info.msg, trx_id, GCP_TRX_PENDING, actx->pinfo, keep_persistent_data);
    error_code = 0;

#.FN_BODY TransactionReply/transactionId
    uint32_t trx_id = 0;
	offset = dissect_h248_trx_id(implicit_tag, actx->pinfo, tree, tvb, offset, &trx_id);
    curr_info.trx = gcp_trx(curr_info.msg, trx_id, GCP_TRX_REPLY, actx->pinfo, keep_persistent_data);
    error_code = 0;

#.FN_BODY SegmentReply/transactionId
    uint32_t trx_id = 0;
	offset = dissect_h248_trx_id(implicit_tag, actx->pinfo, tree, tvb, offset, &trx_id);
    curr_info.trx = gcp_trx(curr_info.msg, trx_id, GCP_TRX_ACK, actx->pinfo, keep_persistent_data);
    error_code = 0;

#.FN_BODY ActionRequest/contextId
    uint32_t ctx_id = 0;
	offset = dissect_h248_ctx_id(implicit_tag, actx->pinfo, tree, tvb, offset, &ctx_id);
    curr_info.ctx = gcp_ctx(curr_info.msg,curr_info.trx,ctx_id,actx->pinfo,keep_persistent_data);
    curr_info.cmd = NULL;
    curr_info.term = NULL;
#.END


#.FN_FTR ActionReply
    if (!curr_info.cmd) {
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
	}
#.END

#.FN_HDR Command/addReq
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_ADD_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_FTR Command/addReq
      curr_info.cmd = NULL;
#.END

#.FN_HDR Command/moveReq
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_MOVE_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();

#.END

#.FN_FTR Command/moveReq
      curr_info.cmd = NULL;
#.END

#.FN_HDR Command/modReq
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_MOD_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR Command/modReq
      curr_info.cmd = NULL;
#.END

#.FN_HDR Command/subtractReq
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_SUB_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR Command/subtractReq
      curr_info.cmd = NULL;
#.END

#.FN_HDR Command/auditCapRequest
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_AUDITCAP_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR Command/auditCapRequest
      curr_info.cmd = NULL;
#.END

#.FN_HDR Command/auditValueRequest
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_AUDITVAL_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR Command/auditValueRequest
      curr_info.cmd = NULL;
#.END

#.FN_HDR Command/notifyReq
	  curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_NOTIFY_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR Command/notifyReq
      curr_info.cmd = NULL;
#.END

#.FN_HDR ServiceChangeRequest
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_SVCCHG_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR ServiceChangeRequest
      curr_info.cmd = NULL;
#.END

#.FN_HDR ContextRequest/topologyReq
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_TOPOLOGY_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR ContextRequest/topologyReq
      curr_info.cmd = NULL;
#.END

#.FN_HDR ActionRequest/contextAttrAuditReq
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_CTX_ATTR_AUDIT_REQ,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END
#.FN_FTR ActionRequest/contextAttrAuditReq
      curr_info.cmd = NULL;
#.END

#.FN_HDR CommandReply/addReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_ADD_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_HDR CommandReply/moveReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_MOVE_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_HDR CommandReply/modReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_MOD_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_HDR CommandReply/subtractReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_SUB_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_HDR CommandReply/notifyReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_NOTIFY_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_HDR ServiceChangeReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_SVCCHG_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_HDR CommandReply/auditCapReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_AUDITCAP_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_BODY CommandReply/auditCapReply
/* h248v1 support */
	if(h248_version > 1) {
		%(DEFAULT_BODY)s
} else {
	/* call V1 of the dissector */
	offset = dissect_h248_AuditReplyV1(implicit_tag, tvb, offset, actx, tree, hf_index);
}
#.END

#.FN_HDR CommandReply/auditValueReply
      curr_info.cmd = gcp_cmd(curr_info.msg,curr_info.trx,curr_info.ctx,GCP_CMD_AUDITVAL_REPLY,offset,actx->pinfo,keep_persistent_data);
      H248_TAP();
#.END

#.FN_BODY CommandReply/auditValueReply
/* h248v1 support */
	if(h248_version > 1) {
		%(DEFAULT_BODY)s
} else {
	/* call V1 of the dissector */
	offset = dissect_h248_AuditReplyV1(implicit_tag, tvb, offset, actx, tree, hf_index);
}
#.END

#.FN_BODY AuditReplyV1
/* h248v1 support */
	offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
		AuditReplyV1_sequence, hf_h248_auditValueReplyV1, ett_h248_AuditReplyV1);
#.END

#.FN_BODY ErrorDescriptor/errorCode
    offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, &error_code);
    expert_add_info(actx->pinfo, actx->created_item, &ei_h248_errored_command);

    if (curr_info.cmd) {
        gcp_cmd_set_error(curr_info.cmd,error_code);
    } else if (curr_info.trx) {
        gcp_trx_set_error(curr_info.trx,error_code);
    }
#.END

#.FN_HDR TerminationID
    curr_info.term = wmem_new0(actx->pinfo->pool, gcp_term_t);
    wild_term = GCP_WILDCARD_NONE;
#.END

#.FN_BODY WildcardField
    tvbuff_t* new_tvb;
    offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb);
    tree = proto_item_add_subtree(actx->created_item,ett_wildcard);
    proto_tree_add_item(tree,hf_h248_term_wild_type,new_tvb,0,1,ENC_BIG_ENDIAN);
    proto_tree_add_item(tree,hf_h248_term_wild_level,new_tvb,0,1,ENC_BIG_ENDIAN);
    proto_tree_add_item(tree,hf_h248_term_wild_position,new_tvb,0,1,ENC_BIG_ENDIAN);

    wild_term = tvb_get_uint8(new_tvb,0) & 0x80 ? GCP_WILDCARD_CHOOSE : GCP_WILDCARD_ALL;
    /* limitation: assume only one wildcard is used */
    wild_card = tvb_get_uint8(new_tvb,0);

#.END

#.FN_BODY TerminationID/id
	tvbuff_t* new_tvb;
	h248_term_info_t term_info;

	term_info.wild_card = wild_card;
	term_info.str = NULL;

	offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb);

	if (new_tvb) {
		curr_info.term->len = tvb_reported_length(new_tvb);
		curr_info.term->type = 0; /* unknown */

		if (h248_term_handle) {
			call_dissector_with_data(h248_term_handle, new_tvb, actx->pinfo, tree, &term_info);
			wild_card = 0xFF;
		}

		if (curr_info.term->len) {
			curr_info.term->buffer = (uint8_t *)tvb_memdup(actx->pinfo->pool,new_tvb,0,curr_info.term->len);
			if(term_info.str){
				curr_info.term->str = wmem_strdup_printf(actx->pinfo->pool, "%s %s",
											bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0),
											term_info.str);
			}else{
				curr_info.term->str = bytes_to_str_punct(actx->pinfo->pool,curr_info.term->buffer,curr_info.term->len, 0);
			}
		}


		curr_info.term = gcp_cmd_add_term(curr_info.msg, curr_info.trx, curr_info.cmd, curr_info.term, wild_term, actx->pinfo, keep_persistent_data);

	} else {
		curr_info.term->len = 0;
		curr_info.term->buffer = (uint8_t*)wmem_strdup(actx->pinfo->pool, "");
		curr_info.term->str = wmem_strdup(actx->pinfo->pool, "?");
	}
#.END

#.FN_BODY SCreasonValueOctetStr VAL_PTR = &parameter_tvb
 tvbuff_t	*parameter_tvb;
 %(DEFAULT_BODY)s

 if (!parameter_tvb)
	return offset;

 dissect_h248_ServiceChangeReasonStr(false, parameter_tvb, 0, actx, tree, hf_h248_serviceChangeReasonStr);
#.END

#.FN_BODY EventParameter
/* H248 v1 support */
	if (h248_version > 1) {
		%(DEFAULT_BODY)s
} else {
	offset = dissect_h248_EventParameterV1( implicit_tag, tvb, offset, actx, tree, hf_index);
}
#.END

#.FN_BODY SigParameter
/* H248 v1 support */
	if (h248_version > 1) {
		%(DEFAULT_BODY)s
} else {
	offset = dissect_h248_SigParameterV1( implicit_tag, tvb, offset, actx, tree, hf_index);
}
#.END

#.TYPE_ATTR
IP4Address/address  TYPE = FT_IPv4  DISPLAY = BASE_NONE  STRINGS = NULL
IP6Address/address  TYPE = FT_IPv6  DISPLAY = BASE_NONE  STRINGS = NULL
ActionRequest/contextId TYPE = FT_UINT32 DISPLAY = BASE_HEX STRINGS = NULL
ActionReply/contextId TYPE = FT_UINT32 DISPLAY = BASE_HEX STRINGS = NULL
ErrorDescriptor/errorCode TYPE = FT_UINT32 DISPLAY = BASE_DEC|BASE_EXT_STRING STRINGS = &h248_reasons_ext