aboutsummaryrefslogtreecommitdiffstats
path: root/library/SABP_CodecPort.ttcn
blob: 65fb54208804b3c73c1e0b0dadd00bd35bf8274a (plain)
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
module SABP_CodecPort {

/* Simple SABP Codec Port, translating between raw TCP octetstring payload
 * towards the IPL4asp port provider, and SABP primitives
 * which carry the decoded SABP data types as payload.
 *
 * (C) 2019 by Harald Welte <laforge@gnumonks.org>
 * All rights reserved.
 *
 * Released under the terms of GNU General Public License, Version 2 or
 * (at your option) any later version.
 */


import from IPL4asp_PortType all;
import from IPL4asp_Types all;
import from SABP_PDU_Descriptions all;
import from SABP_Types all;

type record SABP_RecvFrom {
	ConnectionId	connId,
	SABP_PDU	msg
}

type record SABP_Send {
	ConnectionId	connId,
	SABP_PDU	msg
}

template (value) SABP_Send ts_SABP_Send(ConnectionId conn_id, template (value) SABP_PDU msg) := {
	connId := conn_id,
	msg := msg
}

template SABP_RecvFrom tr_SABP_Recv(template ConnectionId conn_id, template SABP_PDU msg) := {
	connId := conn_id,
	msg := msg
}

private function IPL4_to_SABP_RecvFrom(in ASP_RecvFrom pin, out SABP_RecvFrom pout) {
	pout.connId := pin.connId;
	pout.msg := dec_SABP_PDU(pin.msg);
} with { extension "prototype(fast)" }

private function SABP_to_IPL4_Send(in SABP_Send pin, out ASP_Send pout) {
	pout.connId := pin.connId;
	pout.proto := { tcp := {} };
	pout.msg := enc_SABP_PDU(pin.msg);
} with { extension "prototype(fast)" }

type port SABP_CODEC_PT message {
	out	SABP_Send;
	in	SABP_RecvFrom,
		ASP_ConnId_ReadyToRelease,
		ASP_Event;
} with { extension "user IPL4asp_PT
	out(SABP_Send -> ASP_Send: function(SABP_to_IPL4_Send))
	in(ASP_RecvFrom -> SABP_RecvFrom: function(IPL4_to_SABP_RecvFrom);
	   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
	   ASP_Event -> ASP_Event: simple)"
}



}