blob: bbd849f856812bc25e7fff5c7715a91614a13891 [file] [log] [blame]
Harald Weltef7365592020-04-15 21:48:45 +02001module UECUPS_Types {
2
3import from General_Types all;
4import from Osmocom_Types all;
5
Harald Welte432a1302020-04-17 12:52:40 +02006const integer UECUPS_SCTP_PORT := 4268;
7
Harald Weltef7365592020-04-15 21:48:45 +02008type enumerated UECUPS_AddrType {
9 IPV4 (1),
10 IPV6 (2)
11};
12
13type enumerated UECUPS_Result {
14 OK (1),
15 ERR_INVALID_DATA (2),
16 ERR_NOT_FOUND (3)
17};
18
19type record UECUPS_SockAddr {
20 UECUPS_AddrType addr_type,
21 OCT4_16n ip,
22 uint16_t Port
23};
24
25/* Create a new GTP-U tunnel in the user plane */
26type record UECUPS_CreateTun {
27 /* TEID in transmit + receive direction */
28 uint32_t tx_teid,
29 uint32_t rx_teid,
30
31 /* user address (allocated inside the tunnel) */
32 UECUPS_AddrType user_addr_type,
33 OCT4_16n user_addr,
34
35 /* GTP endpoint (UDP IP/Port tuples) */
36 UECUPS_SockAddr local_gtp_ep,
37 UECUPS_SockAddr remote_gtp_ep,
38
39 /* TUN device */
40 charstring tun_dev_name,
41 charstring tun_netns_name optional
42};
43
44type record UECUPS_CreateTunRes {
45 UECUPS_Result result
46};
47
48/* Destroy an existing GTP-U tunnel in the user plane */
49type record UECUPS_DestroyTun {
50 /* local GTP endpoint + TEID are sufficient for unique identification */
51 UECUPS_SockAddr local_gtp_ep,
52 uint32_t rx_teid
53};
54
55type record UECUPS_DestroyTunRes {
56 UECUPS_Result result
57};
58
Harald Welte24557a72020-04-17 22:08:29 +020059/* User requests deaemon to start a program in given network namespace */
60type record UECUPS_StartProgram {
61 /* the command to be started (with optional environment entries) */
62 charstring command,
63 charstring_list environment optional,
64 /* user + group to use when starting command */
65 charstring run_as_user,
66 /* network namespace in which to start the command */
67 charstring tun_netns_name optional
68};
69type record of charstring charstring_list;
70
71/* Daemon informs us that a program has been started */
72type record UECUPS_StartProgramRes {
73 UECUPS_Result result,
74 integer pid
75};
76
77/* Daemon informs us that a program has terminated */
78type record UECUPS_ProgramTermInd {
79 integer pid,
80 integer exit_code
81};
82
Harald Welte01744692020-04-18 21:00:13 +020083type record UeCUPS_ResetAllState {
84};
85
86type record UeCUPS_ResetAllStateRes {
87 UECUPS_Result result
88};
Harald Welte24557a72020-04-17 22:08:29 +020089
Harald Weltef7365592020-04-15 21:48:45 +020090type union PDU_UECUPS {
91 UECUPS_CreateTun create_tun,
92 UECUPS_CreateTunRes create_tun_res,
Harald Welte01744692020-04-18 21:00:13 +020093
Harald Weltef7365592020-04-15 21:48:45 +020094 UECUPS_DestroyTun destroy_tun,
Harald Welte24557a72020-04-17 22:08:29 +020095 UECUPS_DestroyTunRes destroy_tun_res,
Harald Welte01744692020-04-18 21:00:13 +020096
Harald Welte24557a72020-04-17 22:08:29 +020097 UECUPS_StartProgram start_program,
98 UECUPS_StartProgramRes start_program_res,
Harald Welte01744692020-04-18 21:00:13 +020099 UECUPS_ProgramTermInd program_term_ind,
100
101 UeCUPS_ResetAllState reset_all_state,
102 UeCUPS_ResetAllStateRes reset_all_state_res
Harald Weltef7365592020-04-15 21:48:45 +0200103};
104
105
106
107external function f_enc_PDU_UECUPS(in PDU_UECUPS inp) return octetstring
108 with { extension "prototype(convert) encode(JSON)" }
109external function f_dec_PDU_UECUPS(in octetstring inp) return PDU_UECUPS
110 with { extension "prototype(convert) decode(JSON)" }
111
112
113private function f_get_addrtype(OCT4_16n addr) return UECUPS_AddrType
114{
115 if (lengthof(addr) == 4) {
116 return IPV4;
117 } else {
118 return IPV6;
119 }
120}
121
122private const integer GTP1U_PORT := 2152;
123
124template (value) UECUPS_SockAddr
125ts_UECUPS_SockAddr(OCT4_16n ip, uint16_t Port := GTP1U_PORT) := {
126 addr_type := f_get_addrtype(ip),
127 ip := ip,
128 Port := Port
129}
130
131
132} with { encode "JSON" };