Diameter

Copyright © 2011-2012 Ericsson AB. All Rights Reserved. Diameter 1.1 April 1 2012

Copyright © 2011-2012 Ericsson AB. All Rights Reserved.
The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Ericsson AB. All Rights Reserved.. April 1 2012

Ericsson AB. All Rights Reserved.: Diameter | 1

1. All Rights Reserved. and communicates the reception of incoming Diameter request and answer messages. 1. The diameter application provides two transport modules: diameter_tcp and diameter_sctp for transport over TCP (using gen_tcp) and SCTP (using gen_sctp) respectively.4 Standards Compliance Known points of questionable or non-compliance.1 Introduction 1 Diameter Users Guide The diameter application is a framework for building applications on top of the Diameter protocol. Example code can be found in the diameter application's examples subdirectory. typically. Each Diameter application is also configured with one or more dictionary modules that provide encode/decode functionality for outgoing/incoming Diameter messages. While a service typically implements a single Diameter peer (as identified by an Origin-Host AVP). It supports arbitrary Diameter applications by way of a dictionary interface that allows messages and AVP's to be defined and input into diameter as configuration.3 Examples To be written. Other transports can be provided by any module that implements diameter's transport interface. 1. transports can themselves be associated with capabilities AVP's so that a single service be used to implement more than one Diameter peer. An application using diameter implements these application callback modules to provide the functionality of the Diameter peer(s) it implements. 2 | Ericsson AB.1 Introduction The diameter application is an implementation of the Diameter protocol as defined by RFC 3588. It has support for all roles defined in the RFC: client.2 Using the stack To be written.1. the capabilities that it should send to remote peers at capabilities exchange upon the establishment of transport connections. This chapter provides a short overview of the application. Base Accounting and Relay applications are provided by the diameter application. A module is generated from a specification file using the diameterc utility. 1. Each Diameter application defined on a service is configured with a callback module that implements the application interface through which diameter communicates the connectivity of remote peers. Dictionaries for the RFC 3588 Diameter Common Messages. server and agent. A transport is configured on a service and provides protocol-specific send/receive functionality by way of a transport interface defined by diameter and implemented by a transport module. The service configuration defines the Diameter applications to be supported by the peer and. requests peer selection for outgoing requests.: Diameter . A Diameter peer is implemented by configuring a service and one or more transports using the interface module diameter.

6. It can possibly be implemented on top of diameter as is but this is probably something that diameter should do.) The possibility of configuring the peer's Origin-Host could be added.1. (The identity becoming known upon reception of CEA. the watchdog state machine being the primary one. There is no explicit support for peer discovery (section 5. The current draft deprecates portions of the original RFC's mechanisms however.4. There is no TLS support over SCTP. along with handling of the case that it sends something else.2 RFC 3539 RFC 3539 is more difficult to comply to since it discusses problems as much as it requires functionality but all the MUST's are covered. Ericsson AB.: Diameter | 3 .2). The current RFC 3588 draft acknowledges this by equating TLS with TLS/TCP and DTLS/SCTP but we do not yet support DTLS. The peer state machine's election process (section 5. RFC 3588 requires that a Diameter server support TLS but in practise this seems to mean TLS over SCTP since there are limitations with running over SCTP: see RFC 6083 (DTLS over SCTP). Of the optional functionality.4) isn't implemented as specified since it assumes knowledge of a peer's Origin-Host before sending it a CER.1 RFC 3588 • The End-to-End Security framework (section 2.4 Standards Compliance 1. but for many applications this will just be unnecessary configuration of a value that it has no control over. The document that was to describe it (reference [AAACMS]) was abandoned in an uncompleted state several years ago and the current draft RFC deprecates the framework. including the P Flag in the AVP header. All Rights Reserved.9) isn't implemented since it is largely unspecified. load balancing is left to the diameter user (since it's the one deciding who to send to) and there is no Congestion Manager. • • • 1. which is a response to RFC 3436 (TLS over SCTP).4.

4 | Ericsson AB.: Diameter . All Rights Reserved.1.4 Standards Compliance 2 Reference Manual The Diameter application is a framework for building applications on top of the Diameter protocol.

Basic usage consists of creating a representation of a locally implemented Diameter peer and its capabilities with start_service/2. Beware the difference between diameter application and Diameter application.diameter diameter Erlang module This module provides the interface with which a user creates a service that sends and receives messages using the Diameter protocol as defined in RFC 3588. More generally. The former refers to the Erlang application named diameter whose main api is defined here. Defined in diameter_dict(4). in which case the call-specific arguments are appended to any specified with the callback module. defaults to the value of the dictionary option. application_alias()} An unique identifier for the application in the scope of the service. application_module() = Mod | [Mod | ExtraArgs] | #diameter_callback{} Mod = atom() ExtraArgs = list() A module implementing the callback interface defined in diameter_app(3). Note that additional arguments specific to an outgoing request be specified to call/4. the latter to an application of the Diameter protocol in the sense of RFC 3588. Incoming Diameter requests are communicated as callbacks to a diameter_app(3) callback modules as specified in the service configuration. with default implementations provided by module diameter_callback unless otherwise specified. Optional. All Rights Reserved.: Diameter | 5 . DATA TYPES Address() DiameterIdentity() Time() Unsigned32() UTF8String() Types corresponding to RFC 3588 AVP Data Formats. application_opt() Options defining a Diameter application as configured in an application option passed to start_service/2. capitalized Diameter refers to the RFC and diameter to this implementation. adding transport capability using add_transport/2 and sending Diameter requests and receiving Diameter answers with call/4. See that module for details. Ericsson AB. Any extra arguments are appended to the documented list of arguments for each function. Specifying a #diameter_callback{} record allows individual functions to be configured in place of the usual diameter_app(3) callbacks. application_alias() = term() A name identifying a Diameter application in service configuration passed to start_service/2 and passed to call/4 when sending requests belonging to the application. {alias. The diameter application must be started before calling functions in this module. along with any extra arguments to be appended to those documented for the interface.

