1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd" [
<!ENTITY message '<seealso marker="#message">message()</seealso>'>
<!ENTITY MESSAGES '<seealso marker="#MESSAGES">MESSAGES</seealso>'>
<!ENTITY start '<seealso marker="#Mod:start-3">start/3</seealso>'>
<!ENTITY ip_address
'<seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
%here;
]>
<erlref>
<header>
<copyright>
<year>2011</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
The contents of this file are subject to the Erlang Public License,
Version 1.1, (the "License"); you may not use this file except in
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
</legalnotice>
<title>diameter_transport(3)</title>
<prepared>Anders Svensson</prepared>
<responsible></responsible>
<docno></docno>
<approved></approved>
<checked></checked>
<date></date>
<rev></rev>
<file>diameter_transport.xml</file>
</header>
<module>diameter_transport</module>
<modulesummary>Diameter transport interface.</modulesummary>
<description>
<p>
A module specified as a <c>transport_module</c> to &mod_add_transport;
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).</p>
</description>
<!-- ===================================================================== -->
<section>
<title>DATA TYPES</title>
<taglist>
<marker id="message"/>
<tag><c>message() = binary() | &codec_packet;</c></tag>
<item>
<p>
A Diameter message as passed over the transport interface.</p>
<p>
For an inbound message from a transport process, a &codec_packet; must
contain the received message in its <c>bin</c> field.
In the case of an inbound request, any value set in the
<c>transport_data</c> field will passed back to the transport module
in the corresponding answer message, unless the sender supplies
another value.</p>
<p>
For an outbound message to a transport process, a &codec_packet; has a
value other than <c>undefined</c> in its <c>transport_data</c> field
and has the binary() to send in its <c>bin</c> field.</p>
</item>
</taglist>
</section>
<!-- ===================================================================== -->
<funcs>
<func>
<name>Mod:start({Type, Ref}, Svc, Config)
-> {ok, Pid}
| {ok, Pid, LAddrs}
| {error, Reason}</name>
<fsummary>Start a transport process.</fsummary>
<type>
<v>Type = connect | accept</v>
<v>Ref = &mod_transport_ref;</v>
<v>Svc = #diameter_service{}</v>
<v>Config = term()</v>
<v>Pid = pid()</v>
<v>LAddrs = [&ip_address;]</v>
<v>Reason = term()</v>
</type>
<desc>
<p>
Start a transport process.
Called by diameter as a consequence of a call to &mod_add_transport; in
order to establish or accept a transport connection respectively.
A transport process maintains a connection with a single remote peer.</p>
<p>
<c>Type</c> indicates whether the transport process in question
is being started for a connecting (<c>Type=connect</c>) or listening
(<c>Type=accept</c>) transport.
In the latter case, transport processes are started as required to
accept connections from multiple peers.</p>
<p>
Ref is the value that was returned from the call to &mod_add_transport;
that has lead to starting of a transport process.</p>
<p>
<c>Svc</c> contains capabilities passed to &mod_start_service; and
&mod_add_transport;, values passed to the latter overriding those
passed to the former.</p>
<p>
<c>Config</c> is as passed in <c>transport_config</c> tuple in the
&mod_transport_opt; list passed to &mod_add_transport;.</p>
<p>
The start function should use the <c>Host-IP-Address</c> list in
<c>Svc</c> and/or <c>Config</c> to select an appropriate list of local
IP addresses, and should return this list if different from the
<c>Svc</c> addresses.
In the connecting case, the local address list can instead be
communicated in a <c>connected</c> message (see &MESSAGES; below)
following connection establishment.
In either case, the local address list is used to populate
<c>Host-IP-Address</c> AVPs in outgoing capabilities exchange
messages.</p>
<p>
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.</p>
</desc>
</func>
</funcs>
<!-- ===================================================================== -->
<marker id="MESSAGES"/>
<section>
<title>MESSAGES</title>
<p>
All messages sent over the transport interface are of the
form <c>{diameter, term()}</c>.</p>
<p>
A transport process can expect messages of the following types from
its parent.</p>
<taglist>
<tag><c>{diameter, {send, &message;}}</c></tag>
<item>
<p>
An outbound Diameter message.</p>
</item>
<tag><c>{diameter, {close, Pid}}</c></tag>
<item>
<p>
A request to terminate the transport process after having received DPA
in response to DPR.
The transport process should exit.
<c>Pid</c> is the pid() of the parent process.</p>
</item>
<tag><c>{diameter, {tls, Ref, Type, Bool}}</c></tag>
<item>
<p>
Indication of whether or not capabilities exchange has selected
inband security using TLS.
<c>Ref</c> is a reference() that must be included in the
<c>{diameter, {tls, Ref}}</c> reply message to the transport's
parent process (see below).
<c>Type</c> is either <c>connect</c> or <c>accept</c> depending on
whether the process has been started for a connecting or listening
transport respectively.
<c>Bool</c> is a boolean() indicating whether or not the transport
connection should be upgraded to TLS.</p>
<p>
If TLS is requested (<c>Bool=true</c>) 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 <c>{diameter, {tls, Ref}}</c>
message to the parent process.
A failed handshake should cause the process to exit.</p>
<p>
This message is only sent to a transport process over whose
<c>Inband-Security-Id</c> configuration has indicated support for
TLS.</p>
</item>
</taglist>
<p>
A transport process should send messages of the following types
to its parent.</p>
<taglist>
<tag><c>{diameter, {self(), connected}}</c></tag>
<item>
<p>
Inform the parent that the transport process with <c>Type=accept</c> has
established a connection with the peer.
Not sent if the transport process has <c>Type=connect</c>.</p>
</item>
<tag><c>{diameter, {self(), connected, Remote}}</c></tag>
<tag><c>{diameter, {self(), connected, Remote, [LocalAddr]}}</c></tag>
<item>
<p>
Inform the parent that the transport process with <c>Type=connect</c>
has established a connection with a peer.
Not sent if the transport process has <c>Type=accept</c>.
<c>Remote</c> is an arbitrary term that uniquely identifies the remote
endpoint to which the transport has connected.
A <c>LocalAddr</c> list has the same semantics as one returned from
&start;.</p>
</item>
<tag><c>{diameter, {recv, &message;}}</c></tag>
<item>
<p>
An inbound Diameter message.</p>
</item>
<tag><c>{diameter, {tls, Ref}}</c></tag>
<item>
<p>
Acknowledgment of a successful TLS handshake.
<c>Ref</c> is the reference() received in the
<c>{diameter, {tls, Ref, Type, Bool}}</c> message in response
to which the reply is sent.
A transport must exit if a handshake is not successful.</p>
</item>
</taglist>
</section>
<!-- ===================================================================== -->
<!-- ===================================================================== -->
<section>
<title>SEE ALSO</title>
<p>
&man_tcp;, &man_sctp;</p>
</section>
</erlref>
|