diameter_transport(3erl)
πΈ diameter_transport β Diameter transport interface πΈ
Erlang Module Definition, manual name diameter_transport(3erl), and yes bestie, this is the Diameter transport interface. Itβs lowkey iconic because itβs the blueprint every transport module has to follow. π
β¨ NAME β¨
diameter_transportβ the Diameter transport interface. Periodt.
π¦ DESCRIPTION π¦
So, a module that you specify as a transport_module to diameter:add_transport/2 has to implement the interface documented right here. No cap. The interface is two things: a function that diameter uses to start a transport process, and a message interface that the transport process uses to talk to the process that starts it β aka its parent. π«Ά
π DATA TYPES π
message() = binary() | diameter_codec:packet()
A Diameter message as it gets passed over the transport interface. π
For an inbound message from a transport process, a diameter_codec:packet() must contain the received message in its bin field. If itβs an inbound request, any value set in the transport_data field will be passed back to the transport module in the corresponding answer message β unless the sender supplies another value. π
For an outbound message to a transport process, a diameter_codec:packet() has a value other than undefined in its transport_data field, and it has the binary() to send in its bin field. Slay. β¨
π EXPORTS π
β Mod:start({Type, Ref}, Svc, Config) -> {ok, Pid} | {ok, Pid, LAddrs} | {error, Reason}
Types, bestie:
Type = connect | accept
Ref = diameter:transport_ref()
Svc = #diameter_service{}
Config = term()
Pid = pid()
LAddrs = [inet:ip_address()]
Reason = term()
Start a transport process. diameter calls this as a consequence of a call to diameter:add_transport/2, to establish or accept a transport connection respectively. A transport process maintains a connection with a single remote peer. One peer, one vibe. π
Type tells you whether the transport process in question is being started for a connecting transport (Type=connect) or a listening transport (Type=accept). In the latter case, transport processes are started as required to accept connections from multiple peers. π«
Ref is the value that was returned from the call to diameter:add_transport/2 that has lead to starting of a transport process. Yep, that exact ref. π
Svc contains capabilities passed to diameter:start_service/2 and diameter:add_transport/2 β and values passed to the latter override those passed to the former. The newer config wins, periodt. π₯
Config is as passed in the transport_config tuple in the diameter:transport_opt() list passed to diameter:add_transport/2. Keep it cute and keep it exact. π
The start function should use the Host-IP-Address list in Svc and/or Config to select and return an appropriate list of local IP addresses. In the connecting case, the local address list can instead be communicated in a connected message β see MESSAGES below β following connection establishment. In either case, the local address list is used to populate Host-IP-Address AVPs in outgoing capabilities exchange messages if Host-IP-Address is unspecified. π§
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. Thatβs the rules, bestie. π
π¦ MESSAGES π¦
All messages sent over the transport interface are of the form {diameter, term()}. Thatβs the envelope, always. π
π₯ Messages the transport process can expect from its parent
A transport process can expect messages of the following types from its parent.
{diameter, {send, message() | false}}β an outbound Diameter message. The atomfalsecan only be received when request acknowledgements have been requested β see theackmessage below. π{diameter, {close, Pid}}β a request to terminate the transport process after having received DPA in response to DPR. The transport process should exit.Pidis thepid()of the parent process. Bye bestie. π{diameter, {tls, Ref, Type, Bool}}β an indication of whether or not capabilities exchange has selected inband security using TLS.Refis areference()that must be included in the{diameter, {tls, Ref}}reply message to the transportβs parent process (see below).Typeis eitherconnectoracceptdepending on whether the process has been started for a connecting or listening transport respectively.Boolis aboolean()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. No half-vibes handshakes allowed. π
This message is only sent to a transport process over whose Inband-Security-Id configuration has indicated support for TLS. Check the config, iykyk. π
π€ Messages the transport process should send to its parent
A transport process should send messages of the following types to its parent.
{diameter, {self(), connected}}β inform the parent that the transport process withType=accepthas established a connection with the peer. Not sent if the transport process hasType=connect. π{diameter, {self(), connected, Remote}}and{diameter, {self(), connected, Remote, [LocalAddr]}}β inform the parent that the transport process withType=connecthas established a connection with a peer. Not sent if the transport process hasType=accept.Remoteis an arbitrary term that uniquely identifies the remote endpoint to which the transport has connected. ALocalAddrlist has the same semantics as one returned fromstart/3. Remote bestie identified. π{diameter, ack}β request acknowledgements of unanswered requests. A transport process should send this once before passing incoming Diameter messages intodiameter. As a result, every Diameter request passed intodiameterwith arecvmessage (below) will be answered with asendmessage (above), either amessage()for the transport process to send or the atomfalseif the request has been discarded or otherwise not answered. π«Ά
This is to allow a transport process to keep count of the number of incoming request messages that have not yet been answered or discarded, to allow it to regulate the amount of incoming traffic. Both diameter_tcp and diameter_sctp request acknowledgements when a message_cb is configured, turning send/recv message into callbacks that can be used to regulate traffic. Thatβs the traffic-control fantasy, no cap. π₯
{diameter, {recv, message()}}β an inbound Diameter message. Come on in. π¨{diameter, {tls, Ref}}β acknowledgment of a successful TLS handshake.Refis thereference()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. Successful handshake only, bestie. π
π₯ SEE ALSO π₯
π Cute little sign-off: this page is brought to you by Ericsson AB, version diameter 2.2.7, page diameter_transport(3erl). The original footer doesnβt list a date, so no invented date from me β just source/version/page realness. Mwah. π
π¦ 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