2017-09-04 13:13:25 +00:00
|
|
|
#ifndef _GB_PROXY_H
|
|
|
|
#define _GB_PROXY_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <osmocom/core/msgb.h>
|
2020-09-22 11:21:46 +00:00
|
|
|
#include <osmocom/core/timer.h>
|
2020-12-04 23:31:07 +00:00
|
|
|
#include <osmocom/core/hashtable.h>
|
2018-02-20 23:39:36 +00:00
|
|
|
#include <osmocom/gsm/gsm23003.h>
|
2017-09-04 13:13:25 +00:00
|
|
|
|
2020-09-22 11:21:46 +00:00
|
|
|
#include <osmocom/gprs/gprs_ns2.h>
|
2017-09-04 13:13:25 +00:00
|
|
|
#include <osmocom/vty/command.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <regex.h>
|
2019-03-22 08:44:42 +00:00
|
|
|
#include <stdbool.h>
|
2017-09-04 13:13:25 +00:00
|
|
|
|
|
|
|
#define GBPROXY_INIT_VU_GEN_TX 256
|
|
|
|
|
2020-12-02 18:33:50 +00:00
|
|
|
/* BVCI uses 16 bits */
|
|
|
|
#define BVC_LOG_CTX_FLAG (1<<17)
|
|
|
|
|
2017-09-04 13:13:25 +00:00
|
|
|
struct rate_ctr_group;
|
|
|
|
struct gprs_gb_parse_context;
|
|
|
|
struct tlv_parsed;
|
|
|
|
|
|
|
|
enum gbproxy_global_ctr {
|
|
|
|
GBPROX_GLOB_CTR_INV_BVCI,
|
|
|
|
GBPROX_GLOB_CTR_INV_LAI,
|
|
|
|
GBPROX_GLOB_CTR_INV_RAI,
|
|
|
|
GBPROX_GLOB_CTR_INV_NSEI,
|
|
|
|
GBPROX_GLOB_CTR_PROTO_ERR_BSS,
|
|
|
|
GBPROX_GLOB_CTR_PROTO_ERR_SGSN,
|
|
|
|
GBPROX_GLOB_CTR_NOT_SUPPORTED_BSS,
|
|
|
|
GBPROX_GLOB_CTR_NOT_SUPPORTED_SGSN,
|
|
|
|
GBPROX_GLOB_CTR_RESTART_RESET_SGSN,
|
|
|
|
GBPROX_GLOB_CTR_TX_ERR_SGSN,
|
|
|
|
GBPROX_GLOB_CTR_OTHER_ERR,
|
|
|
|
};
|
|
|
|
|
2020-12-04 21:24:47 +00:00
|
|
|
enum gbproxy_bvc_ctr {
|
2017-09-04 13:13:25 +00:00
|
|
|
GBPROX_PEER_CTR_BLOCKED,
|
|
|
|
GBPROX_PEER_CTR_UNBLOCKED,
|
|
|
|
GBPROX_PEER_CTR_DROPPED,
|
|
|
|
GBPROX_PEER_CTR_INV_NSEI,
|
|
|
|
GBPROX_PEER_CTR_TX_ERR,
|
|
|
|
GBPROX_PEER_CTR_LAST,
|
|
|
|
};
|
|
|
|
|
2019-03-22 07:26:45 +00:00
|
|
|
/* global gb-proxy configuration */
|
2017-09-04 13:13:25 +00:00
|
|
|
struct gbproxy_config {
|
|
|
|
/* parsed from config file */
|
|
|
|
uint16_t nsip_sgsn_nsei;
|
|
|
|
|
2019-03-22 07:26:45 +00:00
|
|
|
/* NS instance of libosmogb */
|
2020-09-22 11:21:46 +00:00
|
|
|
struct gprs_ns2_inst *nsi;
|
2017-09-04 13:13:25 +00:00
|
|
|
|
2020-12-04 22:58:20 +00:00
|
|
|
/* Linked list of all BSS side Gb peers */
|
2020-12-04 23:31:07 +00:00
|
|
|
DECLARE_HASHTABLE(bss_nses, 8);
|
2017-09-04 13:13:25 +00:00
|
|
|
|
|
|
|
/* Counter */
|
|
|
|
struct rate_ctr_group *ctrg;
|
|
|
|
};
|
|
|
|
|
2020-11-26 17:19:21 +00:00
|
|
|
/* One BVC inside an NSE */
|
2020-12-04 21:24:47 +00:00
|
|
|
struct gbproxy_bvc {
|
|
|
|
/* linked to gbproxy_nse.bvcs */
|
2020-12-05 09:14:49 +00:00
|
|
|
struct hlist_node list;
|
2017-09-04 13:13:25 +00:00
|
|
|
|
2020-12-04 21:24:47 +00:00
|
|
|
/* The NSE this BVC belongs to */
|
2020-11-26 17:19:21 +00:00
|
|
|
struct gbproxy_nse *nse;
|
2017-09-04 13:13:25 +00:00
|
|
|
|
2020-12-04 21:24:47 +00:00
|
|
|
/* PTP BVCI of this BVC */
|
2017-09-04 13:13:25 +00:00
|
|
|
uint16_t bvci;
|
|
|
|
|
2020-12-04 21:24:47 +00:00
|
|
|
/* Routing Area that this BVC is part of (raw 04.08 encoding) */
|
2017-09-04 13:13:25 +00:00
|
|
|
uint8_t ra[6];
|
|
|
|
|
2020-11-26 17:19:21 +00:00
|
|
|
/* true if this BVC is blocked */
|
|
|
|
bool blocked;
|
|
|
|
|
2017-09-04 13:13:25 +00:00
|
|
|
/* Counter */
|
|
|
|
struct rate_ctr_group *ctrg;
|
|
|
|
};
|
|
|
|
|
2020-12-04 21:24:47 +00:00
|
|
|
/* one NS Entity that we interact with (BSS/PCU) */
|
2020-11-26 17:19:21 +00:00
|
|
|
struct gbproxy_nse {
|
2020-12-04 22:58:20 +00:00
|
|
|
/* linked to gbproxy_config.bss_nses */
|
2020-12-04 23:31:07 +00:00
|
|
|
struct hlist_node list;
|
2020-11-26 17:19:21 +00:00
|
|
|
|
|
|
|
/* point back to the config */
|
|
|
|
struct gbproxy_config *cfg;
|
|
|
|
|
2020-12-04 21:24:47 +00:00
|
|
|
/* NSEI of the NSE */
|
2020-11-26 17:19:21 +00:00
|
|
|
uint16_t nsei;
|
|
|
|
|
|
|
|
/* List of all BVCs in this NSE */
|
2020-12-05 09:14:49 +00:00
|
|
|
DECLARE_HASHTABLE(bvcs, 10);
|
2020-11-26 17:19:21 +00:00
|
|
|
};
|
|
|
|
|
2020-12-01 15:36:29 +00:00
|
|
|
/* Convenience logging macros for NSE/BVC */
|
|
|
|
#define LOGPNSE_CAT(NSE, SUBSYS, LEVEL, FMT, ARGS...) \
|
|
|
|
LOGP(SUBSYS, LEVEL, "NSE(%05u/BSS) " FMT, (NSE)->nsei, ## ARGS)
|
|
|
|
#define LOGPNSE(NSE, LEVEL, FMT, ARGS...) \
|
|
|
|
LOGPNSE_CAT(NSE, DGPRS, LEVEL, FMT, ## ARGS)
|
|
|
|
|
|
|
|
#define LOGPBVC_CAT(BVC, SUBSYS, LEVEL, FMT, ARGS...) \
|
|
|
|
LOGP(SUBSYS, LEVEL, "NSE(%05u/BSS)-BVC(%05u/%s) " FMT, (BVC)->nse->nsei, (BVC)->bvci, \
|
|
|
|
(BVC)->blocked ? "BLOCKED" : "UNBLOCKED", ## ARGS)
|
|
|
|
#define LOGPBVC(BVC, LEVEL, FMT, ARGS...) \
|
|
|
|
LOGPBVC_CAT(BVC, DGPRS, LEVEL, FMT, ## ARGS)
|
2017-09-04 13:13:25 +00:00
|
|
|
|
|
|
|
/* gb_proxy_vty .c */
|
|
|
|
|
|
|
|
int gbproxy_vty_init(void);
|
|
|
|
int gbproxy_parse_config(const char *config_file, struct gbproxy_config *cfg);
|
|
|
|
|
gb_proxy: Add ctrl interface and nsvc-state, gbproxy-state commands
This patch adds a control interface to osmo-gbproxy as well as the first
two commands to query the state of each NSVC and gbproxy peer.
The "nsvc-state" command replies with
nsei, nsvci, local state, role, remote state of all NSVCs.
The "gbproxy-state" command replies with
nsei, bvci, mcc, mnc, lac, rac, and state of each peer.
Entries are separated by a newline '\n' character. If there are no
entries an empty list is returned. This behaviour is similar to that of
the subscriber-list-active-v1 command in osmo-sgsn.
$ ./osmo_ctrl.py -d 127.0.0.1 -p 4263 -g nsvc-state
Got message: b'GET_REPLY 23 nsvc-state 101,101,DEAD,BLOCKED,SGSN,DEAD,UNBLOCKED\n'
$ ./osmo_ctrl.py -d 127.0.0.1 -p 4263 -g gbproxy-state
Got message: b'GET_REPLY 4871085901306801158 gbproxy-state '
Change-Id: I82c74fd0bfcb9ba4ec3619d9fdaa0cae201b3177
Ticket: OS#3281, SYS#4235
Sponsored-by: On-Waves ehf
2018-06-01 05:21:20 +00:00
|
|
|
/* gb_proxy_ctrl.c */
|
|
|
|
int gb_ctrl_cmds_install(void);
|
|
|
|
|
2017-09-04 13:13:25 +00:00
|
|
|
|
|
|
|
/* gb_proxy.c */
|
|
|
|
int gbproxy_init_config(struct gbproxy_config *cfg);
|
|
|
|
|
|
|
|
/* Main input function for Gb proxy */
|
2020-09-22 11:21:46 +00:00
|
|
|
int gbprox_rcvmsg(void *ctx, struct msgb *msg);
|
2017-09-04 13:13:25 +00:00
|
|
|
|
|
|
|
int gbprox_signal(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data);
|
|
|
|
|
2020-09-22 11:21:46 +00:00
|
|
|
|
|
|
|
int gprs_ns2_prim_cb(struct osmo_prim_hdr *oph, void *ctx);
|
2017-09-04 13:13:25 +00:00
|
|
|
|
|
|
|
void gbprox_reset(struct gbproxy_config *cfg);
|
|
|
|
|
|
|
|
/* Peer handling */
|
2020-12-04 21:24:47 +00:00
|
|
|
struct gbproxy_bvc *gbproxy_bvc_by_bvci(
|
2017-09-04 13:13:25 +00:00
|
|
|
struct gbproxy_config *cfg, uint16_t bvci);
|
2020-12-04 21:24:47 +00:00
|
|
|
struct gbproxy_bvc *gbproxy_bvc_by_nsei(
|
2017-09-04 13:13:25 +00:00
|
|
|
struct gbproxy_config *cfg, uint16_t nsei);
|
2020-12-04 21:24:47 +00:00
|
|
|
struct gbproxy_bvc *gbproxy_bvc_by_rai(
|
2017-09-04 13:13:25 +00:00
|
|
|
struct gbproxy_config *cfg, const uint8_t *ra);
|
2020-12-04 21:24:47 +00:00
|
|
|
struct gbproxy_bvc *gbproxy_bvc_alloc(struct gbproxy_nse *nse, uint16_t bvci);
|
|
|
|
void gbproxy_bvc_free(struct gbproxy_bvc *bvc);
|
|
|
|
void gbproxy_bvc_move(struct gbproxy_bvc *bvc, struct gbproxy_nse *nse);
|
|
|
|
int gbproxy_cleanup_bvcs(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bvci);
|
2017-09-04 13:13:25 +00:00
|
|
|
|
2020-11-26 17:19:21 +00:00
|
|
|
/* NSE handling */
|
|
|
|
struct gbproxy_nse *gbproxy_nse_alloc(struct gbproxy_config *cfg, uint16_t nsei);
|
|
|
|
void gbproxy_nse_free(struct gbproxy_nse *nse);
|
|
|
|
struct gbproxy_nse *gbproxy_nse_by_nsei(struct gbproxy_config *cfg, uint16_t nsei);
|
|
|
|
struct gbproxy_nse *gbproxy_nse_by_nsei_or_new(struct gbproxy_config *cfg, uint16_t nsei);
|
|
|
|
|
2017-09-04 13:13:25 +00:00
|
|
|
#endif
|