blob: 65ae42b02c286d4c761b80004562cdd86d4e5801 [file] [log] [blame]
Harald Welted27ab242019-07-26 13:45:18 +02001module DIAMETER_CodecPort {
2
3/* Simple DIAMETER Codec Port, translating between raw SCTP primitives with
4 * octetstring payload towards the IPL4asp provider, and DIAMETER primitives
5 * which carry the decoded DIAMETER data types as payload.
6 *
7 * (C) 2019 by Harald Welte <laforge@gnumonks.org>
8 * All rights reserved.
9 *
10 * Released under the terms of GNU General Public License, Version 2 or
11 * (at your option) any later version.
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 */
15
16 import from IPL4asp_PortType all;
17 import from IPL4asp_Types all;
18 import from DIAMETER_Types all;
19
20 type record DIAMETER_RecvFrom {
21 ConnectionId connId,
22 HostName remName,
23 PortNumber remPort,
24 HostName locName,
25 PortNumber locPort,
26 PDU_DIAMETER msg
27 };
28
29 template DIAMETER_RecvFrom t_DIAMETER_RecvFrom(template PDU_DIAMETER msg) := {
30 connId := ?,
31 remName := ?,
32 remPort := ?,
33 locName := ?,
34 locPort := ?,
35 msg := msg
36 }
37
38 type record DIAMETER_Send {
39 ConnectionId connId,
40 PDU_DIAMETER msg
41 }
42
43 template DIAMETER_Send t_DIAMETER_Send(template ConnectionId connId, template PDU_DIAMETER msg) := {
44 connId := connId,
45 msg := msg
46 }
47
48 private function IPL4_to_DIAMETER_RecvFrom(in ASP_RecvFrom pin, out DIAMETER_RecvFrom pout) {
49 pout.connId := pin.connId;
50 pout.remName := pin.remName;
51 pout.remPort := pin.remPort;
52 pout.locName := pin.locName;
53 pout.locPort := pin.locPort;
54 pout.msg := f_DIAMETER_Dec(pin.msg);
55 } with { extension "prototype(fast)" };
56
57 private function DIAMETER_to_IPL4_Send(in DIAMETER_Send pin, out ASP_Send pout) {
58 pout.connId := pin.connId;
59 pout.proto := {
60 sctp := {
61 sinfo_stream := omit,
62 sinfo_ppid := 46, /* plain text Diameter in SCTP DATA */
63 remSocks := omit,
64 assocId := omit
65 }
66 };
67 pout.msg := f_DIAMETER_Enc(pin.msg);
68 } with { extension "prototype(fast)" };
69
70 type port DIAMETER_CODEC_PT message {
71 out DIAMETER_Send;
72 in DIAMETER_RecvFrom,
73 ASP_ConnId_ReadyToRelease,
74 ASP_Event;
75 } with { extension "user IPL4asp_PT
76 out(DIAMETER_Send -> ASP_Send:function(DIAMETER_to_IPL4_Send))
77 in(ASP_RecvFrom -> DIAMETER_RecvFrom: function(IPL4_to_DIAMETER_RecvFrom);
78 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
79 ASP_Event -> ASP_Event: simple)"
80 }
81}