summaryrefslogtreecommitdiffstats
path: root/library/GTP_CodecPort.ttcn
blob: 7a3e755d60f0bbda064684495dfbd3d7ae5ffc8b (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* dual-faced port sitting on top of IPL4_asp UDP to encode/decode GTP */
/* (C) 2017 by Harald Welte <laforge@gnumonks.org */
module GTP_CodecPort {
	import from IPL4asp_PortType all;
	import from IPL4asp_Types all;
	import from GTPC_Types all;
	import from GTPU_Types all;

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

	/* Decoded GTP1C (Control Plane), used in send and receive direction */
	type record Gtp1cUnitdata {
		GtpPeer		peer,
		PDU_GTPC	gtpc
	}

	/* Decoded GTP1U (User Plane), used in send and receive direction */
	type record Gtp1uUnitdata {
		GtpPeer		peer,
		PDU_GTPU	gtpu
	}

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

	private function f_enc_Gtp1cUD(in Gtp1cUnitdata 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_GTPC(in_ud.gtpc);
	} with { extension "prototype(fast)" };

	private function f_dec_Gtp1cUD(in ASP_RecvFrom in_ud, out Gtp1cUnitdata 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_GTPC(in_ud.msg);
	} with { extension "prototype(fast)" };


	/* dual-faced port on top of IPL4asp; ASP_Event passed through transparently */
	type port GTPU_PT message {
		out	Gtp1uUnitdata;
		in	Gtp1uUnitdata,
			ASP_ConnId_ReadyToRelease,
			ASP_Event;
	} with { extension "user IPL4asp_PT
		out(Gtp1uUnitdata -> ASP_SendTo: function(f_enc_Gtp1uUD))
		in(ASP_RecvFrom -> Gtp1uUnitdata: function(f_dec_Gtp1uUD);
		   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
		   ASP_Event -> ASP_Event: simple)" }

	function f_enc_Gtp1uUD(in Gtp1uUnitdata 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_GTPU(in_ud.gtpu);
	} with { extension "prototype(fast)" };

	function f_dec_Gtp1uUD(in ASP_RecvFrom in_ud, out Gtp1uUnitdata 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.gtpu := dec_PDU_GTPU(in_ud.msg);
	} with { extension "prototype(fast)" };

}