%% Generated by the Erlang ASN.1 BER-compiler version:1.4.4.11
%% Purpose: encoder and decoder to the types in mod megaco_ber_media_gateway_control_prev3c

-module('megaco_ber_media_gateway_control_prev3c').
-include("megaco_ber_media_gateway_control_prev3c.hrl").
-define('RT_BER',asn1rt_ber_bin).
-export([encoding_rule/0]).
-export([
'enc_Value'/2,
'enc_TimeNotation'/2,
'enc_H221NonStandard'/2,
'enc_NonStandardIdentifier'/2,
'enc_NonStandardData'/2,
'enc_StatisticsParameter'/2,
'enc_StatisticsDescriptor'/2,
'enc_PackagesItem'/2,
'enc_PackagesDescriptor'/2,
'enc_ServiceChangeProfile'/2,
'enc_ServiceChangeMethod'/2,
'enc_ServiceChangeResParm'/2,
'enc_ServiceChangeAddress'/2,
'enc_ServiceChangeParm'/2,
'enc_DigitMapValue'/2,
'enc_DigitMapName'/2,
'enc_DigitMapDescriptor'/2,
'enc_ModemType'/2,
'enc_ModemDescriptor'/2,
'enc_RequestID'/2,
'enc_SigParameter'/2,
'enc_NotifyCompletion'/2,
'enc_SignalName'/2,
'enc_SignalDirection'/2,
'enc_SignalType'/2,
'enc_Signal'/2,
'enc_SeqSigList'/2,
'enc_SignalRequest'/2,
'enc_SignalsDescriptor'/2,
'enc_EventSpec'/2,
'enc_EventBufferDescriptor'/2,
'enc_SecondRequestedActions'/2,
'enc_SecondRequestedEvent'/2,
'enc_SecondEventsDescriptor'/2,
'enc_EventDM'/2,
'enc_RequestedActions'/2,
'enc_NotifyBehaviour'/2,
'enc_RegulatedEmbeddedDescriptor'/2,
'enc_RequestedEvent'/2,
'enc_EventsDescriptor'/2,
'enc_StreamID'/2,
'enc_MuxType'/2,
'enc_MuxDescriptor'/2,
'enc_ServiceState'/2,
'enc_EventBufferControl'/2,
'enc_TerminationStateDescriptor'/2,
'enc_PropertyGroup'/2,
'enc_LocalRemoteDescriptor'/2,
'enc_Relation'/2,
'enc_PkgdName'/2,
'enc_Name'/2,
'enc_PropertyParm'/2,
'enc_StreamMode'/2,
'enc_LocalControlDescriptor'/2,
'enc_StreamParms'/2,
'enc_StreamDescriptor'/2,
'enc_MediaDescriptor'/2,
'enc_TerminationIDList'/2,
'enc_TerminationID'/2,
'enc_WildcardField'/2,
'enc_ServiceChangeResult'/2,
'enc_ServiceChangeReply'/2,
'enc_ServiceChangeRequest'/2,
'enc_EventParameter'/2,
'enc_EventName'/2,
'enc_ObservedEvent'/2,
'enc_ObservedEventsDescriptor'/2,
'enc_NotifyReply'/2,
'enc_NotifyRequest'/2,
'enc_IndAudPackagesDescriptor'/2,
'enc_IndAudStatisticsDescriptor'/2,
'enc_IndAudDigitMapDescriptor'/2,
'enc_IndAudSignal'/2,
'enc_IndAudSeqSigList'/2,
'enc_IndAudSignalsDescriptor'/2,
'enc_IndAudEventBufferDescriptor'/2,
'enc_IndAudEventsDescriptor'/2,
'enc_IndAudTerminationStateDescriptor'/2,
'enc_IndAudPropertyGroup'/2,
'enc_IndAudLocalRemoteDescriptor'/2,
'enc_IndAudPropertyParm'/2,
'enc_IndAudLocalControlDescriptor'/2,
'enc_IndAudStreamParms'/2,
'enc_IndAudStreamDescriptor'/2,
'enc_IndAudMediaDescriptor'/2,
'enc_IndAuditParameter'/2,
'enc_AuditDescriptor'/2,
'enc_AuditReturnParameter'/2,
'enc_TerminationAudit'/2,
'enc_TermListAuditResult'/2,
'enc_AuditResult'/2,
'enc_AuditReply'/2,
'enc_AuditRequest'/2,
'enc_SubtractRequest'/2,
'enc_AmmsReply'/2,
'enc_AmmDescriptor'/2,
'enc_AmmRequest'/2,
'enc_TopologyRequest'/2,
'enc_CommandReply'/2,
'enc_Command'/2,
'enc_CommandRequest'/2,
'enc_SelectLogic'/2,
'enc_ContextAttrAuditRequest'/2,
'enc_ContextRequest'/2,
'enc_ActionReply'/2,
'enc_ActionRequest'/2,
'enc_ContextID'/2,
'enc_ErrorText'/2,
'enc_ErrorCode'/2,
'enc_ErrorDescriptor'/2,
'enc_TransactionAck'/2,
'enc_TransactionResponseAck'/2,
'enc_TransactionReply'/2,
'enc_TransactionPending'/2,
'enc_TransactionRequest'/2,
'enc_TransactionId'/2,
'enc_Transaction'/2,
'enc_PathName'/2,
'enc_IP6Address'/2,
'enc_IP4Address'/2,
'enc_DomainName'/2,
'enc_MId'/2,
'enc_Message'/2,
'enc_AuthData'/2,
'enc_SequenceNum'/2,
'enc_SecurityParmIndex'/2,
'enc_AuthenticationHeader'/2,
'enc_MegacoMessage'/2
]).

-export([
'dec_Value'/2,
'dec_TimeNotation'/2,
'dec_H221NonStandard'/2,
'dec_NonStandardIdentifier'/2,
'dec_NonStandardData'/2,
'dec_StatisticsParameter'/2,
'dec_StatisticsDescriptor'/2,
'dec_PackagesItem'/2,
'dec_PackagesDescriptor'/2,
'dec_ServiceChangeProfile'/2,
'dec_ServiceChangeMethod'/2,
'dec_ServiceChangeResParm'/2,
'dec_ServiceChangeAddress'/2,
'dec_ServiceChangeParm'/2,
'dec_DigitMapValue'/2,
'dec_DigitMapName'/2,
'dec_DigitMapDescriptor'/2,
'dec_ModemType'/2,
'dec_ModemDescriptor'/2,
'dec_RequestID'/2,
'dec_SigParameter'/2,
'dec_NotifyCompletion'/2,
'dec_SignalName'/2,
'dec_SignalDirection'/2,
'dec_SignalType'/2,
'dec_Signal'/2,
'dec_SeqSigList'/2,
'dec_SignalRequest'/2,
'dec_SignalsDescriptor'/2,
'dec_EventSpec'/2,
'dec_EventBufferDescriptor'/2,
'dec_SecondRequestedActions'/2,
'dec_SecondRequestedEvent'/2,
'dec_SecondEventsDescriptor'/2,
'dec_EventDM'/2,
'dec_RequestedActions'/2,
'dec_NotifyBehaviour'/2,
'dec_RegulatedEmbeddedDescriptor'/2,
'dec_RequestedEvent'/2,
'dec_EventsDescriptor'/2,
'dec_StreamID'/2,
'dec_MuxType'/2,
'dec_MuxDescriptor'/2,
'dec_ServiceState'/2,
'dec_EventBufferControl'/2,
'dec_TerminationStateDescriptor'/2,
'dec_PropertyGroup'/2,
'dec_LocalRemoteDescriptor'/2,
'dec_Relation'/2,
'dec_PkgdName'/2,
'dec_Name'/2,
'dec_PropertyParm'/2,
'dec_StreamMode'/2,
'dec_LocalControlDescriptor'/2,
'dec_StreamParms'/2,
'dec_StreamDescriptor'/2,
'dec_MediaDescriptor'/2,
'dec_TerminationIDList'/2,
'dec_TerminationID'/2,
'dec_WildcardField'/2,
'dec_ServiceChangeResult'/2,
'dec_ServiceChangeReply'/2,
'dec_ServiceChangeRequest'/2,
'dec_EventParameter'/2,
'dec_EventName'/2,
'dec_ObservedEvent'/2,
'dec_ObservedEventsDescriptor'/2,
'dec_NotifyReply'/2,
'dec_NotifyRequest'/2,
'dec_IndAudPackagesDescriptor'/2,
'dec_IndAudStatisticsDescriptor'/2,
'dec_IndAudDigitMapDescriptor'/2,
'dec_IndAudSignal'/2,
'dec_IndAudSeqSigList'/2,
'dec_IndAudSignalsDescriptor'/2,
'dec_IndAudEventBufferDescriptor'/2,
'dec_IndAudEventsDescriptor'/2,
'dec_IndAudTerminationStateDescriptor'/2,
'dec_IndAudPropertyGroup'/2,
'dec_IndAudLocalRemoteDescriptor'/2,
'dec_IndAudPropertyParm'/2,
'dec_IndAudLocalControlDescriptor'/2,
'dec_IndAudStreamParms'/2,
'dec_IndAudStreamDescriptor'/2,
'dec_IndAudMediaDescriptor'/2,
'dec_IndAuditParameter'/2,
'dec_AuditDescriptor'/2,
'dec_AuditReturnParameter'/2,
'dec_TerminationAudit'/2,
'dec_TermListAuditResult'/2,
'dec_AuditResult'/2,
'dec_AuditReply'/2,
'dec_AuditRequest'/2,
'dec_SubtractRequest'/2,
'dec_AmmsReply'/2,
'dec_AmmDescriptor'/2,
'dec_AmmRequest'/2,
'dec_TopologyRequest'/2,
'dec_CommandReply'/2,
'dec_Command'/2,
'dec_CommandRequest'/2,
'dec_SelectLogic'/2,
'dec_ContextAttrAuditRequest'/2,
'dec_ContextRequest'/2,
'dec_ActionReply'/2,
'dec_ActionRequest'/2,
'dec_ContextID'/2,
'dec_ErrorText'/2,
'dec_ErrorCode'/2,
'dec_ErrorDescriptor'/2,
'dec_TransactionAck'/2,
'dec_TransactionResponseAck'/2,
'dec_TransactionReply'/2,
'dec_TransactionPending'/2,
'dec_TransactionRequest'/2,
'dec_TransactionId'/2,
'dec_Transaction'/2,
'dec_PathName'/2,
'dec_IP6Address'/2,
'dec_IP4Address'/2,
'dec_DomainName'/2,
'dec_MId'/2,
'dec_Message'/2,
'dec_AuthData'/2,
'dec_SequenceNum'/2,
'dec_SecurityParmIndex'/2,
'dec_AuthenticationHeader'/2,
'dec_MegacoMessage'/2
]).

-export([
'dec_Value'/3,
'dec_TimeNotation'/3,
'dec_H221NonStandard'/3,
'dec_NonStandardIdentifier'/3,
'dec_NonStandardData'/3,
'dec_StatisticsParameter'/3,
'dec_StatisticsDescriptor'/3,
'dec_PackagesItem'/3,
'dec_PackagesDescriptor'/3,
'dec_ServiceChangeProfile'/3,
'dec_ServiceChangeMethod'/3,
'dec_ServiceChangeResParm'/3,
'dec_ServiceChangeAddress'/3,
'dec_ServiceChangeParm'/3,
'dec_DigitMapValue'/3,
'dec_DigitMapName'/3,
'dec_DigitMapDescriptor'/3,
'dec_ModemType'/3,
'dec_ModemDescriptor'/3,
'dec_RequestID'/3,
'dec_SigParameter'/3,
'dec_NotifyCompletion'/3,
'dec_SignalName'/3,
'dec_SignalDirection'/3,
'dec_SignalType'/3,
'dec_Signal'/3,
'dec_SeqSigList'/3,
'dec_SignalRequest'/3,
'dec_SignalsDescriptor'/3,
'dec_EventSpec'/3,
'dec_EventBufferDescriptor'/3,
'dec_SecondRequestedActions'/3,
'dec_SecondRequestedEvent'/3,
'dec_SecondEventsDescriptor'/3,
'dec_EventDM'/3,
'dec_RequestedActions'/3,
'dec_NotifyBehaviour'/3,
'dec_RegulatedEmbeddedDescriptor'/3,
'dec_RequestedEvent'/3,
'dec_EventsDescriptor'/3,
'dec_StreamID'/3,
'dec_MuxType'/3,
'dec_MuxDescriptor'/3,
'dec_ServiceState'/3,
'dec_EventBufferControl'/3,
'dec_TerminationStateDescriptor'/3,
'dec_PropertyGroup'/3,
'dec_LocalRemoteDescriptor'/3,
'dec_Relation'/3,
'dec_PkgdName'/3,
'dec_Name'/3,
'dec_PropertyParm'/3,
'dec_StreamMode'/3,
'dec_LocalControlDescriptor'/3,
'dec_StreamParms'/3,
'dec_StreamDescriptor'/3,
'dec_MediaDescriptor'/3,
'dec_TerminationIDList'/3,
'dec_TerminationID'/3,
'dec_WildcardField'/3,
'dec_ServiceChangeResult'/3,
'dec_ServiceChangeReply'/3,
'dec_ServiceChangeRequest'/3,
'dec_EventParameter'/3,
'dec_EventName'/3,
'dec_ObservedEvent'/3,
'dec_ObservedEventsDescriptor'/3,
'dec_NotifyReply'/3,
'dec_NotifyRequest'/3,
'dec_IndAudPackagesDescriptor'/3,
'dec_IndAudStatisticsDescriptor'/3,
'dec_IndAudDigitMapDescriptor'/3,
'dec_IndAudSignal'/3,
'dec_IndAudSeqSigList'/3,
'dec_IndAudSignalsDescriptor'/3,
'dec_IndAudEventBufferDescriptor'/3,
'dec_IndAudEventsDescriptor'/3,
'dec_IndAudTerminationStateDescriptor'/3,
'dec_IndAudPropertyGroup'/3,
'dec_IndAudLocalRemoteDescriptor'/3,
'dec_IndAudPropertyParm'/3,
'dec_IndAudLocalControlDescriptor'/3,
'dec_IndAudStreamParms'/3,
'dec_IndAudStreamDescriptor'/3,
'dec_IndAudMediaDescriptor'/3,
'dec_IndAuditParameter'/3,
'dec_AuditDescriptor'/3,
'dec_AuditReturnParameter'/3,
'dec_TerminationAudit'/3,
'dec_TermListAuditResult'/3,
'dec_AuditResult'/3,
'dec_AuditReply'/3,
'dec_AuditRequest'/3,
'dec_SubtractRequest'/3,
'dec_AmmsReply'/3,
'dec_AmmDescriptor'/3,
'dec_AmmRequest'/3,
'dec_TopologyRequest'/3,
'dec_CommandReply'/3,
'dec_Command'/3,
'dec_CommandRequest'/3,
'dec_SelectLogic'/3,
'dec_ContextAttrAuditRequest'/3,
'dec_ContextRequest'/3,
'dec_ActionReply'/3,
'dec_ActionRequest'/3,
'dec_ContextID'/3,
'dec_ErrorText'/3,
'dec_ErrorCode'/3,
'dec_ErrorDescriptor'/3,
'dec_TransactionAck'/3,
'dec_TransactionResponseAck'/3,
'dec_TransactionReply'/3,
'dec_TransactionPending'/3,
'dec_TransactionRequest'/3,
'dec_TransactionId'/3,
'dec_Transaction'/3,
'dec_PathName'/3,
'dec_IP6Address'/3,
'dec_IP4Address'/3,
'dec_DomainName'/3,
'dec_MId'/3,
'dec_Message'/3,
'dec_AuthData'/3,
'dec_SequenceNum'/3,
'dec_SecurityParmIndex'/3,
'dec_AuthenticationHeader'/3,
'dec_MegacoMessage'/3
]).

-export([info/0]).


-export([encode/2,decode/2,encode_disp/2,decode_disp/2]).

encoding_rule() ->
   ber.

encode(Type,Data) ->
case catch encode_disp(Type,Data) of
  {'EXIT',{error,Reason}} ->
    {error,Reason};
  {'EXIT',Reason} ->
    {error,{asn1,Reason}};
  {Bytes,_Len} ->
    {ok,wrap_encode(Bytes)};
  Bytes ->
    {ok,wrap_encode(Bytes)}
end.

decode(Type,Data) ->
case catch decode_disp(Type,wrap_decode(Data)) of
  {'EXIT',{error,Reason}} ->
    {error,Reason};
  {'EXIT',Reason} ->
    {error,{asn1,Reason}};
  {X,_Rest} ->
    {ok,X};
  {X,_Rest,_Len} ->
    {ok,X}
end.

encode_disp('Value',Data) -> 'enc_Value'(Data,[]);
encode_disp('TimeNotation',Data) -> 'enc_TimeNotation'(Data,[]);
encode_disp('H221NonStandard',Data) -> 'enc_H221NonStandard'(Data,[]);
encode_disp('NonStandardIdentifier',Data) -> 'enc_NonStandardIdentifier'(Data,[]);
encode_disp('NonStandardData',Data) -> 'enc_NonStandardData'(Data,[]);
encode_disp('StatisticsParameter',Data) -> 'enc_StatisticsParameter'(Data,[]);
encode_disp('StatisticsDescriptor',Data) -> 'enc_StatisticsDescriptor'(Data,[]);
encode_disp('PackagesItem',Data) -> 'enc_PackagesItem'(Data,[]);
encode_disp('PackagesDescriptor',Data) -> 'enc_PackagesDescriptor'(Data,[]);
encode_disp('ServiceChangeProfile',Data) -> 'enc_ServiceChangeProfile'(Data,[]);
encode_disp('ServiceChangeMethod',Data) -> 'enc_ServiceChangeMethod'(Data,[]);
encode_disp('ServiceChangeResParm',Data) -> 'enc_ServiceChangeResParm'(Data,[]);
encode_disp('ServiceChangeAddress',Data) -> 'enc_ServiceChangeAddress'(Data,[]);
encode_disp('ServiceChangeParm',Data) -> 'enc_ServiceChangeParm'(Data,[]);
encode_disp('DigitMapValue',Data) -> 'enc_DigitMapValue'(Data,[]);
encode_disp('DigitMapName',Data) -> 'enc_DigitMapName'(Data,[]);
encode_disp('DigitMapDescriptor',Data) -> 'enc_DigitMapDescriptor'(Data,[]);
encode_disp('ModemType',Data) -> 'enc_ModemType'(Data,[]);
encode_disp('ModemDescriptor',Data) -> 'enc_ModemDescriptor'(Data,[]);
encode_disp('RequestID',Data) -> 'enc_RequestID'(Data,[]);
encode_disp('SigParameter',Data) -> 'enc_SigParameter'(Data,[]);
encode_disp('NotifyCompletion',Data) -> 'enc_NotifyCompletion'(Data,[]);
encode_disp('SignalName',Data) -> 'enc_SignalName'(Data,[]);
encode_disp('SignalDirection',Data) -> 'enc_SignalDirection'(Data,[]);
encode_disp('SignalType',Data) -> 'enc_SignalType'(Data,[]);
encode_disp('Signal',Data) -> 'enc_Signal'(Data,[]);
encode_disp('SeqSigList',Data) -> 'enc_SeqSigList'(Data,[]);
encode_disp('SignalRequest',Data) -> 'enc_SignalRequest'(Data,[]);
encode_disp('SignalsDescriptor',Data) -> 'enc_SignalsDescriptor'(Data,[]);
encode_disp('EventSpec',Data) -> 'enc_EventSpec'(Data,[]);
encode_disp('EventBufferDescriptor',Data) -> 'enc_EventBufferDescriptor'(Data,[]);
encode_disp('SecondRequestedActions',Data) -> 'enc_SecondRequestedActions'(Data,[]);
encode_disp('SecondRequestedEvent',Data) -> 'enc_SecondRequestedEvent'(Data,[]);
encode_disp('SecondEventsDescriptor',Data) -> 'enc_SecondEventsDescriptor'(Data,[]);
encode_disp('EventDM',Data) -> 'enc_EventDM'(Data,[]);
encode_disp('RequestedActions',Data) -> 'enc_RequestedActions'(Data,[]);
encode_disp('NotifyBehaviour',Data) -> 'enc_NotifyBehaviour'(Data,[]);
encode_disp('RegulatedEmbeddedDescriptor',Data) -> 'enc_RegulatedEmbeddedDescriptor'(Data,[]);
encode_disp('RequestedEvent',Data) -> 'enc_RequestedEvent'(Data,[]);
encode_disp('EventsDescriptor',Data) -> 'enc_EventsDescriptor'(Data,[]);
encode_disp('StreamID',Data) -> 'enc_StreamID'(Data,[]);
encode_disp('MuxType',Data) -> 'enc_MuxType'(Data,[]);
encode_disp('MuxDescriptor',Data) -> 'enc_MuxDescriptor'(Data,[]);
encode_disp('ServiceState',Data) -> 'enc_ServiceState'(Data,[]);
encode_disp('EventBufferControl',Data) -> 'enc_EventBufferControl'(Data,[]);
encode_disp('TerminationStateDescriptor',Data) -> 'enc_TerminationStateDescriptor'(Data,[]);
encode_disp('PropertyGroup',Data) -> 'enc_PropertyGroup'(Data,[]);
encode_disp('LocalRemoteDescriptor',Data) -> 'enc_LocalRemoteDescriptor'(Data,[]);
encode_disp('Relation',Data) -> 'enc_Relation'(Data,[]);
encode_disp('PkgdName',Data) -> 'enc_PkgdName'(Data,[]);
encode_disp('Name',Data) -> 'enc_Name'(Data,[]);
encode_disp('PropertyParm',Data) -> 'enc_PropertyParm'(Data,[]);
encode_disp('StreamMode',Data) -> 'enc_StreamMode'(Data,[]);
encode_disp('LocalControlDescriptor',Data) -> 'enc_LocalControlDescriptor'(Data,[]);
encode_disp('StreamParms',Data) -> 'enc_StreamParms'(Data,[]);
encode_disp('StreamDescriptor',Data) -> 'enc_StreamDescriptor'(Data,[]);
encode_disp('MediaDescriptor',Data) -> 'enc_MediaDescriptor'(Data,[]);
encode_disp('TerminationIDList',Data) -> 'enc_TerminationIDList'(Data,[]);
encode_disp('TerminationID',Data) -> 'enc_TerminationID'(Data,[]);
encode_disp('WildcardField',Data) -> 'enc_WildcardField'(Data,[]);
encode_disp('ServiceChangeResult',Data) -> 'enc_ServiceChangeResult'(Data,[]);
encode_disp('ServiceChangeReply',Data) -> 'enc_ServiceChangeReply'(Data,[]);
encode_disp('ServiceChangeRequest',Data) -> 'enc_ServiceChangeRequest'(Data,[]);
encode_disp('EventParameter',Data) -> 'enc_EventParameter'(Data,[]);
encode_disp('EventName',Data) -> 'enc_EventName'(Data,[]);
encode_disp('ObservedEvent',Data) -> 'enc_ObservedEvent'(Data,[]);
encode_disp('ObservedEventsDescriptor',Data) -> 'enc_ObservedEventsDescriptor'(Data,[]);
encode_disp('NotifyReply',Data) -> 'enc_NotifyReply'(Data,[]);
encode_disp('NotifyRequest',Data) -> 'enc_NotifyRequest'(Data,[]);
encode_disp('IndAudPackagesDescriptor',Data) -> 'enc_IndAudPackagesDescriptor'(Data,[]);
encode_disp('IndAudStatisticsDescriptor',Data) -> 'enc_IndAudStatisticsDescriptor'(Data,[]);
encode_disp('IndAudDigitMapDescriptor',Data) -> 'enc_IndAudDigitMapDescriptor'(Data,[]);
encode_disp('IndAudSignal',Data) -> 'enc_IndAudSignal'(Data,[]);
encode_disp('IndAudSeqSigList',Data) -> 'enc_IndAudSeqSigList'(Data,[]);
encode_disp('IndAudSignalsDescriptor',Data) -> 'enc_IndAudSignalsDescriptor'(Data,[]);
encode_disp('IndAudEventBufferDescriptor',Data) -> 'enc_IndAudEventBufferDescriptor'(Data,[]);
encode_disp('IndAudEventsDescriptor',Data) -> 'enc_IndAudEventsDescriptor'(Data,[]);
encode_disp('IndAudTerminationStateDescriptor',Data) -> 'enc_IndAudTerminationStateDescriptor'(Data,[]);
encode_disp('IndAudPropertyGroup',Data) -> 'enc_IndAudPropertyGroup'(Data,[]);
encode_disp('IndAudLocalRemoteDescriptor',Data) -> 'enc_IndAudLocalRemoteDescriptor'(Data,[]);
encode_disp('IndAudPropertyParm',Data) -> 'enc_IndAudPropertyParm'(Data,[]);
encode_disp('IndAudLocalControlDescriptor',Data) -> 'enc_IndAudLocalControlDescriptor'(Data,[]);
encode_disp('IndAudStreamParms',Data) -> 'enc_IndAudStreamParms'(Data,[]);
encode_disp('IndAudStreamDescriptor',Data) -> 'enc_IndAudStreamDescriptor'(Data,[]);
encode_disp('IndAudMediaDescriptor',Data) -> 'enc_IndAudMediaDescriptor'(Data,[]);
encode_disp('IndAuditParameter',Data) -> 'enc_IndAuditParameter'(Data,[]);
encode_disp('AuditDescriptor',Data) -> 'enc_AuditDescriptor'(Data,[]);
encode_disp('AuditReturnParameter',Data) -> 'enc_AuditReturnParameter'(Data,[]);
encode_disp('TerminationAudit',Data) -> 'enc_TerminationAudit'(Data,[]);
encode_disp('TermListAuditResult',Data) -> 'enc_TermListAuditResult'(Data,[]);
encode_disp('AuditResult',Data) -> 'enc_AuditResult'(Data,[]);
encode_disp('AuditReply',Data) -> 'enc_AuditReply'(Data,[]);
encode_disp('AuditRequest',Data) -> 'enc_AuditRequest'(Data,[]);
encode_disp('SubtractRequest',Data) -> 'enc_SubtractRequest'(Data,[]);
encode_disp('AmmsReply',Data) -> 'enc_AmmsReply'(Data,[]);
encode_disp('AmmDescriptor',Data) -> 'enc_AmmDescriptor'(Data,[]);
encode_disp('AmmRequest',Data) -> 'enc_AmmRequest'(Data,[]);
encode_disp('TopologyRequest',Data) -> 'enc_TopologyRequest'(Data,[]);
encode_disp('CommandReply',Data) -> 'enc_CommandReply'(Data,[]);
encode_disp('Command',Data) -> 'enc_Command'(Data,[]);
encode_disp('CommandRequest',Data) -> 'enc_CommandRequest'(Data,[]);
encode_disp('SelectLogic',Data) -> 'enc_SelectLogic'(Data,[]);
encode_disp('ContextAttrAuditRequest',Data) -> 'enc_ContextAttrAuditRequest'(Data,[]);
encode_disp('ContextRequest',Data) -> 'enc_ContextRequest'(Data,[]);
encode_disp('ActionReply',Data) -> 'enc_ActionReply'(Data,[]);
encode_disp('ActionRequest',Data) -> 'enc_ActionRequest'(Data,[]);
encode_disp('ContextID',Data) -> 'enc_ContextID'(Data,[]);
encode_disp('ErrorText',Data) -> 'enc_ErrorText'(Data,[]);
encode_disp('ErrorCode',Data) -> 'enc_ErrorCode'(Data,[]);
encode_disp('ErrorDescriptor',Data) -> 'enc_ErrorDescriptor'(Data,[]);
encode_disp('TransactionAck',Data) -> 'enc_TransactionAck'(Data,[]);
encode_disp('TransactionResponseAck',Data) -> 'enc_TransactionResponseAck'(Data,[]);
encode_disp('TransactionReply',Data) -> 'enc_TransactionReply'(Data,[]);
encode_disp('TransactionPending',Data) -> 'enc_TransactionPending'(Data,[]);
encode_disp('TransactionRequest',Data) -> 'enc_TransactionRequest'(Data,[]);
encode_disp('TransactionId',Data) -> 'enc_TransactionId'(Data,[]);
encode_disp('Transaction',Data) -> 'enc_Transaction'(Data,[]);
encode_disp('PathName',Data) -> 'enc_PathName'(Data,[]);
encode_disp('IP6Address',Data) -> 'enc_IP6Address'(Data,[]);
encode_disp('IP4Address',Data) -> 'enc_IP4Address'(Data,[]);
encode_disp('DomainName',Data) -> 'enc_DomainName'(Data,[]);
encode_disp('MId',Data) -> 'enc_MId'(Data,[]);
encode_disp('Message',Data) -> 'enc_Message'(Data,[]);
encode_disp('AuthData',Data) -> 'enc_AuthData'(Data,[]);
encode_disp('SequenceNum',Data) -> 'enc_SequenceNum'(Data,[]);
encode_disp('SecurityParmIndex',Data) -> 'enc_SecurityParmIndex'(Data,[]);
encode_disp('AuthenticationHeader',Data) -> 'enc_AuthenticationHeader'(Data,[]);
encode_disp('MegacoMessage',Data) -> 'enc_MegacoMessage'(Data,[]);
encode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}).


