⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 megaco_binary_transformer_v2.erl

📁 OTP是开放电信平台的简称
💻 ERL
📖 第 1 页 / 共 4 页
字号:
                tr_EventBufferDescriptor(Val, State);            signalsDescriptor ->                tr_SignalsDescriptor(Val, State);            digitMapDescriptor ->                tr_DigitMapDescriptor(Val, State);            observedEventsDescriptor ->                tr_ObservedEventsDescriptor(Val, State);            statisticsDescriptor ->                tr_StatisticsDescriptor(Val, State);            packagesDescriptor ->                tr_PackagesDescriptor(Val, State);            emptyDescriptors ->                tr_EmptyDescriptors(Val, State)        end,    {Tag, Val2}.tr_EmptyDescriptors(#'AuditDescriptor'{auditToken = Tokens},                    State) ->    case Tokens of        asn1_NOVALUE -> asn1_NOVALUE;        _            -> [tr_auditItem(Token, State) || Token <- Tokens]    end.tr_NotifyRequest(#'NotifyRequest'{terminationID            = IdList,                                  observedEventsDescriptor = ObsDesc,                                  errorDescriptor          = ErrDesc},                 State) ->    %% BUGBUG: Mismatch between ASN.1 and ABNF    %% BUGBUG: The following ought to be a 'choice'    #'NotifyRequest'{terminationID            = [tr_TerminationID(Id, State) ||                                                    Id <- IdList],                     observedEventsDescriptor = tr_ObservedEventsDescriptor(ObsDesc, State),                     errorDescriptor          = tr_opt_ErrorDescriptor(ErrDesc, State)}.tr_NotifyReply(#'NotifyReply'{terminationID   = IdList,                              errorDescriptor = ErrDesc},               State) ->    #'NotifyReply'{terminationID   = [tr_TerminationID(Id, State) || Id <- IdList],                   errorDescriptor = tr_opt_ErrorDescriptor(ErrDesc, State)}.tr_ObservedEventsDescriptor(#'ObservedEventsDescriptor'{requestId        = Id,                                                        observedEventLst = Events},                            State) when list (Events) ->    #'ObservedEventsDescriptor'{requestId        = tr_RequestID(Id, State),                                observedEventLst = [tr_ObservedEvent(E, State) || E <- Events]}.%% ;time per event, because it might be buffered%% observedEvent        = [ TimeStamp LWSP COLON] LWSP %%                        pkgdName [ LBRKT observedEventParameter%%                        *(COMMA observedEventParameter) RBRKT ]%% %% ;at-most-once eventStream, every eventParameterName at most once%% observedEventParameter = eventStream / eventOthertr_ObservedEvent(#'ObservedEvent'{eventName    = Name,                                  streamID     = Id,                                  eventParList = Parms,                                  timeNotation = Time},                 State) ->    #'ObservedEvent'{eventName    = tr_EventName(Name, State),                     streamID     = tr_opt_StreamID(Id, State),                     eventParList = [tr_EventParameter(P, Name, State) || P <- Parms],                     timeNotation = tr_opt_TimeNotation(Time, State)}.tr_EventName(Name, State) ->    Constraint = fun(Item) -> tr_PkgdName(Item, State) end,    resolve(event, Name, State, Constraint).tr_EventParameter(#'EventParameter'{eventParameterName = ParName,                                    value              = Value,				    extraInfo          = Extra},		  EventName,                  State) ->    %% BUGBUG: event parameter name    Constraint = fun(Item) -> tr_Name(Item, State) end,    N = resolve({event_parameter, EventName}, ParName, State, Constraint),    #'EventParameter'{eventParameterName = N,		      value              = tr_Value(Value, State),		      extraInfo          = tr_opt_extraInfo(Extra, State)}.tr_ServiceChangeRequest(#'ServiceChangeRequest'{terminationID      = IdList,                                                serviceChangeParms = Parms},                        State) ->    #'ServiceChangeRequest'{terminationID      = [tr_TerminationID(Id, State) || Id <- IdList],                            serviceChangeParms = tr_ServiceChangeParm(Parms, State)}.%% serviceChangeReply   = ServiceChangeToken EQUAL TerminationID%%                        [LBRKT (errorDescriptor / %%                        serviceChangeReplyDescriptor) RBRKT]%% serviceChangeReplyDescriptor = ServicesToken LBRKT%%                        servChgReplyParm *(COMMA servChgReplyParm) RBRKT%% %% ;at-most-once. Version is REQUIRED on first ServiceChange response%% servChgReplyParm     = (serviceChangeAddress / serviceChangeMgcId /%%                        serviceChangeProfile / serviceChangeVersion )tr_ServiceChangeReply(#'ServiceChangeReply'{terminationID       = IdList,                                            serviceChangeResult = Res},                      State) ->    #'ServiceChangeReply'{terminationID       = [tr_TerminationID(Id, State) || Id <- IdList],                          serviceChangeResult = tr_ServiceChangeResult(Res, State)}.tr_ServiceChangeResult({Tag, Val}, State) ->    Val2 =         case Tag of            errorDescriptor       -> tr_ErrorDescriptor(Val, State);            serviceChangeResParms -> tr_ServiceChangeResParm(Val, State)        end,    {Tag, Val2}.%% TerminationID        = "ROOT" / pathNAME / "$" / "*"%% ; Total length of pathNAME must not exceed 64 chars.%% pathNAME             = ["*"] NAME *("/" / "*"/ ALPHA / DIGIT /"_" / "$" ) %%                        ["@" pathDomainName ]tr_TerminationID(TermId, State) when State#state.mode /= verify ->    resolve(term_id, TermId, State, valid);tr_TerminationID(#'TerminationID'{wildcard = Wild,                                  id       = Id},                 _State) ->    #'TerminationID'{wildcard = Wild,                     id       = Id};tr_TerminationID(#megaco_term_id{contains_wildcards = IsWild,                                 id                 = Id},                 State) ->    #megaco_term_id{contains_wildcards = tr_bool(IsWild, State),                    id                 = [tr_term_id_component(Sub, State) || Sub <- Id]}.tr_opt_bool(asn1_NOVALUE, _State) -> asn1_NOVALUE;tr_opt_bool(Bool, State)         -> tr_bool(Bool, State).tr_bool(true, _State)  -> true;tr_bool(false, _State) -> false.tr_term_id_component(Sub, _State) ->    case Sub of        all    -> all;        choose -> choose;        Char when integer(Char) -> Char    end.%% mediaDescriptor      = MediaToken LBRKT mediaParm *(COMMA mediaParm) RBRKT%% ; at-most-once per item%% ; and either streamParm or streamDescriptor but not both%% mediaParm            = (streamParm / streamDescriptor / %%                         terminationStateDescriptor)%% ; at-most-once%% streamParm           = ( localDescriptor / remoteDescriptor / %%                         localControlDescriptor )%% streamDescriptor     = StreamToken EQUAL StreamID LBRKT streamParm %%                        *(COMMA streamParm) RBRKTtr_MediaDescriptor(#'MediaDescriptor'{termStateDescr = TermState,                                      streams        = Streams},                   State) ->    #'MediaDescriptor'{termStateDescr = tr_opt_TerminationStateDescriptor(TermState, State),                       streams        = tr_opt_streams(Streams, State)}.tr_opt_streams(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_streams({Tag, Val}, State) ->    Val2 =         case Tag of            oneStream   -> tr_StreamParms(Val, State);            multiStream -> [tr_StreamDescriptor(SD, State) || SD <- Val]        end,    {Tag, Val2}.tr_StreamParms(#'StreamParms'{localControlDescriptor = Control,                              localDescriptor        = Local,                              remoteDescriptor       = Remote},               State) ->    #'StreamParms'{localControlDescriptor = tr_opt_LocalControlDescriptor(Control, State),                   localDescriptor        = tr_opt_LocalRemoteDescriptor(Local, State),                   remoteDescriptor       = tr_opt_LocalRemoteDescriptor(Remote, State)}.tr_StreamDescriptor(#'StreamDescriptor'{streamID    = Id,                                        streamParms = Parms},                    State) ->    #'StreamDescriptor'{streamID    = tr_StreamID(Id, State),                        streamParms = tr_StreamParms(Parms, State)}.%% localControlDescriptor = LocalControlToken LBRKT localParm %%                          *(COMMA localParm) RBRKT%% %% ; at-most-once per item%% localParm            = ( streamMode / propertyParm /%%                          reservedValueMode  / reservedGroupMode ) %% reservedValueMode       = ReservedValueToken EQUAL ( "ON" / "OFF" ) %% reservedGroupMode       = ReservedGroupToken EQUAL ( "ON" / "OFF" ) %% %% reservedMode      = ReservedToken EQUAL ( "ON" / "OFF" )%% %% streamMode           = ModeToken EQUAL streamModestr_opt_LocalControlDescriptor(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_LocalControlDescriptor(#'LocalControlDescriptor'{streamMode    = Mode,                                                        reserveGroup  = Group,                                                        reserveValue  = Value,                                                        propertyParms = Props},                              State) ->    #'LocalControlDescriptor'{streamMode    = tr_opt_StreamMode(Mode, State),                              reserveGroup  = tr_opt_bool(Group, State),                              reserveValue  = tr_opt_bool(Value, State),                              propertyParms = [tr_PropertyParm(P, State) || P <- Props]}.tr_opt_StreamMode(Mode, _State) ->    case Mode of        asn1_NOVALUE -> asn1_NOVALUE;        sendOnly     -> sendOnly;        recvOnly     -> recvOnly;        sendRecv     -> sendRecv;        inactive     -> inactive;        loopBack     -> loopBack    end.tr_Name(Name, State) ->    %% BUGBUG: transform    %% BUGBUG: NAME = ALPHA *63(ALPHA / DIGIT / "_" )    tr_STRING(Name, State, 2, 2).tr_PkgdName(Name, State) ->    %% BUGBUG: transform    %% BUGBUG:  pkgdName =  (NAME / "*")  SLASH  (ItemID / "*" )    tr_OCTET_STRING(Name, State, 4, 4).%% When text encoding the protocol, the descriptors consist of session%% descriptions as defined in SDP (RFC2327), except that the "s=", "t="%% and "o=" lines are optional. When multiple session descriptions are%% provided in one descriptor, the "v=" lines are required as delimiters;%% otherwise they are optional.  Implementations shall accept session%% descriptions that are fully conformant to RFC2327. When binary%% encoding the protocol the descriptor consists of groups of properties%% (tag-value pairs) as specified in Annex C.  Each such group may%% contain the parameters of a session description.tr_opt_LocalRemoteDescriptor(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_LocalRemoteDescriptor(#'LocalRemoteDescriptor'{propGrps = Groups},                             State) ->    #'LocalRemoteDescriptor'{propGrps = [tr_PropertyGroup(G, State) || G <- Groups]}.tr_PropertyGroup(Props, State) ->    [tr_PropertyGroupParm(P, State) || P <- Props].tr_PropertyGroupParm(#'PropertyParm'{name  = Name,                                     value = Value},                     State) ->    Constraint = fun(Item) -> tr_PkgdName(Item, State) end,    #'PropertyParm'{name  = resolve(property, Name, State, Constraint),                    value = tr_OCTET_STRING(Value, State, 0, infinity)}.tr_PropertyParm(#'PropertyParm'{name      = Name,                                value     = Value,                                extraInfo = Extra},                State) ->    Constraint = fun(Item) -> tr_PkgdName(Item, State) end,    #'PropertyParm'{name      = resolve(property, Name, State, Constraint),                    value     = tr_Value(Value, State),                    extraInfo = tr_opt_extraInfo(Extra, State)}.tr_opt_extraInfo(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_extraInfo({relation, Rel}, _State) ->    Rel2 =         case Rel of            greaterThan -> greaterThan;            smallerThan -> smallerThan;            unequalTo   -> unequalTo        end,    {relation, Rel2};tr_opt_extraInfo({range, Range}, State) ->    Range2 = tr_bool(Range, State),    {range, Range2};tr_opt_extraInfo({sublist, Sub}, State) ->    Sub2 = tr_bool(Sub, State),    {sublist, Sub2}.tr_opt_TerminationStateDescriptor(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_TerminationStateDescriptor(#'TerminationStateDescriptor'{propertyParms      = Props,                                                                eventBufferControl = Control,                                                                serviceState       = Service},                                  State) ->    #'TerminationStateDescriptor'{propertyParms      = [tr_PropertyParm(P, State) || P <- Props],                                  eventBufferControl = tr_opt_EventBufferControl(Control, State),                                  serviceState       = tr_opt_ServiceState(Service, State)}.tr_opt_EventBufferControl(Control, _State) ->    case Control of        asn1_NOVALUE -> asn1_NOVALUE;        off          -> off;        lockStep     -> lockStep    end.tr_opt_ServiceState(Service, _State) ->    case Service of        asn1_NOVALUE -> asn1_NOVALUE;        test         -> test;        outOfSvc     -> outOfSvc;        inSvc        -> inSvc    end.tr_MuxDescriptor(#'MuxDescriptor'{muxType  = Type,                                  termList = IdList},                 State) ->    #'MuxDescriptor'{muxType  = tr_MuxType(Type, State),                     termList = [tr_TerminationID(Id, State) || Id <- IdList]}.tr_MuxType(Type, _State) ->    case Type of        h221 -> h221;        h223 -> h223;        h226 -> h226;        v76  -> v76    end.tr_opt_StreamID(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_StreamID(Id, State) ->    tr_StreamID(Id, State).tr_StreamID(Id, State) ->    tr_UINT16(Id, State).tr_EventsDescriptor(#'EventsDescriptor'{requestID = Id,                                        eventList = Events},                    State) ->    #'EventsDescriptor'{requestID = tr_opt_RequestID(Id, State),                        eventList = [tr_RequestedEvent(E, State) || E <- Events]}.tr_RequestedEvent(#'RequestedEvent'{pkgdName    = Name,                                    streamID    = Id,                                    evParList   = Parms,                                    eventAction = Actions},                  State)  ->    Constraint = fun(Item) -> tr_PkgdName(Item, State) end,    #'RequestedEvent'{pkgdName    = resolve(event, Name, State, Constraint),                      streamID    = tr_opt_StreamID(Id, State),                      eventAction = tr_opt_RequestedActions(Actions, State),                      evParList   = [tr_EventParameter(P, Name, State) || P <- Parms]}.tr_opt_RequestedActions(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_RequestedActions(#'RequestedActions'{keepActive        = Keep,                                            eventDM           = DM,                                            secondEvent       = Event,                                            signalsDescriptor = SigDesc},                        State) ->    #'RequestedActions'{keepActive        = tr_opt_keepActive(Keep, State),                        eventDM           = tr_opt_EventDM(DM, State),                        secondEvent       = tr_opt_SecondEventsDescriptor(Event, State),                        signalsDescriptor = tr_opt_SignalsDescriptor(SigDesc, State)}.tr_opt_keepActive(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_keepActive(Keep, State) ->    tr_bool(Keep, State).tr_opt_EventDM(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_EventDM({Tag, Val}, State) ->    Val2 =         case Tag of            digitMapName  -> tr_DigitMapName(Val, State);            digitMapValue -> tr_DigitMapValue(Val, State)        end,    {Tag, Val2}.tr_opt_SecondEventsDescriptor(asn1_NOVALUE, _State) ->    asn1_NOVALUE;tr_opt_SecondEventsDescriptor(#'SecondEventsDescriptor'{requestID = Id,                                                        eventList = Events},                              State) ->    #'SecondEventsDescriptor'{requestID = tr_RequestID(Id, State), %% IG v6 6.8 withdrawn                              eventList = [tr_SecondRequestedEvent(E, State) || E <- Events]}.tr_SecondRequestedEvent(#'SecondRequestedEvent'{pkgdName    = Name,                                                streamID    = Id,                                                evParList   = Parms,                                                eventAction = Actions},                        State) ->    Constraint = fun(Item) -> tr_PkgdName(Item, State) end,    #'SecondRequestedEvent'{pkgdName    = resolve(event, Name, State, Constraint),                            streamID    = tr_opt_StreamID(Id, State),                            eventAction = tr_opt_SecondRequestedActions(Actions, State),                            evParList   = [tr_EventParameter(P, Name, State) || P <- Parms]}.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -