-Cands = [Peer]
+Candidates = [peer()]
Peer = peer() | false
SvcName = service_name()
State = NewState = state()
@@ -266,11 +267,9 @@ marker="diameter#start_service">diameter:start_service/2.
The candidate peers list will only include those
which are selected by any filter option specified in the call to
-diameter:call/4.
-
+diameter:call/4, and only
+those which have indicated support for the Diameter application in
+question.
The return values false and {false, State} are
@@ -326,13 +325,14 @@ A returned packet() should set the request to be encoded in its
to pass information to the transport module.
Extra arguments passed to diameter:call/4 can be used to
-communicate transport data to the callback.
-
-
-Any returned packet() can set the header field to a
+communicate transport data to the callback.
+A returned packet() can also set the header field to a
diameter_header record in order to specify values that should
-be preserved in the outgoing request.
-A specified message_length is ignored.
+be preserved in the outgoing request, although this should typically
+not be necessary and allows the callback to set header values
+inappropriately.
+A returned length, cmd_code or application_id is
+ignored.
Returning {discard, Reason} causes the request to be aborted
@@ -361,7 +361,7 @@ Invoked to return a request for encoding and retransmission.
Has the same role as prepare_request/3 in the case that
a peer connection is lost an an alternate peer selected but the
-Packet passed to prepare_retransmit/3 is as returned by
+argument packet() is as returned by the initial
prepare_request/3.
@@ -391,10 +391,12 @@ discarded}.
Invoked when an answer message is received from a peer.
The return value is returned from the call to diameter:call/4 for which the
-callback takes place.
+callback takes place unless the detach option was
+specified.
-The decoded answer record is in the msg field of Packet,
+The decoded answer record is in the msg field of the argument
+packet(),
the undecoded binary in the packet field.
Request is the outgoing request message as was returned from
prepare_request/3 or
@@ -414,8 +416,10 @@ By default, an incoming answer message that cannot be successfully
decoded causes the request process in question to fail, causing the
relevant call to diameter:call/4
-to return {error, failure}.
-There is no handle_error/4 callback in this case.
+to return {error, failure} (unless the detach option was
+specified).
+In particular, there is no handle_error/4 callback in this
+case.
Application configuration may change this behaviour as described for
diameter:start_service/2.
@@ -440,7 +444,8 @@ Invoked when an error occurs before an answer message is received from
a peer in response to an outgoing request.
The return value is returned from the call to diameter:call/4 for which the
-callback takes place.
+callback takes place (unless the detach option was
+specified).
Reason timeout indicates that an answer message has not been
@@ -449,8 +454,7 @@ Reason failover indicates
that the transport connection to the peer to which the request has
been sent has been lost but that not alternate node was available,
possibly because a pick_peer/4
-callback returned false.
-
+callback returned false.
@@ -463,40 +467,33 @@ callback returned false.
Packet = packet()
SvcName = term()
Peer = peer()
-Action = Reply | NoReply | Relay | {eval, Action, ContF}
+Action = Reply | {relay, Opts} | discard | {eval, Action, ContF}
Reply = {reply, message()}
- | {protocol_error, ResultCode}
-NoReply = discard
-Relay = {relay, Opts}
-Opts = list()
+ | {protocol_error, 3000..3999}
+Opts = diameter:call_opts()
ContF = diameter:evaluable()
-ResultCode = 3000..3999
-Invoked when a request message is received from a peer.
-
-
+Invoked when a request message is received from a peer.
The application in which the callback takes place (that is, the
callback module as configured with diameter:start_service/2)
is determined by the Application Identifier in the header of the
-incoming Diameter request message, the selected module being the one
+incoming request message, the selected module being the one
whose corresponding dictionary declares
-itself as defining the application in question, or the RFC 3588 relay
-application if the specific application is unsupported but the relay
-application has been advertised.
+itself as defining either the application in question or the Relay
+application.
-The packet() in which the incoming request is communicated has the
-following signature.
+The argument packet() has the following signature.
#diameter_packet{header = #diameter_header{},
avps = [#diameter_avp{}],
msg = record() | undefined,
- errors = [integer() | {integer(), #diameter_avp{}}],
+ errors = ['Unsigned32'() | {'Unsigned32'(), #diameter_avp{}}],
bin = binary(),
transport_data = term()}
@@ -509,12 +506,16 @@ in diameter_dict(4).
-The errors field specifies any non-protocol errors that were
-encountered in decoding the request and can be returned in a
-reply tuple to have diameter set the Result-Code and Failed-AVP
-AVP's appropriately.
-The list is empty if the request has been received in the relay
-application.
+The errors field specifies any Result-Code's identifying errors
+that were encountered in decoding the request.
+In this case diameter will set both Result-Code and
+Failed-AVP AVP's in a returned
+answer message() before sending it to the peer:
+the returned message() need only set any other required AVP's.
+Note that the errors detected by diameter are all of the 5xxx series
+(Permanent Failures).
+The errors list is empty if the request has been received in
+the relay application.
The transport_data field contains an arbitrary term passed into
@@ -525,34 +526,59 @@ sent back to the transport process unless another value is explicitly
specified.
-The semantics of each of the possible return values are as follows.
-(TODO: more.)
+The semantics of each of the possible return values are as follows.
-{reply, Answer}
+{reply, message()}
-
Send the specified answer message to the peer.
-{relay, Opts}
+{protocol_error, 3000..3999}
-
-Relay a request to another peer.
-
-
-{protocol_error, ResultCode}
--
+Send an answer message to the peer containing the specified
+protocol error.
+Equivalent to
+
+{reply, ['answer-message' | Avps]
+
-Send an answer message to the peer containing the specified 3xxx
-protocol error.
+where Avps sets the Origin-Host, Origin-Realm, the specified
+Result-Code and (if the request sent one) Session-Id AVP's.
-RFC 3588 mandates that only answers with a 3xxx series
+Note that RFC 3588 mandates that only answers with a 3xxx series
Result-Code (protocol errors) may set the E bit.
-Returning a non-3xxx value in a {protocol_error, ResultCode}
-tuple will cause the request process in question to fail.
+Returning a non-3xxx value in a protocol_error tuple
+will cause the request process in question to fail.
+
+
+{relay, Opts}
+-
+
+Relay a request to another peer.
+The appropriate Route-Record AVP will be added to the relayed request
+by diameter and pick_peer/4
+and prepare_request/3
+callback will take place just as if diameter:call/4 had been called
+explicitly.
+However, returning a relay tuple also causes the End-to-End
+Identifier to be preserved in the header of the relayed request as
+required by RFC 3588.
+
+
+The returned Opts should not specify detach and
+the handle_answer/4
+callback following from a relayed request must return its first
+argument, the diameter_packet record containing the answer
+message.
+Note that the extra option can be specified to supply arguments
+that can distinguish the relay case from others if so desired,
+although the form of the request message may be sufficient.
discard
@@ -565,14 +591,14 @@ Discard the request.
-
Handle the request as if Action has been returned and then
-evaluate the evaluable() ContF in the request process.
+evaluate ContF in the request process.
Note that diameter will respond to protocol errors in an incoming
-request without invoking the a handle_request/3 callback.
+request without invoking handle_request/3.