<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- diameter(3)</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/diameter-0.9.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Diameter</strong><br><strong>Reference Manual</strong><br><small>Version 0.9</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p> <ul class="flipMenu"> <li id="loadscrollpos" title="diameter " expanded="true">diameter<ul> <li><a href="diameter.html"> Top of manual page </a></li> <li title="add_transport-2"><a href="diameter.html#add_transport-2">add_transport/2</a></li> <li title="call-4"><a href="diameter.html#call-4">call/4</a></li> <li title="origin_state_id-0"><a href="diameter.html#origin_state_id-0">origin_state_id/0</a></li> <li title="remove_transport-2"><a href="diameter.html#remove_transport-2">remove_transport/2</a></li> <li title="service_info-2"><a href="diameter.html#service_info-2">service_info/2</a></li> <li title="services-0"><a href="diameter.html#services-0">services/0</a></li> <li title="session_id-1"><a href="diameter.html#session_id-1">session_id/1</a></li> <li title="start-0"><a href="diameter.html#start-0">start/0</a></li> <li title="start_service-2"><a href="diameter.html#start_service-2">start_service/2</a></li> <li title="stop-0"><a href="diameter.html#stop-0">stop/0</a></li> <li title="stop_service-1"><a href="diameter.html#stop_service-1">stop_service/1</a></li> <li title="subscribe-1"><a href="diameter.html#subscribe-1">subscribe/1</a></li> <li title="unsubscribe-1"><a href="diameter.html#unsubscribe-1">unsubscribe/1</a></li> </ul> </li> <li title="diameterc"><a href="diameterc.html">diameterc</a></li> <li id="no" title="diameter_app " expanded="false">diameter_app<ul> <li><a href="diameter_app.html"> Top of manual page </a></li> <li title="Mod:peer_up-3"><a href="diameter_app.html#Mod:peer_up-3">Mod:peer_up/3</a></li> <li title="Mod:peer_down-3"><a href="diameter_app.html#Mod:peer_down-3">Mod:peer_down/3</a></li> <li title="Mod:pick_peer-4"><a href="diameter_app.html#Mod:pick_peer-4">Mod:pick_peer/4</a></li> <li title="Mod:prepare_request-3"><a href="diameter_app.html#Mod:prepare_request-3">Mod:prepare_request/3</a></li> <li title="Mod:prepare_retransmit-3"><a href="diameter_app.html#Mod:prepare_retransmit-3">Mod:prepare_retransmit/3</a></li> <li title="Mod:handle_answer-4"><a href="diameter_app.html#Mod:handle_answer-4">Mod:handle_answer/4</a></li> <li title="Mod:handle_error-4"><a href="diameter_app.html#Mod:handle_error-4">Mod:handle_error/4</a></li> <li title="Mod:handle_request-3"><a href="diameter_app.html#Mod:handle_request-3">Mod:handle_request/3</a></li> </ul> </li> <li title="diameter_dict"><a href="diameter_dict.html">diameter_dict</a></li> <li id="no" title="diameter_transport " expanded="false">diameter_transport<ul> <li><a href="diameter_transport.html"> Top of manual page </a></li> <li title="Mod:start-3"><a href="diameter_transport.html#Mod:start-3">Mod:start/3</a></li> </ul> </li> <li id="no" title="diameter_tcp " expanded="false">diameter_tcp<ul> <li><a href="diameter_tcp.html"> Top of manual page </a></li> <li title="start-3"><a href="diameter_tcp.html#start-3">start/3</a></li> </ul> </li> <li id="no" title="diameter_sctp " expanded="false">diameter_sctp<ul> <li><a href="diameter_sctp.html"> Top of manual page </a></li> <li title="start-3"><a href="diameter_sctp.html#start-3">start/3</a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <!-- refpage --><center><h1>diameter</h1></center> <h3>MODULE</h3> <div class="REFBODY">diameter</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">Main API of the diameter application.</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p> 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.</p> <p> Basic usage consists of creating a representation of a locally implemented Diameter peer and its capabilities with <span class="bold_code"><a href="#start_service">start_service/2</a></span>, adding transport capability using <span class="bold_code"><a href="#add_transport">add_transport/2</a></span> and sending Diameter requests and receiving Diameter answers with <span class="bold_code"><a href="#call">call/4</a></span>. Incoming Diameter requests are communicated as callbacks to a <span class="bold_code"><a href="diameter_app.html">diameter_app(3)</a></span> callback modules as specified in the service configuration.</p> <p> Beware the difference between <strong>diameter application</strong> and <strong>Diameter application</strong>. The former refers to the Erlang application named diameter whose main api is defined here, the latter to an application of the Diameter protocol in the sense of RFC 3588. More generally, capitalized Diameter refers to the RFC and diameter to this implementation.</p> <p> The diameter application must be started before calling functions in this module.</p> </p></div> <h3><a name="id193413">DATA TYPES</a></h3> <div class="REFBODY"> <dl> <dt><strong><span class="code">Address()</span></strong></dt> <dt><strong><span class="code">DiameterIdentity()</span></strong></dt> <dt><strong><span class="code">Time()</span></strong></dt> <dt><strong><span class="code">Unsigned32()</span></strong></dt> <dt><strong><span class="code">UTF8String()</span></strong></dt> <dd> <p> Types corresponding to RFC 3588 AVP Data Formats. Defined in <span class="bold_code"><a href="diameter_dict.html">diameter_dict(4)</a></span>.</p> <a name="application_alias"></a> </dd> <dt><strong><span class="code">application_alias() = term()</span></strong></dt> <dd> <p> A name identifying a Diameter application in service configuration passed to <span class="bold_code"><a href="#start_service">start_service/2</a></span> and passed to <span class="bold_code"><a href="#call">call/4</a></span> when sending requests belonging to the application.</p> <a name="application_module"></a> </dd> <dt><strong><span class="code">application_module() = Mod | [Mod | ExtraArgs]</span></strong></dt> <dd> <div class="example"><pre> Mod = atom() ExtraArgs = list() </pre></div> <p> A module implementing the callback interface defined in <span class="bold_code"><a href="diameter_app.html">diameter_app(3)</a></span>, along with any extra arguments to be appended to those documented for the interface. Any extra arguments are appended to the documented list of arguments for each function. Note that additional arguments specific to an outgoing request be specified to <span class="bold_code"><a href="#call">call/4</a></span>, in which case the call-specific arguments are appended to any specified with the callback module.</p> <a name="application_opt"></a> </dd> <dt><strong><span class="code">application_opt()</span></strong></dt> <dd> <p> Options defining a Diameter application as configured in an <span class="code">application</span> option passed to <span class="bold_code"><a href="#start_service">start_service/2</a></span>.</p> <dl> <dt><strong><span class="code">{alias, application_alias()}</span></strong></dt> <dd> <p> An unique identifier for the application in the scope of the service. Optional, defaults to the value of the <span class="code">dictionary</span> option.</p> </dd> <dt><strong><span class="code">{dictionary, atom()}</span></strong></dt> <dd> <p> The name of an encode/decode module for the Diameter messages defined by the application. These modules are generated from a specification file whose format is documented in <span class="bold_code"><a href="diameter_dict.html">diameter_dict(4)</a></span>.</p> </dd> <dt><strong><span class="code">{module, application_module()}</span></strong></dt> <dd> <p> A callback module with which messages of the Diameter application are handled. See <span class="bold_code"><a href="diameter_app.html">diameter_app(3)</a></span> for information on the required interface and semantics.</p> </dd> <dt><strong><span class="code">{state, term()}</span></strong></dt> <dd> <p> The initial callback state. Defaults to the value of the <span class="code">alias</span> option if unspecified. The prevailing state is passed to certain <span class="bold_code"><a href="diameter_app.html">diameter_app(3)</a></span> callbacks, which can then return a new state.</p> </dd> <dt><strong><span class="code">{call_mutates_state, true|false}</span></strong></dt> <dd> <p> Specifies whether or not the <span class="bold_code"><a href="diameter_app.html#pick_peer">pick_peer/4</a></span> application callback (following from a call to <span class="bold_code"><a href="#call">call/4</a></span>) can modifiy state, Defaults to <span class="code">false</span> if unspecified.</p> <p> Note that <span class="bold_code"><a href="diameter_app.html#pick_peer">pick_peer</a></span> callbacks are serialized when these are allowed to modify state, 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.</p> </dd> <dt><strong><span class="code">{answer_errors, callback|report|discard}</span></strong></dt> <dd> <p> Determines the manner in which incoming answer messages containing decode errors are handled. If <span class="code">callback</span> then errors result in a <span class="bold_code"><a href="diameter_app.html#handle_answer">handle_answer/4</a></span> callback in the same fashion as for <span class="bold_code"><a href="diameter_app.html#handle_request">handle_request/3</a></span>, in the <span class="code">errors</span> field of the <span class="code">diameter_packet</span> record passed into the callback. If <span class="code">report</span> then an answer containing errors is discarded without a callback and a warning report is written to the log. If <span class="code">discard</span> then an answer containing errors is silently discarded without a callback. In both the <span class="code">report</span> and <span class="code">discard</span> cases the return value for the <span class="bold_code"><a href="#call">call/4</a></span> invocation in question is as if a callback had taken place and returned <span class="code">{error, failure}</span>.</p> <p> Defaults to <span class="code">report</span> if unspecified.</p> </dd> </dl> <a name="call_opt"></a> </dd> <dt><strong><span class="code">call_opt()</span></strong></dt> <dd> <p> Options available to <span class="bold_code"><a href="#call">call/4</a></span> when sending an outgoing Diameter request.</p> <dl> <dt><strong><span class="code">{extra, list()}</span></strong></dt> <dd> <p> Extra arguments to append to callbacks to the callback module in question. These are appended to any extra arguments configured with the callback itself. Multiple options append to the argument list.</p> </dd> <dt><strong><span class="code">{filter, peer_filter()}</span></strong></dt> <dd> <p> A filter to apply to the list of available peers before passing them to the <span class="bold_code"><a href="diameter_app.html#pick_peer">pick_peer/4</a></span> callback for the application in question. Multiple options are equivalent a single <span class="code">all</span> filter on the corresponding list of filters. Defaults to <span class="code">none</span>.</p> </dd> <dt><strong><span class="code">{timeout, Unsigned32()}</span></strong></dt> <dd> <p> The number of milliseconds after which the request should timeout. Defaults to 5000.</p> </dd> <dt><strong><span class="code">detach</span></strong></dt> <dd> <p> Causes <span class="bold_code"><a href="#call">call/4</a></span> to return <span class="code">ok</span> as soon as the request in question has been encoded instead of waiting for and returning the result from a subsequent <span class="bold_code"><a href="diameter_app.html#handle_answer">handle_answer/4</a></span> or <span class="bold_code"><a href="diameter_app.html#handle_error">handle_error/4</a></span> callback.</p> </dd> </dl> <a name="capability"></a> </dd> <dt><strong><span class="code">capability()</span></strong></dt> <dd> <p> AVP values used in outgoing CER/CEA messages during capabilities exchange. Can be configured both on a service and a transport, the latter taking precedence over the former.</p> <dl> <dt><strong><span class="code">{'Origin-Host', DiameterIdentity()}</span></strong></dt> <dd> <p> Value of the Origin-Host AVP in outgoing messages.</p> </dd> <dt><strong><span class="code">{'Origin-Realm', DiameterIdentity()}</span></strong></dt> <dd> <p> Value of the Origin-Realm AVP in outgoing messages.</p> </dd> <dt><strong><span class="code">{'Host-IP-Address', [Address()]}</span></strong></dt> <dd> <p> Values of Host-IP-Address AVPs. Optional.</p> <p> The list of addresses is available to the start function of a transport module, which either uses them as is or returns a new list (typically as configured as <span class="code">transport_config()</span> on the transport module in question) in order for the correct list of addresses to be sent in capabilities exchange messages.</p> </dd> <dt><strong><span class="code">{'Vendor-Id', Unsigned32()}</span></strong></dt> <dd> <p> Value of the Vendor-Id AVP sent in an outgoing capabilities exchange message.</p> </dd> <dt><strong><span class="code">{'Product-Name', UTF8String()}</span></strong></dt> <dd> <p> Value of the Product-Name AVP sent in an outgoing capabilities exchange message.</p> </dd> <dt><strong><span class="code">{'Origin-State-Id', Unsigned32()}</span></strong></dt> <dd> <p> Value of Origin-State-Id to be included in outgoing messages sent by diameter itself. In particular, the AVP will be included in CER/CEA and DWR/DWA messages. Optional.</p> <p> Setting a value of <span class="code">0</span> (zero) is equivalent to not setting a value as documented in RFC 3588. The function <span class="bold_code"><a href="#origin_state_id">origin_state_id/0</a></span> can be used as to retrieve a value that is set when the diameter application is started.</p> </dd> <dt><strong><span class="code">{'Supported-Vendor-Id', [Unsigned32()]}</span></strong></dt> <dd> <p> Values of Supported-Vendor-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.</p> </dd> <dt><strong><span class="code">{'Auth-Application-Id', [Unsigned32()]}</span></strong></dt> <dd> <p> Values of Auth-Application-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.</p> </dd> <dt><strong><span class="code">{'Acct-Application-Id', [Unsigned32()]}</span></strong></dt> <dd> <p> Values of Acct-Application-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.</p> </dd> <dt><strong><span class="code">{'Vendor-Specific-Application-Id', [Grouped()]}</span></strong></dt> <dd> <p> Values of Vendor-Specific-Application-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.</p> </dd> <dt><strong><span class="code">{'Firmware-Revision', Unsigned32()}</span></strong></dt> <dd> <p> Value of the Firmware-Revision AVP sent in an outgoing capabilities exchange message. Optional.</p> </dd> </dl> <p> Note that each tuple communicates one or more AVP values. It is an error to specify duplicate tuples.</p> <a name="evaluable"></a> </dd> <dt><strong><span class="code">evaluable() = {M,F,A} | fun() | [evaluable() | A]</span></strong></dt> <dd> <p> An expression that can be evaluated as a function in the following sense.</p> <div class="example"><pre> eval([{M,F,A} | T]) -> apply(M, F, T ++ A); eval([F|A]) -> apply(F, A); eval(F) -> eval([F]). </pre></div> <p> Evaluating an evaluable() <span class="code">E</span> on an argument list <span class="code">A</span> is meant in the sense of <span class="code">eval([E|A])</span>.</p> <p> Beware of using local funs (that is, fun expressions not of the form <span class="code">fun Module:Name/Arity</span>) 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.</p> <a name="peer_filter"></a> </dd> <dt><strong><span class="code">peer_filter() = term()</span></strong></dt> <dd> <p> A filter passed to <span class="bold_code"><a href="#call">call/4</a></span> in order to select candidate peers for a <span class="bold_code"><a href="diameter_app.html#pick_peer">pick_peer/4</a></span> callback. Has one of the following types.</p> <dl> <dt><strong><span class="code">none</span></strong></dt> <dd> <p> Matches any peer. This is a convenience that provides a filter equivalent to no filter at all.</p> </dd> <dt><strong><span class="code">host</span></strong></dt> <dd> <p> Matches only those peers whose <span class="code">Origin-Host</span> has the same value as <span class="code">Destination-Host</span> in the outgoing request in question, or any peer if the request does not contain a <span class="code">Destination-Host</span> AVP.</p> </dd> <dt><strong><span class="code">realm</span></strong></dt> <dd> <p> Matches only those peers whose <span class="code">Origin-Realm</span> has the same value as <span class="code">Destination-Realm</span> in the outgoing request in question, or any peer if the request does not contain a <span class="code">Destination-Realm</span> AVP.</p> </dd> <dt><strong><span class="code">{host, any|UTF8String()}</span></strong></dt> <dd> <p> Matches only those peers whose <span class="code">Origin-Host</span> has the specified value, or all peers if the atom <span class="code">any</span>.</p> </dd> <dt><strong><span class="code">{realm, any|UTF8String()</span></strong></dt> <dd> <p> Matches only those peers whose <span class="code">Origin-Realm</span> has the value, or all peers if the atom <span class="code">any</span>.</p> </dd> <dt><strong><span class="code">{eval, evaluable()}</span></strong></dt> <dd> <p> Matches only those peers for which the specified evaluable() evaluates to true on the peer's <span class="code">diameter_caps</span> record.</p> </dd> <dt><strong><span class="code">{neg, peer_filter()}</span></strong></dt> <dd> <p> Matches only those peers not matched by the specified filter.</p> </dd> <dt><strong><span class="code">{all, [peer_filter()]}</span></strong></dt> <dd> <p> Matches only those peers matched by each filter of the specified list.</p> </dd> <dt><strong><span class="code">{any, [peer_filter()]}</span></strong></dt> <dd> <p> Matches only those peers matched by at least one filter of the specified list.</p> </dd> </dl> <a name="service_event"></a> </dd> <dt><strong><span class="code">service_event() = #diameter_event{}</span></strong></dt> <dd> <p> Event message sent to processes that have subscribed using <span class="bold_code"><a href="#subscribe">subscribe/1</a></span>.</p> <p> The <span class="code">info</span> field of the event record can be one of the following.</p> <dl> <dt><strong><span class="code">{up, Ref, Peer, Config, Pkt}</span></strong></dt> <dt><strong><span class="code">{up, Ref, Peer, Config}</span></strong></dt> <dt><strong><span class="code">{down, Ref, Peer, Config}</span></strong></dt> <dd> <div class="example"><pre> Ref = transport_ref() Peer = diameter_app:peer() Config = {connect|listen, [transport_opt()]} Pkt = #diameter_packet{} </pre></div> <p> Reports that the RFC 3539 watchdog state machine has transitioned into (<span class="code">up</span>) or out of (<span class="code">down</span>) the open state. If a <span class="code">diameter_packet</span> record is present in an <span class="code">up</span> tuple then there has been an exchange of capabilities exchange messages and the record contains the received CER or CEA, otherwise the connection has reestablished without the loss or transport connectivity.</p> <p> Note that a single up/down event for a given peer corresponds to as many peer_up/down callbacks as there are Diameter applications shared by the peer, as determined during capablilities exchange. That is, the event communicates connectivity with the peer as a whole while the callbacks communicate connectivity with respect to individual Diameter applications.</p> </dd> <dt><strong><span class="code">{reconnect, Ref, Opts}</span></strong></dt> <dd> <div class="example"><pre> Ref = transport_ref() Opts = [transport_opt()] </pre></div> <p> A connecting transport is attempting to establish/reestablish a transport connection with a peer following <span class="code">reconnect_timer</span> or <span class="code">watchdog_timer</span> expiry.</p> </dd> </dl> <p> For forward compatibility, a subscriber should be prepared to receive <span class="code">diameter_event.info</span> of forms other than those documented above.</p> <a name="service_name"></a> </dd> <dt><strong><span class="code">service_name() = term()</span></strong></dt> <dd> <p> The name of a service as passed to <span class="bold_code"><a href="#start_service">start_service/2</a></span> and with which the service is identified. There can be at most one service with a given name on a given node. Note that <span class="code">erlang:make_ref/0</span> can be used to generate a service name that is somewhat unique.</p> <a name="service_opt"></a> </dd> <dt><strong><span class="code">service_opt()</span></strong></dt> <dd> <p> Options accepted by <span class="bold_code"><a href="#start_service">start_service/2</a></span>. Can be any <span class="code">capability()</span> tuple as well as the following.</p> <dl> <dt><strong><span class="code">{application, [application_opt()]}</span></strong></dt> <dd> <p> Defines a Diameter application supported by the service.</p> <p> A service must define one application for each Diameter application it intends to support. For an outgoing Diameter request, the application is specified by passing the desired application's <span class="code">application_alias()</span> to <span class="bold_code"><a href="#call">call/4</a></span>, while for an incoming request the application identifier in the message header determines the application (and callback module), the application identifier being specified in the <span class="bold_code"><a href="diameter_dict.html">dictionary</a></span> file defining the application.</p> </dd> </dl> <a name="transport_opt"></a> </dd> <dt><strong><span class="code">transport_opt()</span></strong></dt> <dd> <p> Options accepted by <span class="bold_code"><a href="#add_transport">add_transport/2</a></span>.</p> <dl> <dt><strong><span class="code">{transport_module, atom()}</span></strong></dt> <dd> <p> A module implementing a transport process as defined in <span class="bold_code"><a href="diameter_transport.html">diameter_transport(3)</a></span>. Defaults to <span class="code">diameter_tcp</span> if unspecified.</p> <p> The interface required of a transport module is documented in <span class="bold_code"><a href="diameter_transport.html">diameter_transport(3)</a></span>.</p> </dd> <dt><strong><span class="code">{transport_config, term()}</span></strong></dt> <dd> <p> A term passed as the third argument to the <span class="bold_code"><a href="diameter_transport.html#start">start/3</a></span> function of the relevant <span class="code">transport_module</span> in order to start a transport process. Defaults to the empty list if unspecified.</p> </dd> <dt><strong><span class="code">{applications, [application_alias()]}</span></strong></dt> <dd> <p> The list of Diameter applications to which usage of the transport should be restricted. Defaults to all applications configured on the service in question.</p> </dd> <dt><strong><span class="code">{capabilities, [capability()]}</span></strong></dt> <dd> <p> AVP's used to construct outgoing CER/CEA messages. Any AVP specified takes precedence over a corresponding value specified for the service in question.</p> </dd> <dt><strong><span class="code">{watchdog_timer, TwInit}</span></strong></dt> <dd> <div class="example"><pre> TwInit = Unsigned32() | {M,F,A} </pre></div> <p> 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.</p> <p> An integer value must be at least 6000 as required by RFC 3539. Defaults to 30000 if unspecified.</p> </dd> <dt><strong><span class="code">{reconnect_timer, Tc}</span></strong></dt> <dd> <div class="example"><pre> Tc = Unsigned32() </pre></div> <p> For a connecting transport, the RFC 3588 Tc timer, in milliseconds. Note that this timer determines the frequency with which the transport will attempt to establish a connection with its peer only <strong>before</strong> an initial connection is established: once there is an initial connection it's watchdog_timer that determines the frequency of reconnection attempts, as required by RFC 3539.</p> <p> 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 a reestablishment, causing the RFC 3539 state machine to pass to state OPEN rather than REOPEN. 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.</p> <p> Defaults to 30000 for a connecting transport and 60000 for a listening transport.</p> </dd> </dl> <p> Unrecognized options are silently ignored but are returned unmodified by <span class="bold_code"><a href="#service_info">service_info/2</a></span> and can be referred to in predicate functions passed to <span class="bold_code"><a href="#remove_transport">remove_transport/2</a></span>.</p> </dd> </dl> </div> <a name="add_transport"></a> <h3>EXPORTS</h3> <p><a name="add_transport-2"><span class="bold_code">add_transport(SvcName, {connect|listen, Options}) -> {ok, Ref} | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [transport_opt()]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Ref = ref()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p> Add transport capability to a service.</p> <p> The service will start a transport process(es) in order to establish a connection with the peer, either by connecting to the peer (<span class="code">connect</span>) or by accepting incoming connection requests (<span class="code">listen</span>). A connecting transport establishes transport connections with at most one peer, an listening transport potentially with many.</p> <p> 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 <span class="bold_code"><a href="diameter_app.html#peer_up">peer_up/3</a></span> 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.</p> <p> 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. 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.</p> <a name="call"></a> </p></div> <p><a name="call-4"><span class="bold_code">call(SvcName, App, Request, Options) -> ok | Answer | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">App = application_alias()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Request = diameter_app:message()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Answer = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [call_opt()]</span><br> </div> </div> <div class="REFBODY"><p> <p> Send a Diameter request message and possibly return the answer or error.</p> <p> <span class="code">App</span> identifies the Diameter application in which the request is defined and callbacks to the corresponding callback module will follow as described below and in <span class="bold_code"><a href="diameter_app.html">diameter_app(3)</a></span>. Unless the <span class="code">detach</span> option has been specified to cause an earlier return, the call returns either when an answer message is received from the peer or an error occurs. In the case of an answer, the return value is as returned by a <span class="bold_code"><a href="diameter_app.html#handle_answer">handle_answer/4</a></span> callback. In the case of an error, whether or not the error is returned directly by diameter or from a <span class="bold_code"><a href="diameter_app.html#handle_error">handle_error/4</a></span> callback depends on whether or not the outgoing request is successfully encoded for transmission from the peer, the cases being documented below.</p> <p> If there are no suitable peers, or if <span class="bold_code"><a href="diameter_app.html#pick_peer">pick_peer/4</a></span> rejects them by returning 'false', then <span class="code">{error, no_connection}</span> is returned. If <span class="bold_code"><a href="diameter_app.html#pick_peer">pick_peer/4</a></span> selects a candidate peer then a request process is spawned for the outgoing request, in which there is a <span class="bold_code"><a href="diameter_app.html#prepare_request">prepare_request/3</a></span> callback, the message is encoded and sent.</p> <p> There are several error cases which may prevent an answer from being received and passed to a <span class="bold_code"><a href="diameter_app.html#handle_answer">handle_answer/4</a></span> callback:</p> <ul> <li> <p> If the initial encode of the outgoing request fails, then the request process fails and <span class="code">{error, encode}</span> is returned.</p> </li> <li> <p> If the request is successfully encoded and sent but the answer times out then a <span class="bold_code"><a href="diameter_app.html#handle_error">handle_error/4</a></span> callback takes place with <span class="code">Reason = timeout</span>.</p> </li> <li> <p> If the request is successfully encoded and sent but the service in question is stopped before an answer is received then a <span class="bold_code"><a href="diameter_app.html#handle_error">handle_error/4</a></span> callback takes place <span class="code">Reason = cancel</span>.</p> </li> <li> <p> 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 <span class="bold_code"><a href="diameter_app.html#pick_peer">pick_peer/4</a></span> callback rejects the candidates, then a <span class="bold_code"><a href="diameter_app.html#handle_error">handle_error/4</a></span> callback takes place with <span class="code">Reason = failover</span>. If a peer is selected then a <span class="bold_code"><a href="diameter_app.html#prepare_retransmit">prepare_retransmit/3</a></span> callback takes place, after which the semantics are the same as following an initial <span class="bold_code"><a href="diameter_app.html#prepare_request"> prepare_request/3</a></span> callback.</p> </li> <li> <p> If an encode error takes place during retransmission then the request process fails and <span class="code">{error, failure}</span> is returned.</p> </li> <li> <p> If an application callback made in processing the request fails (pick_peer, prepare_request, prepare_retransmit, handle_answer or handle_error) then either <span class="code">{error, encode}</span> or <span class="code">{error, failure}</span> is returned depending on whether or not there has been an attempt to send the request over the transport.</p> </li> </ul> <p> Note that <span class="code">{error, encode}</span> is the only return value which guarantees that the request has <strong>not</strong> been sent over the transport.</p> <a name="origin_state_id"></a> </p></div> <p><a name="origin_state_id-0"><span class="bold_code">origin_state_id() -> Unsigned32()</span></a><br></p> <div class="REFBODY"><p> <p> Return a reasonable value for use as Origin-State-Id in outgoing messages.</p> <p> The value returned is the number of seconds since 19680120T031408Z, the first value that can be encoded as a Diameter Time(), at the time the diameter application was started.</p> <a name="remove_transport"></a> </p></div> <p><a name="remove_transport-2"><span class="bold_code">remove_transport(SvcName, Pred) -> ok</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Pred = Fun | MFA | ref() | list() | true | false</span><br> </div> <div class="REFTYPES"> <span class="bold_code"></span><br> </div> <div class="REFTYPES"> <span class="bold_code">Fun = fun((reference(), connect|listen, list()) -> boolean())</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> | fun((reference(), list()) -> boolean())</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> | fun((list()) -> boolean())</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MFA = {atom(), atom(), list()}</span><br> </div> </div> <div class="REFBODY"><p> <p> Remove previously added transports.</p> <p> <span class="code">Pred</span> determines which transports to remove. An arity-3-valued <span class="code">Pred</span> removes all transports for which <span class="code">Pred(Ref, Type, Opts)</span> returns <span class="code">true</span>, where <span class="code">Type</span> and <span class="code">Opts</span> are as passed to <span class="bold_code"><a href="#add_transport">add_transport/2</a></span> and <span class="code">Ref</span> is as returned by the corresponding call. The remaining forms are equivalent to an arity-3 fun as follows.</p> <div class="example"><pre> Pred = fun(reference(), list()): fun(Ref, _, Opts) -> Pred(Ref, Opts) end Pred = fun(list()): fun(_, _, Opts) -> Pred(Opts) end Pred = reference(): 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 </pre></div> <p> Removing a transport causes all associated transport connections to be broken. A base application DPR message with Disconnect-Cause <span class="code">DO_NOT_WANT_TO_TALK_TO_YOU</span> 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.</p> <a name="service_info"></a> </p></div> <p><a name="service_info-2"><span class="bold_code">service_info(SvcName, Item) -> Value</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Value = term()</span><br> </div> </div> <div class="REFBODY"><p> <p> Return information about a started service.</p> <a name="services"></a> </p></div> <p><a name="services-0"><span class="bold_code">services() -> [SvcName]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> </div> <div class="REFBODY"><p> <p> Return the list of started services.</p> <a name="session_id"></a> </p></div> <p><a name="session_id-1"><span class="bold_code">session_id(Ident) -> OctetString()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Ident = DiameterIdentity()</span><br> </div> </div> <div class="REFBODY"><p> <p> Return a value for a Session-Id AVP.</p> <p> The value has the form required by section 8.8 of RFC 3588. Ident should be the Origin-Host of the peer from which the message containing the returned value will be sent.</p> <a name="start"></a> </p></div> <p><a name="start-0"><span class="bold_code">start() -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"><p> <p> Start the diameter application.</p> <p> The diameter application must be started before starting a service. In a production system this will typically be accomplished by a boot file, not by calling <span class="code">start/0</span> explicitly.</p> <a name="start_service"></a> </p></div> <p><a name="start_service-2"><span class="bold_code">start_service(SvcName, Options) -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [service_opt()]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p> Start a diameter service.</p> <p> A service defines a locally-implemented Diameter peer, specifying the capabilities of the peer to be used during capabilities exchange and the Diameter applications that it supports. Transports are added to a service using <span class="bold_code"><a href="#add_transport">add_transport/2</a></span>.</p> <a name="stop_service"></a> </p></div> <p><a name="stop-0"><span class="bold_code">stop() -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"><p> <p> Stop the diameter application.</p> <p> </p> <a name="stop_service"></a> </p></div> <p><a name="stop_service-1"><span class="bold_code">stop_service(SvcName) -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p> Stop a diameter service.</p> <a name="subscribe"></a> </p></div> <p><a name="subscribe-1"><span class="bold_code">subscribe(SvcName) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> </div> <div class="REFBODY"><p> <p> Subscribe to <span class="code">service_event()</span> messages from a service.</p> <p> It is not an error to subscribe to events from a service that does not yet exist.</p> <a name="unsubscribe"></a> </p></div> <p><a name="unsubscribe-1"><span class="bold_code">unsubscribe(SvcName) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">SvcName = service_name()</span><br> </div> </div> <div class="REFBODY"><p> <p> Unsubscribe to event messages from a service.</p> </p></div> <h3><a name="id200478">SEE ALSO</a></h3> <div class="REFBODY"> <p> <span class="bold_code"><a href="diameter_app.html">diameter_app(3)</a></span>, <span class="bold_code"><a href="diameter_transport.html">diameter_transport(3)</a></span>, <span class="bold_code"><a href="diameter_dict.html">diameter_dict(4)</a></span></p> </div> </div> <div class="footer"> <hr> <p>Copyright © 2011-2011 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>