diameter {dictionary. the latter taking precedence over the former. {state. callback|report|discard} Determines the manner in which incoming answer messages containing decode errors are handled. in the errors field of the diameter_packet record passed into the callback. detach Causes call/4 to return ok as soon as the request in question has been encoded instead of waiting for and returning the result from a subsequent handle_answer/4 or handle_error/4 callback. {module.: Diameter . Multiple options append to the argument list. {extra. Defaults to false if unspecified. which is a potential performance bottleneck. A simple Diameter client may suffer no ill effects from using mutable state but a server or agent that responds to incoming request but sending its own requests should probably avoid it. Multiple options are equivalent a single all filter on the corresponding list of filters. {call_mutates_state. atom()} The name of an encode/decode module for the Diameter messages defined by the application. If callback then errors result in a handle_answer/4 callback in the same fashion as for handle_request/3. See diameter_app(3) for information on the required interface and semantics. Defaults to 5000. peer_filter()} A filter to apply to the list of available peers before passing them to the pick_peer/4 callback for the application in question. Note that pick_peer callbacks are serialized when these are allowed to modify state. 6 | Ericsson AB. Defaults to report if unspecified. {filter. term()} The initial callback state. These modules are generated from a specification file whose format is documented in diameter_dict(4). Defaults to none. true|false} Specifies whether or not the pick_peer/4 application callback (following from a call to call/4) can modifiy state. list()} Extra arguments to append to callbacks to the callback module in question. application_module()} A callback module with which messages of the Diameter application are handled. which can then return a new state. failure}. Defaults to the value of the alias option if unspecified. In both the report and discard cases the return value for the call/4 invocation in question is as if a callback had taken place and returned {error. Unsigned32()} The number of milliseconds after which the request should timeout. call_opt() Options available to call/4 when sending an outgoing Diameter request. {timeout. These are appended to any extra arguments configured with the callback itself. If report then an answer containing errors is discarded without a callback and a warning report is written to the log. An invalid option will cause call/4 to fail. Can be configured both on a service and a transport. capability() AVP values used in outgoing CER/CEA messages during capabilities exchange. The prevailing state is passed to certain diameter_app(3) callbacks. If discard then an answer containing errors is silently discarded without a callback. All Rights Reserved. {answer_errors.

The list of addresses is available to the start function of a transport module. defaults to the empty list. Note that each tuple communicates one or more AVP values. Optional. If 1 (= TLS) is specified then TLS is selected if the CER/CEA received from the peer offers it. Optional. the AVP will be included in CER/CEA and DWR/DWA messages. Ericsson AB. UTF8String()} Value of the Product-Name AVP sent in an outgoing capabilities exchange message. Unsigned32()} Value of the Firmware-Revision AVP sent in an outgoing capabilities exchange message. [Address()]} Values of Host-IP-Address AVPs. All Rights Reserved. DiameterIdentity()} Value of the Origin-Realm AVP in outgoing messages. evaluable() = {M. [Unsigned32()]} Values of Inband-Security-Id AVPs sent in an outgoing capabilities exchange message. defaults to the empty list. {'Firmware-Revision'. {'Host-IP-Address'. Setting a value of 0 (zero) is equivalent to not setting a value as documented in RFC 3588. {'Vendor-Specific-Application-Id'. {'Acct-Application-Id'.diameter {'Origin-Host'. DiameterIdentity()} Value of the Origin-Host AVP in outgoing messages. [Grouped()]} Values of Vendor-Specific-Application-Id AVPs sent in an outgoing capabilities exchange message. Unsigned32()} Value of Origin-State-Id to be included in outgoing messages sent by diameter itself. [Unsigned32()]} Values of Supported-Vendor-Id AVPs sent in an outgoing capabilities exchange message. Optional.F. Optional.: Diameter | 7 . defaults to the empty list. defaults to the empty list. {'Vendor-Id'. {'Auth-Application-Id'. [Unsigned32()]} Values of Acct-Application-Id AVPs sent in an outgoing capabilities exchange message. In particular. {'Origin-State-Id'. {'Product-Name'. {'Inband-Security-Id'. Optional. {'Supported-Vendor-Id'. Unsigned32()} Value of the Vendor-Id AVP sent in an outgoing capabilities exchange message. It is an error to specify duplicate tuples. Optional. [Unsigned32()]} Values of Auth-Application-Id AVPs sent in an outgoing capabilities exchange message. {'Origin-Realm'. Optional. which is equivalent to a list containing only 0 (= NO_INBAND_SECURITY). Optional. which either uses them as is or returns a new list (typically as configured as transport_config() on the transport module in question) in order for the correct list of addresses to be sent in capabilities exchange messages. The function origin_state_id/0 can be used as to retrieve a value that is set when the diameter application is started. defaults to the empty list.A} | fun() | [evaluable() | A] An expression that can be evaluated as a function in the following sense.

8 | Ericsson AB. Has one of the following types.or list-valued message() as documented in diameter_app(3). {eval. {neg. peer_filter() = term() A filter passed to call/4 in order to select candidate peers for a pick_peer/4 callback. A). eval([F|A]) -> apply(F. none Matches any peer. any|DiameterIdentity()} Matches only those peers whose Origin-Host has the specified value. Note that the host and realm filters examine the outgoing request as passed to call/4. fun expressions not of the form fun Module:Name/Arity) in situations in which the fun is not short-lived and code is to be upgraded at runtime since any processes retaining such a fun will have a reference to old code. DiameterIdentity()} filters must be used to achieve the desired result. {host. peer_filter()} Matches only those peers not matched by the specified filter. {any. All Rights Reserved.F. [peer_filter()]} Matches only those peers matched by at least one filter of the specified list. []}. {all. eval([[F|A] | T]) -> eval([F | T ++ A]). An invalid filter is equivalent to {any. [peer_filter()]} Matches only those peers matched by each filter of the specified list. T ++ A). If this is not the case then the {host|realm. and that the message contains at most one of each AVP. Beware of using local funs (that is. or all peers if the atom any. a filter that matches no peer. assuming that this is a record. or all peers if the atom any.: Diameter . {realm. evaluable()} Matches only those peers for which the specified evaluable() returns true on the connection's diameter_caps record. F.diameter eval([{M. host Matches only those peers whose Origin-Host has the same value as Destination-Host in the outgoing request in question. Any other return value or exception is equivalent to false. eval(F) -> eval([F]). Applying an evaluable() E to an argument list A is meant in the sense of eval([E|A]). any|DiameterIdentity() Matches only those peers whose Origin-Realm has the value. or any peer if the request does not contain a Destination-Host AVP. or any peer if the request does not contain a Destination-Realm AVP.A} | T]) -> apply(M. Note also that an empty host/realm (which should not be typical) is equivalent to an unspecified one for the purposes of filtering. realm Matches only those peers whose Origin-Realm has the same value as Destination-Realm in the outgoing request in question. This is a convenience that provides a filter equivalent to no filter at all.

Peer. Result. {reconnect. All Rights Reserved. as determined during capablilities exchange. The capabilities record contains pairs of values for the the local node and remote peer. the event communicates connectivity with the peer as a whole while the callbacks communicate connectivity with respect to individual Diameter applications. CB. Peer. Config.: Diameter | 9 . If a diameter_packet record is present in an up tuple then there has been an exchange of capabilities exchange messages and the record contains the received CER or CEA.diameter service_event() = #diameter_event{} Event message sent to processes that have subscribed using subscribe/1. the tuple indicates the rejecting callback. Ref. Reason. Config} {down. The info field of the event record can be one of the following. Ref. ResultCode|discard} Caps = #diameter_caps{} Pkt = #diameter_packet{} ResultCode = integer() CB = evaluable() An incoming CER has been answered with the indicated result code or discarded. Ref. Pkt} {up. {up. Reason can be one of the following. That is. The packet record contains the CER in question. Ericsson AB. otherwise the connection has reestablished without the loss or transport connectivity. {'CER'. Opts} Ref = transport_ref() Opts = [transport_opt()] A connecting transport is attempting to establish/reestablish a transport connection with a peer following reconnect_timer or watchdog_timer expiry. In the case of rejection by a capabilities callback. Ref. {closed. Caps. Config} Ref = transport_ref() Config = {connect|listen. [transport_opt()]} Capabilities exchange has failed. Peer. Ref. [transport_opt()]} #diameter_packet{} The RFC 3539 watchdog state machine has transitioned into (up) or out of (down) the open state. Config} Ref Peer Config Pkt = = = = transport_ref() diameter_app:peer() {connect|listen. Note that a single up/down event for a given peer corresponds to as many peer_up/peer_down callbacks as there are Diameter applications shared by the peer. Pkt} Result = ResultCode | {capabilities_cb.

transport_opt() Options accepted by add_transport/2. The capabilities record contains only values for the the local node. CB. a subscriber should be prepared to receive info fields of forms other than the above. atom()} A module implementing a transport process as defined in diameter_transport(3). Caps. For an outgoing Diameter request. {'CEA'. An integer-valued Result indicates the result code sent by the peer. The capabilities record contains pairs of values for the the local node and remote peer. Note that erlang:make_ref/0 can be used to generate a service name that is somewhat unique. All Rights Reserved. the application is specified by passing the desired application's application_alias() to call/4. The capabilities record contains only values for the the local node. Can be any capability() tuple as well as the following. service_name() = term() The name of a service as passed to start_service/2 and with which the service is identified. The packet record contains the CEA in question. {ResultCode. Result. Caps. 10 | Ericsson AB. The packet record contains the CER in question. Defaults to diameter_tcp if unspecified. The packet record contains the CEA in question. the tuple indicates the rejecting callback. Caps. ResultCode|discard} Caps = #diameter_caps{} Pkt = #diameter_packet{} ResultCode = integer() An incoming CEA has been rejected for the indicated reason. A service must define one application for each Diameter application it intends to support. {transport_module. Pkt} Result = integer() | atom() | {capabilities_cb. For forward compatibility. service_opt() Options accepted by start_service/2. In the case of rejection by a capabilities callback. the application identifier being specified in the dictionary file defining the application. {'CEA'. There can be at most one service with a given name on a given node.diameter {'CER'. while for an incoming request the application identifier in the message header determines the application (and callback module).: Diameter . [application_opt()]} Defines a Diameter application supported by the service. {application. Pkt} Caps = #diameter_caps{} Pkt = #diameter_packet{} An incoming CER contained errors and has been rejected. Pkt}} ResultCode = integer() Caps = #diameter_caps{} Pkt = #diameter_packet{} An incoming CER contained errors and has been answered with the indicated result code.

allowing the jitter calculation to be performed by the callback.: Diameter | 11 . [application_alias()]} The list of Diameter applications to which usage of the transport should be restricted. For a listening transport. Defaults to 30000 for a connecting transport and 60000 for a listening transport. Multiple capabilities_cb options can be specified. Any AVP specified takes precedence over a corresponding value specified for the service in question. causing the RFC 3539 state machine to pass to state OPEN rather than REOPEN. {transport_config. {applications. term()} A term passed as the third argument to the start/3 function of the relevant transport_module in order to start a transport process. evaluable()} A callback invoked upon reception of CER/CEA during capabilities exchange in order to ask whether or not the connection should be accepted.A} The RFC 3539 watchdog timer. {capabilities. as required by RFC 3539. in milliseconds. Specifying a capability as a transport option may be particularly appropriate for Inband-Security-Id in case TLS is desired over TCP as implemented by diameter_tcp(3) but not over SCTP as implemented by diameter_sctp(3). in which case the corresponding callbacks are applied until either all return ok or one does not.F. An integer value is interpreted as the RFC's TwInit in milliseconds. {reconnect_timer. Defaults to the empty list if unspecified. a jitter of ± 2 seconds being added at each rearming of the timer to compute the RFC's Tw. the RFC 3588 Tc timer. with jitter applied. An MFA is expected to return the RFC's Tw directly. Defaults to all applications configured on the service in question. An integer value must be at least 6000 as required by RFC 3539. [capability()]} AVP's used to construct outgoing CER/CEA messages. Returning integer() causes an incoming CER to be answered with the specified Result-Code. Note that these semantics are not goverened by the RFC and that a listening transport's reconnect_timer should be greater than its peers's Tc plus jitter. Tc} Tc = Unsigned32() For a connecting transport. Note that this timer determines the frequency with which the transport will attempt to establish a connection with its peer only before an initial connection is established: once there is an initial connection it's watchdog_timer that determines the frequency of reconnection attempts. Returning ok accepts the connection. Applied to the transport reference (as returned by add_transport/2) and diameter_caps record of the connection. Ericsson AB. Defaults to 30000 if unspecified.diameter The interface required of a transport module is documented in diameter_transport(3). Returning discard causes an incoming CER to be discarded. All Rights Reserved. {watchdog_timer. DIAMETER_UNKNOWN_PEER. the timer specifies the time after which a previously connected peer will be forgotten: a connection after this time is regarded as an initial connection rather than a reestablishment. Returning unknown is equivalent to returning 3010. Returning anything but ok or a 2xxx series result code causes the transport connection to be broken. TwInit} TwInit = Unsigned32() | {M. {capabilities_cb.

Options) -> ok | Answer | {error. then {error.: Diameter . Reason} Types: SvcName = service_name() App = application_alias() Request = diameter_app:message() | term() Answer = term() Options = [call_opt()] Send a Diameter request message and possibly return the answer or error. whether or not the error is returned directly by diameter or from a handle_error/4 callback depends on whether or not the outgoing request is successfully encoded for transmission from the peer. App identifies the Diameter application in which the request is defined and callbacks to the corresponding callback module will follow as described below and in diameter_app(3). In the case of an answer. either by connecting to the peer (connect) or by accepting incoming connection requests (listen). {connect|listen. then the request process fails and {error. the service takes responsibility for the handling of DWR/DWA and required by RFC 3539 as well as for DPR/DPA. There are several error cases which may prevent an answer from being received and passed to a handle_answer/4 callback: • If the initial encode of the outgoing request fails. or if pick_peer/4 rejects them by returning 'false'. Otherwise pick_peer/4 is followed by a prepare_request/3 callback. All Rights Reserved. Options}) -> {ok. A connecting transport establishes transport connections with at most one peer. 12 | Ericsson AB. The diameter application takes responsibility for exchanging CER/CEA with the peer. Unless the detach option has been specified to cause an earlier return.diameter Unrecognized options are silently ignored but are returned unmodified by service_info/2 and can be referred to in predicate functions passed to remove_transport/2. It is not an error to add a transport to a service that has not yet been configured: a service can be started after configuring transports. the call returns either when an answer message is received from the peer or an error occurs. no_connection} is returned. If there are no suitable peers. Upon successful completion of capabilities exchange the service calls each relevant application module's peer_up/3 callback after which the caller can exchange Diameter messages with the peer over the transport. The service will start a transport process(es) in order to establish a connection with the peer. an listening transport potentially with many. In addition to CER/CEA. App. the return value is as returned by a handle_answer/4 callback. Request. the cases being documented below. call(SvcName. Note that the function returns before a transport connection has been established. encode} is returned. the message is encoded and sent. Ref} | {error. Reason} Types: SvcName = service_name() Options = [transport_opt()] Ref = ref() Reason = term() Add transport capability to a service. In the case of an error. The returned reference uniquely identifies the transport within the scope of the service. Exports add_transport(SvcName.

encode} or {error. If no such peer is available. where Type and Opts are as passed to add_transport/2 and Ref is as returned by the corresponding call. at the time the diameter application was started. Opts) returns true. If the request is successfully encoded and sent but the service in question is stopped before an answer is received then a handle_error/4 callback takes place Reason = cancel. Ericsson AB. prepare_retransmit. the first value that can be encoded as a Diameter Time(). [Ref.Opts end true: fun(_. _. An arity-3-valued Pred removes all transports for which Pred(Ref. The value returned is the number of seconds since 19680120T031408Z. F. All Rights Reserved. Opts) end fun(list()): fun(_. atom(). prepare_request. Type. or if the subsequent pick_peer/4 callback rejects the candidates.A}: fun(Ref. list()} Remove previously added transports. Opts) -> Pred(Opts) end reference(): fun(Ref. A base application DPR message with Disconnect-Cause DO_NOT_WANT_TO_TALK_TO_YOU will be sent to each connected peer before disassociating the transport configuration from the service and terminating the transport upon reception of DPA or timeout. If the transport connection with the peer goes down after the request has been sent but before an answer has been received then an attempt is made to resend the request to an alternate peer. failure} is returned. _) -> false end {M. If an encode error takes place during retransmission then the request process fails and {error. then a handle_error/4 callback takes place with Reason = failover. handle_answer or handle_error) then either {error. connect|listen. _. _. Opts | A]) end Removing a transport causes all associated transport connections to be broken. If a peer is selected then a prepare_retransmit/3 callback takes place. origin_state_id() -> Unsigned32() Return a reasonable value for use as Origin-State-Id in outgoing messages. Opts) -> [] == Pred -. encode} is the only return value which guarantees that the request has not been sent over the transport. remove_transport(SvcName. Opts) -> Pred(Ref. Note that {error. Type.diameter • • • • • If the request is successfully encoded and sent but the answer times out then a handle_error/4 callback takes place with Reason = timeout. after which the semantics are the same as following an initial prepare_request/3 callback.F. The remaining forms are equivalent to an arity-3 fun as follows. If an application callback made in processing the request fails (pick_peer. Opts) -> apply(M. Type. Pred determines which transports to remove. _. Pred Pred Pred Pred Pred Pred Pred = = = = = = = fun(reference(). list()): fun(Ref.: Diameter | 13 . failure} is returned depending on whether or not there has been an attempt to send the request over the transport. list()) -> boolean()) | fun((reference(). _. Pred) -> ok Types: SvcName = service_name() Pred = Fun | MFA | ref() | list() | true | false Fun = fun((reference(). list()) -> boolean()) | fun((list()) -> boolean()) MFA = {atom(). _) -> true end false: fun(_. _) -> Pred == Ref end list(): fun(_. _.

14 | Ericsson AB. Item) -> Value Types: SvcName = service_name() Value = term() Return information about a started service.diameter service_info(SvcName. session_id(Ident) -> OctetString() Types: Ident = DiameterIdentity() Return a value for a Session-Id AVP. Reason} Start the diameter application. stop() -> ok | {error. Reason} Types: SvcName = service_name() Reason = term() Stop a diameter service. not by calling start/0 explicitly. The diameter application must be started before starting a service.: Diameter . A service defines a locally-implemented Diameter peer. Transports are added to a service using add_transport/2. stop_service(SvcName) -> ok | {error. In a production system this will typically be accomplished by a boot file. Ident should be the Origin-Host of the peer from which the message containing the returned value will be sent. Options) -> ok | {error. Reason} Types: SvcName = service_name() Options = [service_opt()] Reason = term() Start a diameter service. The value has the form required by section 8.8 of RFC 3588. start_service(SvcName. specifying the capabilities of the peer to be used during capabilities exchange and the Diameter applications that it supports. All Rights Reserved. services() -> [SvcName] Types: SvcName = service_name() Return the list of started services. start() -> ok | {error. Reason} Stop the diameter application.

It is not an error to subscribe to events from a service that does not yet exist.: Diameter | 15 . unsubscribe(SvcName) -> true Types: SvcName = service_name() Unsubscribe to event messages from a service.diameter subscribe(SvcName) -> true Types: SvcName = service_name() Subscribe to service_event() messages from a service. diameter_transport(3). SEE ALSO diameter_app(3). All Rights Reserved. diameter_dict(4) Ericsson AB.

Inheritance is a beam dependency. not an erl/ hrl dependency. EXIT STATUS Returns 0 on success. All Rights Reserved. -i <dir> Specifies a directory to add to the code path. SEE ALSO diameter_dict(4) 16 | Ericsson AB. Multiple --inherits options can be specified. The resulting source implements the interface diameter requires to encode and decode the dictionary's messages and AVP's. Overrides any setting in the file itself. --name <name> Set @name in the dictionary file. USAGE diameterc [<options>] <file> Transforms a single dictionary file. Defaults to the current working directory.: Diameter . -E Supresses erl generation. --prefix <prefix> Set @prefix in the dictionary file. Use to point at beam files corresponding to dictionaries inherited by the one being compiled using @inherits or --inherits. non-zero on failure. -o <dir> Specifies the directory into which the generated source should be written. effectively ignoring previous inherits. BUGS The identification of errors in the source file is poor. Valid options are as follows. Multiple -i options can be specified. -H Supresses hrl generation.diameterc diameterc Command The diameterc utility is used to transform diameter dictionary files into Erlang source. Specifying '-' as the dictionary has the effect of clearing any previous inherits. --inherits <dict> Append an @inherits to the dictionary file. Overrides any setting in the file itself.

a message can also be encoded as a list whose head is the atom-valued message name (the record name minus any prefix specified in the relevant dictionary file) and whose tail is a list of {FieldName. The callback module implements the Diameter application-specific functionality of a service. Fields of a packet() record should not be set in return values except as documented. Each field of the record is a 2tuple consisting of values for the (local) host and (remote) peer. as well as the capabilities as determined by capabilities exchange. A third representation allows a message to be specified as a list whose head is a diameter_header record and whose tail is a list of diameter_avp records. A callback module must export all of the functions documented below. handle_request/3 is called in response to an incoming Diameter request message. All Rights Reserved. packet() = #diameter_packet{} A container for incoming and outgoing Diameters message that's passed through encode/decode and transport. prepare_request/3. each of whose configuration specifies a callback that handles messages specific to its application. for the call-specific callbacks. The functions themselves are of three distinct flavours: • • • peer_up/3 and peer_down/3 signal the attainment or loss of connectivity with a Diameter peer. This representation is used by diameter itself when relaying requests as directed by the return value of a handle_request/3 callback. Equivalently. prepare_retransmit/3. message() = record() | list() The representation of a Diameter message as passed to diameter:call/4. Should be treated opaquely. All functions will also be passed any extra arguments configured with the callback module itself when calling diameter:start_service/2 and. DATA TYPES capabilities() = #diameter_caps{} A record containing the identities of the local and remote Diameter peers having an established transport connection. It differs from the other other two in that it bypasses the checks for messages that do not agree with their definitions in the dictionary in question (since relays agents must handle arbitrary request): messages are sent exactly as specified. FieldValue} pairs. Note: The arities given for the the callback functions here assume no extra arguments. Optional or possibly multiple values are encoded as lists of values. Ericsson AB. mandatory values as the bare value. handle_answer/4 and handle_error/4 are (or may be) called as a consequence of a call to diameter:call/4 to send an outgoing Diameter request message. any extra arguments passed to diameter:call/4. The messages and AVPs of the Diameter application are defined in a dictionary file whose format is documented in diameter_dict(4) while the callback module is documented here.: Diameter | 17 . pick_peer/4. The record representation is as outlined in diameter_dict(4): a message as defined in a dictionary file is encoded as a record with one field for each component AVP. peer_ref() = term() A term identifying a transport connection with a Diameter peer.diameter_app diameter_app Erlang module A diameter service as started by diameter:start_service/2 configures one of more Diameter applications.

SvcName. Reserved. A new application state can also be returned but only if the Diameter application in question was configured with the option call_mutates_state set to true. Peer. 18 | Ericsson AB. and only those which have indicated support for the Diameter application in question. [host. Peer. {all. capabilities()} A tuple representing a Diameter peer connection. Specified to diameter:start_service/2 when starting the service. All Rights Reserved. State) -> NewState Types: SvcName = service_name() Peer = peer() State = NewState = state() Invoked when a transport connection has been lost following a previous call to peer_up/3. realm]}} option to diameter:call/4) will be placed at the head of the list. Mod:pick_peer(Candidates. Mod:peer_down(SvcName. service_name() = term() The service supporting the Diameter application. NewState} | false Types: Candidates = [peer()] Peer = peer() | false SvcName = service_name() State = NewState = state() Invoked as a consequence of a call to diameter:call/4 to select a destination peer for an outgoing request.: Diameter . The initial state is configured in the call to diameter:start_service/2 that configures the application on a service. Peer} | {Peer. The order of the elements is unspecified except that any peers whose Origin-Host and Origin-Realm matches that of the outgoing request (in the sense of a {filter. peer_down/3 and (optionally) pick_peer/4. Callback functions returning a state are evaluated in a common service-specific process while those not returning state are evaluated in a request-specific process. State) -> NewState Types: SvcName = service_name() Peer = peer() State = NewState = state() Invoked when a transport connection has been established and a successful capabilities exchange has indicated that the peer supports the Diameter application of the application on which the callback module in question has been configured. The candidate peers list will only include those which are selected by any filter option specified in the call to diameter:call/4. the return value indicating the selected peer. as documented for diameter:start_service/2. Exports Mod:peer_up(SvcName. state() = term() The state maintained by the application callback functions peer_up/3.diameter_app peer() = {peer_ref(). State) -> {ok.

Peer) -> Result Types: Packet = packet() SvcName = service_name() Peer = peer() Result = {send. Reason} causes the request to be aborted and the diameter:call/4 for which the callback has taken place to return {error. Mod:prepare_retransmit(Packet. Allows the sender to access the selected peer's capabilities in order to set (for example) Destination-Host and/or Destination-Realm in the outgoing request. State}. Returning discard is equivalent to returning {discard. If transport with the peer is lost before this then a new pick_peer/4 callback takes place to select an alternate peer. A returned packet() can also set the header field to a diameter_header record in order to specify values that should be preserved in the outgoing request. Reason} causes the request to be aborted and a handle_error/4 callback to take place with Reason as initial argument. cmd_code or application_id is ignored. Note that there is no guarantee that a pick_peer/4 callback to select an alternate peer will be followed by any additional callbacks. packet() | message()} | {discard.diameter_app The return values false and {false. packet() | message()} | {discard.: Diameter | 19 . only that the initial pick_peer/4 will be. Mod:handle_answer(Packet. Peer} and {Peer. SvcName. Peer) -> Action Types: Packet = packet() SvcName = service_name() Peer = peer() Action = {send. no_connection} to be returned from diameter:call/4. All Rights Reserved. Many implementations may simply want to return {send. although the callback need not be limited to this usage. Returning a peer() from an initial pick_peer/4 callback will result in a prepare_request/3 callback followed by either handle_answer/4 or handle_error/4 depending on whether or not an answer message is received from the peer. Returning discard is equivalent to returning {discard. although this should typically not be necessary and allows the callback to set header values inappropriately. Returning a peer as false causes {error. since a retransmission to an alternate peer is abandoned if an answer is received from a previously selected peer. Reason}. Reason} | discard Invoked to return a request for encoding and transport. Has the same role as prepare_request/3 in the case that a peer connection is lost an an alternate peer selected but the argument packet() is as returned by the initial prepare_request/3. SvcName. Returning {discard. discarded}. Packet} A returned packet() should set the request to be encoded in its msg field and can set the transport_data field in order to pass information to the transport module. discarded}. Peer) -> Result Types: Packet = packet() Request = message() SvcName = service_name() Ericsson AB. Returning {discard. Request. Extra arguments passed to diameter:call/4 can be used to communicate transport data to the callback. A returned length. State} are equivalent when callback state is mutable. Reason} | discard Invoked to return a request for encoding and retransmission. SvcName. Mod:prepare_request(Packet. as are {ok.

only one of handle_answer/4 or handle_error/4 is called for any given request. causing the relevant call to diameter:call/4 to return {error. PostF} Reply = {reply.diameter_app Peer = peer() Result = term() Invoked when an answer message is received from a peer. the undecoded binary in the packet field. 20 | Ericsson AB. Action. The return value is returned from the call to diameter:call/4 for which the callback takes place unless the detach option was specified. Reason timeout indicates that an answer message has not been received within the required time. All Rights Reserved.3999} Opts = diameter:call_opts() PostF = diameter:evaluable() Invoked when a request message is received from a peer. Peer) -> Action Types: Packet = packet() SvcName = term() Peer = peer() Action = Reply | {relay. failure} (unless the detach option was specified). Request. The argument packet() has the following signature. Mod:handle_error(Reason. Mod:handle_request(Packet.: Diameter . the callback module as configured with diameter:start_service/2) is determined by the Application Identifier in the header of the incoming request message. Similarly. Application configuration may change this behaviour as described for diameter:start_service/2. Reason failover indicates that the transport connection to the peer to which the request has been sent has been lost but that not alternate node was available.. For any given call to diameter:call/4 there is at most one call to the handle_answer callback of the application in question: any duplicate answer (due to retransmission or otherwise) is discarded. In particular. The decoded answer record is in the msg field of the argument packet(). an incoming answer message that cannot be successfully decoded causes the request process in question to fail. SvcName. message()} | {protocol_error. there is no handle_error/4 callback in this case. By default. Request is the outgoing request message as was returned from prepare_request/3 or prepare_retransmit/3 before the request was passed to the transport. SvcName. possibly because a pick_peer/4 callback returned false. Peer) -> Result Types: Reason = timeout | failover | term() Request = message() SvcName = service_name() Peer = peer() Result = term() Invoked when an error occurs before an answer message is received from a peer in response to an outgoing request. the selected module being the one whose corresponding dictionary declares itself as defining either the application in question or the Relay application. 3000. Opts} | discard | {eval. The return value is returned from the call to diameter:call/4 for which the callback takes place (unless the detach option was specified). The application in which the callback takes place (that is.

In this case diameter will set both Result-Code and Failed-AVP AVP's in a returned answer message() before sending it to the peer: the returned message() need only set any other required AVP's. Equivalent to {reply. Note that the extra option can be specified to supply arguments that can distinguish the relay case from others if so desired. Otherwise it contains the record representing the request as outlined in diameter_dict(4). Returning a non-3xxx value in a protocol_error tuple will cause the request process in question to fail. Ericsson AB. Action.3999} Send an answer message to the peer containing the specified protocol error. {relay. message()} Send the specified answer message to the peer. PostF} Handle the request as if Action has been returned and then evaluate PostF in the request process.. Any other return value (for example. The term is preserved in the packet() containing any answer message sent back to the transport process unless another value is explicitly specified. The semantics of each of the possible return values are as follows. or the atom undefined if the transport specified no data. If a routing loop is detected then the request is answered with 3005 (DIAMETER_LOOP_DETECTED). Otherwise a Route-Record AVP (containing the sending peer's Origin-Host) is added to the request and pick_peer/4 and subsequent callbacks take place just as if diameter:call/4 had been called explicitly. Origin-Realm. Opts} Relay a request to another peer in the role of a Diameter relay agent. errors = ['Unsigned32'() | {'Unsigned32'(). Note that RFC 3588 mandates that only answers with a 3xxx series Result-Code (protocol errors) may set the E bit. from a handle_error/4 callback) causes the request to be answered with 3002 (DIAMETER_UNABLE_TO_DELIVER). transport_data = term()} The msg field will be undefined only in case the request has been received in the relay application.: Diameter | 21 . avps = [#diameter_avp{}]. The errors list is empty if the request has been received in the relay application. The End-to-End Identifier of the incoming request is preserved in the header of the relayed request. {eval. discard Discard the request. The returned Opts should not specify detach. 3000. {reply. A subsequent handle_answer/4 callback for the relayed request must return its first argument. All Rights Reserved. Note that the errors detected by diameter are all of the 5xxx series (Permanent Failures). ['answer-message' | Avps] where Avps sets the Origin-Host. bin = binary(). The transport_data field contains an arbitrary term passed into diameter from the transport module in question. The errors field specifies any Result-Code's identifying errors that were encountered in decoding the request. the specified Result-Code and (if the request sent one) SessionId AVP's.diameter_app #diameter_packet{header = #diameter_header{}. #diameter_avp{}}]. the diameter_packet record containing the answer message. {protocol_error. msg = record() | undefined.

All Rights Reserved.: Diameter .diameter_app Note that protocol errors detected by diameter will result in an answer message without handle_request/3 being invoked. 22 | Ericsson AB.

The format of such a file is defined in FILE FORMAT below. Note that a dictionary module should have a unique name so as not collide with existing modules in the system. The diameter application includes three dictionary modules corresponding to applications defined in section 2. The Relay application is given special treatment with regard to encode/decode since the messages and AVPs it handles are not specifically defined. The Application Id is set in the Diameter Header of outgoing messages of the application. Tags consist of an ampersand character followed by a keyword and are separated from their arguments by whitespace. Users add support for their specific applications by creating dictionary files. The order in which sections are specified is unimportant.4 of RFC 3588: diameter_gen_base_rfc3588 for the Diameter Common Messages application with application identifier 0. The section has empty content. All Rights Reserved. Example: Ericsson AB.diameter_dict diameter_dict Name A diameter service as configured with diameter:start_service/2 specifies one or more supported Diameter applications.) These records and the underlying Erlang data types corresponding to Diameter data formats are discussed in MESSAGE RECORDS and DATA TYPES respectively. The tags. Each section starts with a tag followed by zero or more arguments and ends at the the start of the next section or end of file. The codec generation also results in a hrl file that defines records for the messages and grouped AVPs defined for the application. compiling them to Erlang modules using diameterc and configuring the resulting dictionaries modules on a service. DWR/DWA and DPR/DPA. their arguments and the contents of each corresponding section are as follows. and the value in the header of an incoming message is used to identify the relevant dictionary module.: Diameter | 23 . The Common Message and Relay applications are the only applications that diameter itself has any specific knowledge of. FILE FORMAT A dictionary file consists of distinct sections. Can occur at most once and is required if the dictionary defines @messages. Each Diameter application specifies a dictionary module that knows how to encode and decode its messages and AVPs. The generated hrl also contains defines for the possible values of AVPs of type Enumerated. diameter_gen_accounting for the Diameter Base Accounting application with application identifier 3 and diameter_gen_relay the Relay application with application identifier 0xFFFFFFFF. Each section can occur multiple times unless otherwise specified. The section has empty content. (Modulo other available formats as discussed in diameter_app(3). The Common Message application is used for messages that diameter itself handles: CER/CEA. Whitespace separates individual tokens but is otherwise insignificant. these records being what a user of the diameter application sends and receives. @id Number Defines the integer Number as the Diameter Application Id of the application in question. Example: @id 16777231 @name Mod Defines the name of the generated dictionary module. Can occur at most once and defaults to the name of the dictionary file minus any extension if unspecified. The dictionary module is in turn generated from a file that defines these messages and AVPs.

All dictionaries should typically inherit RFC3588 AVPs from diameter_gen_base_rfc3588. Can occur at most once and is required if an AVP sets the V flag and is not otherwise assigned a Vendor-Id. All Rights Reserved. Note that an inherited AVP that sets the V flag takes its Vendor-Id from either @avp_vendor_id in the inheriting dictionary or @vendor in the inherited dictionary. Example: 24 | Ericsson AB. Name documents the owner of the application but is otherwise unused. The section has empty content.diameter_dict @name etsi_e2 @prefix Name Defines Name as the prefix to be added to record and constant names (followed by a '_' character) in the generated dictionary module and hrl. overriding the @vendor default. In particular.: Diameter . Example: @prefix etsi_e2 @vendor Number Name Defines the integer Number as the the default Vendor-Id of AVPs for which the V flag is set. The section has empty content. Can occur at most once. The section content consists of the names of those AVPs whose definitions should be imported from the dictionary. Inheriting from a dictionary that specifies the required @vendor is equivalent to using @avp_vendor_id with a copy of the dictionary's definitions but the former makes for easier reuse. The section content consists of AVP names. Any listed AVPs must not be defined in the current dictionary and it is an error to inherit the same AVP from more than one dictionary. @avp_vendor_id in the inherited dictionary is ignored. an empty list causing all to be imported. Example: @avp_vendor_id 2937 WWW-Auth Domain-Index Region-Set @inherits Mod Defines the name of a dictionary module containing AVP definitions that should be imported into the current dictionary. Example: @vendor 13019 ETSI @avp_vendor_id Number Defines the integer Number as the Vendor-Id of the AVPs listed in the section content. A prefix is optional but can be be used to disambiguate between record and constant names resulting from similarly named messages and AVPs in different Diameter applications.

REQ. The section content consists of definitions of the form specified in section 3. Mod:Name(encode|decode. "Command Code ABNF specification". PXY > < Session-Id > Ericsson AB. type and flags of individual AVPs. The section contents consists of AVP names. Type. @messages RTR ::= < Diameter Header: 287. and Flags is a string of V. All Rights Reserved. code. Name. Data) is expected to provide encode/decode for values of the AVP. @custom_types Mod Specifies AVPs for which module Mod provides encode/decode functions. Type is it's type as declared in the @avp_types section of the dictionary and Data is the value to encode/decode. where Name is the name of the AVP.: Diameter | 25 . For each such name. Type.2 of RFC 3588. M and P characters indicating the flags to be set on an outgoing AVP or a single '-' (minus) character if none are to be set. Example: @avp_types Location-Information Requested-Information 350 353 Grouped Enumerated MV V Note that the P flag has been deprecated by the Diameter Maintenance and Extensions Working Group of the IETF: diameter will set the P flag to 0 as mandated by the current draft standard. Data) rather than Mod:Name(encode|decode. Example: @custom_types rfc4005_avps Framed-IP-Address @codecs Mod Like @custom_types but requires the specified module to export Mod:Type(encode|decode. The section consists of definitions of the form Name Code Type Flags where Code is the integer AVP code.diameter_dict @inherits diameter_gen_base_rfc3588 @avp_types Defines the name. Example: @codecs rfc4005_avps Framed-IP-Address @messages Defines the messages of the application. Type identifies an AVP Data Format as defined in DATA TYPES below. Data).

Section content consists of names and corresponding integer values. Note that the AVP in question can be defined in an inherited dictionary in order to introduce additional values to an enumeration otherwise defined in another dictionary. Example: @enum SIP-Reason-Code PERMANENT_TERMINATION NEW_SIP_SERVER_ASSIGNED 0 1 26 | Ericsson AB. PXY > Session-Id > Auth-Application-Id } Result-Code } Auth-Session-State } Origin-Host } Origin-Realm } Authorization-Lifetime ] Auth-Grace-Period ] Redirect-Host ] Redirect-Host-Usage ] Redirect-Max-Cache-Time ] Proxy-Info ] Route-Record ] AVP ] RTA ::= < < { { { { { [ [ [ [ [ * [ * [ * [ @grouped Defines the contents of the AVPs of the application having type Grouped. @enum Name Defines values of AVP Name having type Enumerated.diameter_dict * * * * { { { { { { [ [ [ [ [ [ Auth-Application-Id } Auth-Session-State } Origin-Host } Origin-Realm } Destination-Host } SIP-Deregistration-Reason } Destination-Realm ] User-Name ] SIP-AOR ] Proxy-Info ] Route-Record ] AVP ] Diameter Header: 287. The section content consists of definitions of the form specified in section 4. Example: @grouped SIP-Deregistration-Reason ::= < { [ * [ AVP Header: 383 > SIP-Reason-Code } SIP-Reason-Info ] AVP ] Specifying a Vendor-Id in the definition of a grouped AVP is equivalent to specifying it with @avp_vendor_id.4 of RFC 3588.: Diameter . "Grouped AVP Values". Integer values can be prefixed with 0x to be interpreted as hexidecimal. All Rights Reserved.

diameter_dict SIP_SERVER_CHANGE REMOVE_SIP_SERVER 2 3 @end Causes parsing of the dictionary to terminate: any remaining content is ignored..2147483647 -9223372036854775807.. the grouped AVP SIP-Deregistration-Reason ::= < { [ * [ AVP Header: 383 > SIP-Reason-Code } SIP-Reason-Info ] AVP ] will result in the following record definition given an empty prefix. Basic AVP Data Formats OctetString() Integer32() Integer64() Unsigned32() Unsigned64() Float32() Float64() Grouped() = = = = = = = = [0. For example.3 ("Derived AVP Data Formats") of RFC 3588 are encoded as values of the types defined here.. For each message or grouped AVP definition.18446744073709551615 '-infinity' | float() | infinity '-infinity' | float() | infinity record() Ericsson AB. The values encoded in the fields of generated records depends on the type and number of times the AVP can occur. Values are passed to diameter:call/4 in a request record when sending a request.. In particular. DATA TYPES The data formats defined in sections 4.9223372036854775807 0.4294967295 0. -record('SIP-Deregistration-Reason' {'SIP-Reason-Code'. The AVP's type is as specified in the AVP definition.: Diameter | 27 . the RFC 3588 types being described below. a record is defined whose name is the message or AVP name prefixed with any dictionary prefix defined with @prefix and whose fields are the names of the AVPs contained in the message or grouped AVP in the order specified in the definition in question.. MESSAGE RECORDS The hrl generated from a dictionary specification defines records for the messages and grouped AVPs defined in @messages and @grouped sections.255] -2147483647. All Rights Reserved. 'AVP'}).2 ("Basic AVP Data Formats") and 4. returned in a resulting answer record and passed to a handle_request callback upon reception of an incoming request. Comments can be included in a dictionary file using semicolon: characters from a semicolon to end of line are ignored. 'SIP-Reason-Info'. an AVP which is specified as occurring exactly once is encoded as a value of the AVP's type while an AVP with any other specification is encoded as a list of values of the AVP's type.

59 0..23 0. The tuple representation is used on decode..20}.2.x.2 of RFC 2373.x. only values between {{1968. The records for grouped AVPs are as discussed in the previous section.. An IPv6 tuple() has length 8 and contains values of type 0. Month.65535. Invalid codepoints will result in encode/decode failure.14.: Diameter .42.{3.8}} and {{2104..23}} (both inclusive) can be encoded. fqdn = FQDN. Day} time() = {Hour.{9. DiameterIdentity() = OctetString() A value must have length at least 1.. UTF8String() = [integer()] List elements are the UTF-8 encodings of the individual characters in the string.1.12 1.255.. values that can be encoded are limited by way of their encoding as four octets as required by RFC 3588 with the required extension from RFC 2030. transport = Transport.26}.diameter_dict On encode. In particular.. All Rights Reserved. "Text Representation of Addresses". an OctetString() IPv4 address is parsed in the usual x.59 Additionally. port = Port. Derived AVP Data Formats Address() = OctetString() | tuple() On encode. time()} where date() = {Year. an OctetString() can be specified as an iolist(). Second} Year Month Day Hour Minute Second = = = = = = integer() 1. excessively large floats (in absolute value) are equivalent to infinity or '-infinity' and excessively large integers result in encode failure. DiameterURI() = OctetString() | #diameter_URI{type = Type.x format while an IPv6 address is parsed in any of the formats specified by section 2.31 0. An IPv4 tuple() has length 4 and contains values of type 0. protocol = Protocol} where Type = aaa | aaas 28 | Ericsson AB. Time() = {date(). Minute.

diameter_app(3) Ericsson AB. diameter(3). sctp and diameter respectively.: Diameter | 29 . IPFilterRule() = OctetString() QoSFilterRule() = OctetString() Values of these types are not currently parsed by diameter.diameter_dict FQDN = OctetString() Port = integer() Transport = sctp | tcp Protocol = diameter | radius | 'tacacs+' On encode. values can be specified using the macros defined in a dictionary's hrl file. All Rights Reserved.3 of RFC 3588. Enumerated() = Integer32() On encode. The grammar of an OctetString-valued DiameterURI() is as specified in section 4. The record representation is used on decode. SEE ALSO diameterc(1). fields port. transport and protocol default to 3868.

Pid}} A request to close the transport connection. Pid} | {ok.: Diameter . Pid. Packet can be either binary() (the message to be sent) or a #diameter_packet{} whose transport_data field containes a value other than undefined. monitor the parent and terminate if it dies. {diameter. Packet}} An outbound Diameter message. and should return this list if different from the service addresses. It should not link to the parent. transport processes are started as required to accept connections from multiple peers. namely Svc#diameter_service. Ref}. Called by diameter as a consequence of a call to diameter:add_transport/2 in order to establish or accept a transport connection respectively. {diameter. Exports Mod:start({Type. 30 | Ericsson AB. Svc. A transport process must implement the message interface documented below. The first argument indicates whether the transport process in question is being started for a connecting (connect) or listening (accept) transport. LAddrs} | {error. MESSAGES All messages sent over the transport interface are of the form {diameter. {send.diameter_transport diameter_transport Erlang module A module specified as a transport_module to diameter:add_transport/2 must implement the interface documented here. Opts) -> {ok. It should exit if its transport connection with its peer is lost. term()}. Pid is the pid() of the parent process. In the latter case. the service addresses being used otherwise. The start function should use the 'Host-IP-Address' list on the service. The transport process should terminate after closing the connection. The interface consists of a function with which diameter starts a transport process and a message interface with which the transport process communicates with the process that starts it (aka its parent). Reason} Types: Type = connect | accept Ref = reference() Svc = #diameter_service{} Opts = term() Pid = pid() LAddrs = [ip_address()] Reason = term() Start a transport process. A transport process maintains a connection with a single remote peer. Ref is in each case the same value that was returned from the call to diameter:add_transport/2 that has lead to starting of a transport process. It should retain the pid of its parent. A transport process can expect the following messages from diameter. All Rights Reserved.host_ip_address. {close. Transport processes for a given service are started sequentially. The returned list is used to populate 'Host-IP-Address' AVPs in outgoing capabilities exchange messages. and/or Opts to select an appropriate list of local IP addresses.

{self(). diameter_sctp(3) Ericsson AB. {tls. Type is either connect or accept depending on whether the process has been started for a connecting or listening transport respectively. Bool is a boolean() indicating whether or not the transport connection should be upgraded to TLS. Ref}} reply message to the transport's parent process (see below). {tls. Ref is the reference() received in the {diameter. Remote is an arbitrary term that uniquely identifies the remote endpoint to which the transport has connected. Packet can be either binary() (the message to be sent) or #diameter_packet{} whose packet field contains a binary(). Packet}} An inbound Diameter message. Not sent if the transport process has Type = connect. Bool}} message in response to which the reply is sent. connected. This message is only sent to a transport process over whose Inband-Security-Id configuration has indicated support for TLS. {recv. Type. {diameter. A transport process should send the following messages to its parent. All Rights Reserved.diameter_transport {diameter. {diameter. Ref}} Acknowledgment of a successful TLS handshake. SEE ALSO diameter_tcp(3). If TLS is requested (Bool = true) then a connecting process should initiate a TLS handshake with the peer and an accepting process should prepare to accept a handshake. {tls. How the transport_data is used/ interpreted is up to the transport module. Bool}} Indication of whether or not capabilities exchange has selected inband security using TLS. A transport must exit if a handshake is not successful. {tls. {tls. Ref is a reference() that must be included in the {diameter. A failed handshake should cause the process to exit. A successful handshake should be followed by a {diameter. Any value (other than undefined) set in the transport_data field will be passed back with a corresponding answer message in the case that the inbound message is a request unless the sender sets another value. {diameter. Not sent if the transport process has Type = accept. Ref. {self(). Ref. Type. connected}} Inform the parent that the transport process with Type = accept has established a connection with the peer. Remote}} Inform the parent that the transport process with Type = connect has established a connection with a peer. Ref}} message to the parent process.: Diameter | 31 . {diameter.

Options binary. Reason} Types: Type = connect | accept Ref = reference() Svc = #diameter_service{} Opt = OwnOpt | SslOpt | OtherOpt Pid = pid() LAddr = ip_address() Reason = term() OwnOpt = {raddr. Svc. Note that option ip specifies the local address. Exports start({Type. TLS security is supported. true} has been specified.: Diameter . If the service specifies more than one Host-IP-Address and option ip is unspecified then then the first of the service's addresses is used as the local address. option port can be specified for a listening transport to specify the local listening port. Ref}. ip_address()} | {rport. Pid. or ssl:listen/3 or gen_tcp:listen/2 for a listening transport. 32 | Ericsson AB. the default being the standardized 3868 if unspecified. Failing to specify TLS capability when ssl_options has been specified will cause the transport process to wait for a notification that will not be forthcoming. Option ssl_options must be specified for a transport that must be able to support TLS: a value of true results in a TLS handshake immediately upon connection establishment while list() specifies options to be passed to ssl:connect/2 of ssl:ssl_accept/2 after capabilities exchange if TLS is negotiated. It can be specified as the value of a transport_module option to diameter:add_transport/2 and implements the behaviour documented in diameter_transport(3). integer()} SslOpt = {ssl_options. [Opt]) -> {ok. The returned local address list has length one. All Rights Reserved. both as an upgrade following capabilities exchange as specified by RFC 3588 and at connection establishment as in the current draft standard. The only diameter_tcp-specific argument is the options list. depending on whether or not {ssl_options. Also. Failing to specify an options list on a TLS-capable transport for which TLS is negotiated will cause TLS handshake to fail. [LAddr]} | {error. Note that the ssl application is required for TLS and must be started before configuring TLS capability on diameter transports. true | list()} OtherOpt = term() The start function required by diameter_transport(3). which will eventually cause the RFC 3539 watchdog to take down the connection. Remaining options are any accepted by ssl:connect/3 or gen_tcp:connect/3 for a connecting transport. so that the transport process will receive notification of whether or not to commence with a TLS handshake following capabilities exchange.diameter_tcp diameter_tcp Erlang module This module implements diameter transport over TCP using gen_tcp. integer()} | {port. Options raddr and rport specify the remote address and port for a connecting transport and are not valid for a listening transport. An ssl_options list must be specified if and only if the transport in question has specified an Inband-SecurityId AVP with value TLS on the relevant call to start_service/2 or add_transport/2. packet and active cannot be specified.

: Diameter | 33 . diameter_transport(3) Ericsson AB. All Rights Reserved.diameter_tcp SEE ALSO diameter(3).

: Diameter . It can be specified as the value of a transport_module option to diameter:add_transport/2 and implements the behaviour documented in diameter_transport(3). Svc. SEE ALSO diameter_transport(3) 34 | Ericsson AB. [Opt]) -> {ok. If none are specified then the values of Host-IP-Address on the service are used. That is. The value undefined uses a "next outbound stream" id and then increments this modulo the total number outbound streams. Note that options ip and port specify the local address and port respectively. Ref}. (In particular. Reason} Types: Type = connect | accept Ref = reference() Svc = #diameter_service{} Opt = {raddr. More than one raddr option can be specified. in which case the connecting transport in question attempts each in sequence until an association is established. For an outbound message. Pid. Multiple ip options can be specified for a multihomed peer. [LAddr]} | {error. active and sctp_events.) Option port defaults to 3868 for a listening transport and 0 for a connecting transport. binary. Id} on an inbound message passed to a handle_request or handle_answer callback. All Rights Reserved.diameter_sctp diameter_sctp Erlang module This module implements diameter transport over SCTP using gen_sctp. Remaining options are any accepted by gen_sctp:open/1. Exports start({Type. with the exception of options mode. either undefined (explicitly of by specifying the outbound message as a binary()) or a tuple should be set in the return value of handle_request (typically by retaining the value passed into this function) or prepare_request. The former is required while latter defaults to 3868 if unspecified. successive values of undefined cycle through all outbound streams. The only diameter_sctp-specific argument is the options list. ip_address()} | {rport. diameter_sctp uses the transport_data field of the diameter_packet record to communicate the stream on which an inbound message has been received. one of these must be specified. or on which an outbound message should be sent: the value will be of the form {stream. Options raddr and rport specify the remote address and port for a connecting transport and not valid for a listening transport. integer()} | term() Pid = pid() LAddr = ip_address() Reason = term() The start function required by diameter_transport(3). list.

Sign up to vote on this title
UsefulNot useful