diameter_transport(3)
π diameter_transport β Erlang Module Definition β¨
okay bestie, welcome to diameter_transport(3), the manual page for the Diameter transport interface. it's giving "spec document that actually ate" π
πΈ NAME πΈ
diameter_transport β Diameter transport interface. periodt.
π¦ DESCRIPTION π¦
so here's the deal: if you hand a module over as a transport_module to diameter:add_transport/2, that module must 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 lets the transport process talk to the process that started it (aka its parent π«Ά).
π¦ DATA TYPES π¦
message() = binary() | diameter_codec:packet()
that's a Diameter message the way it travels over the transport interface. lowkey important, so let's break it down:
- for an inbound message coming from a transport process, a
diameter_codec:packet()has to have the received message sitting in itsbinfield. and if it's an inbound request, whatever value you set in thetransport_datafield gets passed right back to the transport module in the matching answer message π β unless the sender supplies a different value, in which case, respectfully, that one wins. - for an outbound message going to a transport process, a
diameter_codec:packet()has a value that is notundefinedin itstransport_datafield, and it has thebinary()to send in itsbinfield. that's it, that's the vibe.
π MESSAGES π
every single message sent over the transport interface has the exact form {diameter, term()}. iconic, consistent, we love that for us.
a transport process can expect these message types from its parent π
{diameter, {send, message() | false}}β an outbound Diameter message. the atomfalsecan only show up when request acknowledgements have been requested β go read theackmessage below, iykyk π₯{diameter, {close, Pid}}β a request to terminate the transport process, sent after it's received DPA in response to DPR. the transport process should exit.Pidis thepid()of the parent process.{diameter, {tls, Ref, Type, Bool}}β a heads-up about whether or not capabilities exchange has selected inband security using TLS.Refis areference()that has to be included in the{diameter, {tls, Ref}}reply message to the transport's parent process (see below π).Typeis eitherconnectoraccept, depending on whether the process got started for a connecting or a listening transport respectively.Boolis aboolean()saying 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 get ready 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. like, it's over, go home π
not me reminding you: this message is only sent to a transport process whose Inband-Security-Id configuration has indicated support for TLS. no TLS config, no message, periodt.
and a transport process should send these message types to its parent π
{diameter, {self(), connected}}β tells 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}}
{diameter, {self(), connected, Remote, [LocalAddr]}}β tells 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 the transport has connected to. aLocalAddrlist has the same semantics as one returned fromstart/3π{diameter, ack}β request acknowledgements of unanswered requests. a transport process should send this once before passing incoming Diameter messages into diameter. as a result, every Diameter request passed into diameter with 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.
the whole point is to let a transport process keep count of the number of incoming request messages that have not yet been answered or discarded, so it can regulate the amount of incoming traffic. both diameter_tcp and diameter_sctp request acknowledgements when a message_cb is configured, which turns send/recv messages into callbacks you can use to regulate traffic. cute and functional π
{diameter, {recv, message()}}β an inbound Diameter message. hi bestie π{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. no half measures π«
π SEE ALSO π
diameter_tcp, diameter_sctp β go read those next, bestie.
π₯ FUNCTIONS π₯
π CALLBACKS π
β start/3
starts a transport process. diameter calls this 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. one peer, one process, monogamy π«Ά
Typetells you whether the transport process in question is being started for a connecting (Type=connect) or a listening (Type=accept) transport. in theacceptcase, transport processes get started as required to accept connections from multiple peers.Refis the value that was returned from the call todiameter:add_transport/2that has lead to starting of a transport process.Svccontains capabilities passed todiameter:start_service/2anddiameter:add_transport/2, and values passed to the latter override those passed to the former. later wins, that's the law πConfigis as passed in thetransport_configtuple in thediameter:transport_opt()list passed todiameter:add_transport/2.
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 above β¬οΈ) following connection establishment. either way, the local address list is used to populate Host-IP-Address AVPs in outgoing capabilities exchange messages if Host-IP-Address is unspecified.
okay and this part is mandatory, no skipping: 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. and it should exit if its transport connection with its peer is lost. protect your peace and also protect your parent process, fr fr π§
and that's the whole page, bestie β this one came from Ericsson AB, it's diameter 2.7.2, and it's filed under diameter_transport(3). slay, go implement a transport πβ¨π
π¦ where this page comes from
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms