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
|
module Iuh_CodecPort {
/* Simple Iuh Codec Port, translating between raw SCTP primitives with
* octetstring payload towards the IPL4asp provider, and Iuh primitives
* which carry the decoded Iuh data types as payload.
*
* (C) 2021 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* Author: Pau Espin Pedrol <pespin@sysmocom.de>
* All rights reserved.
*
* Released under the terms of GNU General Public License, Version 2 or
* (at your option) any later version.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import from IPL4asp_PortType all;
import from IPL4asp_Types all;
import from HNBAP_PDU_Descriptions all;
import from HNBAP_Types all;
import from RUA_PDU_Descriptions all;
import from RUA_Types all;
import from Iuh_Types all;
type record Iuh_RecvFrom {
ConnectionId connId,
HostName remName,
PortNumber remPort,
HostName locName,
PortNumber locPort,
Iuh_PDU msg
};
template Iuh_RecvFrom t_Iuh_RecvFrom(template Iuh_PDU msg) := {
connId := ?,
remName := ?,
remPort := ?,
locName := ?,
locPort := ?,
msg := msg
}
template Iuh_RecvFrom t_Iuh_RecvFrom_HNBAP(template HNBAP_PDU hnbap_msg := ?) := {
connId := ?,
remName := ?,
remPort := ?,
locName := ?,
locPort := ?,
msg := {
hnbap := hnbap_msg
}
}
template Iuh_RecvFrom t_Iuh_RecvFrom_RUA(template RUA_PDU rua_msg := ?) := {
connId := ?,
remName := ?,
remPort := ?,
locName := ?,
locPort := ?,
msg := {
rua := rua_msg
}
}
type record Iuh_Send {
ConnectionId connId,
Iuh_PDU msg
};
template Iuh_Send t_Iuh_Send_HNBAP(template ConnectionId connId, template HNBAP_PDU hnbap_msg) := {
connId := connId,
msg := {
hnbap := hnbap_msg
}
}
template Iuh_Send t_Iuh_Send_RUA(template ConnectionId connId, template RUA_PDU rua_msg) := {
connId := connId,
msg := {
rua := rua_msg
}
}
private function IPL4_to_Iuh_RecvFrom(in ASP_RecvFrom pin, out Iuh_RecvFrom pout) {
pout.connId := pin.connId;
pout.remName := pin.remName;
pout.remPort := pin.remPort;
pout.locName := pin.locName;
pout.locPort := pin.locPort;
select (pin.proto.sctp.sinfo_ppid) {
case (19) {
pout.msg.rua := dec_RUA_PDU(pin.msg);
}
case (20) {
pout.msg.hnbap := dec_HNBAP_PDU(pin.msg);
}
case else {
pout.msg.payload := pin.msg;
}
}
} with { extension "prototype(fast)" };
private function Iuh_to_IPL4_Send(in Iuh_Send pin, out ASP_Send pout) {
var integer sctp_ppid;
if (ischosen(pin.msg.rua)) {
sctp_ppid := 19;
pout.msg := enc_RUA_PDU(pin.msg.rua);
} else if (ischosen(pin.msg.hnbap)) {
sctp_ppid := 20;
pout.msg := enc_HNBAP_PDU(pin.msg.hnbap);
} else { /*TODO: abort?*/
sctp_ppid := 0;
pout.msg := pin.msg.payload;
}
pout.connId := pin.connId;
pout.proto := {
sctp := {
sinfo_stream := omit,
sinfo_ppid := sctp_ppid,
remSocks := omit,
assocId := omit
}
};
} with { extension "prototype(fast)" };
type port Iuh_CODEC_PT message {
out Iuh_Send;
in Iuh_RecvFrom,
ASP_ConnId_ReadyToRelease,
ASP_Event;
} with { extension "user IPL4asp_PT
out(Iuh_Send -> ASP_Send:function(Iuh_to_IPL4_Send))
in(ASP_RecvFrom -> Iuh_RecvFrom: function(IPL4_to_Iuh_RecvFrom);
ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
ASP_Event -> ASP_Event: simple)"
}
}
|