diameter_tcp(3erl)
π
diameter_tcp(3erl) β Erlang Module Definition, but make it bestie-core π
Hey bestie, welcome to the diameter_tcp(3erl) page. This is the Erlang module definition for Diameter transport over TCP, and it's lowkey iconic. π¦
πΈ NAME πΈ
diameter_tcp β Diameter transport over TCP. That's the whole vibe. π
π DESCRIPTION π
This module implements Diameter transport over TCP using gen_tcp(3erl). 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(3erl). TLS security is supported, either as an upgrade following capabilities exchange or at connection establishment. β¨
π¨ Note: thesslapplication is required for TLS and must be started before configuring TLS capability on diameter transports. No cap, getsslrunning first.
β¨ EXPORTS β¨
π start/3 π
start({Type, Ref}, Svc, [Opt]) -> {ok, Pid} | {ok, Pid, [LAddr]} |
{error, Reason}
Types:
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()} |
{accept, Match} | {port, integer()} | {fragment_timer,
infinity | 0..16#FFFFFFFF} | {message_cb, diameter:eval()} |
{sender, boolean()}
SslOpt = {ssl_options, true | list()}
TcpOpt = term()
Match = inet:ip_address() | string() | [Match]
This is the start function required by diameter_transport(3erl). It's literally required, bestie. π«Ά
{raddr, inet:ip_address()}β specifies the remote address for a connecting transport, and it is not valid for a listening transport. π―{rport, integer()}β specifies the remote port for a connecting transport, and it is not valid for a listening transport. π{accept, Match}β specifies remote addresses for a listening transport, and it is not valid for a connecting transport. If specified, a remote address that does not match one of the specified addresses causes the connection to be aborted. Multipleacceptoptions can be specified. A string-valuedMatchthat does not parse as an address is interpreted as a regular expression. π΅οΈββοΈ{port, integer()}β can be specified for a listening transport to specify the local listening port, the default being the standardized3868. Note that the optionipspecifies the local address. π{fragment_timer, infinity | 0..16#FFFFFFFF}β specifies the timeout, in milliseconds, of a timer used to flush messages from the incoming byte stream even if the number of bytes indicated in theMessage Lengthfield of its Diameter Header have not yet been accumulated: such a message is received over the transport interface after two successive timeouts without the reception of additional bytes. Defaults to1000. β³{message_cb, diameter:eval()}β specifies a callback that is invoked on incoming and outgoing messages, that can be used to implement flow control. It is applied to two arguments: an atom indicating the reason for the callback (send,recv, orackafter a completed send), and the message in question (binary()onrecv,binary()ordiameter_packetrecord onsendorack, orfalseonackwhen an incoming request has been discarded). It should return a list of actions and a new callback as tail; eg.[fun cb/3, State]. Valid actions are the atomssendorrecv, to cause a following message-valued action to be sent/received, a message to send/receive (binary()ordiameter_packetrecord), or aboolean()to enable/disable reading on the socket. More than onesend/recv/message sequence can be returned from the same callback, and an initialsend/recvcan be omitted if the same as the value passed as the callback's first argument. Reading is initially enabled, and returningfalsedoes not imply there cannot be subsequentrecvcallbacks since messages may already have been read. An empty tail is equivalent to the prevailing callback. Defaults to a callback equivalent tofun(ack, _) -> []; (_, Msg) -> [Msg] end. π§{sender, boolean()}β specifies whether or not to use a dedicated process for sending outgoing messages, which avoids the possibility of send blocking reception. Defaults tofalse. If set totruethen amessage_cbthat avoids the possibility of messages being queued in the sender process without bound should be configured. π¬{ssl_options, true | list()}β must be specified for a transport that should support TLS: a value oftrueresults in a TLS handshake immediately upon connection establishment whilelist()specifies options to be passed tossl:connect/2orssl:handshake/2after capabilities exchange if TLS is negotiated. π¦
TcpOpt = term() is the catch-all for the rest, bestie β they're covered right here:
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. Note that the option ip specifies the local address. π₯
β οΈ Anssl_optionslist must be specified if and only if the transport in question has setInband-Security-Idto1(TLS), as specified to eitherdiameter:start_service/2ordiameter: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 whenssl_optionshas 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. π
The first element of a non-empty Host-IP-Address list in Svc provides the local IP address if an ip option is not specified. The local address is either returned from start/3 or passed in a connected message over the transport interface. π
π SEE ALSO π
Signed off with π by Ericsson AB β source/version is diameter 2.2.7, and the footer didn't print a date, so we're not inventing one, bestie. diameter_tcp(3erl) out. π«Άβ¨
π¦ where this page comes from
- debian bookworm: erlang-manpages 1:25.2.3+dfsg-1+deb12u1 Β· Apache-2.0
- debian bookworm: erlang-manpages 1:25.2.3+dfsg-1+deb12u4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms