Diameter transport interface.

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).


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

  • Type = connect | accept
  • Ref = reference()
  • Svc = #diameter_service{}
  • Opts = term()
  • Pid = pid()
  • LAddrs = [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.

Transport processes for a given service are started sequentially.

The start function should use the 'Host-IP-Address' list on the service, namely Svc#diameter_service.host_ip_address, and/or Opts to select an appropriate list of local IP addresses, and should return this list if different from the service addresses. The returned list is used to populate 'Host-IP-Address' AVPs in outgoing capabilities exchange messages, the service addresses being used otherwise.


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{} whose transport_data field containes a value other than undefined.

{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.

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 message to be sent) or #diameter_packet{} whose packet field contains a 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 the transport_data is used/interpreted is up to the transport module.

View Functions