Erlang -- diameter_transport(3)

User's Guide
Reference Manual
Release Notes
PDF
Top

Diameter
Reference Manual
Version 1.2

Expand All
Contract All

Table of Contents

- diameter
  - Top of manual page
  - add_transport/2
  - call/4
  - origin_state_id/0
  - remove_transport/2
  - service_info/2
  - services/0
  - session_id/1
  - start/0
  - start_service/2
  - stop/0
  - stop_service/1
  - subscribe/1
  - unsubscribe/1
- diameterc
- diameter_app
  - Top of manual page
  - Mod:peer_up/3
  - Mod:peer_down/3
  - Mod:pick_peer/4
  - Mod:prepare_request/3
  - Mod:prepare_retransmit/3
  - Mod:handle_answer/4
  - Mod:handle_error/4
  - Mod:handle_request/3
- diameter_dict
- diameter_transport
  - Top of manual page
  - Mod:start/3
- diameter_tcp
  - Top of manual page
  - start/3
- diameter_sctp
  - Top of manual page
  - start/3

# diameter_transport

### MODULE

diameter_transport

### MODULE SUMMARY

Diameter transport interface.

### DESCRIPTION

A module specified as a transport_module to diameter:add_transport/2 must implement the interface documented here. The interface consists of a function with which diameter starts a transport process and a message interface with which the transport process communicates with the process that starts it (aka its parent).

### EXPORTS

Mod:start({Type, Ref}, Svc, Opts) -> {ok, Pid} | {ok, Pid, LAddrs} | {error, Reason}

Types:

Type = connect | accept
Ref = diameter:transport_ref()
Svc = #diameter_service{}
Opts = term()
Pid = pid()
LAddrs = [inet:ip_address()]
Reason = term()

Start a transport process. Called by diameter as a consequence of a call to diameter:add_transport/2 in order to establish or accept a transport connection respectively. A transport process maintains a connection with a single remote peer.

The first argument indicates whether the transport process in question is being started for a connecting (connect) or listening (accept) transport. In the latter case, transport processes are started as required to accept connections from multiple peers. Ref is in each case the same value that was returned from the call to diameter:add_transport/2 that has lead to starting of a transport process.

A transport process must implement the message interface documented below. It should retain the pid of its parent, monitor the parent and terminate if it dies. It should not link to the parent. It should exit if its transport connection with its peer is lost.

The capabilities in the #diameter_service{} record are as passed to diameter:start_service/2 and diameter:add_transport/2, values passed to the latter overriding those passed to the former. The start function should use the Host-IP-Address list and/or Opts to select an appropriate list of local IP addresses, and should return this list if different from the #diameter_service{} addresses. The returned list is used to populate Host-IP-Address AVPs in outgoing capabilities exchange messages, the #diameter_service{} addresses being used otherwise.

### MESSAGES

All messages sent over the transport interface are of the form {diameter, term()}.

A transport process can expect the following messages from diameter.

{diameter, {send, Packet}}

  An outbound Diameter message. Packet can be either binary() (the message to be sent) or a #diameter_packet{} record whose transport_data field contains a value other than undefined and whose bin field contains the binary to send.

{diameter, {close, Pid}}

  A request to close the transport connection. The transport process should terminate after closing the connection. Pid is the pid() of the parent process.

{diameter, {tls, Ref, Type, Bool}}

  Indication of whether or not capabilities exchange has selected inband security using TLS. Ref is a reference() that must be included in the {diameter, {tls, Ref}} reply message to the transport's parent process (see below). Type is either connect or accept depending on whether the process has been started for a connecting or listening transport respectively. Bool is a boolean() indicating whether or not the transport connection should be upgraded to TLS.

  If TLS is requested (Bool=true) then a connecting process should initiate a TLS handshake with the peer and an accepting process should prepare to accept a handshake. A successful handshake should be followed by a {diameter, {tls, Ref}} message to the parent process. A failed handshake should cause the process to exit.

  This message is only sent to a transport process over whose Inband-Security-Id configuration has indicated support for TLS.

A transport process should send the following messages to its parent.

{diameter, {self(), connected}}

  Inform the parent that the transport process with Type=accept has established a connection with the peer. Not sent if the transport process has Type=connect.

{diameter, {self(), connected, Remote}}

  Inform the parent that the transport process with Type=connect has established a connection with a peer. Not sent if the transport process has Type=accept. Remote is an arbitrary term that uniquely identifies the remote endpoint to which the transport has connected.

{diameter, {recv, Packet}}

  An inbound Diameter message. Packet can be either binary() (the received message) or a #diameter_packet{} record whose bin field contains the received binary(). Any value (other than undefined) set in the transport_data field will be passed back with a corresponding answer message in the case that the inbound message is a request unless the sender sets another value. How transport_data is used/interpreted is up to the transport module.

{diameter, {tls, Ref}}

  Acknowledgment of a successful TLS handshake. Ref is the reference() received in the {diameter, {tls, Ref, Type, Bool}} message in response to which the reply is sent. A transport must exit if a handshake is not successful.

### SEE ALSO

diameter_tcp(3), diameter_sctp(3)