.TH diameter 3erl "diameter 1.12.1" "Ericsson AB" "Erlang Module Definition" .SH NAME diameter \- Main API of the diameter application. .SH DESCRIPTION .LP This module provides the interface with which a user can implement a Diameter node that sends and receives messages using the Diameter protocol as defined in RFC 6733\&. .LP Basic usage consists of creating a representation of a locally implemented Diameter node and its capabilities with \fBstart_service/2\fR\&, adding transport capability using \fBadd_transport/2\fR\& and sending Diameter requests and receiving Diameter answers with \fBcall/4\fR\&\&. Incoming Diameter requests are communicated as callbacks to a \fBdiameter_app(3erl)\fR\& callback modules as specified in the service configuration\&. .LP Beware the difference between \fIdiameter\fR\& (not capitalized) and \fIDiameter\fR\& (capitalized)\&. The former refers to the Erlang application named diameter whose main api is defined here, the latter to Diameter protocol in the sense of RFC 6733\&. .LP The diameter application must be started before calling most functions in this module\&. .SH "DATA TYPES" .RS 2 .TP 2 .B \fIAddress()\fR\&: .TP 2 .B \fIDiameterIdentity()\fR\&: .TP 2 .B \fIGrouped()\fR\&: .TP 2 .B \fIOctetString()\fR\&: .TP 2 .B \fITime()\fR\&: .TP 2 .B \fIUnsigned32()\fR\&: .TP 2 .B \fIUTF8String()\fR\&: Types corresponding to RFC 6733 AVP Data Formats\&. Defined in \fBdiameter_dict(5)\fR\&\&. .TP 2 .B \fIapplication_alias() = term()\fR\&: Name identifying a Diameter application in service configuration\&. Passed to \fBcall/4\fR\& when sending requests defined by the application\&. .TP 2 .B \fIapplication_module() = Mod | [Mod | ExtraArgs] | #diameter_callback{}\fR\&: .LP .nf Mod = atom() ExtraArgs = list() .fi .RS 2 .LP Module implementing the callback interface defined in \fBdiameter_app(3erl)\fR\&, along with any extra arguments to be appended to those documented\&. Note that extra arguments specific to an outgoing request can be specified to \fBcall/4\fR\&, in which case those are are appended to any module-specific extra arguments\&. .RE .RS 2 .LP Specifying a \fI#diameter_callback{}\fR\& record allows individual functions to be configured in place of the usual \fBdiameter_app(3erl)\fR\& callbacks\&. See \fIdiameter_callback\&.erl\fR\& for details\&. .RE .TP 2 .B \fIapplication_opt()\fR\&: Options defining a Diameter application\&. Has one the following types\&. .RS 2 .TP 2 .B \fI{alias, \fBapplication_alias()\fR\&}\fR\&: Unique identifier for the application in the scope of the service\&. Defaults to the value of the \fIdictionary\fR\& option\&. .TP 2 .B \fI{dictionary, atom()}\fR\&: Name of an encode/decode module for the Diameter messages defined by the application\&. These modules are generated from files whose format is documented in \fBdiameter_dict(5)\fR\&\&. .TP 2 .B \fI{module, \fBapplication_module()\fR\&}\fR\&: Callback module in which messages of the Diameter application are handled\&. See \fBdiameter_app(3erl)\fR\& for the required interface and semantics\&. .TP 2 .B \fI{state, term()}\fR\&: Initial callback state\&. The prevailing state is passed to some \fBdiameter_app(3erl)\fR\& callbacks, which can then return a new state\&. Defaults to the value of the \fIalias\fR\& option\&. .TP 2 .B \fI{call_mutates_state, true|false}\fR\&: Whether or not the \fBpick_peer/4\fR\& application callback can modify the application state\&. Defaults to \fIfalse\fR\&\&. .LP .RS -4 .B Warning: .RE \fBpick_peer/4\fR\& callbacks are serialized when this option is \fItrue\fR\&, 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 should probably avoid it\&. .TP 2 .B \fI{answer_errors, callback|report|discard}\fR\&: Manner in which incoming answer messages containing decode errors are handled\&. .RS 2 .LP If \fIcallback\fR\& then errors result in a \fBhandle_answer/4\fR\& callback in the same fashion as for \fBhandle_request/3\fR\&, with errors communicated in the \fIerrors\fR\& field of the \fI#diameter_packet{}\fR\& passed to the callback\&. If \fIreport\fR\& then an answer containing errors is discarded without a callback and a warning report is written to the log\&. If \fIdiscard\fR\& then an answer containing errors is silently discarded without a callback\&. In both the \fIreport\fR\& and \fIdiscard\fR\& cases the return value for the \fBcall/4\fR\& invocation in question is as if a callback had taken place and returned \fI{error, failure}\fR\&\&. .RE .RS 2 .LP Defaults to \fIdiscard\fR\&\&. .RE .TP 2 .B \fI{request_errors, answer_3xxx|answer|callback}\fR\&: Manner in which incoming requests are handled when an error other than 3007 (DIAMETER_APPLICATION_UNSUPPORTED, which cannot be associated with an application callback module), is detected\&. .RS 2 .LP If \fIanswer_3xxx\fR\& then requests are answered without a \fBhandle_request/3\fR\& callback taking place\&. If \fIanswer\fR\& then even 5xxx errors are answered without a callback unless the connection in question has configured the RFC 3588 common dictionary as noted below\&. If \fIcallback\fR\& then a \fBhandle_request/3\fR\& callback always takes place and its return value determines the answer sent to the peer, if any\&. .RE .RS 2 .LP Defaults to \fIanswer_3xxx\fR\&\&. .RE .LP .RS -4 .B Note: .RE Answers sent by diameter set the E-bit in the Diameter Header\&. Since RFC 3588 allows only 3xxx result codes in an \fIanswer-message\fR\&, \fIanswer\fR\& has the same semantics as \fIanswer_3xxx\fR\& when the transport in question has been configured with \fIdiameter_gen_base_rfc3588\fR\& as its common dictionary\&. Since RFC 6733 allows both 3xxx and 5xxx result codes in an \fIanswer-message\fR\&, a transport with \fIdiameter_gen_base_rfc6733\fR\& as its common dictionary does distinguish between \fIanswer_3xxx\fR\& and \fIanswer\fR\&\&. .RE .TP 2 .B \fIcall_opt()\fR\&: Options available to \fBcall/4\fR\& when sending an outgoing Diameter request\&. Has one of the following types\&. .RS 2 .TP 2 .B \fI{extra, list()}\fR\&: Extra arguments to append to callbacks to the callback module in question\&. These are appended to any extra arguments configured on the callback itself\&. Multiple options append to the argument list\&. .TP 2 .B \fI{filter, \fBpeer_filter()\fR\&}\fR\&: Filter to apply to the list of available peers before passing it to the \fBpick_peer/4\fR\& callback for the application in question\&. Multiple options are equivalent a single \fIall\fR\& filter on the corresponding list of filters\&. Defaults to \fInone\fR\&\&. .TP 2 .B \fI{timeout, \fBUnsigned32()\fR\&}\fR\&: Number of milliseconds after which the request should timeout\&. Defaults to 5000\&. .TP 2 .B \fIdetach\fR\&: Cause \fBcall/4\fR\& to return \fIok\fR\& as soon as the request in question has been encoded, instead of waiting for and returning the result from a subsequent \fBhandle_answer/4\fR\& or \fBhandle_error/4\fR\& callback\&. .RE .RS 2 .LP An invalid option will cause \fBcall/4\fR\& to fail\&. .RE .TP 2 .B \fIcapability()\fR\&: AVP values sent in outgoing CER or CEA messages during capabilities exchange\&. Can be configured both on a service and a transport, values on the latter taking precedence\&. Has one of the following types\&. .RS 2 .TP 2 .B \fI{\&'Origin-Host\&', \fBDiameterIdentity()\fR\&}\fR\&: .TP 2 .B \fI{\&'Origin-Realm\&', \fBDiameterIdentity()\fR\&}\fR\&: .TP 2 .B \fI{\&'Host-IP-Address\&', [\fBAddress()\fR\&]}\fR\&: An address list is available to the start function of a \fBtransport module\fR\&, which can return a new list for use in the subsequent CER or CEA\&. Host-IP-Address need not be specified if the transport module in question communicates an address list as described in \fBdiameter_transport(3erl)\fR\& .TP 2 .B \fI{\&'Vendor-Id\&', \fBUnsigned32()\fR\&}\fR\&: .TP 2 .B \fI{\&'Product-Name\&', \fBUTF8String()\fR\&}\fR\&: .TP 2 .B \fI{\&'Origin-State-Id\&', \fBUnsigned32()\fR\&}\fR\&: Origin-State-Id is optional but, if configured, will be included in outgoing CER/CEA and DWR/DWA messages\&. Setting a value of \fI0\fR\& (zero) is equivalent to not setting a value, as documented in RFC 6733\&. The function \fBorigin_state_id/0\fR\& can be used as to retrieve a value that is computed when the diameter application is started\&. .TP 2 .B \fI{\&'Supported-Vendor-Id\&', [\fBUnsigned32()\fR\&]}\fR\&: .TP 2 .B \fI{\&'Auth-Application-Id\&', [\fBUnsigned32()\fR\&]}\fR\&: .TP 2 .B \fI{\&'Inband-Security-Id\&', [\fBUnsigned32()\fR\&]}\fR\&: Inband-Security-Id defaults to the empty list, which is equivalent to a list containing only 0 (NO_INBAND_SECURITY)\&. If 1 (TLS) is specified then TLS is selected if the CER/CEA received from the peer offers it\&. .TP 2 .B \fI{\&'Acct-Application-Id\&', [\fBUnsigned32()\fR\&]}\fR\&: .TP 2 .B \fI{\&'Vendor-Specific-Application-Id\&', [\fBGrouped()\fR\&]}\fR\&: .TP 2 .B \fI{\&'Firmware-Revision\&', \fBUnsigned32()\fR\&}\fR\&: .RE .RS 2 .LP Note that each tuple communicates one or more AVP values\&. It is an error to specify duplicate tuples\&. .RE .TP 2 .B \fIevaluable() = {M,F,A} | fun() | [evaluable() | A]\fR\&: An expression that can be evaluated as a function in the following sense\&. .LP .nf eval([{M,F,A} | T]) -> apply(M, F, T ++ A); eval([[F|A] | T]) -> eval([F | T ++ A]); eval([F|A]) -> apply(F, A); eval(F) -> eval([F]). .fi .RS 2 .LP Applying an \fI\fBevaluable()\fR\&\fR\& \fIE\fR\& to an argument list \fIA\fR\& is meant in the sense of \fIeval([E|A])\fR\&\&. .RE .LP .RS -4 .B Warning: .RE Beware of using fun expressions of the form \fIfun Name/Arity\fR\& 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\&. In particular, such a value is typically inappropriate in configuration passed to \fBstart_service/2\fR\& or \fBadd_transport/2\fR\&\&. .TP 2 .B \fIpeer_filter() = term()\fR\&: Filter passed to \fBcall/4\fR\& in order to select candidate peers for a \fBpick_peer/4\fR\& callback\&. Has one of the following types\&. .RS 2 .TP 2 .B \fInone\fR\&: Matches any peer\&. This is a convenience that provides a filter equivalent to no filter\&. .TP 2 .B \fIhost\fR\&: Matches only those peers whose Origin-Host has the same value as Destination-Host in the outgoing request in question, or any peer if the request does not contain a Destination-Host AVP\&. .TP 2 .B \fIrealm\fR\&: Matches only those peers whose Origin-Realm has the same value as Destination-Realm in the outgoing request in question, or any peer if the request does not contain a Destination-Realm AVP\&. .TP 2 .B \fI{host, any|\fBDiameterIdentity()\fR\&}\fR\&: Matches only those peers whose Origin-Host has the specified value, or all peers if the atom \fIany\fR\&\&. .TP 2 .B \fI{realm, any|\fBDiameterIdentity()\fR\&}\fR\&: Matches only those peers whose Origin-Realm has the specified value, or all peers if the atom \fIany\fR\&\&. .TP 2 .B \fI{eval, \fBevaluable()\fR\&}\fR\&: Matches only those peers for which the specified \fI\fBevaluable()\fR\&\fR\& returns \fItrue\fR\& when applied to the connection\&'s \fIdiameter_caps\fR\& record\&. Any other return value or exception is equivalent to \fIfalse\fR\&\&. .TP 2 .B \fI{neg, \fBpeer_filter()\fR\&}\fR\&: Matches only those peers not matched by the specified filter\&. .TP 2 .B \fI{all, [\fBpeer_filter()\fR\&]}\fR\&: Matches only those peers matched by each filter in the specified list\&. .TP 2 .B \fI{any, [\fBpeer_filter()\fR\&]}\fR\&: Matches only those peers matched by at least one filter in the specified list\&. The resulting list will be in match order, peers matching the first filter of the list sorting before those matched by the second, and so on\&. .TP 2 .B \fI{first, [\fBpeer_filter()\fR\&]}\fR\&: Like \fIany\fR\&, but stops at the first filter for which there are matches, which can be much more efficient when there are many peers\&. For example, the following filter causes only peers best matching both the host and realm filters to be presented\&. .LP .nf {first, [{all, [host, realm]}, realm]} .fi .RE .RS 2 .LP An invalid filter is equivalent to \fI{any,[]}\fR\&, a filter that matches no peer\&. .RE .LP .RS -4 .B Note: .RE The \fIhost\fR\& and \fIrealm\fR\& filters cause the Destination-Host and Destination-Realm AVPs to be extracted from the outgoing request, assuming it to be a record- or list-valued \fI\fBdiameter_codec:message()\fR\&\fR\&, and assuming at most one of each AVP\&. If this is not the case then the \fI{host|realm, \fBDiameterIdentity()\fR\&}\fR\& filters must be used to achieve the desired result\&. An empty \fI\fBDiameterIdentity()\fR\&\fR\& (which should not be typical) matches all hosts/realms for the purposes of filtering\&. .LP .RS -4 .B Warning: .RE A \fIhost\fR\& filter is not typically desirable when setting Destination-Host since it will remove peer agents from the candidates list\&. .TP 2 .B \fIservice_event() = #diameter_event{service = \fBservice_name()\fR\&, info = \fBservice_event_info()\fR\&}\fR\&: An event message sent to processes that have subscribed to these using \fBsubscribe/1\fR\&\&. .TP 2 .B \fIservice_event_info() = term()\fR\&: The \fIinfo\fR\& field of a \fBservice_event()\fR\& record\&. Can have one of the following types\&. .RS 2 .TP 2 .B \fIstart\fR\&: .TP 2 .B \fIstop\fR\&: The service is being started or stopped\&. No event precedes a \fIstart\fR\& event\&. No event follows a \fIstop\fR\& event, and this event implies the termination of all transport processes\&. .TP 2 .B \fI{up, Ref, Peer, Config, Pkt}\fR\&: .TP 2 .B \fI{up, Ref, Peer, Config}\fR\&: .TP 2 .B \fI{down, Ref, Peer, Config}\fR\&: .LP .nf Ref = \fBtransport_ref()\fR\& Peer = \fBdiameter_app:peer()\fR\& Config = {connect|listen, [\fBtransport_opt()\fR\&]} Pkt = #diameter_packet{} .fi .RS 2 .LP The RFC 3539 watchdog state machine has transitioned into (\fIup\fR\&) or out of (\fIdown\fR\&) the OKAY state\&. If a \fI#diameter_packet{}\fR\& is present in an \fIup\fR\& event then there has been a capabilities exchange on a newly established transport connection and the record contains the received CER or CEA\&. .RE .RS 2 .LP Note that a single \fIup\fR\& or \fIdown\fR\& event for a given peer corresponds to multiple \fBpeer_up/3\fR\& or \fBpeer_up/3\fR\& callbacks, one for each of the Diameter applications negotiated during capabilities exchange\&. That is, the event communicates connectivity with the peer as a whole while the callbacks communicate connectivity with respect to individual Diameter applications\&. .RE .TP 2 .B \fI{reconnect, Ref, Opts}\fR\&: .LP .nf Ref = \fBtransport_ref()\fR\& Opts = [\fBtransport_opt()\fR\&] .fi .RS 2 .LP A connecting transport is attempting to establish/reestablish a transport connection with a peer following \fBconnect_timer\fR\& or \fBwatchdog_timer\fR\& expiry\&. .RE .TP 2 .B \fI{closed, Ref, Reason, Config}\fR\&: .LP .nf Ref = \fBtransport_ref()\fR\& Config = {connect|listen, [\fBtransport_opt()\fR\&]} .fi .RS 2 .LP Capabilities exchange has failed\&. \fIReason\fR\& can have one of the following types\&. .RE .RS 2 .TP 2 .B \fI{\&'CER\&', Result, Caps, Pkt}\fR\&: .LP .nf Result = ResultCode | {capabilities_cb, CB, ResultCode|discard} Caps = #diameter_caps{} Pkt = #diameter_packet{} ResultCode = integer() CB = \fBevaluable()\fR\& .fi .RS 2 .LP An incoming CER has been answered with the indicated result code, or discarded\&. \fICaps\fR\& contains pairs of values, for the local node and remote peer respectively\&. \fIPkt\fR\& contains the CER in question\&. In the case of rejection by a capabilities callback, the tuple contains the rejecting callback\&. .RE .TP 2 .B \fI{\&'CER\&', Caps, {ResultCode, Pkt}}\fR\&: .LP .nf ResultCode = integer() Caps = #diameter_caps{} Pkt = #diameter_packet{} .fi .RS 2 .LP An incoming CER contained errors and has been answered with the indicated result code\&. \fICaps\fR\& contains values for the local node only\&. \fIPkt\fR\& contains the CER in question\&. .RE .TP 2 .B \fI{\&'CER\&', timeout}\fR\&: An expected CER was not received within \fBcapx_timeout\fR\& of connection establishment\&. .TP 2 .B \fI{\&'CEA\&', Result, Caps, Pkt}\fR\&: .LP .nf Result = ResultCode | atom() | {capabilities_cb, CB, ResultCode|discard} Caps = #diameter_caps{} Pkt = #diameter_packet{} ResultCode = integer() .fi .RS 2 .LP An incoming CEA has been rejected for the indicated reason\&. An integer-valued \fIResult\fR\& indicates the result code sent by the peer\&. \fICaps\fR\& contains pairs of values for the local node and remote peer\&. \fIPkt\fR\& contains the CEA in question\&. In the case of rejection by a capabilities callback, the tuple contains the rejecting callback\&. .RE .TP 2 .B \fI{\&'CEA\&', Caps, Pkt}\fR\&: .LP .nf Caps = #diameter_caps{} Pkt = #diameter_packet{} .fi .RS 2 .LP An incoming CEA contained errors and has been rejected\&. \fICaps\fR\& contains only values for the local node\&. \fIPkt\fR\& contains the CEA in question\&. .RE .TP 2 .B \fI{\&'CEA\&', timeout}\fR\&: An expected CEA was not received within \fBcapx_timeout\fR\& of connection establishment\&. .RE .TP 2 .B \fI{watchdog, Ref, PeerRef, {From, To}, Config}\fR\&: .LP .nf Ref = \fBtransport_ref()\fR\& PeerRef = \fBdiameter_app:peer_ref()\fR\& From, To = initial | okay | suspect | down | reopen Config = {connect|listen, [transport_opt()]} .fi .RS 2 .LP An RFC 3539 watchdog state machine has changed state\&. .RE .TP 2 .B \fIany()\fR\&: For forward compatibility, a subscriber should be prepared to receive info fields of forms other than the above\&. .RE .TP 2 .B \fIservice_name() = term()\fR\&: Name of a service as passed to \fBstart_service/2\fR\& and with which the service is identified\&. There can be at most one service with a given name on a given node\&. Note that \fBerlang:make_ref/0\fR\& can be used to generate a service name that is somewhat unique\&. .TP 2 .B \fIservice_opt()\fR\&: Option passed to \fBstart_service/2\fR\&\&. Can be any \fI\fBcapability()\fR\&\fR\& as well as the following\&. .RS 2 .TP 2 .B \fI{application, [\fBapplication_opt()\fR\&]}\fR\&: A Diameter application supported by the service\&. .RS 2 .LP A service must configure one tuple for each Diameter application it intends to support\&. For an outgoing request, the relevant \fI\fBapplication_alias()\fR\&\fR\& is passed to \fBcall/4\fR\&, while for an incoming request the application identifier in the message header determines the application, the identifier being specified in the application\&'s \fBdictionary\fR\& file\&. .RE .LP .RS -4 .B Warning: .RE The capabilities advertised by a node must match its configured applications\&. In particular, \fIapplication\fR\& configuration must be matched by corresponding \fBcapability()\fR\& configuration, of *-Application-Id AVPs in particular\&. .TP 2 .B \fI{incoming_maxlen, 0\&.\&.16777215}\fR\&: Bound on the expected size of incoming Diameter messages\&. Messages larger than the specified number of bytes are discarded\&. .RS 2 .LP Defaults to \fI16777215\fR\&, the maximum value of the 24-bit Message Length field in a Diameter Header\&. .RE .TP 2 .B \fI{restrict_connections, false | node | nodes | [node()] | evaluable()}\fR\&: The degree to which the service allows multiple transport connections to the same peer, as identified by its Origin-Host at capabilities exchange\&. .RS 2 .LP If \fI[node()]\fR\& then a connection is rejected if another already exists on any of the specified nodes\&. Types \fIfalse\fR\&, \fInode\fR\&, \fInodes\fR\& and \fBevaluable()\fR\& are equivalent to \fI[]\fR\&, \fI[node()]\fR\&, \fI[node()|nodes()]\fR\& and the evaluated value respectively, evaluation of each expression taking place whenever a new connection is to be established\&. Note that \fIfalse\fR\& allows an unlimited number of connections to be established with the same peer\&. .RE .RS 2 .LP Multiple connections are independent and governed by their own peer and watchdog state machines\&. .RE .RS 2 .LP Defaults to \fInodes\fR\&\&. .RE .TP 2 .B \fI{sequence, {H,N} | \fBevaluable()\fR\&}\fR\&: A constant value \fIH\fR\& for the topmost \fI32-N\fR\& bits of of 32-bit End-to-End and Hop-by-Hop Identifiers generated by the service, either explicitly or as a return value of a function to be evaluated at \fBstart_service/2\fR\&\&. In particular, an identifier \fIId\fR\& is mapped to a new identifier as follows\&. .LP .nf (H bsl N) bor (Id band ((1 bsl N) - 1)) .fi .RS 2 .LP Note that RFC 6733 requires that End-to-End Identifiers remain unique for a period of at least 4 minutes and that this and the call rate places a lower bound on appropriate values of \fIN\fR\&: at a rate of \fIR\fR\& requests per second, an \fIN\fR\&-bit counter traverses all of its values in \fI(1 bsl N) div (R*60)\fR\& minutes, so the bound is \fI4*R*60 =< 1 bsl N\fR\&\&. .RE .RS 2 .LP \fIN\fR\& must lie in the range \fI0\&.\&.32\fR\& and \fIH\fR\& must be a non-negative integer less than \fI1 bsl (32-N)\fR\&\&. .RE .RS 2 .LP Defaults to \fI{0,32}\fR\&\&. .RE .LP .RS -4 .B Warning: .RE Multiple Erlang nodes implementing the same Diameter node should be configured with different sequence masks to ensure that each node uses a unique range of End-to-End and Hop-by-Hop Identifiers for outgoing requests\&. .TP 2 .B \fI{share_peers, boolean() | [node()] | evaluable()}\fR\&: Nodes to which peer connections established on the local Erlang node are communicated\&. Shared peers become available in the remote candidates list passed to \fBpick_peer/4\fR\& callbacks on remote nodes whose services are configured to use them: see \fIuse_shared_peers\fR\& below\&. .RS 2 .LP If \fIfalse\fR\& then peers are not shared\&. If \fI[node()]\fR\& then peers are shared with the specified list of nodes\&. If \fIevaluable()\fR\& then peers are shared with the nodes returned by the specified function, evaluated whenever a peer connection becomes available or a remote service requests information about local connections\&. The value \fItrue\fR\& is equivalent to \fIfun \fBerlang:nodes/0\fR\&\fR\&\&. The value \fInode()\fR\& in a list is ignored, so a collection of services can all be configured to share with the same list of nodes\&. .RE .RS 2 .LP Defaults to \fIfalse\fR\&\&. .RE .LP .RS -4 .B Note: .RE Peers are only shared with services of the same name for the purpose of sending outgoing requests\&. Since the value of the \fBapplication_opt()\fR\& \fIalias\fR\&, passed to \fBcall/4\fR\&, is the handle for identifying a peer as a suitable candidate, services that share peers must use the same aliases to identify their supported applications\&. They should typically also configure identical \fBcapabilities()\fR\&, since by sharing peer connections they are distributing the implementation of a single Diameter node across multiple Erlang nodes\&. .TP 2 .B \fI{spawn_opt, [term()]}\fR\&: Options list passed to \fBerlang:spawn_opt/2\fR\& when spawning a process for an incoming Diameter request, unless the transport in question specifies another value\&. Options \fImonitor\fR\& and \fIlink\fR\& are ignored\&. .RS 2 .LP Defaults to the empty list\&. .RE .TP 2 .B \fI{strict_mbit, boolean()}\fR\&: Whether or not to regard an AVP setting the M-bit as erroneous when the command grammar in question does not explicitly allow the AVP\&. If \fItrue\fR\& then such AVPs are regarded as 5001 errors, DIAMETER_AVP_UNSUPPORTED\&. If \fIfalse\fR\& then the M-bit is ignored and policing it becomes the receiver\&'s responsibility\&. .RS 2 .LP Defaults to \fItrue\fR\&\&. .RE .LP .RS -4 .B Warning: .RE RFC 6733 is unclear about the semantics of the M-bit\&. One the one hand, the CCF specification in section 3\&.2 documents AVP in a command grammar as meaning \fIany\fR\& arbitrary AVP; on the other hand, 1\&.3\&.4 states that AVPs setting the M-bit cannot be added to an existing command: the modified command must instead be placed in a new Diameter application\&. .LP The reason for the latter is presumably interoperability: allowing arbitrary AVPs setting the M-bit in a command makes its interpretation implementation-dependent, since there\&'s no guarantee that all implementations will understand the same set of arbitrary AVPs in the context of a given command\&. However, interpreting \fIAVP\fR\& in a command grammar as any AVP, regardless of M-bit, renders 1\&.3\&.4 meaningless, since the receiver can simply ignore any AVP it thinks isn\&'t relevant, regardless of the sender\&'s intent\&. .LP Beware of confusing mandatory in the sense of the M-bit with mandatory in the sense of the command grammar\&. The former is a semantic requirement: that the receiver understand the semantics of the AVP in the context in question\&. The latter is a syntactic requirement: whether or not the AVP must occur in the message in question\&. .TP 2 .B \fI{string_decode, boolean()}\fR\&: Whether or not to decode AVPs of type \fBOctetString()\fR\& and its derived types \fBDiameterIdentity()\fR\&, \fBDiameterURI()\fR\&, \fBIPFilterRule()\fR\&, \fBQoSFilterRule()\fR\&, and \fBUTF8String()\fR\&\&. If \fItrue\fR\& then AVPs of these types are decoded to string()\&. If \fIfalse\fR\& then values are retained as binary()\&. .RS 2 .LP Defaults to \fItrue\fR\&\&. .RE .LP .RS -4 .B Warning: .RE This option should be set to \fIfalse\fR\& since a sufficiently malicious peer can otherwise cause large amounts of memory to be consumed when decoded Diameter messages are passed between processes\&. The default value is for backwards compatibility\&. .TP 2 .B \fI{use_shared_peers, boolean() | [node()] | evaluable()}\fR\&: Nodes from which communicated peers are made available in the remote candidates list of \fBpick_peer/4\fR\& callbacks\&. .RS 2 .LP If \fIfalse\fR\& then remote peers are not used\&. If \fI[node()]\fR\& then only peers from the specified list of nodes are used\&. If \fIevaluable()\fR\& then only peers returned by the specified function are used, evaluated whenever a remote service communicates information about an available peer connection\&. The value \fItrue\fR\& is equivalent to \fIfun \fBerlang:nodes/0\fR\&\fR\&\&. The value \fInode()\fR\& in a list is ignored\&. .RE .RS 2 .LP Defaults to \fIfalse\fR\&\&. .RE .LP .RS -4 .B Note: .RE A service that does not use shared peers will always pass the empty list as the second argument of \fBpick_peer/4\fR\& callbacks\&. .LP .RS -4 .B Warning: .RE Sending a request over a peer connection on a remote node is less efficient than sending it over a local connection\&. It may be preferable to make use of the \fBservice_opt()\fR\& \fIrestrict_connections\fR\& and maintain a dedicated connection on each node from which requests are sent\&. .RE .TP 2 .B \fItransport_opt()\fR\&: Option passed to \fBadd_transport/2\fR\&\&. Has one of the following types\&. .RS 2 .TP 2 .B \fI{applications, [\fBapplication_alias()\fR\&]}\fR\&: Diameter applications to which the transport should be restricted\&. Defaults to all applications configured on the service in question\&. Applications not configured on the service in question are ignored\&. .LP .RS -4 .B Warning: .RE The capabilities advertised by a node must match its configured applications\&. In particular, setting \fIapplications\fR\& on a transport typically implies having to set matching *-Application-Id AVPs in a \fBcapabilities()\fR\& tuple\&. .TP 2 .B \fI{capabilities, [\fBcapability()\fR\&]}\fR\&: AVPs used to construct outgoing CER/CEA messages\&. Values take precedence over any specified on the service in question\&. .RS 2 .LP 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 \fBdiameter_tcp(3erl)\fR\&\&. .RE .TP 2 .B \fI{capabilities_cb, \fBevaluable()\fR\&}\fR\&: Callback invoked upon reception of CER/CEA during capabilities exchange in order to ask whether or not the connection should be accepted\&. Applied to the \fI\fBtransport_ref()\fR\&\fR\& and \fI#diameter_caps{}\fR\& record of the connection\&. .RS 2 .LP The return value can have one of the following types\&. .RE .RS 2 .TP 2 .B \fIok\fR\&: Accept the connection\&. .TP 2 .B \fIinteger()\fR\&: Causes an incoming CER to be answered with the specified Result-Code\&. .TP 2 .B \fIdiscard\fR\&: Causes an incoming CER to be discarded without CEA being sent\&. .TP 2 .B \fIunknown\fR\&: Equivalent to returning \fI3010\fR\&, DIAMETER_UNKNOWN_PEER\&. .RE .RS 2 .LP Returning anything but \fIok\fR\& or a 2xxx series result code causes the transport connection to be broken\&. Multiple \fBcapabilities_cb\fR\& options can be specified, in which case the corresponding callbacks are applied until either all return \fIok\fR\& or one does not\&. .RE .TP 2 .B \fI{capx_timeout, \fBUnsigned32()\fR\&}\fR\&: Number of milliseconds after which a transport process having an established transport connection will be terminated if the expected capabilities exchange message (CER or CEA) is not received from the peer\&. For a connecting transport, the timing of connection attempts is governed by \fBconnect_timer\fR\& or \fBwatchdog_timer\fR\& expiry\&. For a listening transport, the peer determines the timing\&. .RS 2 .LP Defaults to 10000\&. .RE .TP 2 .B \fI{connect_timer, Tc}\fR\&: .LP .nf Tc = \fBUnsigned32()\fR\& .fi .RS 2 .LP For a connecting transport, the RFC 6733 Tc timer, in milliseconds\&. This timer determines the frequency with which a transport attempts to establish an initial connection with its peer following transport configuration\&. Once an initial connection has been established, \fBwatchdog_timer\fR\& determines the frequency of reconnection attempts, as required by RFC 3539\&. .RE .RS 2 .LP For a listening transport, 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 reestablishment, causing the RFC 3539 state machine to pass to state OKAY rather than REOPEN\&. Note that these semantics are not governed by the RFC and that a listening transport\&'s \fBconnect_timer\fR\& should be greater than its peer\&'s Tw plus jitter\&. .RE .RS 2 .LP Defaults to 30000 for a connecting transport and 60000 for a listening transport\&. .RE .TP 2 .B \fI{disconnect_cb, \fBevaluable()\fR\&}\fR\&: Callback invoked prior to terminating the transport process of a transport connection having watchdog state \fIOKAY\fR\&\&. Applied to \fIapplication|service|transport\fR\& and the \fI\fBtransport_ref()\fR\&\fR\& and \fI\fBdiameter_app:peer()\fR\&\fR\& in question: \fIapplication\fR\& indicates that the diameter application is being stopped, \fIservice\fR\& that the service in question is being stopped by \fBstop_service/1\fR\&, and \fItransport\fR\& that the transport in question is being removed by \fBremove_transport/2\fR\&\&. .RS 2 .LP The return value can have one of the following types\&. .RE .RS 2 .TP 2 .B \fI{dpr, [option()]}\fR\&: Send Disconnect-Peer-Request to the peer, the transport process being terminated following reception of Disconnect-Peer-Answer or timeout\&. An \fIoption()\fR\& can be one of the following\&. .RS 2 .TP 2 .B \fI{cause, 0|rebooting|1|busy|2|goaway}\fR\&: Disconnect-Cause to send, \fIREBOOTING\fR\&, \fIBUSY\fR\& and \fIDO_NOT_WANT_TO_TALK_TO_YOU\fR\& respectively\&. Defaults to \fIrebooting\fR\& for \fIReason=service|application\fR\& and \fIgoaway\fR\& for \fIReason=transport\fR\&\&. .TP 2 .B \fI{timeout, \fBUnsigned32()\fR\&}\fR\&: Number of milliseconds after which the transport process is terminated if DPA has not been received\&. Defaults to the value of \fBdpa_timeout\fR\&\&. .RE .TP 2 .B \fIdpr\fR\&: Equivalent to \fI{dpr, []}\fR\&\&. .TP 2 .B \fIclose\fR\&: Terminate the transport process without Disconnect-Peer-Request being sent to the peer\&. .TP 2 .B \fIignore\fR\&: Equivalent to not having configured the callback\&. .RE .RS 2 .LP Multiple \fBdisconnect_cb\fR\& options can be specified, in which case the corresponding callbacks are applied until one of them returns a value other than \fIignore\fR\&\&. All callbacks returning \fIignore\fR\& is equivalent to not having configured them\&. .RE .RS 2 .LP Defaults to a single callback returning \fIdpr\fR\&\&. .RE .TP 2 .B \fI{dpa_timeout, \fBUnsigned32()\fR\&}\fR\&: Number of milliseconds after which a transport connection is terminated following an outgoing DPR if DPA is not received\&. .RS 2 .LP Defaults to 1000\&. .RE .TP 2 .B \fI{dpr_timeout, \fBUnsigned32()\fR\&}\fR\&: Number of milliseconds after which a transport connection is terminated following an incoming DPR if the peer does not close the connection\&. .RS 2 .LP Defaults to 5000\&. .RE .TP 2 .B \fI{length_errors, exit|handle|discard}\fR\&: How to deal with errors in the Message Length field of the Diameter Header in an incoming message\&. An error in this context is that the length is not at least 20 bytes (the length of a Header), is not a multiple of 4 (a valid length) or is not the length of the message in question, as received over the transport interface documented in \fBdiameter_transport(3erl)\fR\&\&. .RS 2 .LP If \fIexit\fR\& then the transport process in question exits\&. If \fIhandle\fR\& then the message is processed as usual, a resulting \fBhandle_request/3\fR\& or \fBhandle_answer/4\fR\& callback (if one takes place) indicating the \fI5015\fR\& error (DIAMETER_INVALID_MESSAGE_LENGTH)\&. If \fIdiscard\fR\& then the message in question is silently discarded\&. .RE .RS 2 .LP Defaults to \fIexit\fR\&\&. .RE .LP .RS -4 .B Note: .RE The default value reflects the fact that a transport module for a stream-oriented transport like TCP may not be able to recover from a message length error since such a transport must use the Message Length header to divide the incoming byte stream into individual Diameter messages\&. An invalid length leaves it with no reliable way to rediscover message boundaries, which may result in the failure of subsequent messages\&. See \fBdiameter_tcp(3erl)\fR\& for the behaviour of that module\&. .TP 2 .B \fI{pool_size, pos_integer()}\fR\&: Number of transport processes to start\&. For a listening transport, determines the size of the pool of accepting transport processes, a larger number being desirable for processing multiple concurrent peer connection attempts\&. For a connecting transport, determines the number of connections to the peer in question that will be attempted to be establshed: the \fBservice_opt()\fR\&: \fIrestrict_connections\fR\& should also be configured on the service in question to allow multiple connections to the same peer\&. .TP 2 .B \fI{spawn_opt, [term()]}\fR\&: Options passed to \fBerlang:spawn_opt/2\fR\& when spawning a process for an incoming Diameter request\&. Options \fImonitor\fR\& and \fIlink\fR\& are ignored\&. .RS 2 .LP Defaults to the list configured on the service if not specified\&. .RE .TP 2 .B \fI{transport_config, term()}\fR\&: .TP 2 .B \fI{transport_config, term(), \fBUnsigned32()\fR\& | infinity}\fR\&: Term passed as the third argument to the \fBstart/3\fR\& function of the relevant \fBtransport module\fR\& in order to start a transport process\&. Defaults to the empty list\&. .RS 2 .LP The 3-tuple form additionally specifies an interval, in milliseconds, after which a started transport process should be terminated if it has not yet established a connection\&. For example, the following options on a connecting transport request a connection with one peer over SCTP or another (typically the same) over TCP\&. .RE .LP .nf {transport_module, diameter_sctp} {transport_config, SctpOpts, 5000} {transport_module, diameter_tcp} {transport_config, TcpOpts} .fi .RS 2 .LP To listen on both SCTP and TCP, define one transport for each\&. .RE .TP 2 .B \fI{transport_module, atom()}\fR\&: Module implementing a transport process as defined in \fBdiameter_transport(3erl)\fR\&\&. Defaults to \fIdiameter_tcp\fR\&\&. .RS 2 .LP Multiple \fItransport_module\fR\& and \fBtransport_config\fR\& options are allowed\&. The order of these is significant in this case (and only in this case), a \fItransport_module\fR\& being paired with the first \fBtransport_config\fR\& following it in the options list, or the default value for trailing modules\&. Transport starts will be attempted with each of the modules in order until one establishes a connection within the corresponding timeout (see below) or all fail\&. .RE .TP 2 .B \fI{watchdog_config, [{okay|suspect, non_neg_integer()}]}\fR\&: Configuration that alters the behaviour of the watchdog state machine\&. On key \fIokay\fR\&, the non-negative number of answered DWR messages before transitioning from REOPEN to OKAY\&. On key \fIsuspect\fR\&, the number of watchdog timeouts before transitioning from OKAY to SUSPECT when DWR is unanswered, or 0 to not make the transition\&. .RS 2 .LP Defaults to \fI[{okay, 3}, {suspect, 1}]\fR\&\&. Not specifying a key is equivalent to specifying the default value for that key\&. .RE .LP .RS -4 .B Warning: .RE The default value is as required by RFC 3539: changing it results in non-standard behaviour that should only be used to simulate misbehaving nodes during test\&. .TP 2 .B \fI{watchdog_timer, TwInit}\fR\&: .LP .nf TwInit = \fBUnsigned32()\fR\& | {M,F,A} .fi .RS 2 .LP The RFC 3539 watchdog timer\&. An integer value is interpreted as the RFC\&'s TwInit in milliseconds, a jitter of +/- 2 seconds being added at each rearming of the timer to compute the RFC\&'s Tw\&. An MFA is expected to return the RFC\&'s Tw directly, with jitter applied, allowing the jitter calculation to be performed by the callback\&. .RE .RS 2 .LP An integer value must be at least 6000 as required by RFC 3539\&. Defaults to 30000\&. .RE .RE .RS 2 .LP Unrecognized options are silently ignored but are returned unmodified by \fBservice_info/2\fR\& and can be referred to in predicate functions passed to \fBremove_transport/2\fR\&\&. .RE .TP 2 .B \fItransport_ref() = reference()\fR\&: Reference returned by \fBadd_transport/2\fR\& that identifies the configuration\&. .RE .SH EXPORTS .LP .B add_transport(SvcName, {connect|listen, [Opt]}) -> {ok, Ref} | {error, Reason} .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br Opt = \fBtransport_opt()\fR\& .br Ref = \fBtransport_ref()\fR\& .br Reason = term() .br .RE .RE .RS .LP Add transport capability to a service\&. .LP The service will start transport processes as required in order to establish a connection with the peer, either by connecting to the peer (\fIconnect\fR\&) or by accepting incoming connection requests (\fIlisten\fR\&)\&. A connecting transport establishes transport connections with at most one peer, an listening transport potentially with many\&. .LP The diameter application takes responsibility for exchanging CER/CEA with the peer\&. Upon successful completion of capabilities exchange the service calls each relevant application module\&'s \fBpeer_up/3\fR\& callback after which the caller can exchange Diameter messages with the peer over the transport\&. In addition to CER/CEA, the service takes responsibility for the handling of DWR/DWA and required by RFC 3539, as well as for DPR/DPA\&. .LP The returned reference uniquely identifies the transport within the scope of the service\&. Note that the function returns before a transport connection has been established\&. .LP .RS -4 .B Note: .RE 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 its transports\&. .RE .LP .B call(SvcName, App, Request, [Opt]) -> Answer | ok | {error, Reason} .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br App = \fBapplication_alias()\fR\& .br Request = \fBdiameter_codec:message()\fR\& .br Answer = term() .br Opt = \fBcall_opt()\fR\& .br .RE .RE .RS .LP Send a Diameter request message\&. .LP \fIApp\fR\& specifies the Diameter application in which the request is defined and callbacks to the corresponding callback module will follow as described below and in \fBdiameter_app(3erl)\fR\&\&. Unless the \fIdetach\fR\& option is specified, the call returns either when an answer message is received from the peer or an error occurs\&. In the answer case, the return value is as returned by a \fBhandle_answer/4\fR\& callback\&. In the error case, whether or not the error is returned directly by diameter or from a \fBhandle_error/4\fR\& callback depends on whether or not the outgoing request is successfully encoded for transmission to the peer, the cases being documented below\&. .LP If there are no suitable peers, or if \fBpick_peer/4\fR\& rejects them by returning \fIfalse\fR\&, then \fI{error,no_connection}\fR\& is returned\&. Otherwise \fBpick_peer/4\fR\& is followed by a \fBprepare_request/3\fR\& callback, the message is encoded and then sent\&. .LP There are several error cases which may prevent an answer from being received and passed to a \fBhandle_answer/4\fR\& callback: .RS 2 .TP 2 * If the initial encode of the outgoing request fails, then the request process fails and \fI{error,encode}\fR\& is returned\&. .LP .TP 2 * If the request is successfully encoded and sent but the answer times out then a \fBhandle_error/4\fR\& callback takes place with \fIReason = timeout\fR\&\&. .LP .TP 2 * If the request is successfully encoded and sent but the service in question is stopped before an answer is received then a \fBhandle_error/4\fR\& callback takes place with \fIReason = cancel\fR\&\&. .LP .TP 2 * 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\&. If no such peer is available, or if the subsequent \fBpick_peer/4\fR\& callback rejects the candidates, then a \fBhandle_error/4\fR\& callback takes place with \fIReason = failover\fR\&\&. If a peer is selected then a \fBprepare_retransmit/3\fR\& callback takes place, after which the semantics are the same as following an initial \fBprepare_request/3\fR\& callback\&. .LP .TP 2 * If an encode error takes place during retransmission then the request process fails and \fI{error,failure}\fR\& is returned\&. .LP .TP 2 * If an application callback made in processing the request fails (pick_peer, prepare_request, prepare_retransmit, handle_answer or handle_error) then either \fI{error,encode}\fR\& or \fI{error,failure}\fR\& is returned depending on whether or not there has been an attempt to send the request over the transport\&. .LP .RE .LP Note that \fI{error,encode}\fR\& is the only return value which guarantees that the request has \fInot\fR\& been sent over the transport connection\&. .RE .LP .B origin_state_id() -> \fBUnsigned32()\fR\& .br .RS .LP Return a reasonable value for use as Origin-State-Id in outgoing messages\&. .LP The value returned is the number of seconds since 19680120T031408Z, the first value that can be encoded as a Diameter \fI\fBTime()\fR\&\fR\&, at the time the diameter application was started\&. .RE .LP .B remove_transport(SvcName, Pred) -> ok | {error, Reason} .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br Pred = Fun | MFA | \fBtransport_ref()\fR\& | list() | true | false .br .br Fun = fun((\fBtransport_ref()\fR\&, connect|listen, list()) -> boolean()) .br | fun((\fBtransport_ref()\fR\&, list()) -> boolean()) .br | fun((list()) -> boolean()) .br MFA = {atom(), atom(), list()} .br Reason = term() .br .RE .RE .RS .LP Remove previously added transports\&. .LP \fIPred\fR\& determines which transports to remove\&. An arity-3-valued \fIPred\fR\& removes all transports for which \fIPred(Ref, Type, Opts)\fR\& returns \fItrue\fR\&, where \fIType\fR\& and \fIOpts\fR\& are as passed to \fBadd_transport/2\fR\& and \fIRef\fR\& is as returned by it\&. The remaining forms are equivalent to an arity-3 fun as follows\&. .LP .nf Pred = fun(transport_ref(), list()): fun(Ref, _, Opts) -> Pred(Ref, Opts) end Pred = fun(list()): fun(_, _, Opts) -> Pred(Opts) end Pred = transport_ref(): fun(Ref, _, _) -> Pred == Ref end Pred = list(): fun(_, _, Opts) -> [] == Pred -- Opts end Pred = true: fun(_, _, _) -> true end Pred = false: fun(_, _, _) -> false end Pred = {M,F,A}: fun(Ref, Type, Opts) -> apply(M, F, [Ref, Type, Opts | A]) end .fi .LP Removing a transport causes the corresponding transport processes to be terminated\&. Whether or not a DPR message is sent to a peer is controlled by value of \fBdisconnect_cb\fR\& configured on the transport\&. .RE .LP .B service_info(SvcName, Info) -> term() .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br Info = Item | [Info] .br Item = atom() .br .RE .RE .RS .LP Return information about a started service\&. Requesting info for an unknown service causes \fIundefined\fR\& to be returned\&. Requesting a list of items causes a tagged list to be returned\&. .LP \fIItem\fR\& can be one of the following\&. .RS 2 .TP 2 .B \fI\&'Origin-Host\&'\fR\&: .TP 2 .B \fI\&'Origin-Realm\&'\fR\&: .TP 2 .B \fI\&'Vendor-Id\&'\fR\&: .TP 2 .B \fI\&'Product-Name\&'\fR\&: .TP 2 .B \fI\&'Origin-State-Id\&'\fR\&: .TP 2 .B \fI\&'Host-IP-Address\&'\fR\&: .TP 2 .B \fI\&'Supported-Vendor\&'\fR\&: .TP 2 .B \fI\&'Auth-Application-Id\&'\fR\&: .TP 2 .B \fI\&'Inband-Security-Id\&'\fR\&: .TP 2 .B \fI\&'Acct-Application-Id\&'\fR\&: .TP 2 .B \fI\&'Vendor-Specific-Application-Id\&'\fR\&: .TP 2 .B \fI\&'Firmware-Revision\&'\fR\&: Return a capability value as configured with \fBstart_service/2\fR\&\&. .TP 2 .B \fIapplications\fR\&: Return the list of applications as configured with \fBstart_service/2\fR\&\&. .TP 2 .B \fIcapabilities\fR\&: Return a tagged list of all capabilities values as configured with \fBstart_service/2\fR\&\&. .TP 2 .B \fItransport\fR\&: Return a list containing one entry for each of the service\&'s transport as configured with \fBadd_transport/2\fR\&\&. Each entry is a tagged list containing both configuration and information about established peer connections\&. An example return value with for a client service with Origin-Host "client\&.example\&.com" configured with a single transport connected to "server\&.example\&.com" might look as follows\&. .LP .nf [[{ref,#Ref<0.0.0.93>}, {type,connect}, {options,[{transport_module,diameter_tcp}, {transport_config,[{ip,{127,0,0,1}}, {raddr,{127,0,0,1}}, {rport,3868}, {reuseaddr,true}]}]}, {watchdog,{<0.66.0>,{1346,171491,996448},okay}}, {peer,{<0.67.0>,{1346,171491,999906}}}, {apps,[{0,common}]}, {caps,[{origin_host,{"client.example.com","server.example.com"}}, {origin_realm,{"example.com","example.com"}}, {host_ip_address,{[{127,0,0,1}],[{127,0,0,1}]}}, {vendor_id,{0,193}}, {product_name,{"Client","Server"}}, {origin_state_id,{[],[]}}, {supported_vendor_id,{[],[]}}, {auth_application_id,{[0],[0]}}, {inband_security_id,{[],[0]}}, {acct_application_id,{[],[]}}, {vendor_specific_application_id,{[],[]}}, {firmware_revision,{[],[]}}, {avp,{[],[]}}]}, {port,[{owner,<0.69.0>}, {module,diameter_tcp}, {socket,{{127,0,0,1},48758}}, {peer,{{127,0,0,1},3868}}, {statistics,[{recv_oct,656}, {recv_cnt,6}, {recv_max,148}, {recv_avg,109}, {recv_dvi,19}, {send_oct,836}, {send_cnt,6}, {send_max,184}, {send_avg,139}, {send_pend,0}]}]}, {statistics,[{{{0,258,0},recv},3}, {{{0,258,1},send},3}, {{{0,258,0},recv,{'Result-Code',2001}},3}, {{{0,257,0},recv},1}, {{{0,257,1},send},1}, {{{0,257,0},recv,{'Result-Code',2001}},1}, {{{0,280,1},recv},2}, {{{0,280,0},send},2}, {{{0,280,0},send,{'Result-Code',2001}},2}]}]] .fi .RS 2 .LP Here \fIref\fR\& is a \fI\fBtransport_ref()\fR\&\fR\& and \fIoptions\fR\& the corresponding \fI\fBtransport_opt()\fR\&\fR\& list passed to \fBadd_transport/2\fR\&\&. The \fIwatchdog\fR\& entry shows the state of a connection\&'s RFC 3539 watchdog state machine\&. The \fIpeer\fR\& entry identifies the \fI\fBdiameter_app:peer_ref()\fR\&\fR\& for which there will have been \fBpeer_up/3\fR\& callbacks for the Diameter applications identified by the \fIapps\fR\& entry, \fIcommon\fR\& being the \fI\fBapplication_alias()\fR\&\fR\&\&. The \fIcaps\fR\& entry identifies the capabilities sent by the local node and received from the peer during capabilities exchange\&. The \fIport\fR\& entry displays socket-level information about the transport connection\&. The \fIstatistics\fR\& entry presents Diameter-level counters, an entry like \fI{{{0,280,1},recv},2}\fR\& saying that the client has received 2 DWR messages: \fI{0,280,1} = {Application_Id, Command_Code, R_Flag}\fR\&\&. .RE .RS 2 .LP Note that \fIwatchdog\fR\&, \fIpeer\fR\&, \fIapps\fR\&, \fIcaps\fR\& and \fIport\fR\& entries depend on connectivity with the peer and may not be present\&. Note also that the \fIstatistics\fR\& entry presents values accumulated during the lifetime of the transport configuration\&. .RE .RS 2 .LP A listening transport presents its information slightly differently since there may be multiple accepted connections for the same \fI\fBtransport_ref()\fR\&\fR\&\&. The \fItransport\fR\& info returned by a server with a single client connection might look as follows\&. .RE .LP .nf [[{ref,#Ref<0.0.0.61>}, {type,listen}, {options,[{transport_module,diameter_tcp}, {transport_config,[{reuseaddr,true}, {ip,{127,0,0,1}}, {port,3868}]}]}, {accept,[[{watchdog,{<0.56.0>,{1346,171481,226895},okay}}, {peer,{<0.58.0>,{1346,171491,999511}}}, {apps,[{0,common}]}, {caps,[{origin_host,{"server.example.com","client.example.com"}}, {origin_realm,{"example.com","example.com"}}, {host_ip_address,{[{127,0,0,1}],[{127,0,0,1}]}}, {vendor_id,{193,0}}, {product_name,{"Server","Client"}}, {origin_state_id,{[],[]}}, {supported_vendor_id,{[],[]}}, {auth_application_id,{[0],[0]}}, {inband_security_id,{[],[]}}, {acct_application_id,{[],[]}}, {vendor_specific_application_id,{[],[]}}, {firmware_revision,{[],[]}}, {avp,{[],[]}}]}, {port,[{owner,<0.62.0>}, {module,diameter_tcp}, {socket,{{127,0,0,1},3868}}, {peer,{{127,0,0,1},48758}}, {statistics,[{recv_oct,1576}, {recv_cnt,16}, {recv_max,184}, {recv_avg,98}, {recv_dvi,26}, {send_oct,1396}, {send_cnt,16}, {send_max,148}, {send_avg,87}, {send_pend,0}]}]}], [{watchdog,{<0.72.0>,{1346,171491,998404},initial}}]]}, {statistics,[{{{0,280,0},recv},7}, {{{0,280,1},send},7}, {{{0,280,0},recv,{'Result-Code',2001}},7}, {{{0,258,1},recv},3}, {{{0,258,0},send},3}, {{{0,258,0},send,{'Result-Code',2001}},3}, {{{0,280,1},recv},5}, {{{0,280,0},send},5}, {{{0,280,0},send,{'Result-Code',2001}},5}, {{{0,257,1},recv},1}, {{{0,257,0},send},1}, {{{0,257,0},send,{'Result-Code',2001}},1}]}]] .fi .RS 2 .LP The information presented here is as in the \fIconnect\fR\& case except that the client connections are grouped under an \fIaccept\fR\& tuple\&. .RE .RS 2 .LP Whether or not the \fBtransport_opt()\fR\& \fIpool_size\fR\& has been configured affects the format of the listing in the case of a connecting transport, since a value greater than 1 implies multiple transport processes for the same \fI\fBtransport_ref()\fR\&\fR\&, as in the listening case\&. The format in this case is similar to the listening case, with a \fIpool\fR\& tuple in place of an \fIaccept\fR\& tuple\&. .RE .TP 2 .B \fIconnections\fR\&: Return a list containing one entry for every established transport connection whose watchdog state machine is not in the \fIdown\fR\& state\&. This is a flat view of \fItransport\fR\& info which lists only active connections and for which Diameter-level statistics are accumulated only for the lifetime of the transport connection\&. A return value for the server above might look as follows\&. .LP .nf [[{ref,#Ref<0.0.0.61>}, {type,accept}, {options,[{transport_module,diameter_tcp}, {transport_config,[{reuseaddr,true}, {ip,{127,0,0,1}}, {port,3868}]}]}, {watchdog,{<0.56.0>,{1346,171481,226895},okay}}, {peer,{<0.58.0>,{1346,171491,999511}}}, {apps,[{0,common}]}, {caps,[{origin_host,{"server.example.com","client.example.com"}}, {origin_realm,{"example.com","example.com"}}, {host_ip_address,{[{127,0,0,1}],[{127,0,0,1}]}}, {vendor_id,{193,0}}, {product_name,{"Server","Client"}}, {origin_state_id,{[],[]}}, {supported_vendor_id,{[],[]}}, {auth_application_id,{[0],[0]}}, {inband_security_id,{[],[]}}, {acct_application_id,{[],[]}}, {vendor_specific_application_id,{[],[]}}, {firmware_revision,{[],[]}}, {avp,{[],[]}}]}, {port,[{owner,<0.62.0>}, {module,diameter_tcp}, {socket,{{127,0,0,1},3868}}, {peer,{{127,0,0,1},48758}}, {statistics,[{recv_oct,10124}, {recv_cnt,132}, {recv_max,184}, {recv_avg,76}, {recv_dvi,9}, {send_oct,10016}, {send_cnt,132}, {send_max,148}, {send_avg,75}, {send_pend,0}]}]}, {statistics,[{{{0,280,0},recv},62}, {{{0,280,1},send},62}, {{{0,280,0},recv,{'Result-Code',2001}},62}, {{{0,258,1},recv},3}, {{{0,258,0},send},3}, {{{0,258,0},send,{'Result-Code',2001}},3}, {{{0,280,1},recv},66}, {{{0,280,0},send},66}, {{{0,280,0},send,{'Result-Code',2001}},66}, {{{0,257,1},recv},1}, {{{0,257,0},send},1}, {{{0,257,0},send,{'Result-Code',2001}},1}]}]] .fi .RS 2 .LP Note that there may be multiple entries with the same \fIref\fR\&, in contrast to \fItransport\fR\& info\&. .RE .TP 2 .B \fIstatistics\fR\&: Return a \fI{{Counter, Ref}, non_neg_integer()}\fR\& list of counter values\&. \fIRef\fR\& can be either a \fI\fBtransport_ref()\fR\&\fR\& or a \fI\fBdiameter_app:peer_ref()\fR\&\fR\&\&. Entries for the latter are folded into corresponding entries for the former as peer connections go down\&. Entries for both are removed at \fBremove_transport/2\fR\&\&. The Diameter-level statistics returned by \fItransport\fR\& and \fIconnections\fR\& info are based upon these entries\&. .TP 2 .B \fI\fBdiameter_app:peer_ref()\fR\&\fR\&: Return transport configuration associated with a single peer, as passed to \fBadd_transport/2\fR\&\&. The returned list is empty if the peer is unknown\&. Otherwise it contains the \fIref\fR\&, \fItype\fR\& and \fIoptions\fR\& tuples as in \fItransport\fR\& and \fIconnections\fR\& info above\&. For example: .LP .nf [{ref,#Ref<0.0.0.61>}, {type,accept}, {options,[{transport_module,diameter_tcp}, {transport_config,[{reuseaddr,true}, {ip,{127,0,0,1}}, {port,3868}]}]}] .fi .RE .RE .LP .B services() -> [SvcName] .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br .RE .RE .RS .LP Return the list of started services\&. .RE .LP .B session_id(Ident) -> \fBOctetString()\fR\& .br .RS .LP Types: .RS 3 Ident = \fBDiameterIdentity()\fR\& .br .RE .RE .RS .LP Return a value for a Session-Id AVP\&. .LP The value has the form required by section 8\&.8 of RFC 6733\&. Ident should be the Origin-Host of the peer from which the message containing the returned value will be sent\&. .RE .LP .B start() -> ok | {error, Reason} .br .RS .LP Start the diameter application\&. .LP The diameter application must be started before starting a service\&. In a production system this is typically accomplished by a boot file, not by calling \fIstart/0\fR\& explicitly\&. .RE .LP .B start_service(SvcName, Options) -> ok | {error, Reason} .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br Options = [\fBservice_opt()\fR\&] .br Reason = term() .br .RE .RE .RS .LP Start a diameter service\&. .LP A service defines a locally-implemented Diameter node, specifying the capabilities to be advertised during capabilities exchange\&. Transports are added to a service using \fBadd_transport/2\fR\&\&. .LP .RS -4 .B Note: .RE A transport can both override its service\&'s capabilities and restrict its supported Diameter applications so "service = Diameter node as identified by Origin-Host" is not necessarily the case\&. .RE .LP .B stop() -> ok | {error, Reason} .br .RS .LP Stop the diameter application\&. .LP .RE .LP .B stop_service(SvcName) -> ok | {error, Reason} .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br Reason = term() .br .RE .RE .RS .LP Stop a diameter service\&. .LP Stopping a service causes all associated transport connections to be broken\&. A DPR message with be sent as in the case of \fBremove_transport/2\fR\&\&. .LP .RS -4 .B Note: .RE Stopping a service does not remove any associated transports: \fBremove_transport/2\fR\& must be called to remove transport configuration\&. .RE .LP .B subscribe(SvcName) -> true .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br .RE .RE .RS .LP Subscribe to \fI\fBservice_event()\fR\&\fR\& messages from a service\&. .LP It is not an error to subscribe to events from a service that does not yet exist\&. Doing so before adding transports is required to guarantee the reception of all transport-related events\&. .RE .LP .B unsubscribe(SvcName) -> true .br .RS .LP Types: .RS 3 SvcName = \fBservice_name()\fR\& .br .RE .RE .RS .LP Unsubscribe to event messages from a service\&. .RE .SH "SEE ALSO" .LP \fBdiameter_app(3erl)\fR\&, \fBdiameter_transport(3erl)\fR\&, \fBdiameter_dict(5)\fR\&