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
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 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]).
Evaluating 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{}
Reports that the RFC 3539 watchdog state machine has
transitioned into (
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.
Ref = transport_ref()
Opts = [transport_opt()]
A connecting transport is attempting to establish/reestablish a
transport connection with a peer following
For forward compatibility, a subscriber should be prepared to receive
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.
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.