Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 1 | /*! \file gprs_ns2_internal.h */ |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include <stdbool.h> |
| 6 | #include <stdint.h> |
| 7 | |
| 8 | #include <osmocom/gprs/protocol/gsm_08_16.h> |
| 9 | #include <osmocom/gprs/gprs_ns2.h> |
| 10 | |
Harald Welte | f294974 | 2021-01-20 14:54:14 +0100 | [diff] [blame] | 11 | #define LOGNSE(nse, lvl, fmt, args ...) \ |
| 12 | LOGP(DLNS, lvl, "NSE(%05u) " fmt, (nse)->nsei, ## args) |
| 13 | |
| 14 | #define LOGBIND(bind, lvl, fmt, args ...) \ |
| 15 | LOGP(DLNS, lvl, "BIND(%s) " fmt, (bind)->name, ## args) |
| 16 | |
| 17 | |
| 18 | #define LOGNSVC(nsvc, lvl, fmt, args ...) \ |
| 19 | do { \ |
| 20 | if ((nsvc)->nsvci_is_valid) { \ |
| 21 | LOGP(DLNS, lvl, "NSE(%05u)-NSVC(%05u) " fmt, \ |
| 22 | (nsvc)->nse->nsei, (nsvc)->nsvci, ## args); \ |
| 23 | } else { \ |
| 24 | LOGP(DLNS, lvl, "NSE(%05u)-NSVC(none) " fmt, \ |
| 25 | (nsvc)->nse->nsei, ## args); \ |
| 26 | } \ |
| 27 | } while (0) |
| 28 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 29 | struct osmo_fsm_inst; |
| 30 | struct tlv_parsed; |
| 31 | struct vty; |
| 32 | |
| 33 | struct gprs_ns2_vc_driver; |
| 34 | struct gprs_ns2_vc_bind; |
| 35 | |
Alexander Couzens | 90ee963 | 2020-12-07 06:18:32 +0100 | [diff] [blame] | 36 | #define NS_TIMERS_COUNT 10 |
Harald Welte | 3a44d17 | 2020-12-16 12:02:51 +0100 | [diff] [blame] | 37 | #define NS_TIMERS "(tns-block|tns-block-retries|tns-reset|tns-reset-retries|tns-test|tns-alive|tns-alive-retries|tsns-prov|tsns-size-retries|tsns-config-retries)" |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 38 | #define NS_TIMERS_HELP \ |
| 39 | "(un)blocking Timer (Tns-block) timeout\n" \ |
| 40 | "(un)blocking Timer (Tns-block) number of retries\n" \ |
| 41 | "Reset Timer (Tns-reset) timeout\n" \ |
| 42 | "Reset Timer (Tns-reset) number of retries\n" \ |
| 43 | "Test Timer (Tns-test) timeout\n" \ |
| 44 | "Alive Timer (Tns-alive) timeout\n" \ |
| 45 | "Alive Timer (Tns-alive) number of retries\n" \ |
Alexander Couzens | 90ee963 | 2020-12-07 06:18:32 +0100 | [diff] [blame] | 46 | "SNS Provision Timer (Tsns-prov) timeout\n" \ |
| 47 | "SNS Size number of retries\n" \ |
| 48 | "SNS Config number of retries\n" \ |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 49 | |
| 50 | /* Educated guess - LLC user payload is 1500 bytes plus possible headers */ |
| 51 | #define NS_ALLOC_SIZE 3072 |
| 52 | #define NS_ALLOC_HEADROOM 20 |
| 53 | |
| 54 | enum ns2_timeout { |
| 55 | NS_TOUT_TNS_BLOCK, |
| 56 | NS_TOUT_TNS_BLOCK_RETRIES, |
| 57 | NS_TOUT_TNS_RESET, |
| 58 | NS_TOUT_TNS_RESET_RETRIES, |
| 59 | NS_TOUT_TNS_TEST, |
| 60 | NS_TOUT_TNS_ALIVE, |
| 61 | NS_TOUT_TNS_ALIVE_RETRIES, |
| 62 | NS_TOUT_TSNS_PROV, |
Alexander Couzens | 90ee963 | 2020-12-07 06:18:32 +0100 | [diff] [blame] | 63 | NS_TOUT_TSNS_SIZE_RETRIES, |
| 64 | NS_TOUT_TSNS_CONFIG_RETRIES, |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | enum nsvc_timer_mode { |
| 68 | /* standard timers */ |
| 69 | NSVC_TIMER_TNS_TEST, |
| 70 | NSVC_TIMER_TNS_ALIVE, |
| 71 | NSVC_TIMER_TNS_RESET, |
| 72 | _NSVC_TIMER_NR, |
| 73 | }; |
| 74 | |
Harald Welte | 7634607 | 2021-01-31 11:54:02 +0100 | [diff] [blame] | 75 | enum ns2_vc_stat { |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 76 | NS_STAT_ALIVE_DELAY, |
| 77 | }; |
| 78 | |
Harald Welte | 7634607 | 2021-01-31 11:54:02 +0100 | [diff] [blame] | 79 | enum ns2_bind_stat { |
| 80 | NS2_BIND_STAT_BACKLOG_LEN, |
| 81 | }; |
| 82 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 83 | /*! Osmocom NS2 VC create status */ |
Alexander Couzens | ba5a992 | 2021-01-25 16:03:23 +0100 | [diff] [blame] | 84 | enum ns2_cs { |
| 85 | NS2_CS_CREATED, /*!< A NSVC object has been created */ |
| 86 | NS2_CS_FOUND, /*!< A NSVC object has been found */ |
| 87 | NS2_CS_REJECTED, /*!< Rejected and answered message */ |
| 88 | NS2_CS_SKIPPED, /*!< Skipped message */ |
| 89 | NS2_CS_ERROR, /*!< Failed to process message */ |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 90 | }; |
| 91 | |
Harald Welte | 3d5eaee | 2021-01-30 21:33:02 +0100 | [diff] [blame] | 92 | enum ns_ctr { |
| 93 | NS_CTR_PKTS_IN, |
| 94 | NS_CTR_PKTS_OUT, |
Harald Welte | f22ae5a | 2021-01-30 22:01:28 +0100 | [diff] [blame] | 95 | NS_CTR_PKTS_OUT_DROP, |
Harald Welte | 3d5eaee | 2021-01-30 21:33:02 +0100 | [diff] [blame] | 96 | NS_CTR_BYTES_IN, |
| 97 | NS_CTR_BYTES_OUT, |
Harald Welte | f22ae5a | 2021-01-30 22:01:28 +0100 | [diff] [blame] | 98 | NS_CTR_BYTES_OUT_DROP, |
Harald Welte | 3d5eaee | 2021-01-30 21:33:02 +0100 | [diff] [blame] | 99 | NS_CTR_BLOCKED, |
Harald Welte | b40bf8b | 2021-01-30 22:43:01 +0100 | [diff] [blame] | 100 | NS_CTR_UNBLOCKED, |
Harald Welte | 3d5eaee | 2021-01-30 21:33:02 +0100 | [diff] [blame] | 101 | NS_CTR_DEAD, |
| 102 | NS_CTR_REPLACED, |
| 103 | NS_CTR_NSEI_CHG, |
| 104 | NS_CTR_INV_VCI, |
| 105 | NS_CTR_INV_NSEI, |
| 106 | NS_CTR_LOST_ALIVE, |
| 107 | NS_CTR_LOST_RESET, |
| 108 | }; |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 109 | |
| 110 | #define NSE_S_BLOCKED 0x0001 |
| 111 | #define NSE_S_ALIVE 0x0002 |
| 112 | #define NSE_S_RESET 0x0004 |
| 113 | |
| 114 | #define NS_DESC_B(st) ((st) & NSE_S_BLOCKED ? "BLOCKED" : "UNBLOCKED") |
| 115 | #define NS_DESC_A(st) ((st) & NSE_S_ALIVE ? "ALIVE" : "DEAD") |
| 116 | #define NS_DESC_R(st) ((st) & NSE_S_RESET ? "RESET" : "UNRESET") |
| 117 | |
| 118 | /*! An instance of the NS protocol stack */ |
| 119 | struct gprs_ns2_inst { |
| 120 | /*! callback to the user for incoming UNIT DATA IND */ |
| 121 | osmo_prim_cb cb; |
| 122 | |
| 123 | /*! callback data */ |
| 124 | void *cb_data; |
| 125 | |
| 126 | /*! linked lists of all NSVC binds (e.g. IPv4 bind, but could be also E1 */ |
| 127 | struct llist_head binding; |
| 128 | |
| 129 | /*! linked lists of all NSVC in this instance */ |
| 130 | struct llist_head nse; |
| 131 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 132 | uint16_t timeout[NS_TIMERS_COUNT]; |
| 133 | |
| 134 | /*! workaround for rate counter until rate counter accepts char str as index */ |
Harald Welte | 97ccbf7 | 2021-01-31 11:49:19 +0100 | [diff] [blame] | 135 | uint32_t nsvc_rate_ctr_idx; |
Harald Welte | 7634607 | 2021-01-31 11:54:02 +0100 | [diff] [blame] | 136 | uint32_t bind_rate_ctr_idx; |
Harald Welte | 53a2fde | 2020-12-01 22:21:14 +0100 | [diff] [blame] | 137 | |
| 138 | /*! libmnl netlink socket for link state monitoring */ |
| 139 | struct osmo_mnl *linkmon_mnl; |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 140 | }; |
| 141 | |
Harald Welte | 53a2fde | 2020-12-01 22:21:14 +0100 | [diff] [blame] | 142 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 143 | /*! Structure repesenting a NSE. The BSS/PCU will only have a single NSE, while SGSN has one for each BSS/PCU */ |
| 144 | struct gprs_ns2_nse { |
| 145 | uint16_t nsei; |
| 146 | |
| 147 | /*! entry back to ns2_inst */ |
| 148 | struct gprs_ns2_inst *nsi; |
| 149 | |
| 150 | /*! llist entry for gprs_ns2_inst */ |
| 151 | struct llist_head list; |
| 152 | |
| 153 | /*! llist head to hold all nsvc */ |
| 154 | struct llist_head nsvc; |
| 155 | |
Alexander Couzens | 8a2a1a4 | 2020-12-26 18:00:17 +0100 | [diff] [blame] | 156 | /*! count all active NSVCs */ |
| 157 | int nsvc_count; |
Alexander Couzens | fc3dd1f | 2020-11-19 00:41:47 +0100 | [diff] [blame] | 158 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 159 | /*! true if this NSE was created by VTY or pcu socket) */ |
| 160 | bool persistent; |
| 161 | |
Alexander Couzens | da0a285 | 2020-10-01 23:24:07 +0200 | [diff] [blame] | 162 | /*! true if this NSE wasn't yet alive at all. |
| 163 | * Will be true after the first status ind with NS_AFF_CAUSE_RECOVERY */ |
| 164 | bool first; |
| 165 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 166 | /*! true if this NSE has at least one alive VC */ |
| 167 | bool alive; |
| 168 | |
Alexander Couzens | aac9016 | 2020-11-19 02:44:04 +0100 | [diff] [blame] | 169 | /*! which link-layer are we based on? */ |
| 170 | enum gprs_ns2_ll ll; |
| 171 | |
Alexander Couzens | d923cff | 2020-12-01 01:03:52 +0100 | [diff] [blame] | 172 | /*! which dialect does this NSE speaks? */ |
| 173 | enum gprs_ns2_dialect dialect; |
| 174 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 175 | struct osmo_fsm_inst *bss_sns_fi; |
Harald Welte | 3221f87 | 2021-01-18 14:58:51 +0100 | [diff] [blame] | 176 | |
Alexander Couzens | e052c41 | 2021-02-15 02:10:57 +0100 | [diff] [blame] | 177 | /*! sum of all the data weight of _alive_ NS-VCs */ |
Harald Welte | 3221f87 | 2021-01-18 14:58:51 +0100 | [diff] [blame] | 178 | uint32_t sum_data_weight; |
| 179 | |
Alexander Couzens | e052c41 | 2021-02-15 02:10:57 +0100 | [diff] [blame] | 180 | /*! sum of all the signalling weight of _alive_ NS-VCs */ |
Harald Welte | 3221f87 | 2021-01-18 14:58:51 +0100 | [diff] [blame] | 181 | uint32_t sum_sig_weight; |
Alexander Couzens | 4f1128f | 2021-01-20 17:42:48 +0100 | [diff] [blame] | 182 | |
| 183 | /*! MTU of a NS PDU. This is the lowest MTU of all NSVCs */ |
| 184 | uint16_t mtu; |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | /*! Structure representing a single NS-VC */ |
| 188 | struct gprs_ns2_vc { |
| 189 | /*! list of NS-VCs within NSE */ |
| 190 | struct llist_head list; |
| 191 | |
| 192 | /*! list of NS-VCs within bind, bind is the owner! */ |
| 193 | struct llist_head blist; |
| 194 | |
| 195 | /*! pointer to NS Instance */ |
| 196 | struct gprs_ns2_nse *nse; |
| 197 | |
| 198 | /*! pointer to NS VL bind. bind own the memory of this instance */ |
| 199 | struct gprs_ns2_vc_bind *bind; |
| 200 | |
| 201 | /*! true if this NS was created by VTY or pcu socket) */ |
| 202 | bool persistent; |
| 203 | |
| 204 | /*! uniquely identifies NS-VC if VC contains nsvci */ |
| 205 | uint16_t nsvci; |
| 206 | |
| 207 | /*! signalling weight. 0 = don't use for signalling (BVCI == 0)*/ |
| 208 | uint8_t sig_weight; |
| 209 | |
Alexander Couzens | fc3dd1f | 2020-11-19 00:41:47 +0100 | [diff] [blame] | 210 | /*! signalling packet counter for the load sharing function */ |
| 211 | uint8_t sig_counter; |
| 212 | |
| 213 | /*! data weight. 0 = don't use for user data (BVCI != 0) */ |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 214 | uint8_t data_weight; |
| 215 | |
| 216 | /*! can be used by the bind/driver of the virtual circuit. e.g. ipv4/ipv6/frgre/e1 */ |
| 217 | void *priv; |
| 218 | |
| 219 | bool nsvci_is_valid; |
| 220 | bool sns_only; |
| 221 | |
| 222 | struct rate_ctr_group *ctrg; |
| 223 | struct osmo_stat_item_group *statg; |
| 224 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 225 | enum gprs_ns2_vc_mode mode; |
| 226 | |
| 227 | struct osmo_fsm_inst *fi; |
| 228 | }; |
| 229 | |
| 230 | /*! Structure repesenting a bind instance. E.g. IPv4 listen port. */ |
| 231 | struct gprs_ns2_vc_bind { |
Alexander Couzens | aaa55a6 | 2020-12-03 06:02:03 +0100 | [diff] [blame] | 232 | /*! unique name */ |
| 233 | const char *name; |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 234 | /*! list entry in nsi */ |
| 235 | struct llist_head list; |
| 236 | /*! list of all VC */ |
| 237 | struct llist_head nsvc; |
| 238 | /*! driver private structure */ |
| 239 | void *priv; |
| 240 | /*! a pointer back to the nsi */ |
| 241 | struct gprs_ns2_inst *nsi; |
| 242 | struct gprs_ns2_vc_driver *driver; |
| 243 | |
Alexander Couzens | d923cff | 2020-12-01 01:03:52 +0100 | [diff] [blame] | 244 | bool accept_ipaccess; |
| 245 | bool accept_sns; |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 246 | |
Alexander Couzens | 1c8785d | 2020-12-17 06:58:53 +0100 | [diff] [blame] | 247 | /*! transfer capability in mbit */ |
| 248 | int transfer_capability; |
| 249 | |
Alexander Couzens | 4f1128f | 2021-01-20 17:42:48 +0100 | [diff] [blame] | 250 | /*! MTU of a NS PDU on this bind. */ |
| 251 | uint16_t mtu; |
| 252 | |
Alexander Couzens | aac9016 | 2020-11-19 02:44:04 +0100 | [diff] [blame] | 253 | /*! which link-layer are we based on? */ |
| 254 | enum gprs_ns2_ll ll; |
| 255 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 256 | /*! send a msg over a VC */ |
| 257 | int (*send_vc)(struct gprs_ns2_vc *nsvc, struct msgb *msg); |
| 258 | |
| 259 | /*! free the vc priv data */ |
| 260 | void (*free_vc)(struct gprs_ns2_vc *nsvc); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 261 | |
Alexander Couzens | 22f3471 | 2020-10-02 02:34:39 +0200 | [diff] [blame] | 262 | /*! allow to show information for the vty */ |
| 263 | void (*dump_vty)(const struct gprs_ns2_vc_bind *bind, |
| 264 | struct vty *vty, bool stats); |
Harald Welte | 7634607 | 2021-01-31 11:54:02 +0100 | [diff] [blame] | 265 | |
Alexander Couzens | c470476 | 2021-02-08 23:13:12 +0100 | [diff] [blame] | 266 | /*! the IP-SNS signalling weight when doing dynamic configuration */ |
| 267 | uint8_t sns_sig_weight; |
| 268 | /*! the IP-SNS data weight when doing dynamic configuration */ |
| 269 | uint8_t sns_data_weight; |
| 270 | |
Harald Welte | 7634607 | 2021-01-31 11:54:02 +0100 | [diff] [blame] | 271 | struct osmo_stat_item_group *statg; |
Alexander Couzens | 22f3471 | 2020-10-02 02:34:39 +0200 | [diff] [blame] | 272 | }; |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 273 | |
| 274 | struct gprs_ns2_vc_driver { |
| 275 | const char *name; |
| 276 | void *priv; |
| 277 | void (*free_bind)(struct gprs_ns2_vc_bind *driver); |
| 278 | }; |
| 279 | |
Alexander Couzens | ba5a992 | 2021-01-25 16:03:23 +0100 | [diff] [blame] | 280 | enum ns2_cs ns2_create_vc(struct gprs_ns2_vc_bind *bind, |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 281 | struct msgb *msg, |
Harald Welte | 7d0daac | 2021-03-02 23:08:43 +0100 | [diff] [blame] | 282 | const struct osmo_sockaddr *remote, |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 283 | const char *logname, |
| 284 | struct msgb **reject, |
| 285 | struct gprs_ns2_vc **success); |
| 286 | |
Alexander Couzens | ffd49d0 | 2020-09-24 00:47:17 +0200 | [diff] [blame] | 287 | int ns2_recv_vc(struct gprs_ns2_vc *nsvc, |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 288 | struct msgb *msg); |
| 289 | |
| 290 | struct gprs_ns2_vc *ns2_vc_alloc(struct gprs_ns2_vc_bind *bind, |
| 291 | struct gprs_ns2_nse *nse, |
Alexander Couzens | d923cff | 2020-12-01 01:03:52 +0100 | [diff] [blame] | 292 | bool initiater, |
Harald Welte | 603f404 | 2020-11-29 17:39:19 +0100 | [diff] [blame] | 293 | enum gprs_ns2_vc_mode vc_mode, |
| 294 | const char *id); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 295 | |
Harald Welte | c3aa8f9 | 2021-01-31 11:41:34 +0100 | [diff] [blame] | 296 | int ns2_bind_alloc(struct gprs_ns2_inst *nsi, const char *name, |
| 297 | struct gprs_ns2_vc_bind **result); |
| 298 | |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 299 | struct msgb *ns2_msgb_alloc(void); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 300 | |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 301 | void ns2_sns_write_vty(struct vty *vty, const struct gprs_ns2_nse *nse); |
| 302 | void ns2_sns_dump_vty(struct vty *vty, const char *prefix, const struct gprs_ns2_nse *nse, bool stats); |
Alexander Couzens | bf95f0f | 2020-10-01 22:56:03 +0200 | [diff] [blame] | 303 | void ns2_prim_status_ind(struct gprs_ns2_nse *nse, |
Daniel Willmann | 15c09a8 | 2020-11-03 23:05:43 +0100 | [diff] [blame] | 304 | struct gprs_ns2_vc *nsvc, |
Alexander Couzens | bf95f0f | 2020-10-01 22:56:03 +0200 | [diff] [blame] | 305 | uint16_t bvci, |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 306 | enum gprs_ns2_affecting_cause cause); |
| 307 | void ns2_nse_notify_alive(struct gprs_ns2_vc *nsvc, bool alive); |
Alexander Couzens | 4f1128f | 2021-01-20 17:42:48 +0100 | [diff] [blame] | 308 | void ns2_nse_update_mtu(struct gprs_ns2_nse *nse); |
Harald Welte | 06d9bf9 | 2021-03-05 10:20:11 +0100 | [diff] [blame] | 309 | int ns2_nse_set_dialect(struct gprs_ns2_nse *nse, enum gprs_ns2_dialect dialect); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 310 | |
| 311 | /* message */ |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 312 | int ns2_validate(struct gprs_ns2_vc *nsvc, |
| 313 | uint8_t pdu_type, |
| 314 | struct msgb *msg, |
| 315 | struct tlv_parsed *tp, |
| 316 | uint8_t *cause); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 317 | |
| 318 | /* SNS messages */ |
| 319 | int ns2_tx_sns_ack(struct gprs_ns2_vc *nsvc, uint8_t trans_id, uint8_t *cause, |
| 320 | const struct gprs_ns_ie_ip4_elem *ip4_elems, |
| 321 | unsigned int num_ip4_elems, |
| 322 | const struct gprs_ns_ie_ip6_elem *ip6_elems, |
| 323 | unsigned int num_ip6_elems); |
| 324 | int ns2_tx_sns_config(struct gprs_ns2_vc *nsvc, bool end_flag, |
| 325 | const struct gprs_ns_ie_ip4_elem *ip4_elems, |
| 326 | unsigned int num_ip4_elems, |
| 327 | const struct gprs_ns_ie_ip6_elem *ip6_elems, |
| 328 | unsigned int num_ip6_elems); |
| 329 | int ns2_tx_sns_config_ack(struct gprs_ns2_vc *nsvc, uint8_t *cause); |
| 330 | int ns2_tx_sns_size(struct gprs_ns2_vc *nsvc, bool reset_flag, uint16_t max_nr_nsvc, |
| 331 | int ip4_ep_nr, int ip6_ep_nr); |
| 332 | int ns2_tx_sns_size_ack(struct gprs_ns2_vc *nsvc, uint8_t *cause); |
| 333 | |
| 334 | /* transmit message over a VC */ |
| 335 | int ns2_tx_block(struct gprs_ns2_vc *nsvc, uint8_t cause); |
| 336 | int ns2_tx_block_ack(struct gprs_ns2_vc *nsvc); |
| 337 | |
| 338 | int ns2_tx_reset(struct gprs_ns2_vc *nsvc, uint8_t cause); |
| 339 | int ns2_tx_reset_ack(struct gprs_ns2_vc *nsvc); |
| 340 | |
| 341 | int ns2_tx_unblock(struct gprs_ns2_vc *nsvc); |
| 342 | int ns2_tx_unblock_ack(struct gprs_ns2_vc *nsvc); |
| 343 | |
| 344 | int ns2_tx_alive(struct gprs_ns2_vc *nsvc); |
| 345 | int ns2_tx_alive_ack(struct gprs_ns2_vc *nsvc); |
| 346 | |
| 347 | int ns2_tx_unit_data(struct gprs_ns2_vc *nsvc, |
| 348 | uint16_t bvci, uint8_t sducontrol, |
| 349 | struct msgb *msg); |
| 350 | |
| 351 | int ns2_tx_status(struct gprs_ns2_vc *nsvc, uint8_t cause, |
| 352 | uint16_t bvci, struct msgb *orig_msg); |
| 353 | |
| 354 | /* driver */ |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 355 | struct gprs_ns2_vc *ns2_ip_bind_connect(struct gprs_ns2_vc_bind *bind, |
| 356 | struct gprs_ns2_nse *nse, |
| 357 | const struct osmo_sockaddr *remote); |
Alexander Couzens | e769f52 | 2020-12-07 07:37:07 +0100 | [diff] [blame] | 358 | int ns2_ip_count_bind(struct gprs_ns2_inst *nsi, struct osmo_sockaddr *remote); |
| 359 | struct gprs_ns2_vc_bind *ns2_ip_get_bind_by_index(struct gprs_ns2_inst *nsi, |
| 360 | struct osmo_sockaddr *remote, |
| 361 | int index); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 362 | |
| 363 | /* sns */ |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 364 | int ns2_sns_rx(struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 365 | struct osmo_fsm_inst *ns2_sns_bss_fsm_alloc(struct gprs_ns2_nse *nse, |
| 366 | const char *id); |
Alexander Couzens | be7cecc | 2021-02-03 18:25:27 +0100 | [diff] [blame] | 367 | void ns2_sns_replace_nsvc(struct gprs_ns2_vc *nsvc); |
| 368 | void ns2_sns_notify_alive(struct gprs_ns2_nse *nse, struct gprs_ns2_vc *nsvc, bool alive); |
Alexander Couzens | c470476 | 2021-02-08 23:13:12 +0100 | [diff] [blame] | 369 | void ns2_sns_update_weights(struct gprs_ns2_vc_bind *bind); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 370 | |
| 371 | /* vc */ |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 372 | struct osmo_fsm_inst *ns2_vc_fsm_alloc(struct gprs_ns2_vc *nsvc, |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 373 | const char *id, bool initiate); |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 374 | int ns2_vc_fsm_start(struct gprs_ns2_vc *nsvc); |
| 375 | int ns2_vc_force_unconfigured(struct gprs_ns2_vc *nsvc); |
| 376 | int ns2_vc_rx(struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp); |
| 377 | int ns2_vc_is_alive(struct gprs_ns2_vc *nsvc); |
| 378 | int ns2_vc_is_unblocked(struct gprs_ns2_vc *nsvc); |
Alexander Couzens | 47afc42 | 2021-01-17 20:12:46 +0100 | [diff] [blame] | 379 | int ns2_vc_block(struct gprs_ns2_vc *nsvc); |
| 380 | int ns2_vc_unblock(struct gprs_ns2_vc *nsvc); |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 381 | |
Alexander Couzens | 6a16149 | 2020-07-12 13:45:50 +0200 | [diff] [blame] | 382 | /* nse */ |
| 383 | void ns2_nse_notify_unblocked(struct gprs_ns2_vc *nsvc, bool unblocked); |
Alexander Couzens | 8dfc24c | 2021-01-25 16:09:23 +0100 | [diff] [blame] | 384 | enum gprs_ns2_vc_mode ns2_dialect_to_vc_mode(enum gprs_ns2_dialect dialect); |
Alexander Couzens | 1c8785d | 2020-12-17 06:58:53 +0100 | [diff] [blame] | 385 | int ns2_count_transfer_cap(struct gprs_ns2_nse *nse, |
| 386 | uint16_t bvci); |