decode_disp('Value',Data) -> 'dec_Value'(Data,mandatory);
decode_disp('TimeNotation',Data) -> 'dec_TimeNotation'(Data,mandatory);
decode_disp('H221NonStandard',Data) -> 'dec_H221NonStandard'(Data,mandatory);
decode_disp('NonStandardIdentifier',Data) -> 'dec_NonStandardIdentifier'(Data,mandatory);
decode_disp('NonStandardData',Data) -> 'dec_NonStandardData'(Data,mandatory);
decode_disp('StatisticsParameter',Data) -> 'dec_StatisticsParameter'(Data,mandatory);
decode_disp('StatisticsDescriptor',Data) -> 'dec_StatisticsDescriptor'(Data,mandatory);
decode_disp('PackagesItem',Data) -> 'dec_PackagesItem'(Data,mandatory);
decode_disp('PackagesDescriptor',Data) -> 'dec_PackagesDescriptor'(Data,mandatory);
decode_disp('ServiceChangeProfile',Data) -> 'dec_ServiceChangeProfile'(Data,mandatory);
decode_disp('ServiceChangeMethod',Data) -> 'dec_ServiceChangeMethod'(Data,mandatory);
decode_disp('ServiceChangeResParm',Data) -> 'dec_ServiceChangeResParm'(Data,mandatory);
decode_disp('ServiceChangeAddress',Data) -> 'dec_ServiceChangeAddress'(Data,mandatory);
decode_disp('ServiceChangeParm',Data) -> 'dec_ServiceChangeParm'(Data,mandatory);
decode_disp('DigitMapValue',Data) -> 'dec_DigitMapValue'(Data,mandatory);
decode_disp('DigitMapName',Data) -> 'dec_DigitMapName'(Data,mandatory);
decode_disp('DigitMapDescriptor',Data) -> 'dec_DigitMapDescriptor'(Data,mandatory);
decode_disp('ModemType',Data) -> 'dec_ModemType'(Data,mandatory);
decode_disp('ModemDescriptor',Data) -> 'dec_ModemDescriptor'(Data,mandatory);
decode_disp('RequestID',Data) -> 'dec_RequestID'(Data,mandatory);
decode_disp('SigParameter',Data) -> 'dec_SigParameter'(Data,mandatory);
decode_disp('NotifyCompletion',Data) -> 'dec_NotifyCompletion'(Data,mandatory);
decode_disp('SignalName',Data) -> 'dec_SignalName'(Data,mandatory);
decode_disp('SignalDirection',Data) -> 'dec_SignalDirection'(Data,mandatory);
decode_disp('SignalType',Data) -> 'dec_SignalType'(Data,mandatory);
decode_disp('Signal',Data) -> 'dec_Signal'(Data,mandatory);
decode_disp('SeqSigList',Data) -> 'dec_SeqSigList'(Data,mandatory);
decode_disp('SignalRequest',Data) -> 'dec_SignalRequest'(Data,mandatory);
decode_disp('SignalsDescriptor',Data) -> 'dec_SignalsDescriptor'(Data,mandatory);
decode_disp('EventSpec',Data) -> 'dec_EventSpec'(Data,mandatory);
decode_disp('EventBufferDescriptor',Data) -> 'dec_EventBufferDescriptor'(Data,mandatory);
decode_disp('SecondRequestedActions',Data) -> 'dec_SecondRequestedActions'(Data,mandatory);
decode_disp('SecondRequestedEvent',Data) -> 'dec_SecondRequestedEvent'(Data,mandatory);
decode_disp('SecondEventsDescriptor',Data) -> 'dec_SecondEventsDescriptor'(Data,mandatory);
decode_disp('EventDM',Data) -> 'dec_EventDM'(Data,mandatory);
decode_disp('RequestedActions',Data) -> 'dec_RequestedActions'(Data,mandatory);
decode_disp('NotifyBehaviour',Data) -> 'dec_NotifyBehaviour'(Data,mandatory);
decode_disp('RegulatedEmbeddedDescriptor',Data) -> 'dec_RegulatedEmbeddedDescriptor'(Data,mandatory);
decode_disp('RequestedEvent',Data) -> 'dec_RequestedEvent'(Data,mandatory);
decode_disp('EventsDescriptor',Data) -> 'dec_EventsDescriptor'(Data,mandatory);
decode_disp('StreamID',Data) -> 'dec_StreamID'(Data,mandatory);
decode_disp('MuxType',Data) -> 'dec_MuxType'(Data,mandatory);
decode_disp('MuxDescriptor',Data) -> 'dec_MuxDescriptor'(Data,mandatory);
decode_disp('ServiceState',Data) -> 'dec_ServiceState'(Data,mandatory);
decode_disp('EventBufferControl',Data) -> 'dec_EventBufferControl'(Data,mandatory);
decode_disp('TerminationStateDescriptor',Data) -> 'dec_TerminationStateDescriptor'(Data,mandatory);
decode_disp('PropertyGroup',Data) -> 'dec_PropertyGroup'(Data,mandatory);
decode_disp('LocalRemoteDescriptor',Data) -> 'dec_LocalRemoteDescriptor'(Data,mandatory);
decode_disp('Relation',Data) -> 'dec_Relation'(Data,mandatory);
decode_disp('PkgdName',Data) -> 'dec_PkgdName'(Data,mandatory);
decode_disp('Name',Data) -> 'dec_Name'(Data,mandatory);
decode_disp('PropertyParm',Data) -> 'dec_PropertyParm'(Data,mandatory);
decode_disp('StreamMode',Data) -> 'dec_StreamMode'(Data,mandatory);
decode_disp('LocalControlDescriptor',Data) -> 'dec_LocalControlDescriptor'(Data,mandatory);
decode_disp('StreamParms',Data) -> 'dec_StreamParms'(Data,mandatory);
decode_disp('StreamDescriptor',Data) -> 'dec_StreamDescriptor'(Data,mandatory);
decode_disp('MediaDescriptor',Data) -> 'dec_MediaDescriptor'(Data,mandatory);
decode_disp('TerminationIDList',Data) -> 'dec_TerminationIDList'(Data,mandatory);
decode_disp('TerminationID',Data) -> 'dec_TerminationID'(Data,mandatory);
decode_disp('WildcardField',Data) -> 'dec_WildcardField'(Data,mandatory);
decode_disp('ServiceChangeResult',Data) -> 'dec_ServiceChangeResult'(Data,mandatory);
decode_disp('ServiceChangeReply',Data) -> 'dec_ServiceChangeReply'(Data,mandatory);
decode_disp('ServiceChangeRequest',Data) -> 'dec_ServiceChangeRequest'(Data,mandatory);
decode_disp('EventParameter',Data) -> 'dec_EventParameter'(Data,mandatory);
decode_disp('EventName',Data) -> 'dec_EventName'(Data,mandatory);
decode_disp('ObservedEvent',Data) -> 'dec_ObservedEvent'(Data,mandatory);
decode_disp('ObservedEventsDescriptor',Data) -> 'dec_ObservedEventsDescriptor'(Data,mandatory);
decode_disp('NotifyReply',Data) -> 'dec_NotifyReply'(Data,mandatory);
decode_disp('NotifyRequest',Data) -> 'dec_NotifyRequest'(Data,mandatory);
decode_disp('IndAudPackagesDescriptor',Data) -> 'dec_IndAudPackagesDescriptor'(Data,mandatory);
decode_disp('IndAudStatisticsDescriptor',Data) -> 'dec_IndAudStatisticsDescriptor'(Data,mandatory);
decode_disp('IndAudDigitMapDescriptor',Data) -> 'dec_IndAudDigitMapDescriptor'(Data,mandatory);
decode_disp('IndAudSignal',Data) -> 'dec_IndAudSignal'(Data,mandatory);
decode_disp('IndAudSeqSigList',Data) -> 'dec_IndAudSeqSigList'(Data,mandatory);
decode_disp('IndAudSignalsDescriptor',Data) -> 'dec_IndAudSignalsDescriptor'(Data,mandatory);
decode_disp('IndAudEventBufferDescriptor',Data) -> 'dec_IndAudEventBufferDescriptor'(Data,mandatory);
decode_disp('IndAudEventsDescriptor',Data) -> 'dec_IndAudEventsDescriptor'(Data,mandatory);
decode_disp('IndAudTerminationStateDescriptor',Data) -> 'dec_IndAudTerminationStateDescriptor'(Data,mandatory);
decode_disp('IndAudPropertyGroup',Data) -> 'dec_IndAudPropertyGroup'(Data,mandatory);
decode_disp('IndAudLocalRemoteDescriptor',Data) -> 'dec_IndAudLocalRemoteDescriptor'(Data,mandatory);
decode_disp('IndAudPropertyParm',Data) -> 'dec_IndAudPropertyParm'(Data,mandatory);
decode_disp('IndAudLocalControlDescriptor',Data) -> 'dec_IndAudLocalControlDescriptor'(Data,mandatory);
decode_disp('IndAudStreamParms',Data) -> 'dec_IndAudStreamParms'(Data,mandatory);
decode_disp('IndAudStreamDescriptor',Data) -> 'dec_IndAudStreamDescriptor'(Data,mandatory);
decode_disp('IndAudMediaDescriptor',Data) -> 'dec_IndAudMediaDescriptor'(Data,mandatory);
decode_disp('IndAuditParameter',Data) -> 'dec_IndAuditParameter'(Data,mandatory);
decode_disp('AuditDescriptor',Data) -> 'dec_AuditDescriptor'(Data,mandatory);
decode_disp('AuditReturnParameter',Data) -> 'dec_AuditReturnParameter'(Data,mandatory);
decode_disp('TerminationAudit',Data) -> 'dec_TerminationAudit'(Data,mandatory);
decode_disp('TermListAuditResult',Data) -> 'dec_TermListAuditResult'(Data,mandatory);
decode_disp('AuditResult',Data) -> 'dec_AuditResult'(Data,mandatory);
decode_disp('AuditReply',Data) -> 'dec_AuditReply'(Data,mandatory);
decode_disp('AuditRequest',Data) -> 'dec_AuditRequest'(Data,mandatory);
decode_disp('SubtractRequest',Data) -> 'dec_SubtractRequest'(Data,mandatory);
decode_disp('AmmsReply',Data) -> 'dec_AmmsReply'(Data,mandatory);
decode_disp('AmmDescriptor',Data) -> 'dec_AmmDescriptor'(Data,mandatory);
decode_disp('AmmRequest',Data) -> 'dec_AmmRequest'(Data,mandatory);
decode_disp('TopologyRequest',Data) -> 'dec_TopologyRequest'(Data,mandatory);
decode_disp('CommandReply',Data) -> 'dec_CommandReply'(Data,mandatory);
decode_disp('Command',Data) -> 'dec_Command'(Data,mandatory);
decode_disp('CommandRequest',Data) -> 'dec_CommandRequest'(Data,mandatory);
decode_disp('SelectLogic',Data) -> 'dec_SelectLogic'(Data,mandatory);
decode_disp('ContextAttrAuditRequest',Data) -> 'dec_ContextAttrAuditRequest'(Data,mandatory);
decode_disp('ContextRequest',Data) -> 'dec_ContextRequest'(Data,mandatory);
decode_disp('ActionReply',Data) -> 'dec_ActionReply'(Data,mandatory);
decode_disp('ActionRequest',Data) -> 'dec_ActionRequest'(Data,mandatory);
decode_disp('ContextID',Data) -> 'dec_ContextID'(Data,mandatory);
decode_disp('ErrorText',Data) -> 'dec_ErrorText'(Data,mandatory);
decode_disp('ErrorCode',Data) -> 'dec_ErrorCode'(Data,mandatory);
decode_disp('ErrorDescriptor',Data) -> 'dec_ErrorDescriptor'(Data,mandatory);
decode_disp('TransactionAck',Data) -> 'dec_TransactionAck'(Data,mandatory);
decode_disp('TransactionResponseAck',Data) -> 'dec_TransactionResponseAck'(Data,mandatory);
decode_disp('TransactionReply',Data) -> 'dec_TransactionReply'(Data,mandatory);
decode_disp('TransactionPending',Data) -> 'dec_TransactionPending'(Data,mandatory);
decode_disp('TransactionRequest',Data) -> 'dec_TransactionRequest'(Data,mandatory);
decode_disp('TransactionId',Data) -> 'dec_TransactionId'(Data,mandatory);
decode_disp('Transaction',Data) -> 'dec_Transaction'(Data,mandatory);
decode_disp('PathName',Data) -> 'dec_PathName'(Data,mandatory);
decode_disp('IP6Address',Data) -> 'dec_IP6Address'(Data,mandatory);
decode_disp('IP4Address',Data) -> 'dec_IP4Address'(Data,mandatory);
decode_disp('DomainName',Data) -> 'dec_DomainName'(Data,mandatory);
decode_disp('MId',Data) -> 'dec_MId'(Data,mandatory);
decode_disp('Message',Data) -> 'dec_Message'(Data,mandatory);
decode_disp('AuthData',Data) -> 'dec_AuthData'(Data,mandatory);
decode_disp('SequenceNum',Data) -> 'dec_SequenceNum'(Data,mandatory);
decode_disp('SecurityParmIndex',Data) -> 'dec_SecurityParmIndex'(Data,mandatory);
decode_disp('AuthenticationHeader',Data) -> 'dec_AuthenticationHeader'(Data,mandatory);
decode_disp('MegacoMessage',Data) -> 'dec_MegacoMessage'(Data,mandatory);
decode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}).



wrap_encode(Bytes) when list(Bytes) ->
   binary_to_list(list_to_binary(Bytes));
wrap_encode(Bytes) when binary(Bytes) ->
   binary_to_list(Bytes);
wrap_encode(Bytes) -> Bytes.

wrap_decode(Bytes) when list(Bytes) ->
   list_to_binary(Bytes);
wrap_decode(Bytes) -> Bytes.


info() ->
  [{vsn,'1.4.4.11'},   {module,'megaco_ber_media_gateway_control_prev3c'},   {options,[ber,
 report_errors,
 {cwd,"/work/a/ports/lang/erlang/work/otp_src_R11B-1/lib/megaco/src/binary"},
 {outdir,"/work/a/ports/lang/erlang/work/otp_src_R11B-1/lib/megaco/src/binary"},
 noobj,
 {i,"."},
 {i,"/work/a/ports/lang/erlang/work/otp_src_R11B-1/lib/megaco/src/binary"}]}].


%%================================
%%  Value
%%================================

'enc_Value'({'Value',Val}, TagIn) ->
   'enc_Value'(Val, TagIn);

'enc_Value'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_Value_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_Value_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_Value_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
   'enc_Value_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_Value'(Bytes, OptOrMand) ->
   'dec_Value'(Bytes, OptOrMand, []).

'dec_Value'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
end, [], []).




