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.
Basic usage consists of creating a representation of a
locally implemented Diameter peer and its capabilities with
Beware the difference between diameter application and Diameter application. 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.
The diameter application must be started before calling functions in this module.
Types corresponding to RFC 3588 AVP Data Formats.
Defined in
A name identifying a Diameter application in
service configuration passed to
Mod = atom()
ExtraArgs = list()
A module implementing the callback interface defined in
Specifying a
Options defining a Diameter application as configured in an
An unique identifier for the application in the scope of the
service.
Optional, defaults to the value of the
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
A callback module with which messages of the Diameter application are
handled.
See
The initial callback state.
Defaults to the value of the
Specifies whether or not the
Note that
Determines the manner in which incoming answer messages containing
decode errors are handled.
If
Defaults to
Options available to
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.
A filter to apply to the list of available peers before passing them to
the
The number of milliseconds after which the request should timeout. Defaults to 5000.
Causes
An invalid option will cause
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.
Value of the Origin-Host AVP in outgoing messages.
Value of the Origin-Realm AVP in outgoing messages.
Values of Host-IP-Address AVPs. Optional.
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
Value of the Vendor-Id AVP sent in an outgoing capabilities exchange message.
Value of the Product-Name AVP sent in an outgoing capabilities exchange message.
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.
Setting a value of
Values of Supported-Vendor-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.
Values of Auth-Application-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.
Values of Inband-Security-Id AVPs sent in an outgoing capabilities exchange message. Optional, 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.
Values of Acct-Application-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.
Values of Vendor-Specific-Application-Id AVPs sent in an outgoing capabilities exchange message. Optional, defaults to the empty list.
Value of the Firmware-Revision AVP sent in an outgoing capabilities exchange message. Optional.
Note that each tuple communicates one or more AVP values. It is an error to specify duplicate tuples.
An expression that can be evaluated as a function in the following sense.
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]).
Applying an evaluable()
Beware of using local funs (that is, fun expressions not of the
form
A filter passed to
Matches any peer. This is a convenience that provides a filter equivalent to no filter at all.
Matches only those peers whose
Matches only those peers whose
Matches only those peers whose
Matches only those peers whose
Matches only those peers for which the specified evaluable() returns
Matches only those peers not matched by the specified filter.
Matches only those peers matched by each filter of the specified list.
Matches only those peers matched by at least one filter of the specified list.
Note that the
An invalid filter is equivalent to
Event message sent to processes that have subscribed using
The
Ref = transport_ref()
Peer = diameter_app:peer()
Config = {connect|listen, [transport_opt()]}
Pkt = #diameter_packet{}
The RFC 3539 watchdog state machine has
transitioned into (
Note that a single up/down event for a given peer corresponds to
as many
Ref = transport_ref()
Opts = [transport_opt()]
A connecting transport is attempting to establish/reestablish a
transport connection with a peer following
Ref = transport_ref()
Config = {connect|listen, [transport_opt()]}
Capabilities exchange has failed.
Result = ResultCode | {capabilities_cb, CB, ResultCode|discard}
Caps = #diameter_caps{}
Pkt = #diameter_packet{}
ResultCode = integer()
CB = evaluable()
An incoming CER has been answered with the indicated result code or discarded. The capabilities record contains pairs of values for the the local node and remote peer. The packet record contains the CER in question. In the case of rejection by a capabilities callback, the tuple indicates the rejecting callback.
ResultCode = integer()
Caps = #diameter_caps{}
Pkt = #diameter_packet{}
An incoming CER contained errors and has been answered with the indicated result code. The capabilities record contains only values for the the local node. The packet record contains the CER in question.
Result = integer() | atom() | {capabilities_cb, CB, ResultCode|discard}
Caps = #diameter_caps{}
Pkt = #diameter_packet{}
ResultCode = integer()
An incoming CEA has been rejected for the indicated reason.
An integer-valued
Caps = #diameter_caps{}
Pkt = #diameter_packet{}
An incoming CER contained errors and has been rejected. The capabilities record contains only values for the the local node. The packet record contains the CEA in question.
For forward compatibility, a subscriber should be prepared to receive info fields of forms other than the above.
The name of a service as passed to
Options accepted by
Defines a Diameter application supported by the service.
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
Options accepted by
A module implementing a transport process as defined in
The interface required of a transport module is documented in
A term passed as the third argument to the
The list of Diameter applications to which usage of the transport should be restricted. Defaults to all applications configured on the service in question.
AVP's used to construct outgoing CER/CEA messages. Any AVP specified takes precedence over a corresponding value specified for the service in question.
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
A 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 transport reference (as returned by
Multiple
TwInit = Unsigned32()
| {M,F,A}
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.
An integer value must be at least 6000 as required by RFC 3539. Defaults to 30000 if unspecified.
Tc = Unsigned32()
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 before 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.
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.
Defaults to 30000 for a connecting transport and 60000 for a listening transport.
Unrecognized options are silently ignored but are returned unmodified
by
Add transport capability to a service.
The service will start a transport process(es) in order to establish a
connection with the peer, either by connecting to the peer
(
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
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.
Send a Diameter request message and possibly return the answer or error.
If there are no suitable peers, or if
There are several error cases which may prevent an
answer from being received and passed to a
If the initial encode of the outgoing request
fails, then the request process fails and
If the request is successfully encoded and sent but
the answer times out then a
If the request is successfully encoded and sent but the service in
question is stopped before an answer is received then a
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
If an encode error takes place during
retransmission then the request process fails and
If an application callback made in processing the request fails
(pick_peer, prepare_request, prepare_retransmit,
handle_answer or handle_error) then either
Note that
Return a reasonable value for use as Origin-State-Id in outgoing messages.
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.
Remove previously added transports.
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
Removing a transport causes all associated transport connections to
be broken.
A base application DPR message with
Disconnect-Cause
Return information about a started service.
Return the list of started services.
Return a value for a Session-Id AVP.
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.
Start the diameter application.
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
Start a diameter service.
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
Stop the diameter application.
Stop a diameter service.
Subscribe to
It is not an error to subscribe to events from a service that does not yet exist.
Unsubscribe to event messages from a service.