Harald Welte | f736559 | 2020-04-15 21:48:45 +0200 | [diff] [blame] | 1 | module UECUPS_Types { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | |
Harald Welte | 432a130 | 2020-04-17 12:52:40 +0200 | [diff] [blame] | 6 | const integer UECUPS_SCTP_PORT := 4268; |
| 7 | |
Harald Welte | f736559 | 2020-04-15 21:48:45 +0200 | [diff] [blame] | 8 | type enumerated UECUPS_AddrType { |
| 9 | IPV4 (1), |
| 10 | IPV6 (2) |
| 11 | }; |
| 12 | |
| 13 | type enumerated UECUPS_Result { |
| 14 | OK (1), |
| 15 | ERR_INVALID_DATA (2), |
| 16 | ERR_NOT_FOUND (3) |
| 17 | }; |
| 18 | |
| 19 | type 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 */ |
| 26 | type 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 | |
| 44 | type record UECUPS_CreateTunRes { |
| 45 | UECUPS_Result result |
| 46 | }; |
| 47 | |
| 48 | /* Destroy an existing GTP-U tunnel in the user plane */ |
| 49 | type 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 | |
| 55 | type record UECUPS_DestroyTunRes { |
| 56 | UECUPS_Result result |
| 57 | }; |
| 58 | |
Harald Welte | 24557a7 | 2020-04-17 22:08:29 +0200 | [diff] [blame] | 59 | /* User requests deaemon to start a program in given network namespace */ |
| 60 | type 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 | }; |
| 69 | type record of charstring charstring_list; |
| 70 | |
| 71 | /* Daemon informs us that a program has been started */ |
| 72 | type record UECUPS_StartProgramRes { |
| 73 | UECUPS_Result result, |
| 74 | integer pid |
| 75 | }; |
| 76 | |
| 77 | /* Daemon informs us that a program has terminated */ |
| 78 | type record UECUPS_ProgramTermInd { |
| 79 | integer pid, |
| 80 | integer exit_code |
| 81 | }; |
| 82 | |
Harald Welte | 0174469 | 2020-04-18 21:00:13 +0200 | [diff] [blame] | 83 | type record UeCUPS_ResetAllState { |
| 84 | }; |
| 85 | |
| 86 | type record UeCUPS_ResetAllStateRes { |
| 87 | UECUPS_Result result |
| 88 | }; |
Harald Welte | 24557a7 | 2020-04-17 22:08:29 +0200 | [diff] [blame] | 89 | |
Harald Welte | f736559 | 2020-04-15 21:48:45 +0200 | [diff] [blame] | 90 | type union PDU_UECUPS { |
| 91 | UECUPS_CreateTun create_tun, |
| 92 | UECUPS_CreateTunRes create_tun_res, |
Harald Welte | 0174469 | 2020-04-18 21:00:13 +0200 | [diff] [blame] | 93 | |
Harald Welte | f736559 | 2020-04-15 21:48:45 +0200 | [diff] [blame] | 94 | UECUPS_DestroyTun destroy_tun, |
Harald Welte | 24557a7 | 2020-04-17 22:08:29 +0200 | [diff] [blame] | 95 | UECUPS_DestroyTunRes destroy_tun_res, |
Harald Welte | 0174469 | 2020-04-18 21:00:13 +0200 | [diff] [blame] | 96 | |
Harald Welte | 24557a7 | 2020-04-17 22:08:29 +0200 | [diff] [blame] | 97 | UECUPS_StartProgram start_program, |
| 98 | UECUPS_StartProgramRes start_program_res, |
Harald Welte | 0174469 | 2020-04-18 21:00:13 +0200 | [diff] [blame] | 99 | UECUPS_ProgramTermInd program_term_ind, |
| 100 | |
| 101 | UeCUPS_ResetAllState reset_all_state, |
| 102 | UeCUPS_ResetAllStateRes reset_all_state_res |
Harald Welte | f736559 | 2020-04-15 21:48:45 +0200 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | |
| 106 | |
| 107 | external function f_enc_PDU_UECUPS(in PDU_UECUPS inp) return octetstring |
| 108 | with { extension "prototype(convert) encode(JSON)" } |
| 109 | external function f_dec_PDU_UECUPS(in octetstring inp) return PDU_UECUPS |
| 110 | with { extension "prototype(convert) decode(JSON)" } |
| 111 | |
| 112 | |
| 113 | private 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 | |
| 122 | private const integer GTP1U_PORT := 2152; |
| 123 | |
| 124 | template (value) UECUPS_SockAddr |
| 125 | ts_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" }; |