aboutsummaryrefslogtreecommitdiffstats
path: root/library/GTPv2_CodecPort.ttcn
blob: e9cf57e89c22766acaa5991b78d1e46d94f7573d (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
/* dual-faced port sitting on top of IPL4_asp UDP to encode/decode GTPv2C
 * (C) 2019 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.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */


module GTPv2_CodecPort {
	import from IPL4asp_PortType all;
	import from IPL4asp_Types all;
	import from GTPv2_Types all;

	/* identifies a remote peer (sender or receiver) */
	type record GtpPeer {
		ConnectionId	connId,
		HostName	remName,
		IPL4asp_Types.PortNumber	remPort
	}

	/* Decoded GTP2C (Control Plane), used in send and receive direction */
	type record Gtp2cUnitdata {
		GtpPeer		peer,
		PDU_GTPCv2	gtpc
	}

 	/* Translation port on top of IPL4asp; ASP_Event passed through transparently */
	type port GTPv2C_PT message {
		out	Gtp2cUnitdata;
		in	Gtp2cUnitdata,
			ASP_ConnId_ReadyToRelease,
			ASP_Event;
	} with { extension "user IPL4asp_PT
		out(Gtp2cUnitdata -> ASP_SendTo: function(f_enc_Gtp2cUD))
		in(ASP_RecvFrom -> Gtp2cUnitdata: function(f_dec_Gtp2cUD);
		   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
		   ASP_Event -> ASP_Event: simple)" }

	private function f_enc_Gtp2cUD(in Gtp2cUnitdata in_ud, out ASP_SendTo out_ud) {
		out_ud.connId := in_ud.peer.connId;
		out_ud.remName := in_ud.peer.remName;
		out_ud.remPort := in_ud.peer.remPort;
		out_ud.proto := { udp := {} };
		out_ud.msg := enc_PDU_GTPCv2(in_ud.gtpc);
	} with { extension "prototype(fast)" };

	private function f_dec_Gtp2cUD(in ASP_RecvFrom in_ud, out Gtp2cUnitdata out_ud) {
		out_ud.peer.connId := in_ud.connId;
		out_ud.peer.remName := in_ud.remName;
		out_ud.peer.remPort := in_ud.remPort;
		out_ud.gtpc := dec_PDU_GTPCv2(in_ud.msg);
	} with { extension "prototype(fast)" };

}