%%================================
%%  TimeNotation
%%================================
'enc_TimeNotation'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type IA5String
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(2,Val,date), 22, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type IA5String
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(3,Val,time), 22, [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_TimeNotation'(Bytes, OptOrMand) ->
   'dec_TimeNotation'(Bytes, OptOrMand, []).

'dec_TimeNotation'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type IA5String
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_restricted_string(Bytes2,8,22,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type IA5String
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_restricted_string(Bytes3,8,22,[{tag,128,1,'IMPLICIT',0}], no_length, mandatory),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'TimeNotation', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  H221NonStandard
%%================================
'enc_H221NonStandard'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,t35CountryCode1), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,t35CountryCode2), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type INTEGER
%%-------------------------------------------------
   {EncBytes3,EncLen3} = ?RT_BER:encode_integer([], ?RT_BER:cindex(4,Val,t35Extension), [{tag,128,2,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 4 with type INTEGER
%%-------------------------------------------------
   {EncBytes4,EncLen4} = ?RT_BER:encode_integer([], ?RT_BER:cindex(5,Val,manufacturerCode), [{tag,128,3,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_H221NonStandard'(Bytes, OptOrMand) ->
   'dec_H221NonStandard'(Bytes, OptOrMand, []).

'dec_H221NonStandard'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,255},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_integer(Bytes3,{0,255},[{tag,128,1,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 3 with type INTEGER
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_integer(Bytes4,{0,255},[{tag,128,2,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 4 with type INTEGER
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = ?RT_BER:decode_integer(Bytes5,{0,65535},[{tag,128,3,'IMPLICIT',0}], mandatory),

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'H221NonStandard', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  NonStandardIdentifier
%%================================

'enc_NonStandardIdentifier'({'NonStandardIdentifier',Val}, TagIn) ->
   'enc_NonStandardIdentifier'(Val, TagIn);

'enc_NonStandardIdentifier'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      object ->
         ?RT_BER:encode_object_identifier(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      h221NonStandard ->
         'enc_H221NonStandard'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      experimental ->
         ?RT_BER:encode_restricted_string([], element(2,Val), 22, [{tag,128,2,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_NonStandardIdentifier'(Bytes, OptOrMand) ->
   'dec_NonStandardIdentifier'(Bytes, OptOrMand, []).

'dec_NonStandardIdentifier'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'object'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_object_identifier(Bytes1,[{tag,128,0,'IMPLICIT',0}], mandatory),
         {{object, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'h221NonStandard'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_H221NonStandard'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{h221NonStandard, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'experimental'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_restricted_string(Bytes1,8,22,[{tag,128,2,'IMPLICIT',0}], no_length, mandatory),
         {{experimental, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  NonStandardData
%%================================
'enc_NonStandardData'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:NonStandardIdentifier
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_NonStandardIdentifier'(?RT_BER:cindex(2,Val,nonStandardIdentifier), [{tag,128,0,'EXPLICIT',32}]),

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,data), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_NonStandardData'(Bytes, OptOrMand) ->
   'dec_NonStandardData'(Bytes, OptOrMand, []).

'dec_NonStandardData'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:NonStandardIdentifier
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_NonStandardIdentifier'(Bytes2, mandatory, [{tag,128,0,'EXPLICIT',32}]),

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[{tag,128,1,'IMPLICIT',0}], no_length, mandatory),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'NonStandardData', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  StatisticsParameter
%%================================
'enc_StatisticsParameter'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,statName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Value OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,statValue) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_Value'(?RT_BER:cindex(3,Val,statValue), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_StatisticsParameter'(Bytes, OptOrMand) ->
   'dec_StatisticsParameter'(Bytes, OptOrMand, []).

'dec_StatisticsParameter'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Value OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_Value'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'StatisticsParameter', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  StatisticsDescriptor
%%================================

'enc_StatisticsDescriptor'({'StatisticsDescriptor',Val}, TagIn) ->
   'enc_StatisticsDescriptor'(Val, TagIn);

'enc_StatisticsDescriptor'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_StatisticsDescriptor_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_StatisticsDescriptor_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_StatisticsDescriptor_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_StatisticsParameter'(H, []),
   'enc_StatisticsDescriptor_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_StatisticsDescriptor'(Bytes, OptOrMand) ->
   'dec_StatisticsDescriptor'(Bytes, OptOrMand, []).

'dec_StatisticsDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_StatisticsParameter'/3, [], []).




%%================================
%%  PackagesItem
%%================================
'enc_PackagesItem'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,packageName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,packageVersion), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_PackagesItem'(Bytes, OptOrMand) ->
   'dec_PackagesItem'(Bytes, OptOrMand, []).

'dec_PackagesItem'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,2,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_integer(Bytes3,{0,99},[{tag,128,1,'IMPLICIT',0}], mandatory),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'PackagesItem', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  PackagesDescriptor
%%================================

'enc_PackagesDescriptor'({'PackagesDescriptor',Val}, TagIn) ->
   'enc_PackagesDescriptor'(Val, TagIn);

'enc_PackagesDescriptor'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_PackagesDescriptor_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_PackagesDescriptor_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_PackagesDescriptor_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_PackagesItem'(H, []),
   'enc_PackagesDescriptor_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_PackagesDescriptor'(Bytes, OptOrMand) ->
   'dec_PackagesDescriptor'(Bytes, OptOrMand, []).

'dec_PackagesDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PackagesItem'/3, [], []).




%%================================
%%  ServiceChangeProfile
%%================================
'enc_ServiceChangeProfile'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type IA5String
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(2,Val,profileName), 22, [{tag,128,0,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1],
  LenSoFar = EncLen1,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_ServiceChangeProfile'(Bytes, OptOrMand) ->
   'dec_ServiceChangeProfile'(Bytes, OptOrMand, []).

'dec_ServiceChangeProfile'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type IA5String
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_restricted_string(Bytes2,{1,67},22,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

   {Bytes4,Rb3} = ?RT_BER:restbytes2(RemBytes, Bytes3,noext),
   {{'ServiceChangeProfile', Term1}, Bytes4, Rb1+Rb2+Rb3}.


%%================================
%%  ServiceChangeMethod
%%================================

'enc_ServiceChangeMethod'({'ServiceChangeMethod',Val}, TagIn) ->
   'enc_ServiceChangeMethod'(Val, TagIn);

'enc_ServiceChangeMethod'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
failover -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
forced -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
graceful -> ?RT_BER:encode_enumerated(2,TagIn ++ []);
restart -> ?RT_BER:encode_enumerated(3,TagIn ++ []);
disconnected -> ?RT_BER:encode_enumerated(4,TagIn ++ []);
handOff -> ?RT_BER:encode_enumerated(5,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_ServiceChangeMethod'(Bytes, OptOrMand) ->
   'dec_ServiceChangeMethod'(Bytes, OptOrMand, []).

'dec_ServiceChangeMethod'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{failover,0},{forced,1},{graceful,2},{restart,3},{disconnected,4},{handOff,5}],[]},TagIn++[], OptOrMand).



%%================================
%%  ServiceChangeResParm
%%================================
'enc_ServiceChangeResParm'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:MId OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,serviceChangeMgcId) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_MId'(?RT_BER:cindex(2,Val,serviceChangeMgcId), [{tag,128,0,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeAddress OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,serviceChangeAddress) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ServiceChangeAddress'(?RT_BER:cindex(3,Val,serviceChangeAddress), [{tag,128,1,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,serviceChangeVersion) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(4,Val,serviceChangeVersion), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:ServiceChangeProfile OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,serviceChangeProfile) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ServiceChangeProfile'(?RT_BER:cindex(5,Val,serviceChangeProfile), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5   External megaco_ber_media_gateway_control_prev3c:TimeNotation OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,timestamp) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_TimeNotation'(?RT_BER:cindex(6,Val,timestamp), [{tag,128,4,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_ServiceChangeResParm'(Bytes, OptOrMand) ->
   'dec_ServiceChangeResParm'(Bytes, OptOrMand, []).

'dec_ServiceChangeResParm'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:MId OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
'dec_MId'(Bytes2, opt_or_default, [{tag,128,0,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeAddress OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_ServiceChangeAddress'(Bytes3, opt_or_default, [{tag,128,1,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_integer(Bytes4,{0,99},[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:ServiceChangeProfile OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_ServiceChangeProfile'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5   External megaco_ber_media_gateway_control_prev3c:TimeNotation OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
'dec_TimeNotation'(Bytes6, opt_or_default, [{tag,128,4,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

   {Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,ext),
   {{'ServiceChangeResParm', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}.


%%================================
%%  ServiceChangeAddress
%%================================

'enc_ServiceChangeAddress'({'ServiceChangeAddress',Val}, TagIn) ->
   'enc_ServiceChangeAddress'(Val, TagIn);

'enc_ServiceChangeAddress'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      portNumber ->
         ?RT_BER:encode_integer([], element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      ip4Address ->
         'enc_IP4Address'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      ip6Address ->
         'enc_IP6Address'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      domainName ->
         'enc_DomainName'(element(2,Val), [{tag,128,3,'IMPLICIT',0}]);
      deviceName ->
         ?RT_BER:encode_restricted_string([], element(2,Val), 22, [{tag,128,4,'IMPLICIT',0}]);
      mtpAddress ->
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,5,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_ServiceChangeAddress'(Bytes, OptOrMand) ->
   'dec_ServiceChangeAddress'(Bytes, OptOrMand, []).

'dec_ServiceChangeAddress'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'portNumber'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_integer(Bytes1,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory),
         {{portNumber, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'ip4Address'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IP4Address'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{ip4Address, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'ip6Address'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IP6Address'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{ip6Address, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'domainName'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_DomainName'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',0}]),
         {{domainName, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'deviceName'
      <<2:2,_:1,4:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_restricted_string(Bytes1,{1,64},22,[{tag,128,4,'IMPLICIT',0}], no_length, mandatory),
         {{deviceName, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'mtpAddress'
      <<2:2,_:1,5:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,{2,4},[{tag,128,5,'IMPLICIT',0}], no_length, mandatory),
         {{mtpAddress, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  ServiceChangeParm
%%================================
'enc_ServiceChangeParm'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type ENUMERATED
%%-------------------------------------------------
   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,serviceChangeMethod) of {asn1_enum,_}->?RT_BER:cindex(2,Val,serviceChangeMethod);{_,_}->element(2,?RT_BER:cindex(2,Val,serviceChangeMethod));_->?RT_BER:cindex(2,Val,serviceChangeMethod) end) of
failover -> ?RT_BER:encode_enumerated(0,[{tag,128,0,'IMPLICIT',0}]);
forced -> ?RT_BER:encode_enumerated(1,[{tag,128,0,'IMPLICIT',0}]);
graceful -> ?RT_BER:encode_enumerated(2,[{tag,128,0,'IMPLICIT',0}]);
restart -> ?RT_BER:encode_enumerated(3,[{tag,128,0,'IMPLICIT',0}]);
disconnected -> ?RT_BER:encode_enumerated(4,[{tag,128,0,'IMPLICIT',0}]);
handOff -> ?RT_BER:encode_enumerated(5,[{tag,128,0,'IMPLICIT',0}]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[{tag,128,0,'IMPLICIT',0}]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeAddress OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,serviceChangeAddress) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ServiceChangeAddress'(?RT_BER:cindex(3,Val,serviceChangeAddress), [{tag,128,1,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,serviceChangeVersion) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(4,Val,serviceChangeVersion), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:ServiceChangeProfile OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,serviceChangeProfile) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ServiceChangeProfile'(?RT_BER:cindex(5,Val,serviceChangeProfile), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5   External megaco_ber_media_gateway_control_prev3c:Value
%%-------------------------------------------------
   {EncBytes5,EncLen5} = 'enc_Value'(?RT_BER:cindex(6,Val,serviceChangeReason), [{tag,128,4,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 6 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes6,EncLen6} =  case ?RT_BER:cindex(7,Val,serviceChangeDelay) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(7,Val,serviceChangeDelay), [{tag,128,5,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 7   External megaco_ber_media_gateway_control_prev3c:MId OPTIONAL
%%-------------------------------------------------
   {EncBytes7,EncLen7} =  case ?RT_BER:cindex(8,Val,serviceChangeMgcId) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_MId'(?RT_BER:cindex(8,Val,serviceChangeMgcId), [{tag,128,6,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 8   External megaco_ber_media_gateway_control_prev3c:TimeNotation OPTIONAL
%%-------------------------------------------------
   {EncBytes8,EncLen8} =  case ?RT_BER:cindex(9,Val,timeStamp) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_TimeNotation'(?RT_BER:cindex(9,Val,timeStamp), [{tag,128,7,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 9   External megaco_ber_media_gateway_control_prev3c:NonStandardData OPTIONAL
%%-------------------------------------------------
   {EncBytes9,EncLen9} =  case ?RT_BER:cindex(10,Val,nonStandardData) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_NonStandardData'(?RT_BER:cindex(10,Val,nonStandardData), [{tag,128,8,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 10   External megaco_ber_media_gateway_control_prev3c:AuditDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes10,EncLen10} =  case ?RT_BER:cindex(11,Val,serviceChangeInfo) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_AuditDescriptor'(?RT_BER:cindex(11,Val,serviceChangeInfo), [{tag,128,9,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 11 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes11,EncLen11} =  case ?RT_BER:cindex(12,Val,serviceChangeIncompleteFlag) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(12,Val,serviceChangeIncompleteFlag), [{tag,128,10,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_ServiceChangeParm'(Bytes, OptOrMand) ->
   'dec_ServiceChangeParm'(Bytes, OptOrMand, []).

'dec_ServiceChangeParm'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type ENUMERATED
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],{[{failover,0},{forced,1},{graceful,2},{restart,3},{disconnected,4},{handOff,5}],[]},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeAddress OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_ServiceChangeAddress'(Bytes3, opt_or_default, [{tag,128,1,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_integer(Bytes4,{0,99},[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:ServiceChangeProfile OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_ServiceChangeProfile'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5   External megaco_ber_media_gateway_control_prev3c:Value
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = 'dec_Value'(Bytes6, mandatory, [{tag,128,4,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 6 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term6,Bytes8,Rb7} = case Bytes7 of
<<2:2,_:1,5:5,_/binary>> ->
?RT_BER:decode_integer(Bytes7,{0,4294967295},[{tag,128,5,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes7, 0 }
end,

%%-------------------------------------------------
%% attribute number 7   External megaco_ber_media_gateway_control_prev3c:MId OPTIONAL
%%-------------------------------------------------
   {Term7,Bytes9,Rb8} = case Bytes8 of
<<2:2,_:1,6:5,_/binary>> ->
'dec_MId'(Bytes8, opt_or_default, [{tag,128,6,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes8, 0 }
end,

%%-------------------------------------------------
%% attribute number 8   External megaco_ber_media_gateway_control_prev3c:TimeNotation OPTIONAL
%%-------------------------------------------------
   {Term8,Bytes10,Rb9} = case Bytes9 of
<<2:2,_:1,7:5,_/binary>> ->
'dec_TimeNotation'(Bytes9, opt_or_default, [{tag,128,7,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes9, 0 }
end,

%%-------------------------------------------------
%% attribute number 9   External megaco_ber_media_gateway_control_prev3c:NonStandardData OPTIONAL
%%-------------------------------------------------
   {Term9,Bytes11,Rb10} = case Bytes10 of
<<2:2,_:1,8:5,_/binary>> ->
'dec_NonStandardData'(Bytes10, opt_or_default, [{tag,128,8,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes10, 0 }
end,

%%-------------------------------------------------
%% attribute number 10   External megaco_ber_media_gateway_control_prev3c:AuditDescriptor OPTIONAL
%%-------------------------------------------------
   {Term10,Bytes12,Rb11} = case Bytes11 of
<<2:2,_:1,9:5,_/binary>> ->
'dec_AuditDescriptor'(Bytes11, opt_or_default, [{tag,128,9,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes11, 0 }
end,

%%-------------------------------------------------
%% attribute number 11 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term11,Bytes13,Rb12} = case Bytes12 of
<<2:2,_:1,10:5,_/binary>> ->
?RT_BER:decode_null(Bytes12,[{tag,128,10,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes12, 0 }
end,

   {Bytes14,Rb13} = ?RT_BER:restbytes2(RemBytes, Bytes13,ext),
   {{'ServiceChangeParm', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9, Term10, Term11}, Bytes14, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8+Rb9+Rb10+Rb11+Rb12+Rb13}.


%%================================
%%  DigitMapValue
%%================================
'enc_DigitMapValue'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,startTimer) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,startTimer), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,shortTimer) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,shortTimer), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,longTimer) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(4,Val,longTimer), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type IA5String
%%-------------------------------------------------
   {EncBytes4,EncLen4} = ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(5,Val,digitMapBody), 22, [{tag,128,3,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 5 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,durationTimer) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(6,Val,durationTimer), [{tag,128,4,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_DigitMapValue'(Bytes, OptOrMand) ->
   'dec_DigitMapValue'(Bytes, OptOrMand, []).

'dec_DigitMapValue'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_integer(Bytes2,{0,99},[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,99},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_integer(Bytes4,{0,99},[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type IA5String
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = ?RT_BER:decode_restricted_string(Bytes5,[],22,[{tag,128,3,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 5 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
?RT_BER:decode_integer(Bytes6,{0,99},[{tag,128,4,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

   {Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,ext),
   {{'DigitMapValue', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}.


%%================================
%%  DigitMapName
%%================================

'enc_DigitMapName'({'DigitMapName',Val}, TagIn) ->
   'enc_DigitMapName'(Val, TagIn);

'enc_DigitMapName'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_DigitMapName'(Bytes, OptOrMand) ->
   'dec_DigitMapName'(Bytes, OptOrMand, []).

'dec_DigitMapName'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,2,TagIn++[], no_length, OptOrMand).



%%================================
%%  DigitMapDescriptor
%%================================
'enc_DigitMapDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,digitMapName) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,digitMapName), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:DigitMapValue OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,digitMapValue) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_DigitMapValue'(?RT_BER:cindex(3,Val,digitMapValue), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_DigitMapDescriptor'(Bytes, OptOrMand) ->
   'dec_DigitMapDescriptor'(Bytes, OptOrMand, []).

'dec_DigitMapDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_octet_string(Bytes2,2,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:DigitMapValue OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_DigitMapValue'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'DigitMapDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  ModemType
%%================================

'enc_ModemType'({'ModemType',Val}, TagIn) ->
   'enc_ModemType'(Val, TagIn);

'enc_ModemType'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
v18 -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
v22 -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
v22bis -> ?RT_BER:encode_enumerated(2,TagIn ++ []);
v32 -> ?RT_BER:encode_enumerated(3,TagIn ++ []);
v32bis -> ?RT_BER:encode_enumerated(4,TagIn ++ []);
v34 -> ?RT_BER:encode_enumerated(5,TagIn ++ []);
v90 -> ?RT_BER:encode_enumerated(6,TagIn ++ []);
v91 -> ?RT_BER:encode_enumerated(7,TagIn ++ []);
synchISDN -> ?RT_BER:encode_enumerated(8,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_ModemType'(Bytes, OptOrMand) ->
   'dec_ModemType'(Bytes, OptOrMand, []).

'dec_ModemType'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{v18,0},{v22,1},{v22bis,2},{v32,3},{v32bis,4},{v34,5},{v90,6},{v91,7},{synchISDN,8}],[]},TagIn++[], OptOrMand).



%%================================
%%  ModemDescriptor
%%================================
'enc_ModemDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_ModemDescriptor_mtl'(?RT_BER:cindex(2,Val,mtl), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_ModemDescriptor_mpl'(?RT_BER:cindex(3,Val,mpl), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:NonStandardData OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,nonStandardData) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_NonStandardData'(?RT_BER:cindex(4,Val,nonStandardData), [{tag,128,2,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  ModemDescriptor_mtl
%%================================

'enc_ModemDescriptor_mtl'({'ModemDescriptor_mtl',Val}, TagIn) ->
   'enc_ModemDescriptor_mtl'(Val, TagIn);

'enc_ModemDescriptor_mtl'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ModemDescriptor_mtl_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ModemDescriptor_mtl_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ModemDescriptor_mtl_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = case (case H of {asn1_enum,_}->H;{_,_}->element(2,H);_->H end) of
v18 -> ?RT_BER:encode_enumerated(0,[]);
v22 -> ?RT_BER:encode_enumerated(1,[]);
v22bis -> ?RT_BER:encode_enumerated(2,[]);
v32 -> ?RT_BER:encode_enumerated(3,[]);
v32bis -> ?RT_BER:encode_enumerated(4,[]);
v34 -> ?RT_BER:encode_enumerated(5,[]);
v90 -> ?RT_BER:encode_enumerated(6,[]);
v91 -> ?RT_BER:encode_enumerated(7,[]);
synchISDN -> ?RT_BER:encode_enumerated(8,[]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end,
   'enc_ModemDescriptor_mtl_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ModemDescriptor_mtl'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
?RT_BER:decode_enumerated(FBytes,[],{[{v18,0},{v22,1},{v22bis,2},{v32,3},{v32bis,4},{v34,5},{v90,6},{v91,7},{synchISDN,8}],[]},[], mandatory)
end, [], []).





%%================================
%%  ModemDescriptor_mpl
%%================================

'enc_ModemDescriptor_mpl'({'ModemDescriptor_mpl',Val}, TagIn) ->
   'enc_ModemDescriptor_mpl'(Val, TagIn);

'enc_ModemDescriptor_mpl'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ModemDescriptor_mpl_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ModemDescriptor_mpl_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ModemDescriptor_mpl_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_PropertyParm'(H, []),
   'enc_ModemDescriptor_mpl_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ModemDescriptor_mpl'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PropertyParm'/3, [], []).




'dec_ModemDescriptor'(Bytes, OptOrMand) ->
   'dec_ModemDescriptor'(Bytes, OptOrMand, []).

'dec_ModemDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_ModemDescriptor_mtl'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_ModemDescriptor_mpl'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:NonStandardData OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_NonStandardData'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
   {{'ModemDescriptor', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  RequestID
%%================================

'enc_RequestID'({'RequestID',Val}, TagIn) ->
   'enc_RequestID'(Val, TagIn);

'enc_RequestID'(Val, TagIn) ->
?RT_BER:encode_integer([], Val, TagIn ++ []).


'dec_RequestID'(Bytes, OptOrMand) ->
   'dec_RequestID'(Bytes, OptOrMand, []).

'dec_RequestID'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_integer(Bytes,{0,4294967295},TagIn++[], OptOrMand).



%%================================
%%  SigParameter
%%================================
'enc_SigParameter'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,sigParameterName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Value
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_Value'(?RT_BER:cindex(3,Val,value), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,extraInfo) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SigParameter_extraInfo'(?RT_BER:cindex(4,Val,extraInfo), [{tag,128,2,'EXPLICIT',32}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  SigParameter_extraInfo
%%================================

'enc_SigParameter_extraInfo'({'SigParameter_extraInfo',Val}, TagIn) ->
   'enc_SigParameter_extraInfo'(Val, TagIn);

'enc_SigParameter_extraInfo'(Val, TagIn) ->
      {EncBytes,EncLen} = case element(1,Val) of
      relation ->
         case (case element(2,Val) of {asn1_enum,_}->element(2,Val);{_,_}->element(2,element(2,Val));_->element(2,Val) end) of
greaterThan -> ?RT_BER:encode_enumerated(0,[{tag,128,0,'IMPLICIT',0}]);
smallerThan -> ?RT_BER:encode_enumerated(1,[{tag,128,0,'IMPLICIT',0}]);
unequalTo -> ?RT_BER:encode_enumerated(2,[{tag,128,0,'IMPLICIT',0}]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[{tag,128,0,'IMPLICIT',0}]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end;
      range ->
         ?RT_BER:encode_boolean(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      sublist ->
         ?RT_BER:encode_boolean(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).


'dec_SigParameter_extraInfo'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'relation'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_enumerated(Bytes1,[],{[{greaterThan,0},{smallerThan,1},{unequalTo,2}],[]},[{tag,128,0,'IMPLICIT',0}], mandatory),
         {{relation, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'range'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_boolean(Bytes1,[{tag,128,1,'IMPLICIT',0}], mandatory),
         {{range, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'sublist'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_boolean(Bytes1,[{tag,128,2,'IMPLICIT',0}], mandatory),
         {{sublist, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


'dec_SigParameter'(Bytes, OptOrMand) ->
   'dec_SigParameter'(Bytes, OptOrMand, []).

'dec_SigParameter'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,2,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Value
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_Value'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_SigParameter_extraInfo'(Bytes4, opt_or_default, [{tag,128,2,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'SigParameter', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  NotifyCompletion
%%================================

'enc_NotifyCompletion'({'NotifyCompletion',Val}, TagIn) ->
   'enc_NotifyCompletion'(Val, TagIn);

'enc_NotifyCompletion'(Val, TagIn) ->
?RT_BER:encode_bit_string([], Val, [{onTimeOut,0},{onInterruptByEvent,1},{onInterruptByNewSignalDescr,2},{otherReason,3},{onIteration,4}], TagIn ++ []).


'dec_NotifyCompletion'(Bytes, OptOrMand) ->
   'dec_NotifyCompletion'(Bytes, OptOrMand, []).

'dec_NotifyCompletion'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_bit_string(Bytes,[],[{onTimeOut,0},{onInterruptByEvent,1},{onInterruptByNewSignalDescr,2},{otherReason,3},{onIteration,4}],TagIn++[], no_length, OptOrMand).



%%================================
%%  SignalName
%%================================

'enc_SignalName'({'SignalName',Val}, TagIn) ->
   'enc_SignalName'(Val, TagIn);

'enc_SignalName'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_SignalName'(Bytes, OptOrMand) ->
   'dec_SignalName'(Bytes, OptOrMand, []).

'dec_SignalName'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,4,TagIn++[], no_length, OptOrMand).



%%================================
%%  SignalDirection
%%================================

'enc_SignalDirection'({'SignalDirection',Val}, TagIn) ->
   'enc_SignalDirection'(Val, TagIn);

'enc_SignalDirection'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
internal -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
external -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
both -> ?RT_BER:encode_enumerated(3,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_SignalDirection'(Bytes, OptOrMand) ->
   'dec_SignalDirection'(Bytes, OptOrMand, []).

'dec_SignalDirection'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{internal,0},{external,1},{both,3}],[]},TagIn++[], OptOrMand).



%%================================
%%  SignalType
%%================================

'enc_SignalType'({'SignalType',Val}, TagIn) ->
   'enc_SignalType'(Val, TagIn);

'enc_SignalType'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
brief -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
onOff -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
timeOut -> ?RT_BER:encode_enumerated(2,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_SignalType'(Bytes, OptOrMand) ->
   'dec_SignalType'(Bytes, OptOrMand, []).

'dec_SignalType'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{brief,0},{onOff,1},{timeOut,2}],[]},TagIn++[], OptOrMand).



%%================================
%%  Signal
%%================================
'enc_Signal'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,signalName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,streamID), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,sigType) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(4,Val,sigType) of {asn1_enum,_}->?RT_BER:cindex(4,Val,sigType);{_,_}->element(2,?RT_BER:cindex(4,Val,sigType));_->?RT_BER:cindex(4,Val,sigType) end) of
brief -> ?RT_BER:encode_enumerated(0,[{tag,128,2,'IMPLICIT',0}]);
onOff -> ?RT_BER:encode_enumerated(1,[{tag,128,2,'IMPLICIT',0}]);
timeOut -> ?RT_BER:encode_enumerated(2,[{tag,128,2,'IMPLICIT',0}]);
{asn1_enum,Enumval3} -> ?RT_BER:encode_enumerated(Enumval3,[{tag,128,2,'IMPLICIT',0}]);
Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}})
end
       end,

%%-------------------------------------------------
%% attribute number 4 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,duration) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(5,Val,duration), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5 with type BIT STRING OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,notifyCompletion) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_bit_string([], ?RT_BER:cindex(6,Val,notifyCompletion), [{onTimeOut,0},{onInterruptByEvent,1},{onInterruptByNewSignalDescr,2},{otherReason,3},{onIteration,4}], [{tag,128,4,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 6 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes6,EncLen6} =  case ?RT_BER:cindex(7,Val,keepActive) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(7,Val,keepActive), [{tag,128,5,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 7 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes7,EncLen7} = 'enc_Signal_sigParList'(?RT_BER:cindex(8,Val,sigParList), [{tag,128,6,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 8 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes8,EncLen8} =  case ?RT_BER:cindex(9,Val,direction) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(9,Val,direction) of {asn1_enum,_}->?RT_BER:cindex(9,Val,direction);{_,_}->element(2,?RT_BER:cindex(9,Val,direction));_->?RT_BER:cindex(9,Val,direction) end) of
internal -> ?RT_BER:encode_enumerated(0,[{tag,128,7,'IMPLICIT',0}]);
external -> ?RT_BER:encode_enumerated(1,[{tag,128,7,'IMPLICIT',0}]);
both -> ?RT_BER:encode_enumerated(3,[{tag,128,7,'IMPLICIT',0}]);
{asn1_enum,Enumval8} -> ?RT_BER:encode_enumerated(Enumval8,[{tag,128,7,'IMPLICIT',0}]);
Enumval9 -> exit({error,{asn1, {enumerated_not_in_range,Enumval9}}})
end
       end,

%%-------------------------------------------------
%% attribute number 9 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes9,EncLen9} =  case ?RT_BER:cindex(10,Val,requestID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(10,Val,requestID), [{tag,128,8,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 10 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes10,EncLen10} =  case ?RT_BER:cindex(11,Val,intersigDelay) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(11,Val,intersigDelay), [{tag,128,9,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  Signal_sigParList
%%================================

'enc_Signal_sigParList'({'Signal_sigParList',Val}, TagIn) ->
   'enc_Signal_sigParList'(Val, TagIn);

'enc_Signal_sigParList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_Signal_sigParList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_Signal_sigParList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_Signal_sigParList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_SigParameter'(H, []),
   'enc_Signal_sigParList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_Signal_sigParList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_SigParameter'/3, [], []).




'dec_Signal'(Bytes, OptOrMand) ->
   'dec_Signal'(Bytes, OptOrMand, []).

'dec_Signal'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes4,[],{[{brief,0},{onOff,1},{timeOut,2}],[]},[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
?RT_BER:decode_integer(Bytes5,{0,65535},[{tag,128,3,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5 with type BIT STRING OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
?RT_BER:decode_bit_string(Bytes6,[],[{onTimeOut,0},{onInterruptByEvent,1},{onInterruptByNewSignalDescr,2},{otherReason,3},{onIteration,4}],[{tag,128,4,'IMPLICIT',0}], no_length, mandatory);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

%%-------------------------------------------------
%% attribute number 6 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term6,Bytes8,Rb7} = case Bytes7 of
<<2:2,_:1,5:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes7,[{tag,128,5,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes7, 0 }
end,

%%-------------------------------------------------
%% attribute number 7 with type SEQUENCE OF
%%-------------------------------------------------
   {Term7,Bytes9,Rb8} = 'dec_Signal_sigParList'(Bytes8, mandatory, [{tag,128,6,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 8 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term8,Bytes10,Rb9} = case Bytes9 of
<<2:2,_:1,7:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes9,[],{[{internal,0},{external,1},{both,3}],[]},[{tag,128,7,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes9, 0 }
end,

%%-------------------------------------------------
%% attribute number 9 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term9,Bytes11,Rb10} = case Bytes10 of
<<2:2,_:1,8:5,_/binary>> ->
?RT_BER:decode_integer(Bytes10,{0,4294967295},[{tag,128,8,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes10, 0 }
end,

%%-------------------------------------------------
%% attribute number 10 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term10,Bytes12,Rb11} = case Bytes11 of
<<2:2,_:1,9:5,_/binary>> ->
?RT_BER:decode_integer(Bytes11,{0,65535},[{tag,128,9,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes11, 0 }
end,

   {Bytes13,Rb12} = ?RT_BER:restbytes2(RemBytes, Bytes12,ext),
   {{'Signal', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9, Term10}, Bytes13, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8+Rb9+Rb10+Rb11+Rb12}.


%%================================
%%  SeqSigList
%%================================
'enc_SeqSigList'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,id), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_SeqSigList_signalList'(?RT_BER:cindex(3,Val,signalList), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  SeqSigList_signalList
%%================================

'enc_SeqSigList_signalList'({'SeqSigList_signalList',Val}, TagIn) ->
   'enc_SeqSigList_signalList'(Val, TagIn);

'enc_SeqSigList_signalList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_SeqSigList_signalList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_SeqSigList_signalList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_SeqSigList_signalList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_Signal'(H, []),
   'enc_SeqSigList_signalList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_SeqSigList_signalList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Signal'/3, [], []).




'dec_SeqSigList'(Bytes, OptOrMand) ->
   'dec_SeqSigList'(Bytes, OptOrMand, []).

'dec_SeqSigList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_SeqSigList_signalList'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'SeqSigList', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  SignalRequest
%%================================

'enc_SignalRequest'({'SignalRequest',Val}, TagIn) ->
   'enc_SignalRequest'(Val, TagIn);

'enc_SignalRequest'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      signal ->
         'enc_Signal'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      seqSigList ->
         'enc_SeqSigList'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_SignalRequest'(Bytes, OptOrMand) ->
   'dec_SignalRequest'(Bytes, OptOrMand, []).

'dec_SignalRequest'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'signal'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_Signal'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{signal, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'seqSigList'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_SeqSigList'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{seqSigList, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  SignalsDescriptor
%%================================

'enc_SignalsDescriptor'({'SignalsDescriptor',Val}, TagIn) ->
   'enc_SignalsDescriptor'(Val, TagIn);

'enc_SignalsDescriptor'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_SignalsDescriptor_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_SignalsDescriptor_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_SignalsDescriptor_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_SignalRequest'(H, []),
   'enc_SignalsDescriptor_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_SignalsDescriptor'(Bytes, OptOrMand) ->
   'dec_SignalsDescriptor'(Bytes, OptOrMand, []).

'dec_SignalsDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_SignalRequest'/3, [], []).




%%================================
%%  EventSpec
%%================================
'enc_EventSpec'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,eventName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,streamID), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes3,EncLen3} = 'enc_EventSpec_eventParList'(?RT_BER:cindex(4,Val,eventParList), [{tag,128,2,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  EventSpec_eventParList
%%================================

'enc_EventSpec_eventParList'({'EventSpec_eventParList',Val}, TagIn) ->
   'enc_EventSpec_eventParList'(Val, TagIn);

'enc_EventSpec_eventParList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_EventSpec_eventParList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_EventSpec_eventParList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_EventSpec_eventParList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_EventParameter'(H, []),
   'enc_EventSpec_eventParList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_EventSpec_eventParList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_EventParameter'/3, [], []).




'dec_EventSpec'(Bytes, OptOrMand) ->
   'dec_EventSpec'(Bytes, OptOrMand, []).

'dec_EventSpec'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type SEQUENCE OF
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = 'dec_EventSpec_eventParList'(Bytes4, mandatory, [{tag,128,2,'IMPLICIT',0}]),

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'EventSpec', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  EventBufferDescriptor
%%================================

'enc_EventBufferDescriptor'({'EventBufferDescriptor',Val}, TagIn) ->
   'enc_EventBufferDescriptor'(Val, TagIn);

'enc_EventBufferDescriptor'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_EventBufferDescriptor_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_EventBufferDescriptor_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_EventBufferDescriptor_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_EventSpec'(H, []),
   'enc_EventBufferDescriptor_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_EventBufferDescriptor'(Bytes, OptOrMand) ->
   'dec_EventBufferDescriptor'(Bytes, OptOrMand, []).

'dec_EventBufferDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_EventSpec'/3, [], []).




%%================================
%%  SecondRequestedActions
%%================================
'enc_SecondRequestedActions'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,keepActive) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(2,Val,keepActive), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:EventDM OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,eventDM) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_EventDM'(?RT_BER:cindex(3,Val,eventDM), [{tag,128,1,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:SignalsDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,signalsDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SignalsDescriptor'(?RT_BER:cindex(4,Val,signalsDescriptor), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:NotifyBehaviour OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,notifyBehaviour) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_NotifyBehaviour'(?RT_BER:cindex(5,Val,notifyBehaviour), [{tag,128,3,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 5 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,resetEventsDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(6,Val,resetEventsDescriptor), [{tag,128,4,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_SecondRequestedActions'(Bytes, OptOrMand) ->
   'dec_SecondRequestedActions'(Bytes, OptOrMand, []).

'dec_SecondRequestedActions'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes2,[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:EventDM OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_EventDM'(Bytes3, opt_or_default, [{tag,128,1,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:SignalsDescriptor OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_SignalsDescriptor'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:NotifyBehaviour OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_NotifyBehaviour'(Bytes5, opt_or_default, [{tag,128,3,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
?RT_BER:decode_null(Bytes6,[{tag,128,4,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

   {Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,ext),
   {{'SecondRequestedActions', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}.


%%================================
%%  SecondRequestedEvent
%%================================
'enc_SecondRequestedEvent'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,pkgdName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,streamID), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:SecondRequestedActions OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,eventAction) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SecondRequestedActions'(?RT_BER:cindex(4,Val,eventAction), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes4,EncLen4} = 'enc_SecondRequestedEvent_evParList'(?RT_BER:cindex(5,Val,evParList), [{tag,128,3,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  SecondRequestedEvent_evParList
%%================================

'enc_SecondRequestedEvent_evParList'({'SecondRequestedEvent_evParList',Val}, TagIn) ->
   'enc_SecondRequestedEvent_evParList'(Val, TagIn);

'enc_SecondRequestedEvent_evParList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_SecondRequestedEvent_evParList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_SecondRequestedEvent_evParList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_SecondRequestedEvent_evParList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_EventParameter'(H, []),
   'enc_SecondRequestedEvent_evParList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_SecondRequestedEvent_evParList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_EventParameter'/3, [], []).




'dec_SecondRequestedEvent'(Bytes, OptOrMand) ->
   'dec_SecondRequestedEvent'(Bytes, OptOrMand, []).

'dec_SecondRequestedEvent'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:SecondRequestedActions OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_SecondRequestedActions'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = 'dec_SecondRequestedEvent_evParList'(Bytes5, mandatory, [{tag,128,3,'IMPLICIT',0}]),

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'SecondRequestedEvent', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  SecondEventsDescriptor
%%================================
'enc_SecondEventsDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,requestID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,requestID), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_SecondEventsDescriptor_eventList'(?RT_BER:cindex(3,Val,eventList), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  SecondEventsDescriptor_eventList
%%================================

'enc_SecondEventsDescriptor_eventList'({'SecondEventsDescriptor_eventList',Val}, TagIn) ->
   'enc_SecondEventsDescriptor_eventList'(Val, TagIn);

'enc_SecondEventsDescriptor_eventList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_SecondEventsDescriptor_eventList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_SecondEventsDescriptor_eventList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_SecondEventsDescriptor_eventList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_SecondRequestedEvent'(H, []),
   'enc_SecondEventsDescriptor_eventList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_SecondEventsDescriptor_eventList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_SecondRequestedEvent'/3, [], []).




'dec_SecondEventsDescriptor'(Bytes, OptOrMand) ->
   'dec_SecondEventsDescriptor'(Bytes, OptOrMand, []).

'dec_SecondEventsDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_SecondEventsDescriptor_eventList'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'SecondEventsDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  EventDM
%%================================

'enc_EventDM'({'EventDM',Val}, TagIn) ->
   'enc_EventDM'(Val, TagIn);

'enc_EventDM'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      digitMapName ->
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      digitMapValue ->
         'enc_DigitMapValue'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_EventDM'(Bytes, OptOrMand) ->
   'dec_EventDM'(Bytes, OptOrMand, []).

'dec_EventDM'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'digitMapName'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,2,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),
         {{digitMapName, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'digitMapValue'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_DigitMapValue'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{digitMapValue, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


%%================================
%%  RequestedActions
%%================================
'enc_RequestedActions'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,keepActive) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(2,Val,keepActive), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:EventDM OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,eventDM) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_EventDM'(?RT_BER:cindex(3,Val,eventDM), [{tag,128,1,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:SecondEventsDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,secondEvent) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SecondEventsDescriptor'(?RT_BER:cindex(4,Val,secondEvent), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:SignalsDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,signalsDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SignalsDescriptor'(?RT_BER:cindex(5,Val,signalsDescriptor), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5   External megaco_ber_media_gateway_control_prev3c:NotifyBehaviour OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,notifyBehaviour) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_NotifyBehaviour'(?RT_BER:cindex(6,Val,notifyBehaviour), [{tag,128,4,'EXPLICIT',32}])
       end,

%%-------------------------------------------------
%% attribute number 6 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes6,EncLen6} =  case ?RT_BER:cindex(7,Val,resetEventsDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(7,Val,resetEventsDescriptor), [{tag,128,5,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_RequestedActions'(Bytes, OptOrMand) ->
   'dec_RequestedActions'(Bytes, OptOrMand, []).

'dec_RequestedActions'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes2,[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:EventDM OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_EventDM'(Bytes3, opt_or_default, [{tag,128,1,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:SecondEventsDescriptor OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_SecondEventsDescriptor'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:SignalsDescriptor OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_SignalsDescriptor'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5   External megaco_ber_media_gateway_control_prev3c:NotifyBehaviour OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
'dec_NotifyBehaviour'(Bytes6, opt_or_default, [{tag,128,4,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

%%-------------------------------------------------
%% attribute number 6 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term6,Bytes8,Rb7} = case Bytes7 of
<<2:2,_:1,5:5,_/binary>> ->
?RT_BER:decode_null(Bytes7,[{tag,128,5,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes7, 0 }
end,

   {Bytes9,Rb8} = ?RT_BER:restbytes2(RemBytes, Bytes8,ext),
   {{'RequestedActions', Term1, Term2, Term3, Term4, Term5, Term6}, Bytes9, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8}.


%%================================
%%  NotifyBehaviour
%%================================

'enc_NotifyBehaviour'({'NotifyBehaviour',Val}, TagIn) ->
   'enc_NotifyBehaviour'(Val, TagIn);

'enc_NotifyBehaviour'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      notifyImmediate ->
         ?RT_BER:encode_null(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      notifyRegulated ->
         'enc_RegulatedEmbeddedDescriptor'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      neverNotify ->
         ?RT_BER:encode_null(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_NotifyBehaviour'(Bytes, OptOrMand) ->
   'dec_NotifyBehaviour'(Bytes, OptOrMand, []).

'dec_NotifyBehaviour'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'notifyImmediate'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_null(Bytes1,[{tag,128,0,'IMPLICIT',0}], mandatory),
         {{notifyImmediate, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'notifyRegulated'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_RegulatedEmbeddedDescriptor'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{notifyRegulated, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'neverNotify'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_null(Bytes1,[{tag,128,2,'IMPLICIT',0}], mandatory),
         {{neverNotify, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  RegulatedEmbeddedDescriptor
%%================================
'enc_RegulatedEmbeddedDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:SecondEventsDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,secondEvent) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SecondEventsDescriptor'(?RT_BER:cindex(2,Val,secondEvent), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:SignalsDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,signalsDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SignalsDescriptor'(?RT_BER:cindex(3,Val,signalsDescriptor), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_RegulatedEmbeddedDescriptor'(Bytes, OptOrMand) ->
   'dec_RegulatedEmbeddedDescriptor'(Bytes, OptOrMand, []).

'dec_RegulatedEmbeddedDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:SecondEventsDescriptor OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
'dec_SecondEventsDescriptor'(Bytes2, opt_or_default, [{tag,128,0,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:SignalsDescriptor OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_SignalsDescriptor'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'RegulatedEmbeddedDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  RequestedEvent
%%================================
'enc_RequestedEvent'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,pkgdName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,streamID), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:RequestedActions OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,eventAction) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_RequestedActions'(?RT_BER:cindex(4,Val,eventAction), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes4,EncLen4} = 'enc_RequestedEvent_evParList'(?RT_BER:cindex(5,Val,evParList), [{tag,128,3,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  RequestedEvent_evParList
%%================================

'enc_RequestedEvent_evParList'({'RequestedEvent_evParList',Val}, TagIn) ->
   'enc_RequestedEvent_evParList'(Val, TagIn);

'enc_RequestedEvent_evParList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_RequestedEvent_evParList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_RequestedEvent_evParList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_RequestedEvent_evParList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_EventParameter'(H, []),
   'enc_RequestedEvent_evParList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_RequestedEvent_evParList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_EventParameter'/3, [], []).




'dec_RequestedEvent'(Bytes, OptOrMand) ->
   'dec_RequestedEvent'(Bytes, OptOrMand, []).

'dec_RequestedEvent'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:RequestedActions OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_RequestedActions'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = 'dec_RequestedEvent_evParList'(Bytes5, mandatory, [{tag,128,3,'IMPLICIT',0}]),

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'RequestedEvent', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  EventsDescriptor
%%================================
'enc_EventsDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,requestID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,requestID), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_EventsDescriptor_eventList'(?RT_BER:cindex(3,Val,eventList), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  EventsDescriptor_eventList
%%================================

'enc_EventsDescriptor_eventList'({'EventsDescriptor_eventList',Val}, TagIn) ->
   'enc_EventsDescriptor_eventList'(Val, TagIn);

'enc_EventsDescriptor_eventList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_EventsDescriptor_eventList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_EventsDescriptor_eventList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_EventsDescriptor_eventList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_RequestedEvent'(H, []),
   'enc_EventsDescriptor_eventList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_EventsDescriptor_eventList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_RequestedEvent'/3, [], []).




'dec_EventsDescriptor'(Bytes, OptOrMand) ->
   'dec_EventsDescriptor'(Bytes, OptOrMand, []).

'dec_EventsDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_EventsDescriptor_eventList'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'EventsDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  StreamID
%%================================

'enc_StreamID'({'StreamID',Val}, TagIn) ->
   'enc_StreamID'(Val, TagIn);

'enc_StreamID'(Val, TagIn) ->
?RT_BER:encode_integer([], Val, TagIn ++ []).


'dec_StreamID'(Bytes, OptOrMand) ->
   'dec_StreamID'(Bytes, OptOrMand, []).

'dec_StreamID'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_integer(Bytes,{0,65535},TagIn++[], OptOrMand).



%%================================
%%  MuxType
%%================================

'enc_MuxType'({'MuxType',Val}, TagIn) ->
   'enc_MuxType'(Val, TagIn);

'enc_MuxType'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
h221 -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
h223 -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
h226 -> ?RT_BER:encode_enumerated(2,TagIn ++ []);
v76 -> ?RT_BER:encode_enumerated(3,TagIn ++ []);
nx64k -> ?RT_BER:encode_enumerated(4,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_MuxType'(Bytes, OptOrMand) ->
   'dec_MuxType'(Bytes, OptOrMand, []).

'dec_MuxType'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{h221,0},{h223,1},{h226,2},{v76,3}],[{nx64k,4}]},TagIn++[], OptOrMand).



%%================================
%%  MuxDescriptor
%%================================
'enc_MuxDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type ENUMERATED
%%-------------------------------------------------
   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,muxType) of {asn1_enum,_}->?RT_BER:cindex(2,Val,muxType);{_,_}->element(2,?RT_BER:cindex(2,Val,muxType));_->?RT_BER:cindex(2,Val,muxType) end) of
h221 -> ?RT_BER:encode_enumerated(0,[{tag,128,0,'IMPLICIT',0}]);
h223 -> ?RT_BER:encode_enumerated(1,[{tag,128,0,'IMPLICIT',0}]);
h226 -> ?RT_BER:encode_enumerated(2,[{tag,128,0,'IMPLICIT',0}]);
v76 -> ?RT_BER:encode_enumerated(3,[{tag,128,0,'IMPLICIT',0}]);
nx64k -> ?RT_BER:encode_enumerated(4,[{tag,128,0,'IMPLICIT',0}]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[{tag,128,0,'IMPLICIT',0}]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end,

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_MuxDescriptor_termList'(?RT_BER:cindex(3,Val,termList), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:NonStandardData OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,nonStandardData) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_NonStandardData'(?RT_BER:cindex(4,Val,nonStandardData), [{tag,128,2,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  MuxDescriptor_termList
%%================================

'enc_MuxDescriptor_termList'({'MuxDescriptor_termList',Val}, TagIn) ->
   'enc_MuxDescriptor_termList'(Val, TagIn);

'enc_MuxDescriptor_termList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_MuxDescriptor_termList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_MuxDescriptor_termList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_MuxDescriptor_termList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_TerminationID'(H, []),
   'enc_MuxDescriptor_termList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_MuxDescriptor_termList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_TerminationID'/3, [], []).




'dec_MuxDescriptor'(Bytes, OptOrMand) ->
   'dec_MuxDescriptor'(Bytes, OptOrMand, []).

'dec_MuxDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type ENUMERATED
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],{[{h221,0},{h223,1},{h226,2},{v76,3}],[{nx64k,4}]},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_MuxDescriptor_termList'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:NonStandardData OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_NonStandardData'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'MuxDescriptor', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  ServiceState
%%================================

'enc_ServiceState'({'ServiceState',Val}, TagIn) ->
   'enc_ServiceState'(Val, TagIn);

'enc_ServiceState'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
test -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
outOfSvc -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
inSvc -> ?RT_BER:encode_enumerated(2,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_ServiceState'(Bytes, OptOrMand) ->
   'dec_ServiceState'(Bytes, OptOrMand, []).

'dec_ServiceState'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{test,0},{outOfSvc,1},{inSvc,2}],[]},TagIn++[], OptOrMand).



%%================================
%%  EventBufferControl
%%================================

'enc_EventBufferControl'({'EventBufferControl',Val}, TagIn) ->
   'enc_EventBufferControl'(Val, TagIn);

'enc_EventBufferControl'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
off -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
lockStep -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_EventBufferControl'(Bytes, OptOrMand) ->
   'dec_EventBufferControl'(Bytes, OptOrMand, []).

'dec_EventBufferControl'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{off,0},{lockStep,1}],[]},TagIn++[], OptOrMand).



%%================================
%%  TerminationStateDescriptor
%%================================
'enc_TerminationStateDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationStateDescriptor_propertyParms'(?RT_BER:cindex(2,Val,propertyParms), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,eventBufferControl) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(3,Val,eventBufferControl) of {asn1_enum,_}->?RT_BER:cindex(3,Val,eventBufferControl);{_,_}->element(2,?RT_BER:cindex(3,Val,eventBufferControl));_->?RT_BER:cindex(3,Val,eventBufferControl) end) of
off -> ?RT_BER:encode_enumerated(0,[{tag,128,1,'IMPLICIT',0}]);
lockStep -> ?RT_BER:encode_enumerated(1,[{tag,128,1,'IMPLICIT',0}]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[{tag,128,1,'IMPLICIT',0}]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end
       end,

%%-------------------------------------------------
%% attribute number 3 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,serviceState) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(4,Val,serviceState) of {asn1_enum,_}->?RT_BER:cindex(4,Val,serviceState);{_,_}->element(2,?RT_BER:cindex(4,Val,serviceState));_->?RT_BER:cindex(4,Val,serviceState) end) of
test -> ?RT_BER:encode_enumerated(0,[{tag,128,2,'IMPLICIT',0}]);
outOfSvc -> ?RT_BER:encode_enumerated(1,[{tag,128,2,'IMPLICIT',0}]);
inSvc -> ?RT_BER:encode_enumerated(2,[{tag,128,2,'IMPLICIT',0}]);
{asn1_enum,Enumval3} -> ?RT_BER:encode_enumerated(Enumval3,[{tag,128,2,'IMPLICIT',0}]);
Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}})
end
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  TerminationStateDescriptor_propertyParms
%%================================

'enc_TerminationStateDescriptor_propertyParms'({'TerminationStateDescriptor_propertyParms',Val}, TagIn) ->
   'enc_TerminationStateDescriptor_propertyParms'(Val, TagIn);

'enc_TerminationStateDescriptor_propertyParms'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_TerminationStateDescriptor_propertyParms_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_TerminationStateDescriptor_propertyParms_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_TerminationStateDescriptor_propertyParms_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_PropertyParm'(H, []),
   'enc_TerminationStateDescriptor_propertyParms_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_TerminationStateDescriptor_propertyParms'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PropertyParm'/3, [], []).




'dec_TerminationStateDescriptor'(Bytes, OptOrMand) ->
   'dec_TerminationStateDescriptor'(Bytes, OptOrMand, []).

'dec_TerminationStateDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationStateDescriptor_propertyParms'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes3,[],{[{off,0},{lockStep,1}],[]},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes4,[],{[{test,0},{outOfSvc,1},{inSvc,2}],[]},[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'TerminationStateDescriptor', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  PropertyGroup
%%================================

'enc_PropertyGroup'({'PropertyGroup',Val}, TagIn) ->
   'enc_PropertyGroup'(Val, TagIn);

'enc_PropertyGroup'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_PropertyGroup_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_PropertyGroup_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_PropertyGroup_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_PropertyParm'(H, []),
   'enc_PropertyGroup_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_PropertyGroup'(Bytes, OptOrMand) ->
   'dec_PropertyGroup'(Bytes, OptOrMand, []).

'dec_PropertyGroup'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PropertyParm'/3, [], []).




%%================================
%%  LocalRemoteDescriptor
%%================================
'enc_LocalRemoteDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_LocalRemoteDescriptor_propGrps'(?RT_BER:cindex(2,Val,propGrps), [{tag,128,0,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1],
  LenSoFar = EncLen1,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  LocalRemoteDescriptor_propGrps
%%================================

'enc_LocalRemoteDescriptor_propGrps'({'LocalRemoteDescriptor_propGrps',Val}, TagIn) ->
   'enc_LocalRemoteDescriptor_propGrps'(Val, TagIn);

'enc_LocalRemoteDescriptor_propGrps'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_LocalRemoteDescriptor_propGrps_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_LocalRemoteDescriptor_propGrps_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_LocalRemoteDescriptor_propGrps_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_PropertyGroup'(H, []),
   'enc_LocalRemoteDescriptor_propGrps_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_LocalRemoteDescriptor_propGrps'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PropertyGroup'/3, [], []).




'dec_LocalRemoteDescriptor'(Bytes, OptOrMand) ->
   'dec_LocalRemoteDescriptor'(Bytes, OptOrMand, []).

'dec_LocalRemoteDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_LocalRemoteDescriptor_propGrps'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

   {Bytes4,Rb3} = ?RT_BER:restbytes2(RemBytes, Bytes3,ext),
   {{'LocalRemoteDescriptor', Term1}, Bytes4, Rb1+Rb2+Rb3}.


%%================================
%%  Relation
%%================================

'enc_Relation'({'Relation',Val}, TagIn) ->
   'enc_Relation'(Val, TagIn);

'enc_Relation'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
greaterThan -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
smallerThan -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
unequalTo -> ?RT_BER:encode_enumerated(2,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_Relation'(Bytes, OptOrMand) ->
   'dec_Relation'(Bytes, OptOrMand, []).

'dec_Relation'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{greaterThan,0},{smallerThan,1},{unequalTo,2}],[]},TagIn++[], OptOrMand).



%%================================
%%  PkgdName
%%================================

'enc_PkgdName'({'PkgdName',Val}, TagIn) ->
   'enc_PkgdName'(Val, TagIn);

'enc_PkgdName'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_PkgdName'(Bytes, OptOrMand) ->
   'dec_PkgdName'(Bytes, OptOrMand, []).

'dec_PkgdName'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,4,TagIn++[], no_length, OptOrMand).



%%================================
%%  Name
%%================================

'enc_Name'({'Name',Val}, TagIn) ->
   'enc_Name'(Val, TagIn);

'enc_Name'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_Name'(Bytes, OptOrMand) ->
   'dec_Name'(Bytes, OptOrMand, []).

'dec_Name'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,2,TagIn++[], no_length, OptOrMand).



%%================================
%%  PropertyParm
%%================================
'enc_PropertyParm'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,name), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_PropertyParm_value'(?RT_BER:cindex(3,Val,value), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,extraInfo) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_PropertyParm_extraInfo'(?RT_BER:cindex(4,Val,extraInfo), [{tag,128,2,'EXPLICIT',32}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  PropertyParm_value
%%================================

'enc_PropertyParm_value'({'PropertyParm_value',Val}, TagIn) ->
   'enc_PropertyParm_value'(Val, TagIn);

'enc_PropertyParm_value'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_PropertyParm_value_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_PropertyParm_value_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_PropertyParm_value_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
   'enc_PropertyParm_value_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_PropertyParm_value'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
end, [], []).





%%================================
%%  PropertyParm_extraInfo
%%================================

'enc_PropertyParm_extraInfo'({'PropertyParm_extraInfo',Val}, TagIn) ->
   'enc_PropertyParm_extraInfo'(Val, TagIn);

'enc_PropertyParm_extraInfo'(Val, TagIn) ->
      {EncBytes,EncLen} = case element(1,Val) of
      relation ->
         case (case element(2,Val) of {asn1_enum,_}->element(2,Val);{_,_}->element(2,element(2,Val));_->element(2,Val) end) of
greaterThan -> ?RT_BER:encode_enumerated(0,[{tag,128,0,'IMPLICIT',0}]);
smallerThan -> ?RT_BER:encode_enumerated(1,[{tag,128,0,'IMPLICIT',0}]);
unequalTo -> ?RT_BER:encode_enumerated(2,[{tag,128,0,'IMPLICIT',0}]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[{tag,128,0,'IMPLICIT',0}]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end;
      range ->
         ?RT_BER:encode_boolean(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      sublist ->
         ?RT_BER:encode_boolean(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).


'dec_PropertyParm_extraInfo'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'relation'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_enumerated(Bytes1,[],{[{greaterThan,0},{smallerThan,1},{unequalTo,2}],[]},[{tag,128,0,'IMPLICIT',0}], mandatory),
         {{relation, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'range'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_boolean(Bytes1,[{tag,128,1,'IMPLICIT',0}], mandatory),
         {{range, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'sublist'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_boolean(Bytes1,[{tag,128,2,'IMPLICIT',0}], mandatory),
         {{sublist, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


'dec_PropertyParm'(Bytes, OptOrMand) ->
   'dec_PropertyParm'(Bytes, OptOrMand, []).

'dec_PropertyParm'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_PropertyParm_value'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_PropertyParm_extraInfo'(Bytes4, opt_or_default, [{tag,128,2,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'PropertyParm', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  StreamMode
%%================================

'enc_StreamMode'({'StreamMode',Val}, TagIn) ->
   'enc_StreamMode'(Val, TagIn);

'enc_StreamMode'(Val, TagIn) ->
case (case Val of {asn1_enum,_}->Val;{_,_}->element(2,Val);_->Val end) of
sendOnly -> ?RT_BER:encode_enumerated(0,TagIn ++ []);
recvOnly -> ?RT_BER:encode_enumerated(1,TagIn ++ []);
sendRecv -> ?RT_BER:encode_enumerated(2,TagIn ++ []);
inactive -> ?RT_BER:encode_enumerated(3,TagIn ++ []);
loopBack -> ?RT_BER:encode_enumerated(4,TagIn ++ []);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,TagIn ++ []);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end.


'dec_StreamMode'(Bytes, OptOrMand) ->
   'dec_StreamMode'(Bytes, OptOrMand, []).

'dec_StreamMode'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_enumerated(Bytes,[],{[{sendOnly,0},{recvOnly,1},{sendRecv,2},{inactive,3},{loopBack,4}],[]},TagIn++[], OptOrMand).



%%================================
%%  LocalControlDescriptor
%%================================
'enc_LocalControlDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,streamMode) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(2,Val,streamMode) of {asn1_enum,_}->?RT_BER:cindex(2,Val,streamMode);{_,_}->element(2,?RT_BER:cindex(2,Val,streamMode));_->?RT_BER:cindex(2,Val,streamMode) end) of
sendOnly -> ?RT_BER:encode_enumerated(0,[{tag,128,0,'IMPLICIT',0}]);
recvOnly -> ?RT_BER:encode_enumerated(1,[{tag,128,0,'IMPLICIT',0}]);
sendRecv -> ?RT_BER:encode_enumerated(2,[{tag,128,0,'IMPLICIT',0}]);
inactive -> ?RT_BER:encode_enumerated(3,[{tag,128,0,'IMPLICIT',0}]);
loopBack -> ?RT_BER:encode_enumerated(4,[{tag,128,0,'IMPLICIT',0}]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[{tag,128,0,'IMPLICIT',0}]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end
       end,

%%-------------------------------------------------
%% attribute number 2 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,reserveValue) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(3,Val,reserveValue), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,reserveGroup) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(4,Val,reserveGroup), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes4,EncLen4} = 'enc_LocalControlDescriptor_propertyParms'(?RT_BER:cindex(5,Val,propertyParms), [{tag,128,3,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  LocalControlDescriptor_propertyParms
%%================================

'enc_LocalControlDescriptor_propertyParms'({'LocalControlDescriptor_propertyParms',Val}, TagIn) ->
   'enc_LocalControlDescriptor_propertyParms'(Val, TagIn);

'enc_LocalControlDescriptor_propertyParms'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_LocalControlDescriptor_propertyParms_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_LocalControlDescriptor_propertyParms_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_LocalControlDescriptor_propertyParms_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_PropertyParm'(H, []),
   'enc_LocalControlDescriptor_propertyParms_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_LocalControlDescriptor_propertyParms'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PropertyParm'/3, [], []).




'dec_LocalControlDescriptor'(Bytes, OptOrMand) ->
   'dec_LocalControlDescriptor'(Bytes, OptOrMand, []).

'dec_LocalControlDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes2,[],{[{sendOnly,0},{recvOnly,1},{sendRecv,2},{inactive,3},{loopBack,4}],[]},[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes3,[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes4,[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = 'dec_LocalControlDescriptor_propertyParms'(Bytes5, mandatory, [{tag,128,3,'IMPLICIT',0}]),

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'LocalControlDescriptor', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  StreamParms
%%================================
'enc_StreamParms'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:LocalControlDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,localControlDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_LocalControlDescriptor'(?RT_BER:cindex(2,Val,localControlDescriptor), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:LocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,localDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_LocalRemoteDescriptor'(?RT_BER:cindex(3,Val,localDescriptor), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:LocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,remoteDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_LocalRemoteDescriptor'(?RT_BER:cindex(4,Val,remoteDescriptor), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:StatisticsDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,statisticsDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_StatisticsDescriptor'(?RT_BER:cindex(5,Val,statisticsDescriptor), [{tag,128,3,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_StreamParms'(Bytes, OptOrMand) ->
   'dec_StreamParms'(Bytes, OptOrMand, []).

'dec_StreamParms'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:LocalControlDescriptor OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
'dec_LocalControlDescriptor'(Bytes2, opt_or_default, [{tag,128,0,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:LocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_LocalRemoteDescriptor'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:LocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_LocalRemoteDescriptor'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:StatisticsDescriptor OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_StatisticsDescriptor'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'StreamParms', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  StreamDescriptor
%%================================
'enc_StreamDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,streamID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:StreamParms
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_StreamParms'(?RT_BER:cindex(3,Val,streamParms), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_StreamDescriptor'(Bytes, OptOrMand) ->
   'dec_StreamDescriptor'(Bytes, OptOrMand, []).

'dec_StreamDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:StreamParms
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_StreamParms'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'StreamDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  MediaDescriptor
%%================================
'enc_MediaDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationStateDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,termStateDescr) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_TerminationStateDescriptor'(?RT_BER:cindex(2,Val,termStateDescr), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streams) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_MediaDescriptor_streams'(?RT_BER:cindex(3,Val,streams), [{tag,128,1,'EXPLICIT',32}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  MediaDescriptor_streams
%%================================

'enc_MediaDescriptor_streams'({'MediaDescriptor_streams',Val}, TagIn) ->
   'enc_MediaDescriptor_streams'(Val, TagIn);

'enc_MediaDescriptor_streams'(Val, TagIn) ->
      {EncBytes,EncLen} = case element(1,Val) of
      oneStream ->
         'enc_StreamParms'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      multiStream ->
         'enc_MediaDescriptor_streams_multiStream'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).





%%================================
%%  MediaDescriptor_streams_multiStream
%%================================

'enc_MediaDescriptor_streams_multiStream'({'MediaDescriptor_streams_multiStream',Val}, TagIn) ->
   'enc_MediaDescriptor_streams_multiStream'(Val, TagIn);

'enc_MediaDescriptor_streams_multiStream'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_MediaDescriptor_streams_multiStream_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_MediaDescriptor_streams_multiStream_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_MediaDescriptor_streams_multiStream_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_StreamDescriptor'(H, []),
   'enc_MediaDescriptor_streams_multiStream_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_MediaDescriptor_streams_multiStream'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_StreamDescriptor'/3, [], []).


'dec_MediaDescriptor_streams'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'oneStream'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_StreamParms'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{oneStream, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'multiStream'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_MediaDescriptor_streams_multiStream'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{multiStream, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


'dec_MediaDescriptor'(Bytes, OptOrMand) ->
   'dec_MediaDescriptor'(Bytes, OptOrMand, []).

'dec_MediaDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationStateDescriptor OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
'dec_TerminationStateDescriptor'(Bytes2, opt_or_default, [{tag,128,0,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_MediaDescriptor_streams'(Bytes3, opt_or_default, [{tag,128,1,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'MediaDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  TerminationIDList
%%================================

'enc_TerminationIDList'({'TerminationIDList',Val}, TagIn) ->
   'enc_TerminationIDList'(Val, TagIn);

'enc_TerminationIDList'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_TerminationIDList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_TerminationIDList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_TerminationIDList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_TerminationID'(H, []),
   'enc_TerminationIDList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_TerminationIDList'(Bytes, OptOrMand) ->
   'dec_TerminationIDList'(Bytes, OptOrMand, []).

'dec_TerminationIDList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_TerminationID'/3, [], []).




%%================================
%%  TerminationID
%%================================
'enc_TerminationID'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationID_wildcard'(?RT_BER:cindex(2,Val,wildcard), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,id), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  TerminationID_wildcard
%%================================

'enc_TerminationID_wildcard'({'TerminationID_wildcard',Val}, TagIn) ->
   'enc_TerminationID_wildcard'(Val, TagIn);

'enc_TerminationID_wildcard'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_TerminationID_wildcard_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_TerminationID_wildcard_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_TerminationID_wildcard_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
   'enc_TerminationID_wildcard_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_TerminationID_wildcard'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
?RT_BER:decode_octet_string(FBytes,1,[], no_length, mandatory)
end, [], []).




'dec_TerminationID'(Bytes, OptOrMand) ->
   'dec_TerminationID'(Bytes, OptOrMand, []).

'dec_TerminationID'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationID_wildcard'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,{1,8},[{tag,128,1,'IMPLICIT',0}], no_length, mandatory),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'TerminationID', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  WildcardField
%%================================

'enc_WildcardField'({'WildcardField',Val}, TagIn) ->
   'enc_WildcardField'(Val, TagIn);

'enc_WildcardField'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_WildcardField'(Bytes, OptOrMand) ->
   'dec_WildcardField'(Bytes, OptOrMand, []).

'dec_WildcardField'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,1,TagIn++[], no_length, OptOrMand).



%%================================
%%  ServiceChangeResult
%%================================

'enc_ServiceChangeResult'({'ServiceChangeResult',Val}, TagIn) ->
   'enc_ServiceChangeResult'(Val, TagIn);

'enc_ServiceChangeResult'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      errorDescriptor ->
         'enc_ErrorDescriptor'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      serviceChangeResParms ->
         'enc_ServiceChangeResParm'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_ServiceChangeResult'(Bytes, OptOrMand) ->
   'dec_ServiceChangeResult'(Bytes, OptOrMand, []).

'dec_ServiceChangeResult'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'errorDescriptor'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ErrorDescriptor'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{errorDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'serviceChangeResParms'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ServiceChangeResParm'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{serviceChangeResParms, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


%%================================
%%  ServiceChangeReply
%%================================
'enc_ServiceChangeReply'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeResult
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_ServiceChangeResult'(?RT_BER:cindex(3,Val,serviceChangeResult), [{tag,128,1,'EXPLICIT',32}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_ServiceChangeReply'(Bytes, OptOrMand) ->
   'dec_ServiceChangeReply'(Bytes, OptOrMand, []).

'dec_ServiceChangeReply'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeResult
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_ServiceChangeResult'(Bytes3, mandatory, [{tag,128,1,'EXPLICIT',32}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'ServiceChangeReply', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  ServiceChangeRequest
%%================================
'enc_ServiceChangeRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeParm
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_ServiceChangeParm'(?RT_BER:cindex(3,Val,serviceChangeParms), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_ServiceChangeRequest'(Bytes, OptOrMand) ->
   'dec_ServiceChangeRequest'(Bytes, OptOrMand, []).

'dec_ServiceChangeRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ServiceChangeParm
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_ServiceChangeParm'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'ServiceChangeRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  EventParameter
%%================================
'enc_EventParameter'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,eventParameterName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Value
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_Value'(?RT_BER:cindex(3,Val,value), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,extraInfo) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_EventParameter_extraInfo'(?RT_BER:cindex(4,Val,extraInfo), [{tag,128,2,'EXPLICIT',32}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  EventParameter_extraInfo
%%================================

'enc_EventParameter_extraInfo'({'EventParameter_extraInfo',Val}, TagIn) ->
   'enc_EventParameter_extraInfo'(Val, TagIn);

'enc_EventParameter_extraInfo'(Val, TagIn) ->
      {EncBytes,EncLen} = case element(1,Val) of
      relation ->
         case (case element(2,Val) of {asn1_enum,_}->element(2,Val);{_,_}->element(2,element(2,Val));_->element(2,Val) end) of
greaterThan -> ?RT_BER:encode_enumerated(0,[{tag,128,0,'IMPLICIT',0}]);
smallerThan -> ?RT_BER:encode_enumerated(1,[{tag,128,0,'IMPLICIT',0}]);
unequalTo -> ?RT_BER:encode_enumerated(2,[{tag,128,0,'IMPLICIT',0}]);
{asn1_enum,Enumval1} -> ?RT_BER:encode_enumerated(Enumval1,[{tag,128,0,'IMPLICIT',0}]);
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
end;
      range ->
         ?RT_BER:encode_boolean(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      sublist ->
         ?RT_BER:encode_boolean(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).


'dec_EventParameter_extraInfo'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'relation'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_enumerated(Bytes1,[],{[{greaterThan,0},{smallerThan,1},{unequalTo,2}],[]},[{tag,128,0,'IMPLICIT',0}], mandatory),
         {{relation, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'range'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_boolean(Bytes1,[{tag,128,1,'IMPLICIT',0}], mandatory),
         {{range, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'sublist'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_boolean(Bytes1,[{tag,128,2,'IMPLICIT',0}], mandatory),
         {{sublist, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


'dec_EventParameter'(Bytes, OptOrMand) ->
   'dec_EventParameter'(Bytes, OptOrMand, []).

'dec_EventParameter'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,2,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Value
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_Value'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_EventParameter_extraInfo'(Bytes4, opt_or_default, [{tag,128,2,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'EventParameter', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  EventName
%%================================

'enc_EventName'({'EventName',Val}, TagIn) ->
   'enc_EventName'(Val, TagIn);

'enc_EventName'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_EventName'(Bytes, OptOrMand) ->
   'dec_EventName'(Bytes, OptOrMand, []).

'dec_EventName'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,4,TagIn++[], no_length, OptOrMand).



%%================================
%%  ObservedEvent
%%================================
'enc_ObservedEvent'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,eventName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,streamID), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes3,EncLen3} = 'enc_ObservedEvent_eventParList'(?RT_BER:cindex(4,Val,eventParList), [{tag,128,2,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:TimeNotation OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,timeNotation) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_TimeNotation'(?RT_BER:cindex(5,Val,timeNotation), [{tag,128,3,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  ObservedEvent_eventParList
%%================================

'enc_ObservedEvent_eventParList'({'ObservedEvent_eventParList',Val}, TagIn) ->
   'enc_ObservedEvent_eventParList'(Val, TagIn);

'enc_ObservedEvent_eventParList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ObservedEvent_eventParList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ObservedEvent_eventParList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ObservedEvent_eventParList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_EventParameter'(H, []),
   'enc_ObservedEvent_eventParList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ObservedEvent_eventParList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_EventParameter'/3, [], []).




'dec_ObservedEvent'(Bytes, OptOrMand) ->
   'dec_ObservedEvent'(Bytes, OptOrMand, []).

'dec_ObservedEvent'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type SEQUENCE OF
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = 'dec_ObservedEvent_eventParList'(Bytes4, mandatory, [{tag,128,2,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:TimeNotation OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_TimeNotation'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'ObservedEvent', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  ObservedEventsDescriptor
%%================================
'enc_ObservedEventsDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,requestId), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_ObservedEventsDescriptor_observedEventLst'(?RT_BER:cindex(3,Val,observedEventLst), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  ObservedEventsDescriptor_observedEventLst
%%================================

'enc_ObservedEventsDescriptor_observedEventLst'({'ObservedEventsDescriptor_observedEventLst',Val}, TagIn) ->
   'enc_ObservedEventsDescriptor_observedEventLst'(Val, TagIn);

'enc_ObservedEventsDescriptor_observedEventLst'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ObservedEventsDescriptor_observedEventLst_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ObservedEventsDescriptor_observedEventLst_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ObservedEventsDescriptor_observedEventLst_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_ObservedEvent'(H, []),
   'enc_ObservedEventsDescriptor_observedEventLst_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ObservedEventsDescriptor_observedEventLst'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_ObservedEvent'/3, [], []).




'dec_ObservedEventsDescriptor'(Bytes, OptOrMand) ->
   'dec_ObservedEventsDescriptor'(Bytes, OptOrMand, []).

'dec_ObservedEventsDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_ObservedEventsDescriptor_observedEventLst'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'ObservedEventsDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  NotifyReply
%%================================
'enc_NotifyReply'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ErrorDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,errorDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ErrorDescriptor'(?RT_BER:cindex(3,Val,errorDescriptor), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_NotifyReply'(Bytes, OptOrMand) ->
   'dec_NotifyReply'(Bytes, OptOrMand, []).

'dec_NotifyReply'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ErrorDescriptor OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_ErrorDescriptor'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'NotifyReply', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  NotifyRequest
%%================================
'enc_NotifyRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ObservedEventsDescriptor
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_ObservedEventsDescriptor'(?RT_BER:cindex(3,Val,observedEventsDescriptor), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:ErrorDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,errorDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ErrorDescriptor'(?RT_BER:cindex(4,Val,errorDescriptor), [{tag,128,2,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_NotifyRequest'(Bytes, OptOrMand) ->
   'dec_NotifyRequest'(Bytes, OptOrMand, []).

'dec_NotifyRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ObservedEventsDescriptor
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_ObservedEventsDescriptor'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:ErrorDescriptor OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_ErrorDescriptor'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'NotifyRequest', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  IndAudPackagesDescriptor
%%================================
'enc_IndAudPackagesDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,packageName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,packageVersion), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudPackagesDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudPackagesDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudPackagesDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,2,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_integer(Bytes3,{0,99},[{tag,128,1,'IMPLICIT',0}], mandatory),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'IndAudPackagesDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IndAudStatisticsDescriptor
%%================================
'enc_IndAudStatisticsDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,statName), [{tag,128,0,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1],
  LenSoFar = EncLen1,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudStatisticsDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudStatisticsDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudStatisticsDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

   {Bytes4,Rb3} = ?RT_BER:restbytes2(RemBytes, Bytes3,noext),
   {{'IndAudStatisticsDescriptor', Term1}, Bytes4, Rb1+Rb2+Rb3}.


%%================================
%%  IndAudDigitMapDescriptor
%%================================
'enc_IndAudDigitMapDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,digitMapName) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,digitMapName), [{tag,128,0,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1],
  LenSoFar = EncLen1,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudDigitMapDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudDigitMapDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudDigitMapDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_octet_string(Bytes2,2,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

   {Bytes4,Rb3} = ?RT_BER:restbytes2(RemBytes, Bytes3,noext),
   {{'IndAudDigitMapDescriptor', Term1}, Bytes4, Rb1+Rb2+Rb3}.


%%================================
%%  IndAudSignal
%%================================
'enc_IndAudSignal'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,signalName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,streamID), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,signalRequestID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(4,Val,signalRequestID), [{tag,128,2,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudSignal'(Bytes, OptOrMand) ->
   'dec_IndAudSignal'(Bytes, OptOrMand, []).

'dec_IndAudSignal'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_integer(Bytes4,{0,4294967295},[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'IndAudSignal', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  IndAudSeqSigList
%%================================
'enc_IndAudSeqSigList'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,id), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudSignal OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,signalList) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudSignal'(?RT_BER:cindex(3,Val,signalList), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudSeqSigList'(Bytes, OptOrMand) ->
   'dec_IndAudSeqSigList'(Bytes, OptOrMand, []).

'dec_IndAudSeqSigList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudSignal OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_IndAudSignal'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'IndAudSeqSigList', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IndAudSignalsDescriptor
%%================================

'enc_IndAudSignalsDescriptor'({'IndAudSignalsDescriptor',Val}, TagIn) ->
   'enc_IndAudSignalsDescriptor'(Val, TagIn);

'enc_IndAudSignalsDescriptor'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      signal ->
         'enc_IndAudSignal'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      seqSigList ->
         'enc_IndAudSeqSigList'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_IndAudSignalsDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudSignalsDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudSignalsDescriptor'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'signal'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudSignal'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{signal, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'seqSigList'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudSeqSigList'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{seqSigList, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  IndAudEventBufferDescriptor
%%================================
'enc_IndAudEventBufferDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,eventName), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,streamID), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudEventBufferDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudEventBufferDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudEventBufferDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'IndAudEventBufferDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IndAudEventsDescriptor
%%================================
'enc_IndAudEventsDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,requestID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,requestID), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,pkgdName), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(4,Val,streamID), [{tag,128,2,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudEventsDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudEventsDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudEventsDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,4,[{tag,128,1,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 3 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_integer(Bytes4,{0,65535},[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'IndAudEventsDescriptor', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  IndAudTerminationStateDescriptor
%%================================
'enc_IndAudTerminationStateDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_IndAudTerminationStateDescriptor_propertyParms'(?RT_BER:cindex(2,Val,propertyParms), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,eventBufferControl) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(3,Val,eventBufferControl), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,serviceState) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(4,Val,serviceState), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,serviceStateSel) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(5,Val,serviceStateSel) of {asn1_enum,_}->?RT_BER:cindex(5,Val,serviceStateSel);{_,_}->element(2,?RT_BER:cindex(5,Val,serviceStateSel));_->?RT_BER:cindex(5,Val,serviceStateSel) end) of
test -> ?RT_BER:encode_enumerated(0,[{tag,128,3,'IMPLICIT',0}]);
outOfSvc -> ?RT_BER:encode_enumerated(1,[{tag,128,3,'IMPLICIT',0}]);
inSvc -> ?RT_BER:encode_enumerated(2,[{tag,128,3,'IMPLICIT',0}]);
{asn1_enum,Enumval3} -> ?RT_BER:encode_enumerated(Enumval3,[{tag,128,3,'IMPLICIT',0}]);
Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}})
end
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  IndAudTerminationStateDescriptor_propertyParms
%%================================

'enc_IndAudTerminationStateDescriptor_propertyParms'({'IndAudTerminationStateDescriptor_propertyParms',Val}, TagIn) ->
   'enc_IndAudTerminationStateDescriptor_propertyParms'(Val, TagIn);

'enc_IndAudTerminationStateDescriptor_propertyParms'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_IndAudTerminationStateDescriptor_propertyParms_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_IndAudTerminationStateDescriptor_propertyParms_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_IndAudTerminationStateDescriptor_propertyParms_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_IndAudPropertyParm'(H, []),
   'enc_IndAudTerminationStateDescriptor_propertyParms_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_IndAudTerminationStateDescriptor_propertyParms'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_IndAudPropertyParm'/3, [], []).




'dec_IndAudTerminationStateDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudTerminationStateDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudTerminationStateDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type SEQUENCE OF
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_IndAudTerminationStateDescriptor_propertyParms'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_null(Bytes3,[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_null(Bytes4,[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes5,[],{[{test,0},{outOfSvc,1},{inSvc,2}],[]},[{tag,128,3,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'IndAudTerminationStateDescriptor', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  IndAudPropertyGroup
%%================================

'enc_IndAudPropertyGroup'({'IndAudPropertyGroup',Val}, TagIn) ->
   'enc_IndAudPropertyGroup'(Val, TagIn);

'enc_IndAudPropertyGroup'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_IndAudPropertyGroup_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_IndAudPropertyGroup_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_IndAudPropertyGroup_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_IndAudPropertyParm'(H, []),
   'enc_IndAudPropertyGroup_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_IndAudPropertyGroup'(Bytes, OptOrMand) ->
   'dec_IndAudPropertyGroup'(Bytes, OptOrMand, []).

'dec_IndAudPropertyGroup'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_IndAudPropertyParm'/3, [], []).




%%================================
%%  IndAudLocalRemoteDescriptor
%%================================
'enc_IndAudLocalRemoteDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,propGroupID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,propGroupID), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudPropertyGroup
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_IndAudPropertyGroup'(?RT_BER:cindex(3,Val,propGrps), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudLocalRemoteDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudLocalRemoteDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudLocalRemoteDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_integer(Bytes2,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudPropertyGroup
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_IndAudPropertyGroup'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'IndAudLocalRemoteDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IndAudPropertyParm
%%================================
'enc_IndAudPropertyParm'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,name), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:PropertyParm OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,propertyParms) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_PropertyParm'(?RT_BER:cindex(3,Val,propertyParms), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudPropertyParm'(Bytes, OptOrMand) ->
   'dec_IndAudPropertyParm'(Bytes, OptOrMand, []).

'dec_IndAudPropertyParm'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:PropertyParm OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_PropertyParm'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'IndAudPropertyParm', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IndAudLocalControlDescriptor
%%================================
'enc_IndAudLocalControlDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,streamMode) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(2,Val,streamMode), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,reserveValue) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(3,Val,reserveValue), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,reserveGroup) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(4,Val,reserveGroup), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,propertyParms) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudLocalControlDescriptor_propertyParms'(?RT_BER:cindex(5,Val,propertyParms), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,streamModeSel) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(6,Val,streamModeSel) of {asn1_enum,_}->?RT_BER:cindex(6,Val,streamModeSel);{_,_}->element(2,?RT_BER:cindex(6,Val,streamModeSel));_->?RT_BER:cindex(6,Val,streamModeSel) end) of
sendOnly -> ?RT_BER:encode_enumerated(0,[{tag,128,4,'IMPLICIT',0}]);
recvOnly -> ?RT_BER:encode_enumerated(1,[{tag,128,4,'IMPLICIT',0}]);
sendRecv -> ?RT_BER:encode_enumerated(2,[{tag,128,4,'IMPLICIT',0}]);
inactive -> ?RT_BER:encode_enumerated(3,[{tag,128,4,'IMPLICIT',0}]);
loopBack -> ?RT_BER:encode_enumerated(4,[{tag,128,4,'IMPLICIT',0}]);
{asn1_enum,Enumval4} -> ?RT_BER:encode_enumerated(Enumval4,[{tag,128,4,'IMPLICIT',0}]);
Enumval5 -> exit({error,{asn1, {enumerated_not_in_range,Enumval5}}})
end
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  IndAudLocalControlDescriptor_propertyParms
%%================================

'enc_IndAudLocalControlDescriptor_propertyParms'({'IndAudLocalControlDescriptor_propertyParms',Val}, TagIn) ->
   'enc_IndAudLocalControlDescriptor_propertyParms'(Val, TagIn);

'enc_IndAudLocalControlDescriptor_propertyParms'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_IndAudLocalControlDescriptor_propertyParms_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_IndAudLocalControlDescriptor_propertyParms_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_IndAudLocalControlDescriptor_propertyParms_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_IndAudPropertyParm'(H, []),
   'enc_IndAudLocalControlDescriptor_propertyParms_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_IndAudLocalControlDescriptor_propertyParms'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_IndAudPropertyParm'/3, [], []).




'dec_IndAudLocalControlDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudLocalControlDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudLocalControlDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_null(Bytes2,[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_null(Bytes3,[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_null(Bytes4,[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_IndAudLocalControlDescriptor_propertyParms'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes6,[],{[{sendOnly,0},{recvOnly,1},{sendRecv,2},{inactive,3},{loopBack,4}],[]},[{tag,128,4,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

   {Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,ext),
   {{'IndAudLocalControlDescriptor', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}.


%%================================
%%  IndAudStreamParms
%%================================
'enc_IndAudStreamParms'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:IndAudLocalControlDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,localControlDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudLocalControlDescriptor'(?RT_BER:cindex(2,Val,localControlDescriptor), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudLocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,localDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudLocalRemoteDescriptor'(?RT_BER:cindex(3,Val,localDescriptor), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:IndAudLocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,remoteDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudLocalRemoteDescriptor'(?RT_BER:cindex(4,Val,remoteDescriptor), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:IndAudStatisticsDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,statisticsDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudStatisticsDescriptor'(?RT_BER:cindex(5,Val,statisticsDescriptor), [{tag,128,3,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudStreamParms'(Bytes, OptOrMand) ->
   'dec_IndAudStreamParms'(Bytes, OptOrMand, []).

'dec_IndAudStreamParms'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:IndAudLocalControlDescriptor OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
'dec_IndAudLocalControlDescriptor'(Bytes2, opt_or_default, [{tag,128,0,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudLocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_IndAudLocalRemoteDescriptor'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:IndAudLocalRemoteDescriptor OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_IndAudLocalRemoteDescriptor'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4   External megaco_ber_media_gateway_control_prev3c:IndAudStatisticsDescriptor OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
'dec_IndAudStatisticsDescriptor'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,ext),
   {{'IndAudStreamParms', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  IndAudStreamDescriptor
%%================================
'enc_IndAudStreamDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,streamID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudStreamParms
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_IndAudStreamParms'(?RT_BER:cindex(3,Val,streamParms), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IndAudStreamDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudStreamDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudStreamDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:IndAudStreamParms
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_IndAudStreamParms'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'IndAudStreamDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IndAudMediaDescriptor
%%================================
'enc_IndAudMediaDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:IndAudTerminationStateDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,termStateDescr) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudTerminationStateDescriptor'(?RT_BER:cindex(2,Val,termStateDescr), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,streams) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_IndAudMediaDescriptor_streams'(?RT_BER:cindex(3,Val,streams), [{tag,128,1,'EXPLICIT',32}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  IndAudMediaDescriptor_streams
%%================================

'enc_IndAudMediaDescriptor_streams'({'IndAudMediaDescriptor_streams',Val}, TagIn) ->
   'enc_IndAudMediaDescriptor_streams'(Val, TagIn);

'enc_IndAudMediaDescriptor_streams'(Val, TagIn) ->
      {EncBytes,EncLen} = case element(1,Val) of
      oneStream ->
         'enc_IndAudStreamParms'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      multiStream ->
         'enc_IndAudMediaDescriptor_streams_multiStream'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).





%%================================
%%  IndAudMediaDescriptor_streams_multiStream
%%================================

'enc_IndAudMediaDescriptor_streams_multiStream'({'IndAudMediaDescriptor_streams_multiStream',Val}, TagIn) ->
   'enc_IndAudMediaDescriptor_streams_multiStream'(Val, TagIn);

'enc_IndAudMediaDescriptor_streams_multiStream'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_IndAudMediaDescriptor_streams_multiStream_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_IndAudMediaDescriptor_streams_multiStream_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_IndAudMediaDescriptor_streams_multiStream_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_IndAudStreamDescriptor'(H, []),
   'enc_IndAudMediaDescriptor_streams_multiStream_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_IndAudMediaDescriptor_streams_multiStream'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_IndAudStreamDescriptor'/3, [], []).


'dec_IndAudMediaDescriptor_streams'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'oneStream'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudStreamParms'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{oneStream, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'multiStream'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudMediaDescriptor_streams_multiStream'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{multiStream, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


'dec_IndAudMediaDescriptor'(Bytes, OptOrMand) ->
   'dec_IndAudMediaDescriptor'(Bytes, OptOrMand, []).

'dec_IndAudMediaDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:IndAudTerminationStateDescriptor OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
'dec_IndAudTerminationStateDescriptor'(Bytes2, opt_or_default, [{tag,128,0,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type CHOICE OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_IndAudMediaDescriptor_streams'(Bytes3, opt_or_default, [{tag,128,1,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'IndAudMediaDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IndAuditParameter
%%================================

'enc_IndAuditParameter'({'IndAuditParameter',Val}, TagIn) ->
   'enc_IndAuditParameter'(Val, TagIn);

'enc_IndAuditParameter'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      indAudMediaDescriptor ->
         'enc_IndAudMediaDescriptor'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      indAudEventsDescriptor ->
         'enc_IndAudEventsDescriptor'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      indAudEventBufferDescriptor ->
         'enc_IndAudEventBufferDescriptor'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      indAudSignalsDescriptor ->
         'enc_IndAudSignalsDescriptor'(element(2,Val), [{tag,128,3,'EXPLICIT',32}]);
      indAudDigitMapDescriptor ->
         'enc_IndAudDigitMapDescriptor'(element(2,Val), [{tag,128,4,'IMPLICIT',0}]);
      indAudStatisticsDescriptor ->
         'enc_IndAudStatisticsDescriptor'(element(2,Val), [{tag,128,5,'IMPLICIT',0}]);
      indAudPackagesDescriptor ->
         'enc_IndAudPackagesDescriptor'(element(2,Val), [{tag,128,6,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_IndAuditParameter'(Bytes, OptOrMand) ->
   'dec_IndAuditParameter'(Bytes, OptOrMand, []).

'dec_IndAuditParameter'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'indAudMediaDescriptor'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudMediaDescriptor'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{indAudMediaDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'indAudEventsDescriptor'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudEventsDescriptor'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{indAudEventsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'indAudEventBufferDescriptor'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudEventBufferDescriptor'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{indAudEventBufferDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'indAudSignalsDescriptor'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudSignalsDescriptor'(Bytes1, mandatory, [{tag,128,3,'EXPLICIT',32}]),
         {{indAudSignalsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'indAudDigitMapDescriptor'
      <<2:2,_:1,4:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudDigitMapDescriptor'(Bytes1, mandatory, [{tag,128,4,'IMPLICIT',0}]),
         {{indAudDigitMapDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'indAudStatisticsDescriptor'
      <<2:2,_:1,5:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudStatisticsDescriptor'(Bytes1, mandatory, [{tag,128,5,'IMPLICIT',0}]),
         {{indAudStatisticsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'indAudPackagesDescriptor'
      <<2:2,_:1,6:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IndAudPackagesDescriptor'(Bytes1, mandatory, [{tag,128,6,'IMPLICIT',0}]),
         {{indAudPackagesDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  AuditDescriptor
%%================================
'enc_AuditDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type BIT STRING OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,auditToken) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_bit_string([], ?RT_BER:cindex(2,Val,auditToken), [{muxToken,0},{modemToken,1},{mediaToken,2},{eventsToken,3},{signalsToken,4},{digitMapToken,5},{statsToken,6},{observedEventsToken,7},{packagesToken,8},{eventBufferToken,9}], [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,auditPropertyToken) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_AuditDescriptor_auditPropertyToken'(?RT_BER:cindex(3,Val,auditPropertyToken), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  AuditDescriptor_auditPropertyToken
%%================================

'enc_AuditDescriptor_auditPropertyToken'({'AuditDescriptor_auditPropertyToken',Val}, TagIn) ->
   'enc_AuditDescriptor_auditPropertyToken'(Val, TagIn);

'enc_AuditDescriptor_auditPropertyToken'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_AuditDescriptor_auditPropertyToken_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_AuditDescriptor_auditPropertyToken_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_AuditDescriptor_auditPropertyToken_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_IndAuditParameter'(H, []),
   'enc_AuditDescriptor_auditPropertyToken_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_AuditDescriptor_auditPropertyToken'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_IndAuditParameter'/3, [], []).




'dec_AuditDescriptor'(Bytes, OptOrMand) ->
   'dec_AuditDescriptor'(Bytes, OptOrMand, []).

'dec_AuditDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type BIT STRING OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_bit_string(Bytes2,[],[{muxToken,0},{modemToken,1},{mediaToken,2},{eventsToken,3},{signalsToken,4},{digitMapToken,5},{statsToken,6},{observedEventsToken,7},{packagesToken,8},{eventBufferToken,9}],[{tag,128,0,'IMPLICIT',0}], no_length, mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_AuditDescriptor_auditPropertyToken'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'AuditDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  AuditReturnParameter
%%================================

'enc_AuditReturnParameter'({'AuditReturnParameter',Val}, TagIn) ->
   'enc_AuditReturnParameter'(Val, TagIn);

'enc_AuditReturnParameter'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      errorDescriptor ->
         'enc_ErrorDescriptor'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      mediaDescriptor ->
         'enc_MediaDescriptor'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      modemDescriptor ->
         'enc_ModemDescriptor'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      muxDescriptor ->
         'enc_MuxDescriptor'(element(2,Val), [{tag,128,3,'IMPLICIT',0}]);
      eventsDescriptor ->
         'enc_EventsDescriptor'(element(2,Val), [{tag,128,4,'IMPLICIT',0}]);
      eventBufferDescriptor ->
         'enc_EventBufferDescriptor'(element(2,Val), [{tag,128,5,'IMPLICIT',0}]);
      signalsDescriptor ->
         'enc_SignalsDescriptor'(element(2,Val), [{tag,128,6,'IMPLICIT',0}]);
      digitMapDescriptor ->
         'enc_DigitMapDescriptor'(element(2,Val), [{tag,128,7,'IMPLICIT',0}]);
      observedEventsDescriptor ->
         'enc_ObservedEventsDescriptor'(element(2,Val), [{tag,128,8,'IMPLICIT',0}]);
      statisticsDescriptor ->
         'enc_StatisticsDescriptor'(element(2,Val), [{tag,128,9,'IMPLICIT',0}]);
      packagesDescriptor ->
         'enc_PackagesDescriptor'(element(2,Val), [{tag,128,10,'IMPLICIT',0}]);
      emptyDescriptors ->
         'enc_AuditDescriptor'(element(2,Val), [{tag,128,11,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_AuditReturnParameter'(Bytes, OptOrMand) ->
   'dec_AuditReturnParameter'(Bytes, OptOrMand, []).

'dec_AuditReturnParameter'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'errorDescriptor'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ErrorDescriptor'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{errorDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'mediaDescriptor'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_MediaDescriptor'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{mediaDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'modemDescriptor'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ModemDescriptor'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{modemDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'muxDescriptor'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_MuxDescriptor'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',0}]),
         {{muxDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'eventsDescriptor'
      <<2:2,_:1,4:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_EventsDescriptor'(Bytes1, mandatory, [{tag,128,4,'IMPLICIT',0}]),
         {{eventsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'eventBufferDescriptor'
      <<2:2,_:1,5:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_EventBufferDescriptor'(Bytes1, mandatory, [{tag,128,5,'IMPLICIT',0}]),
         {{eventBufferDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'signalsDescriptor'
      <<2:2,_:1,6:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_SignalsDescriptor'(Bytes1, mandatory, [{tag,128,6,'IMPLICIT',0}]),
         {{signalsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'digitMapDescriptor'
      <<2:2,_:1,7:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_DigitMapDescriptor'(Bytes1, mandatory, [{tag,128,7,'IMPLICIT',0}]),
         {{digitMapDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'observedEventsDescriptor'
      <<2:2,_:1,8:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ObservedEventsDescriptor'(Bytes1, mandatory, [{tag,128,8,'IMPLICIT',0}]),
         {{observedEventsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'statisticsDescriptor'
      <<2:2,_:1,9:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_StatisticsDescriptor'(Bytes1, mandatory, [{tag,128,9,'IMPLICIT',0}]),
         {{statisticsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'packagesDescriptor'
      <<2:2,_:1,10:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_PackagesDescriptor'(Bytes1, mandatory, [{tag,128,10,'IMPLICIT',0}]),
         {{packagesDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'emptyDescriptors'
      <<2:2,_:1,11:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AuditDescriptor'(Bytes1, mandatory, [{tag,128,11,'IMPLICIT',0}]),
         {{emptyDescriptors, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  TerminationAudit
%%================================

'enc_TerminationAudit'({'TerminationAudit',Val}, TagIn) ->
   'enc_TerminationAudit'(Val, TagIn);

'enc_TerminationAudit'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_TerminationAudit_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_TerminationAudit_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_TerminationAudit_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_AuditReturnParameter'(H, []),
   'enc_TerminationAudit_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_TerminationAudit'(Bytes, OptOrMand) ->
   'dec_TerminationAudit'(Bytes, OptOrMand, []).

'dec_TerminationAudit'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_AuditReturnParameter'/3, [], []).




%%================================
%%  TermListAuditResult
%%================================
'enc_TermListAuditResult'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationIDList), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationAudit
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_TerminationAudit'(?RT_BER:cindex(3,Val,terminationAuditResult), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_TermListAuditResult'(Bytes, OptOrMand) ->
   'dec_TermListAuditResult'(Bytes, OptOrMand, []).

'dec_TermListAuditResult'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationAudit
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_TerminationAudit'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'TermListAuditResult', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  AuditResult
%%================================
'enc_AuditResult'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationID'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationAudit
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_TerminationAudit'(?RT_BER:cindex(3,Val,terminationAuditResult), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_AuditResult'(Bytes, OptOrMand) ->
   'dec_AuditResult'(Bytes, OptOrMand, []).

'dec_AuditResult'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationID'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationAudit
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_TerminationAudit'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'AuditResult', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  AuditReply
%%================================

'enc_AuditReply'({'AuditReply',Val}, TagIn) ->
   'enc_AuditReply'(Val, TagIn);

'enc_AuditReply'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      contextAuditResult ->
         'enc_TerminationIDList'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      error ->
         'enc_ErrorDescriptor'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      auditResult ->
         'enc_AuditResult'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      auditResultTermList ->
         'enc_TermListAuditResult'(element(2,Val), [{tag,128,3,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_AuditReply'(Bytes, OptOrMand) ->
   'dec_AuditReply'(Bytes, OptOrMand, []).

'dec_AuditReply'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'contextAuditResult'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_TerminationIDList'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{contextAuditResult, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'error'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ErrorDescriptor'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{error, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'auditResult'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AuditResult'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{auditResult, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'auditResultTermList'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_TermListAuditResult'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',0}]),
         {{auditResultTermList, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  AuditRequest
%%================================
'enc_AuditRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationID'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:AuditDescriptor
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_AuditDescriptor'(?RT_BER:cindex(3,Val,auditDescriptor), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:TerminationIDList OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,terminationIDList) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_TerminationIDList'(?RT_BER:cindex(4,Val,terminationIDList), [{tag,128,2,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_AuditRequest'(Bytes, OptOrMand) ->
   'dec_AuditRequest'(Bytes, OptOrMand, []).

'dec_AuditRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationID'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:AuditDescriptor
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_AuditDescriptor'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:TerminationIDList OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_TerminationIDList'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'AuditRequest', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  SubtractRequest
%%================================
'enc_SubtractRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:AuditDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,auditDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_AuditDescriptor'(?RT_BER:cindex(3,Val,auditDescriptor), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_SubtractRequest'(Bytes, OptOrMand) ->
   'dec_SubtractRequest'(Bytes, OptOrMand, []).

'dec_SubtractRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:AuditDescriptor OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_AuditDescriptor'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'SubtractRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  AmmsReply
%%================================
'enc_AmmsReply'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationAudit OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,terminationAudit) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_TerminationAudit'(?RT_BER:cindex(3,Val,terminationAudit), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_AmmsReply'(Bytes, OptOrMand) ->
   'dec_AmmsReply'(Bytes, OptOrMand, []).

'dec_AmmsReply'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationAudit OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_TerminationAudit'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'AmmsReply', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  AmmDescriptor
%%================================

'enc_AmmDescriptor'({'AmmDescriptor',Val}, TagIn) ->
   'enc_AmmDescriptor'(Val, TagIn);

'enc_AmmDescriptor'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      mediaDescriptor ->
         'enc_MediaDescriptor'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      modemDescriptor ->
         'enc_ModemDescriptor'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      muxDescriptor ->
         'enc_MuxDescriptor'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      eventsDescriptor ->
         'enc_EventsDescriptor'(element(2,Val), [{tag,128,3,'IMPLICIT',0}]);
      eventBufferDescriptor ->
         'enc_EventBufferDescriptor'(element(2,Val), [{tag,128,4,'IMPLICIT',0}]);
      signalsDescriptor ->
         'enc_SignalsDescriptor'(element(2,Val), [{tag,128,5,'IMPLICIT',0}]);
      digitMapDescriptor ->
         'enc_DigitMapDescriptor'(element(2,Val), [{tag,128,6,'IMPLICIT',0}]);
      auditDescriptor ->
         'enc_AuditDescriptor'(element(2,Val), [{tag,128,7,'IMPLICIT',0}]);
      statisticsDescriptor ->
         'enc_StatisticsDescriptor'(element(2,Val), [{tag,128,8,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_AmmDescriptor'(Bytes, OptOrMand) ->
   'dec_AmmDescriptor'(Bytes, OptOrMand, []).

'dec_AmmDescriptor'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'mediaDescriptor'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_MediaDescriptor'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{mediaDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'modemDescriptor'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ModemDescriptor'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{modemDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'muxDescriptor'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_MuxDescriptor'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{muxDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'eventsDescriptor'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_EventsDescriptor'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',0}]),
         {{eventsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'eventBufferDescriptor'
      <<2:2,_:1,4:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_EventBufferDescriptor'(Bytes1, mandatory, [{tag,128,4,'IMPLICIT',0}]),
         {{eventBufferDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'signalsDescriptor'
      <<2:2,_:1,5:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_SignalsDescriptor'(Bytes1, mandatory, [{tag,128,5,'IMPLICIT',0}]),
         {{signalsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'digitMapDescriptor'
      <<2:2,_:1,6:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_DigitMapDescriptor'(Bytes1, mandatory, [{tag,128,6,'IMPLICIT',0}]),
         {{digitMapDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'auditDescriptor'
      <<2:2,_:1,7:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AuditDescriptor'(Bytes1, mandatory, [{tag,128,7,'IMPLICIT',0}]),
         {{auditDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'statisticsDescriptor'
      <<2:2,_:1,8:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_StatisticsDescriptor'(Bytes1, mandatory, [{tag,128,8,'IMPLICIT',0}]),
         {{statisticsDescriptor, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  AmmRequest
%%================================
'enc_AmmRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationIDList'(?RT_BER:cindex(2,Val,terminationID), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_AmmRequest_descriptors'(?RT_BER:cindex(3,Val,descriptors), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  AmmRequest_descriptors
%%================================

'enc_AmmRequest_descriptors'({'AmmRequest_descriptors',Val}, TagIn) ->
   'enc_AmmRequest_descriptors'(Val, TagIn);

'enc_AmmRequest_descriptors'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_AmmRequest_descriptors_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_AmmRequest_descriptors_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_AmmRequest_descriptors_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_AmmDescriptor'(H, []),
   'enc_AmmRequest_descriptors_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_AmmRequest_descriptors'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_AmmDescriptor'/3, [], []).




'dec_AmmRequest'(Bytes, OptOrMand) ->
   'dec_AmmRequest'(Bytes, OptOrMand, []).

'dec_AmmRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationIDList
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationIDList'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_AmmRequest_descriptors'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'AmmRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  TopologyRequest
%%================================
'enc_TopologyRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_TerminationID'(?RT_BER:cindex(2,Val,terminationFrom), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_TerminationID'(?RT_BER:cindex(3,Val,terminationTo), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type ENUMERATED
%%-------------------------------------------------
   {EncBytes3,EncLen3} = case (case ?RT_BER:cindex(4,Val,topologyDirection) of {_,_}->element(2,?RT_BER:cindex(4,Val,topologyDirection));_->?RT_BER:cindex(4,Val,topologyDirection) end) of
bothway -> ?RT_BER:encode_enumerated(0,[{tag,128,2,'IMPLICIT',0}]);
isolate -> ?RT_BER:encode_enumerated(1,[{tag,128,2,'IMPLICIT',0}]);
oneway -> ?RT_BER:encode_enumerated(2,[{tag,128,2,'IMPLICIT',0}]);
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
end,

%%-------------------------------------------------
%% attribute number 4 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,streamID) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(5,Val,streamID), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,topologyDirectionExtension) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            case (case ?RT_BER:cindex(6,Val,topologyDirectionExtension) of {asn1_enum,_}->?RT_BER:cindex(6,Val,topologyDirectionExtension);{_,_}->element(2,?RT_BER:cindex(6,Val,topologyDirectionExtension));_->?RT_BER:cindex(6,Val,topologyDirectionExtension) end) of
onewayexternal -> ?RT_BER:encode_enumerated(0,[{tag,128,4,'IMPLICIT',0}]);
onewayboth -> ?RT_BER:encode_enumerated(1,[{tag,128,4,'IMPLICIT',0}]);
{asn1_enum,Enumval3} -> ?RT_BER:encode_enumerated(Enumval3,[{tag,128,4,'IMPLICIT',0}]);
Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}})
end
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_TopologyRequest'(Bytes, OptOrMand) ->
   'dec_TopologyRequest'(Bytes, OptOrMand, []).

'dec_TopologyRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_TerminationID'(Bytes2, mandatory, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:TerminationID
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_TerminationID'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type ENUMERATED
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_enumerated(Bytes4,[],[{bothway,0},{isolate,1},{oneway,2}],[{tag,128,2,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 4 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
?RT_BER:decode_integer(Bytes5,{0,65535},[{tag,128,3,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5 with type ENUMERATED OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
?RT_BER:decode_enumerated(Bytes6,[],{[{onewayexternal,0},{onewayboth,1}],[]},[{tag,128,4,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

   {Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,ext),
   {{'TopologyRequest', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}.


%%================================
%%  CommandReply
%%================================

'enc_CommandReply'({'CommandReply',Val}, TagIn) ->
   'enc_CommandReply'(Val, TagIn);

'enc_CommandReply'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      addReply ->
         'enc_AmmsReply'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      moveReply ->
         'enc_AmmsReply'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      modReply ->
         'enc_AmmsReply'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      subtractReply ->
         'enc_AmmsReply'(element(2,Val), [{tag,128,3,'IMPLICIT',0}]);
      auditCapReply ->
         'enc_AuditReply'(element(2,Val), [{tag,128,4,'EXPLICIT',32}]);
      auditValueReply ->
         'enc_AuditReply'(element(2,Val), [{tag,128,5,'EXPLICIT',32}]);
      notifyReply ->
         'enc_NotifyReply'(element(2,Val), [{tag,128,6,'IMPLICIT',0}]);
      serviceChangeReply ->
         'enc_ServiceChangeReply'(element(2,Val), [{tag,128,7,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_CommandReply'(Bytes, OptOrMand) ->
   'dec_CommandReply'(Bytes, OptOrMand, []).

'dec_CommandReply'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'addReply'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AmmsReply'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{addReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'moveReply'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AmmsReply'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{moveReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'modReply'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AmmsReply'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{modReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'subtractReply'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AmmsReply'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',0}]),
         {{subtractReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'auditCapReply'
      <<2:2,_:1,4:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AuditReply'(Bytes1, mandatory, [{tag,128,4,'EXPLICIT',32}]),
         {{auditCapReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'auditValueReply'
      <<2:2,_:1,5:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AuditReply'(Bytes1, mandatory, [{tag,128,5,'EXPLICIT',32}]),
         {{auditValueReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'notifyReply'
      <<2:2,_:1,6:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_NotifyReply'(Bytes1, mandatory, [{tag,128,6,'IMPLICIT',0}]),
         {{notifyReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'serviceChangeReply'
      <<2:2,_:1,7:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ServiceChangeReply'(Bytes1, mandatory, [{tag,128,7,'IMPLICIT',0}]),
         {{serviceChangeReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  Command
%%================================

'enc_Command'({'Command',Val}, TagIn) ->
   'enc_Command'(Val, TagIn);

'enc_Command'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      addReq ->
         'enc_AmmRequest'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      moveReq ->
         'enc_AmmRequest'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      modReq ->
         'enc_AmmRequest'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      subtractReq ->
         'enc_SubtractRequest'(element(2,Val), [{tag,128,3,'IMPLICIT',0}]);
      auditCapRequest ->
         'enc_AuditRequest'(element(2,Val), [{tag,128,4,'IMPLICIT',0}]);
      auditValueRequest ->
         'enc_AuditRequest'(element(2,Val), [{tag,128,5,'IMPLICIT',0}]);
      notifyReq ->
         'enc_NotifyRequest'(element(2,Val), [{tag,128,6,'IMPLICIT',0}]);
      serviceChangeReq ->
         'enc_ServiceChangeRequest'(element(2,Val), [{tag,128,7,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_Command'(Bytes, OptOrMand) ->
   'dec_Command'(Bytes, OptOrMand, []).

'dec_Command'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'addReq'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AmmRequest'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{addReq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'moveReq'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AmmRequest'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{moveReq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'modReq'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AmmRequest'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{modReq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'subtractReq'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_SubtractRequest'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',0}]),
         {{subtractReq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'auditCapRequest'
      <<2:2,_:1,4:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AuditRequest'(Bytes1, mandatory, [{tag,128,4,'IMPLICIT',0}]),
         {{auditCapRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'auditValueRequest'
      <<2:2,_:1,5:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_AuditRequest'(Bytes1, mandatory, [{tag,128,5,'IMPLICIT',0}]),
         {{auditValueRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'notifyReq'
      <<2:2,_:1,6:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_NotifyRequest'(Bytes1, mandatory, [{tag,128,6,'IMPLICIT',0}]),
         {{notifyReq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'serviceChangeReq'
      <<2:2,_:1,7:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ServiceChangeRequest'(Bytes1, mandatory, [{tag,128,7,'IMPLICIT',0}]),
         {{serviceChangeReq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  CommandRequest
%%================================
'enc_CommandRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:Command
%%-------------------------------------------------
   {EncBytes1,EncLen1} = 'enc_Command'(?RT_BER:cindex(2,Val,command), [{tag,128,0,'EXPLICIT',32}]),

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,optional) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(3,Val,optional), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,wildcardReturn) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(4,Val,wildcardReturn), [{tag,128,2,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_CommandRequest'(Bytes, OptOrMand) ->
   'dec_CommandRequest'(Bytes, OptOrMand, []).

'dec_CommandRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:Command
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = 'dec_Command'(Bytes2, mandatory, [{tag,128,0,'EXPLICIT',32}]),

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_null(Bytes3,[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_null(Bytes4,[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'CommandRequest', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  SelectLogic
%%================================

'enc_SelectLogic'({'SelectLogic',Val}, TagIn) ->
   'enc_SelectLogic'(Val, TagIn);

'enc_SelectLogic'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      andAUDITSelect ->
         ?RT_BER:encode_null(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      orAUDITSelect ->
         ?RT_BER:encode_null(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_SelectLogic'(Bytes, OptOrMand) ->
   'dec_SelectLogic'(Bytes, OptOrMand, []).

'dec_SelectLogic'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'andAUDITSelect'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_null(Bytes1,[{tag,128,0,'IMPLICIT',0}], mandatory),
         {{andAUDITSelect, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'orAUDITSelect'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_null(Bytes1,[{tag,128,1,'IMPLICIT',0}], mandatory),
         {{orAUDITSelect, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  ContextAttrAuditRequest
%%================================
'enc_ContextAttrAuditRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,topology) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(2,Val,topology), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,emergency) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(3,Val,emergency), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,priority) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(4,Val,priority), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,iepscallind) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(5,Val,iepscallind), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,contextPropAud) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ContextAttrAuditRequest_contextPropAud'(?RT_BER:cindex(6,Val,contextPropAud), [{tag,128,4,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 6 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes6,EncLen6} =  case ?RT_BER:cindex(7,Val,selectpriority) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(7,Val,selectpriority), [{tag,128,5,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 7 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes7,EncLen7} =  case ?RT_BER:cindex(8,Val,selectemergency) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(8,Val,selectemergency), [{tag,128,6,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 8 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes8,EncLen8} =  case ?RT_BER:cindex(9,Val,selectiepscallind) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(9,Val,selectiepscallind), [{tag,128,7,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 9   External megaco_ber_media_gateway_control_prev3c:SelectLogic OPTIONAL
%%-------------------------------------------------
   {EncBytes9,EncLen9} =  case ?RT_BER:cindex(10,Val,selectLogic) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_SelectLogic'(?RT_BER:cindex(10,Val,selectLogic), [{tag,128,8,'EXPLICIT',32}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  ContextAttrAuditRequest_contextPropAud
%%================================

'enc_ContextAttrAuditRequest_contextPropAud'({'ContextAttrAuditRequest_contextPropAud',Val}, TagIn) ->
   'enc_ContextAttrAuditRequest_contextPropAud'(Val, TagIn);

'enc_ContextAttrAuditRequest_contextPropAud'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ContextAttrAuditRequest_contextPropAud_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ContextAttrAuditRequest_contextPropAud_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ContextAttrAuditRequest_contextPropAud_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_IndAudPropertyParm'(H, []),
   'enc_ContextAttrAuditRequest_contextPropAud_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ContextAttrAuditRequest_contextPropAud'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_IndAudPropertyParm'/3, [], []).




'dec_ContextAttrAuditRequest'(Bytes, OptOrMand) ->
   'dec_ContextAttrAuditRequest'(Bytes, OptOrMand, []).

'dec_ContextAttrAuditRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_null(Bytes2,[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_null(Bytes3,[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
?RT_BER:decode_null(Bytes4,[{tag,128,2,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
?RT_BER:decode_null(Bytes5,[{tag,128,3,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
'dec_ContextAttrAuditRequest_contextPropAud'(Bytes6, opt_or_default, [{tag,128,4,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

%%-------------------------------------------------
%% attribute number 6 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term6,Bytes8,Rb7} = case Bytes7 of
<<2:2,_:1,5:5,_/binary>> ->
?RT_BER:decode_integer(Bytes7,{0,15},[{tag,128,5,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes7, 0 }
end,

%%-------------------------------------------------
%% attribute number 7 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term7,Bytes9,Rb8} = case Bytes8 of
<<2:2,_:1,6:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes8,[{tag,128,6,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes8, 0 }
end,

%%-------------------------------------------------
%% attribute number 8 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term8,Bytes10,Rb9} = case Bytes9 of
<<2:2,_:1,7:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes9,[{tag,128,7,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes9, 0 }
end,

%%-------------------------------------------------
%% attribute number 9   External megaco_ber_media_gateway_control_prev3c:SelectLogic OPTIONAL
%%-------------------------------------------------
   {Term9,Bytes11,Rb10} = case Bytes10 of
<<2:2,_:1,8:5,_/binary>> ->
'dec_SelectLogic'(Bytes10, opt_or_default, [{tag,128,8,'EXPLICIT',32}]);
_ ->
{ asn1_NOVALUE, Bytes10, 0 }
end,

   {Bytes12,Rb11} = ?RT_BER:restbytes2(RemBytes, Bytes11,ext),
   {{'ContextAttrAuditRequest', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9}, Bytes12, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8+Rb9+Rb10+Rb11}.


%%================================
%%  ContextRequest
%%================================
'enc_ContextRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,priority) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,priority), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,emergency) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(3,Val,emergency), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,topologyReq) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ContextRequest_topologyReq'(?RT_BER:cindex(4,Val,topologyReq), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,iepscallind) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_boolean(?RT_BER:cindex(5,Val,iepscallind), [{tag,128,3,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 5 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,contextProp) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ContextRequest_contextProp'(?RT_BER:cindex(6,Val,contextProp), [{tag,128,4,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 6 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {EncBytes6,EncLen6} =  case ?RT_BER:cindex(7,Val,contextList) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ContextRequest_contextList'(?RT_BER:cindex(7,Val,contextList), [{tag,128,5,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  ContextRequest_topologyReq
%%================================

'enc_ContextRequest_topologyReq'({'ContextRequest_topologyReq',Val}, TagIn) ->
   'enc_ContextRequest_topologyReq'(Val, TagIn);

'enc_ContextRequest_topologyReq'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ContextRequest_topologyReq_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ContextRequest_topologyReq_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ContextRequest_topologyReq_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_TopologyRequest'(H, []),
   'enc_ContextRequest_topologyReq_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ContextRequest_topologyReq'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_TopologyRequest'/3, [], []).





%%================================
%%  ContextRequest_contextProp
%%================================

'enc_ContextRequest_contextProp'({'ContextRequest_contextProp',Val}, TagIn) ->
   'enc_ContextRequest_contextProp'(Val, TagIn);

'enc_ContextRequest_contextProp'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ContextRequest_contextProp_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ContextRequest_contextProp_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ContextRequest_contextProp_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_PropertyParm'(H, []),
   'enc_ContextRequest_contextProp_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ContextRequest_contextProp'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PropertyParm'/3, [], []).





%%================================
%%  ContextRequest_contextList
%%================================

'enc_ContextRequest_contextList'({'ContextRequest_contextList',Val}, TagIn) ->
   'enc_ContextRequest_contextList'(Val, TagIn);

'enc_ContextRequest_contextList'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ContextRequest_contextList_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ContextRequest_contextList_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ContextRequest_contextList_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = ?RT_BER:encode_integer([], H, []),
   'enc_ContextRequest_contextList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ContextRequest_contextList'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
?RT_BER:decode_integer(FBytes,{0,4294967295},[], mandatory)
end, [], []).




'dec_ContextRequest'(Bytes, OptOrMand) ->
   'dec_ContextRequest'(Bytes, OptOrMand, []).

'dec_ContextRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
?RT_BER:decode_integer(Bytes2,{0,15},[{tag,128,0,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes3,[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_ContextRequest_topologyReq'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type BOOLEAN OPTIONAL
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = case Bytes5 of
<<2:2,_:1,3:5,_/binary>> ->
?RT_BER:decode_boolean(Bytes5,[{tag,128,3,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes5, 0 }
end,

%%-------------------------------------------------
%% attribute number 5 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {Term5,Bytes7,Rb6} = case Bytes6 of
<<2:2,_:1,4:5,_/binary>> ->
'dec_ContextRequest_contextProp'(Bytes6, opt_or_default, [{tag,128,4,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes6, 0 }
end,

%%-------------------------------------------------
%% attribute number 6 with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
   {Term6,Bytes8,Rb7} = case Bytes7 of
<<2:2,_:1,5:5,_/binary>> ->
'dec_ContextRequest_contextList'(Bytes7, opt_or_default, [{tag,128,5,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes7, 0 }
end,

   {Bytes9,Rb8} = ?RT_BER:restbytes2(RemBytes, Bytes8,ext),
   {{'ContextRequest', Term1, Term2, Term3, Term4, Term5, Term6}, Bytes9, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8}.


%%================================
%%  ActionReply
%%================================
'enc_ActionReply'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,contextId), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ErrorDescriptor OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,errorDescriptor) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ErrorDescriptor'(?RT_BER:cindex(3,Val,errorDescriptor), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:ContextRequest OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,contextReply) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ContextRequest'(?RT_BER:cindex(4,Val,contextReply), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes4,EncLen4} = 'enc_ActionReply_commandReply'(?RT_BER:cindex(5,Val,commandReply), [{tag,128,3,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  ActionReply_commandReply
%%================================

'enc_ActionReply_commandReply'({'ActionReply_commandReply',Val}, TagIn) ->
   'enc_ActionReply_commandReply'(Val, TagIn);

'enc_ActionReply_commandReply'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ActionReply_commandReply_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ActionReply_commandReply_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ActionReply_commandReply_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_CommandReply'(H, []),
   'enc_ActionReply_commandReply_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ActionReply_commandReply'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_CommandReply'/3, [], []).




'dec_ActionReply'(Bytes, OptOrMand) ->
   'dec_ActionReply'(Bytes, OptOrMand, []).

'dec_ActionReply'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ErrorDescriptor OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_ErrorDescriptor'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:ContextRequest OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_ContextRequest'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = 'dec_ActionReply_commandReply'(Bytes5, mandatory, [{tag,128,3,'IMPLICIT',0}]),

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
   {{'ActionReply', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  ActionRequest
%%================================
'enc_ActionRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,contextId), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ContextRequest OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,contextRequest) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ContextRequest'(?RT_BER:cindex(3,Val,contextRequest), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:ContextAttrAuditRequest OPTIONAL
%%-------------------------------------------------
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,contextAttrAuditReq) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_ContextAttrAuditRequest'(?RT_BER:cindex(4,Val,contextAttrAuditReq), [{tag,128,2,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes4,EncLen4} = 'enc_ActionRequest_commandRequests'(?RT_BER:cindex(5,Val,commandRequests), [{tag,128,3,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  ActionRequest_commandRequests
%%================================

'enc_ActionRequest_commandRequests'({'ActionRequest_commandRequests',Val}, TagIn) ->
   'enc_ActionRequest_commandRequests'(Val, TagIn);

'enc_ActionRequest_commandRequests'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_ActionRequest_commandRequests_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_ActionRequest_commandRequests_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_ActionRequest_commandRequests_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_CommandRequest'(H, []),
   'enc_ActionRequest_commandRequests_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_ActionRequest_commandRequests'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_CommandRequest'/3, [], []).




'dec_ActionRequest'(Bytes, OptOrMand) ->
   'dec_ActionRequest'(Bytes, OptOrMand, []).

'dec_ActionRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:ContextRequest OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
'dec_ContextRequest'(Bytes3, opt_or_default, [{tag,128,1,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3   External megaco_ber_media_gateway_control_prev3c:ContextAttrAuditRequest OPTIONAL
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = case Bytes4 of
<<2:2,_:1,2:5,_/binary>> ->
'dec_ContextAttrAuditRequest'(Bytes4, opt_or_default, [{tag,128,2,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes4, 0 }
end,

%%-------------------------------------------------
%% attribute number 4 with type SEQUENCE OF
%%-------------------------------------------------
   {Term4,Bytes6,Rb5} = 'dec_ActionRequest_commandRequests'(Bytes5, mandatory, [{tag,128,3,'IMPLICIT',0}]),

   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
   {{'ActionRequest', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.


%%================================
%%  ContextID
%%================================

'enc_ContextID'({'ContextID',Val}, TagIn) ->
   'enc_ContextID'(Val, TagIn);

'enc_ContextID'(Val, TagIn) ->
?RT_BER:encode_integer([], Val, TagIn ++ []).


'dec_ContextID'(Bytes, OptOrMand) ->
   'dec_ContextID'(Bytes, OptOrMand, []).

'dec_ContextID'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_integer(Bytes,{0,4294967295},TagIn++[], OptOrMand).



%%================================
%%  ErrorText
%%================================

'enc_ErrorText'({'ErrorText',Val}, TagIn) ->
   'enc_ErrorText'(Val, TagIn);

'enc_ErrorText'(Val, TagIn) ->
?RT_BER:encode_restricted_string([], Val, 22, TagIn ++ []).


'dec_ErrorText'(Bytes, OptOrMand) ->
   'dec_ErrorText'(Bytes, OptOrMand, []).

'dec_ErrorText'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_restricted_string(Bytes,[],22,TagIn++[], no_length, OptOrMand).



%%================================
%%  ErrorCode
%%================================

'enc_ErrorCode'({'ErrorCode',Val}, TagIn) ->
   'enc_ErrorCode'(Val, TagIn);

'enc_ErrorCode'(Val, TagIn) ->
?RT_BER:encode_integer([], Val, TagIn ++ []).


'dec_ErrorCode'(Bytes, OptOrMand) ->
   'dec_ErrorCode'(Bytes, OptOrMand, []).

'dec_ErrorCode'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_integer(Bytes,{0,65535},TagIn++[], OptOrMand).



%%================================
%%  ErrorDescriptor
%%================================
'enc_ErrorDescriptor'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,errorCode), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type IA5String OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,errorText) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(3,Val,errorText), 22, [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_ErrorDescriptor'(Bytes, OptOrMand) ->
   'dec_ErrorDescriptor'(Bytes, OptOrMand, []).

'dec_ErrorDescriptor'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type IA5String OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_restricted_string(Bytes3,[],22,[{tag,128,1,'IMPLICIT',0}], no_length, mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'ErrorDescriptor', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  TransactionAck
%%================================
'enc_TransactionAck'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,firstAck), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,lastAck) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,lastAck), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_TransactionAck'(Bytes, OptOrMand) ->
   'dec_TransactionAck'(Bytes, OptOrMand, []).

'dec_TransactionAck'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,4294967295},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'TransactionAck', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  TransactionResponseAck
%%================================

'enc_TransactionResponseAck'({'TransactionResponseAck',Val}, TagIn) ->
   'enc_TransactionResponseAck'(Val, TagIn);

'enc_TransactionResponseAck'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_TransactionResponseAck_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_TransactionResponseAck_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_TransactionResponseAck_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_TransactionAck'(H, []),
   'enc_TransactionResponseAck_components'(T,[EncBytes|AccBytes], AccLen + EncLen).



'dec_TransactionResponseAck'(Bytes, OptOrMand) ->
   'dec_TransactionResponseAck'(Bytes, OptOrMand, []).

'dec_TransactionResponseAck'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_TransactionAck'/3, [], []).




%%================================
%%  TransactionReply
%%================================
'enc_TransactionReply'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,transactionId), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,immAckRequired) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_null(?RT_BER:cindex(3,Val,immAckRequired), [{tag,128,1,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 3 with type CHOICE
%%-------------------------------------------------
   {EncBytes3,EncLen3} = 'enc_TransactionReply_transactionResult'(?RT_BER:cindex(4,Val,transactionResult), [{tag,128,2,'EXPLICIT',32}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  TransactionReply_transactionResult
%%================================

'enc_TransactionReply_transactionResult'({'TransactionReply_transactionResult',Val}, TagIn) ->
   'enc_TransactionReply_transactionResult'(Val, TagIn);

'enc_TransactionReply_transactionResult'(Val, TagIn) ->
      {EncBytes,EncLen} = case element(1,Val) of
      transactionError ->
         'enc_ErrorDescriptor'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      actionReplies ->
         'enc_TransactionReply_transactionResult_actionReplies'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).





%%================================
%%  TransactionReply_transactionResult_actionReplies
%%================================

'enc_TransactionReply_transactionResult_actionReplies'({'TransactionReply_transactionResult_actionReplies',Val}, TagIn) ->
   'enc_TransactionReply_transactionResult_actionReplies'(Val, TagIn);

'enc_TransactionReply_transactionResult_actionReplies'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_TransactionReply_transactionResult_actionReplies_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_TransactionReply_transactionResult_actionReplies_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_TransactionReply_transactionResult_actionReplies_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_ActionReply'(H, []),
   'enc_TransactionReply_transactionResult_actionReplies_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_TransactionReply_transactionResult_actionReplies'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_ActionReply'/3, [], []).


'dec_TransactionReply_transactionResult'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'transactionError'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ErrorDescriptor'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{transactionError, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'actionReplies'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_TransactionReply_transactionResult_actionReplies'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{actionReplies, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


'dec_TransactionReply'(Bytes, OptOrMand) ->
   'dec_TransactionReply'(Bytes, OptOrMand, []).

'dec_TransactionReply'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type NULL OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_null(Bytes3,[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

%%-------------------------------------------------
%% attribute number 3 with type CHOICE
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = 'dec_TransactionReply_transactionResult'(Bytes4, mandatory, [{tag,128,2,'EXPLICIT',32}]),

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'TransactionReply', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  TransactionPending
%%================================
'enc_TransactionPending'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,transactionId), [{tag,128,0,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1],
  LenSoFar = EncLen1,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_TransactionPending'(Bytes, OptOrMand) ->
   'dec_TransactionPending'(Bytes, OptOrMand, []).

'dec_TransactionPending'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory),

   {Bytes4,Rb3} = ?RT_BER:restbytes2(RemBytes, Bytes3,ext),
   {{'TransactionPending', Term1}, Bytes4, Rb1+Rb2+Rb3}.


%%================================
%%  TransactionRequest
%%================================
'enc_TransactionRequest'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,transactionId), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_TransactionRequest_actions'(?RT_BER:cindex(3,Val,actions), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  TransactionRequest_actions
%%================================

'enc_TransactionRequest_actions'({'TransactionRequest_actions',Val}, TagIn) ->
   'enc_TransactionRequest_actions'(Val, TagIn);

'enc_TransactionRequest_actions'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_TransactionRequest_actions_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_TransactionRequest_actions_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_TransactionRequest_actions_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_ActionRequest'(H, []),
   'enc_TransactionRequest_actions_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_TransactionRequest_actions'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_ActionRequest'/3, [], []).




'dec_TransactionRequest'(Bytes, OptOrMand) ->
   'dec_TransactionRequest'(Bytes, OptOrMand, []).

'dec_TransactionRequest'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,4294967295},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2 with type SEQUENCE OF
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_TransactionRequest_actions'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,ext),
   {{'TransactionRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  TransactionId
%%================================

'enc_TransactionId'({'TransactionId',Val}, TagIn) ->
   'enc_TransactionId'(Val, TagIn);

'enc_TransactionId'(Val, TagIn) ->
?RT_BER:encode_integer([], Val, TagIn ++ []).


'dec_TransactionId'(Bytes, OptOrMand) ->
   'dec_TransactionId'(Bytes, OptOrMand, []).

'dec_TransactionId'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_integer(Bytes,{0,4294967295},TagIn++[], OptOrMand).



%%================================
%%  Transaction
%%================================

'enc_Transaction'({'Transaction',Val}, TagIn) ->
   'enc_Transaction'(Val, TagIn);

'enc_Transaction'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      transactionRequest ->
         'enc_TransactionRequest'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      transactionPending ->
         'enc_TransactionPending'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      transactionReply ->
         'enc_TransactionReply'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      transactionResponseAck ->
         'enc_TransactionResponseAck'(element(2,Val), [{tag,128,3,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_Transaction'(Bytes, OptOrMand) ->
   'dec_Transaction'(Bytes, OptOrMand, []).

'dec_Transaction'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'transactionRequest'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_TransactionRequest'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{transactionRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'transactionPending'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_TransactionPending'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{transactionPending, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'transactionReply'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_TransactionReply'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{transactionReply, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'transactionResponseAck'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_TransactionResponseAck'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',0}]),
         {{transactionResponseAck, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  PathName
%%================================

'enc_PathName'({'PathName',Val}, TagIn) ->
   'enc_PathName'(Val, TagIn);

'enc_PathName'(Val, TagIn) ->
?RT_BER:encode_restricted_string([], Val, 22, TagIn ++ []).


'dec_PathName'(Bytes, OptOrMand) ->
   'dec_PathName'(Bytes, OptOrMand, []).

'dec_PathName'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_restricted_string(Bytes,{1,64},22,TagIn++[], no_length, OptOrMand).



%%================================
%%  IP6Address
%%================================
'enc_IP6Address'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,address), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,portNumber) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,portNumber), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IP6Address'(Bytes, OptOrMand) ->
   'dec_IP6Address'(Bytes, OptOrMand, []).

'dec_IP6Address'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,16,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'IP6Address', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  IP4Address
%%================================
'enc_IP4Address'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,address), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,portNumber) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,portNumber), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_IP4Address'(Bytes, OptOrMand) ->
   'dec_IP4Address'(Bytes, OptOrMand, []).

'dec_IP4Address'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'IP4Address', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  DomainName
%%================================
'enc_DomainName'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type IA5String
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(2,Val,name), 22, [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,portNumber) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            ?RT_BER:encode_integer([], ?RT_BER:cindex(3,Val,portNumber), [{tag,128,1,'IMPLICIT',0}])
       end,

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_DomainName'(Bytes, OptOrMand) ->
   'dec_DomainName'(Bytes, OptOrMand, []).

'dec_DomainName'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type IA5String
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_restricted_string(Bytes2,[],22,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type INTEGER OPTIONAL
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = case Bytes3 of
<<2:2,_:1,1:5,_/binary>> ->
?RT_BER:decode_integer(Bytes3,{0,65535},[{tag,128,1,'IMPLICIT',0}], mandatory);
_ ->
{ asn1_NOVALUE, Bytes3, 0 }
end,

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'DomainName', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.


%%================================
%%  MId
%%================================

'enc_MId'({'MId',Val}, TagIn) ->
   'enc_MId'(Val, TagIn);

'enc_MId'(Val, TagIn) ->
   {EncBytes,EncLen} = case element(1,Val) of
      ip4Address ->
         'enc_IP4Address'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      ip6Address ->
         'enc_IP6Address'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      domainName ->
         'enc_DomainName'(element(2,Val), [{tag,128,2,'IMPLICIT',0}]);
      deviceName ->
         ?RT_BER:encode_restricted_string([], element(2,Val), 22, [{tag,128,3,'IMPLICIT',0}]);
      mtpAddress ->
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,4,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).




'dec_MId'(Bytes, OptOrMand) ->
   'dec_MId'(Bytes, OptOrMand, []).

'dec_MId'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'ip4Address'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IP4Address'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{ip4Address, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'ip6Address'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_IP6Address'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{ip6Address, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'domainName'
      <<2:2,_:1,2:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_DomainName'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',0}]),
         {{domainName, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'deviceName'
      <<2:2,_:1,3:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_restricted_string(Bytes1,{1,64},22,[{tag,128,3,'IMPLICIT',0}], no_length, mandatory),
         {{deviceName, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'mtpAddress'
      <<2:2,_:1,4:5,_/binary>> ->
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,{2,4},[{tag,128,4,'IMPLICIT',0}], no_length, mandatory),
         {{mtpAddress, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      _ -> 
         {{asn1_ExtAlt,Bytes1},<<>>, RbExp}
   end.


%%================================
%%  Message
%%================================
'enc_Message'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,version), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:MId
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_MId'(?RT_BER:cindex(3,Val,mId), [{tag,128,1,'EXPLICIT',32}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE
%%-------------------------------------------------
   {EncBytes3,EncLen3} = 'enc_Message_messageBody'(?RT_BER:cindex(4,Val,messageBody), [{tag,128,2,'EXPLICIT',32}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).



%%================================
%%  Message_messageBody
%%================================

'enc_Message_messageBody'({'Message_messageBody',Val}, TagIn) ->
   'enc_Message_messageBody'(Val, TagIn);

'enc_Message_messageBody'(Val, TagIn) ->
      {EncBytes,EncLen} = case element(1,Val) of
      messageError ->
         'enc_ErrorDescriptor'(element(2,Val), [{tag,128,0,'IMPLICIT',0}]);
      transactions ->
         'enc_Message_messageBody_transactions'(element(2,Val), [{tag,128,1,'IMPLICIT',0}]);
      Else -> 
         exit({error,{asn1,{invalid_choice_type,Else}}})
   end,

?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).





%%================================
%%  Message_messageBody_transactions
%%================================

'enc_Message_messageBody_transactions'({'Message_messageBody_transactions',Val}, TagIn) ->
   'enc_Message_messageBody_transactions'(Val, TagIn);

'enc_Message_messageBody_transactions'(Val, TagIn) ->
      {EncBytes,EncLen} = 'enc_Message_messageBody_transactions_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).

'enc_Message_messageBody_transactions_components'([], AccBytes, AccLen) -> 
   {lists:reverse(AccBytes),AccLen};

'enc_Message_messageBody_transactions_components'([H|T],AccBytes, AccLen) ->
   {EncBytes,EncLen} = 'enc_Transaction'(H, []),
   'enc_Message_messageBody_transactions_components'(T,[EncBytes|AccBytes], AccLen + EncLen).

'dec_Message_messageBody_transactions'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Transaction'/3, [], []).


'dec_Message_messageBody'(Bytes, OptOrMand, TagIn) ->
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
   case Bytes1 of

%% 'messageError'
      <<2:2,_:1,0:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_ErrorDescriptor'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',0}]),
         {{messageError, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};


%% 'transactions'
      <<2:2,_:1,1:5,_/binary>> ->
         {Dec, Rest, RbCho} = 'dec_Message_messageBody_transactions'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',0}]),
         {{transactions, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};

      Else -> 
         case OptOrMand of
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
         end
   end.


'dec_Message'(Bytes, OptOrMand) ->
   'dec_Message'(Bytes, OptOrMand, []).

'dec_Message'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type INTEGER
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,99},[{tag,128,0,'IMPLICIT',0}], mandatory),

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:MId
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_MId'(Bytes3, mandatory, [{tag,128,1,'EXPLICIT',32}]),

%%-------------------------------------------------
%% attribute number 3 with type CHOICE
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = 'dec_Message_messageBody'(Bytes4, mandatory, [{tag,128,2,'EXPLICIT',32}]),

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,ext),
   {{'Message', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  AuthData
%%================================

'enc_AuthData'({'AuthData',Val}, TagIn) ->
   'enc_AuthData'(Val, TagIn);

'enc_AuthData'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_AuthData'(Bytes, OptOrMand) ->
   'dec_AuthData'(Bytes, OptOrMand, []).

'dec_AuthData'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,{12,32},TagIn++[], no_length, OptOrMand).



%%================================
%%  SequenceNum
%%================================

'enc_SequenceNum'({'SequenceNum',Val}, TagIn) ->
   'enc_SequenceNum'(Val, TagIn);

'enc_SequenceNum'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_SequenceNum'(Bytes, OptOrMand) ->
   'dec_SequenceNum'(Bytes, OptOrMand, []).

'dec_SequenceNum'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,4,TagIn++[], no_length, OptOrMand).



%%================================
%%  SecurityParmIndex
%%================================

'enc_SecurityParmIndex'({'SecurityParmIndex',Val}, TagIn) ->
   'enc_SecurityParmIndex'(Val, TagIn);

'enc_SecurityParmIndex'(Val, TagIn) ->
?RT_BER:encode_octet_string([], Val, TagIn ++ []).


'dec_SecurityParmIndex'(Bytes, OptOrMand) ->
   'dec_SecurityParmIndex'(Bytes, OptOrMand, []).

'dec_SecurityParmIndex'(Bytes, OptOrMand, TagIn) ->
?RT_BER:decode_octet_string(Bytes,4,TagIn++[], no_length, OptOrMand).



%%================================
%%  AuthenticationHeader
%%================================
'enc_AuthenticationHeader'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,secParmIndex), [{tag,128,0,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,seqNum), [{tag,128,1,'IMPLICIT',0}]),

%%-------------------------------------------------
%% attribute number 3 with type OCTET STRING
%%-------------------------------------------------
   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,ad), [{tag,128,2,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_AuthenticationHeader'(Bytes, OptOrMand) ->
   'dec_AuthenticationHeader'(Bytes, OptOrMand, []).

'dec_AuthenticationHeader'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1 with type OCTET STRING
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,4,[{tag,128,0,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 2 with type OCTET STRING
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,4,[{tag,128,1,'IMPLICIT',0}], no_length, mandatory),

%%-------------------------------------------------
%% attribute number 3 with type OCTET STRING
%%-------------------------------------------------
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,{12,32},[{tag,128,2,'IMPLICIT',0}], no_length, mandatory),

   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
   {{'AuthenticationHeader', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.


%%================================
%%  MegacoMessage
%%================================
'enc_MegacoMessage'(Val, TagIn) ->

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:AuthenticationHeader OPTIONAL
%%-------------------------------------------------
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,authHeader) of
         asn1_NOVALUE -> {<<>>,0};
         _ ->
            'enc_AuthenticationHeader'(?RT_BER:cindex(2,Val,authHeader), [{tag,128,0,'IMPLICIT',0}])
       end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Message
%%-------------------------------------------------
   {EncBytes2,EncLen2} = 'enc_Message'(?RT_BER:cindex(3,Val,mess), [{tag,128,1,'IMPLICIT',0}]),

   BytesSoFar = [EncBytes1, EncBytes2],
  LenSoFar = EncLen1 + EncLen2,
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).


'dec_MegacoMessage'(Bytes, OptOrMand) ->
   'dec_MegacoMessage'(Bytes, OptOrMand, []).

'dec_MegacoMessage'(Bytes, OptOrMand, TagIn) ->
   %%-------------------------------------------------
   %% decode tag and length 
   %%-------------------------------------------------
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),

%%-------------------------------------------------
%% attribute number 1   External megaco_ber_media_gateway_control_prev3c:AuthenticationHeader OPTIONAL
%%-------------------------------------------------
   {Term1,Bytes3,Rb2} = case Bytes2 of
<<2:2,_:1,0:5,_/binary>> ->
'dec_AuthenticationHeader'(Bytes2, opt_or_default, [{tag,128,0,'IMPLICIT',0}]);
_ ->
{ asn1_NOVALUE, Bytes2, 0 }
end,

%%-------------------------------------------------
%% attribute number 2   External megaco_ber_media_gateway_control_prev3c:Message
%%-------------------------------------------------
   {Term2,Bytes4,Rb3} = 'dec_Message'(Bytes3, mandatory, [{tag,128,1,'IMPLICIT',0}]),

   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
   {{'MegacoMessage', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
