Diameter transport over TCP.

This module implements diameter transport over TCP using gen_tcp(3). It can be specified as the value of a transport_module option to diameter:add_transport/2 and implements the behaviour documented in diameter_transport(3). TLS security is supported, both as an upgrade following capabilities exchange as specified by RFC 6733 and at connection establishment as in the current draft standard.

Note that the ssl application is required for TLS and must be started before configuring TLS capability on diameter transports.


start({Type, Ref}, Svc, [Opt]) -> {ok, Pid, [LAddr]} | {error, Reason}

  • Type = connect | accept
  • Ref = diameter:transport_ref()
  • Svc = #diameter_service{}
  • Opt = OwnOpt | SslOpt | TcpOpt
  • Pid = pid()
  • LAddr = inet:ip_address()
  • Reason = term()
  • OwnOpt = {raddr, inet:ip_address()} | {rport, integer()} | {port, integer()}
  • SslOpt = {ssl_options, true | list()}
  • TcpOpt = term()

The start function required by diameter_transport(3).

The only diameter_tcp-specific argument is the options list. Options raddr and rport specify the remote address and port for a connecting transport and are not valid for a listening transport. Option ssl_options must be specified for a transport that should support TLS: a value of true results in a TLS handshake immediately upon connection establishment while list() specifies options to be passed to ssl:connect/2 or ssl:ssl_accept/2 after capabilities exchange if TLS is negotiated. Remaining options are any accepted by ssl:connect/3 or gen_tcp:connect/3 for a connecting transport, or ssl:listen/2 or gen_tcp:listen/2 for a listening transport, depending on whether or not {ssl_options, true} has been specified. Options binary, packet and active cannot be specified. Also, option port can be specified for a listening transport to specify the local listening port, the default being the standardized 3868 if unspecified. Note that the option ip specifies the local address.

An ssl_options list must be specified if and only if the transport in question has set Inband-Security-Id to 1 (TLS), as specified to either diameter:start_service/2 or diameter:add_transport/2, so that the transport process will receive notification of whether or not to commence with a TLS handshake following capabilities exchange. Failing to specify an options list on a TLS-capable transport for which TLS is negotiated will cause TLS handshake to fail. Failing to specify TLS capability when ssl_options has been specified will cause the transport process to wait for a notification that will not be forthcoming, which will eventually cause the RFC 3539 watchdog to take down the connection.

If the #diameter_service{} record has more than one Host-IP-Address and option ip is unspecified then the first of the these addresses is used as the local address.

The returned local address list has length one.