2010-05-01 09:28:43 +00:00
|
|
|
#ifndef _GB_PROXY_H
|
|
|
|
#define _GB_PROXY_H
|
|
|
|
|
|
|
|
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/msgb.h>
|
2010-05-01 09:28:43 +00:00
|
|
|
|
2012-06-16 06:59:56 +00:00
|
|
|
#include <osmocom/gprs/gprs_ns.h>
|
2010-05-19 17:45:32 +00:00
|
|
|
#include <osmocom/vty/command.h>
|
2010-05-01 09:28:43 +00:00
|
|
|
|
2014-08-04 09:10:09 +00:00
|
|
|
struct rate_ctr_group;
|
|
|
|
|
2014-05-28 08:59:10 +00:00
|
|
|
enum gbproxy_patch_mode {
|
|
|
|
GBPROX_PATCH_DEFAULT,
|
|
|
|
GBPROX_PATCH_BSSGP, /*!< BSGGP messages only */
|
|
|
|
GBPROX_PATCH_LLC_ATTACH_REQ, /*!< BSSGP and Attach Request */
|
|
|
|
GBPROX_PATCH_LLC_ATTACH, /*!< BSSGP and Attach Request/Response */
|
|
|
|
GBPROX_PATCH_LLC_GMM, /*!< BSSGP and all GMM msgs */
|
2014-05-23 18:48:07 +00:00
|
|
|
GBPROX_PATCH_LLC_GSM, /*!< BSSGP and all GMM and GSM msgs */
|
2014-05-28 08:59:10 +00:00
|
|
|
GBPROX_PATCH_LLC, /*!< BSSGP and all supported LLC msgs */
|
|
|
|
};
|
|
|
|
|
2010-05-01 09:28:43 +00:00
|
|
|
struct gbproxy_config {
|
|
|
|
/* parsed from config file */
|
2011-04-18 15:04:00 +00:00
|
|
|
uint16_t nsip_sgsn_nsei;
|
2010-05-01 09:28:43 +00:00
|
|
|
|
|
|
|
/* misc */
|
|
|
|
struct gprs_ns_inst *nsi;
|
2014-05-19 08:14:58 +00:00
|
|
|
|
2014-08-04 09:10:09 +00:00
|
|
|
/* Linked list of all Gb peers (except SGSN) */
|
|
|
|
struct llist_head bts_peers;
|
|
|
|
|
2014-05-19 08:14:58 +00:00
|
|
|
/* force mcc/mnc */
|
|
|
|
int core_mnc;
|
|
|
|
int core_mcc;
|
2014-05-23 18:48:07 +00:00
|
|
|
uint8_t* core_apn;
|
|
|
|
size_t core_apn_size;
|
2014-06-06 16:49:23 +00:00
|
|
|
char * match_re;
|
2014-05-28 08:59:10 +00:00
|
|
|
enum gbproxy_patch_mode patch_mode;
|
2014-06-06 16:49:23 +00:00
|
|
|
int tlli_max_age;
|
|
|
|
int tlli_max_len;
|
2010-05-01 09:28:43 +00:00
|
|
|
};
|
|
|
|
|
2014-08-04 09:10:09 +00:00
|
|
|
struct gbprox_patch_state {
|
|
|
|
int local_mnc;
|
|
|
|
int local_mcc;
|
|
|
|
|
|
|
|
/* List of TLLIs for which patching is enabled */
|
|
|
|
struct llist_head enabled_tllis;
|
|
|
|
int enabled_tllis_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gbprox_peer {
|
|
|
|
struct llist_head list;
|
|
|
|
|
|
|
|
/* NSEI of the peer entity */
|
|
|
|
uint16_t nsei;
|
|
|
|
|
|
|
|
/* BVCI used for Point-to-Point to this peer */
|
|
|
|
uint16_t bvci;
|
|
|
|
int blocked;
|
|
|
|
|
|
|
|
/* Routeing Area that this peer is part of (raw 04.08 encoding) */
|
|
|
|
uint8_t ra[6];
|
|
|
|
|
|
|
|
/* Counter */
|
|
|
|
struct rate_ctr_group *ctrg;
|
|
|
|
|
|
|
|
struct gbprox_patch_state patch_state;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gbprox_tlli_info {
|
|
|
|
struct llist_head list;
|
|
|
|
|
|
|
|
uint32_t tlli;
|
|
|
|
time_t timestamp;
|
|
|
|
uint8_t *mi_data;
|
|
|
|
size_t mi_data_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-05-03 16:54:58 +00:00
|
|
|
extern struct gbproxy_config gbcfg;
|
2010-05-01 09:28:43 +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.c */
|
2014-08-04 09:10:09 +00:00
|
|
|
int gbproxy_init_config(struct gbproxy_config *cfg);
|
2010-05-01 09:28:43 +00:00
|
|
|
|
|
|
|
/* Main input function for Gb proxy */
|
2013-10-15 10:00:27 +00:00
|
|
|
int gbprox_rcvmsg(struct msgb *msg, uint16_t nsei, uint16_t ns_bvci, uint16_t nsvci);
|
2010-05-01 09:28:43 +00:00
|
|
|
|
2010-05-11 04:34:24 +00:00
|
|
|
int gbprox_signal(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data);
|
2010-05-14 11:53:08 +00:00
|
|
|
|
|
|
|
/* Reset all persistent NS-VC's */
|
|
|
|
int gbprox_reset_persistent_nsvcs(struct gprs_ns_inst *nsi);
|
|
|
|
|
2014-07-07 08:45:59 +00:00
|
|
|
int gbprox_dump_global(FILE *stream, int indent);
|
|
|
|
int gbprox_dump_peers(FILE *stream, int indent);
|
2013-10-24 10:48:55 +00:00
|
|
|
void gbprox_reset();
|
2014-05-23 18:48:07 +00:00
|
|
|
|
|
|
|
char *gbprox_apn_to_str(char *str, const uint8_t *apn_enc, size_t max_chars);
|
|
|
|
int gbprox_str_to_apn(uint8_t *apn_enc, const char *str, size_t max_chars);
|
2014-06-06 16:49:23 +00:00
|
|
|
|
|
|
|
int gbprox_set_patch_filter(const char *filter, const char **err_msg);
|
2014-08-04 09:10:09 +00:00
|
|
|
|
|
|
|
void gbprox_delete_tlli(struct gbprox_peer *peer,
|
|
|
|
struct gbprox_tlli_info *tlli_info);
|
|
|
|
int gbprox_remove_stale_ttlis(struct gbprox_peer *peer, time_t now);
|
|
|
|
int gbprox_cleanup_peers(uint16_t nsei, uint16_t bvci);
|
|
|
|
|
|
|
|
/* tmp */
|
|
|
|
struct rate_ctr_group *get_global_ctrg(void);
|
|
|
|
struct gbprox_peer *peer_by_nsei(uint16_t nsei);
|
2010-05-01 09:28:43 +00:00
|
|
|
#endif
|