2010-03-14 07:45:01 +00:00
|
|
|
#ifndef _GPRS_SGSN_H
|
|
|
|
#define _GPRS_SGSN_H
|
|
|
|
|
2010-05-02 09:26:34 +00:00
|
|
|
#include <stdint.h>
|
2010-05-17 20:58:03 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include <osmocore/gsm48.h>
|
2010-05-02 09:26:34 +00:00
|
|
|
|
2010-05-16 22:44:57 +00:00
|
|
|
#define GSM_IMSI_LENGTH 17
|
|
|
|
#define GSM_IMEI_LENGTH 17
|
|
|
|
#define GSM_EXTENSION_LENGTH 15
|
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
/* TS 04.08 4.1.3.3 GMM mobility management states on the network side */
|
|
|
|
enum gprs_mm_state {
|
|
|
|
GMM_DEREGISTERED, /* 4.1.3.3.1.1 */
|
|
|
|
GMM_COMMON_PROC_INIT, /* 4.1.3.3.1.2 */
|
|
|
|
GMM_REGISTERED_NORMAL, /* 4.1.3.3.2.1 */
|
|
|
|
GMM_REGISTERED_SUSPENDED, /* 4.1.3.3.2.2 */
|
|
|
|
GMM_DEREGISTERED_INIT, /* 4.1.3.3.1.4 */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum gprs_ciph_algo {
|
|
|
|
GPRS_ALGO_GEA0,
|
|
|
|
GPRS_ALGO_GEA1,
|
|
|
|
GPRS_ALGO_GEA2,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MS_RADIO_ACCESS_CAPA
|
|
|
|
|
|
|
|
/* According to TS 03.60, Table 5: SGSN MM and PDP Contexts */
|
2010-05-01 14:45:46 +00:00
|
|
|
/* Extended by 3GPP TS 23.060, Table 6: SGSN MM and PDP Contexts */
|
2010-03-14 07:45:01 +00:00
|
|
|
struct sgsn_mm_ctx {
|
|
|
|
struct llist_head list;
|
|
|
|
|
|
|
|
char imsi[GSM_IMSI_LENGTH];
|
|
|
|
enum gprs_mm_state mm_state;
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t p_tmsi;
|
|
|
|
uint32_t p_tmsi_sig;
|
2010-03-14 07:45:01 +00:00
|
|
|
char imei[GSM_IMEI_LENGTH];
|
2010-05-01 14:45:46 +00:00
|
|
|
/* Opt: Software Version Numbber / TS 23.195 */
|
2010-03-14 07:45:01 +00:00
|
|
|
char msisdn[GSM_EXTENSION_LENGTH];
|
|
|
|
struct gprs_ra_id ra;
|
2010-05-02 09:26:34 +00:00
|
|
|
uint16_t cell_id;
|
|
|
|
uint32_t cell_id_age;
|
|
|
|
uint16_t sac; /* Iu: Service Area Code */
|
|
|
|
uint32_t sac_age;/* Iu: Service Area Code age */
|
2010-03-14 07:45:01 +00:00
|
|
|
/* VLR number */
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t new_sgsn_addr;
|
2010-03-14 07:45:01 +00:00
|
|
|
/* Authentication Triplets */
|
|
|
|
/* Kc */
|
2010-05-01 14:45:46 +00:00
|
|
|
/* Iu: CK, IK, KSI */
|
2010-03-14 07:45:01 +00:00
|
|
|
/* CKSN */
|
|
|
|
enum gprs_ciph_algo ciph_algo;
|
|
|
|
struct {
|
2010-05-02 09:26:34 +00:00
|
|
|
uint8_t buf[14]; /* 10.5.5.12a */
|
|
|
|
uint8_t len;
|
2010-03-14 07:45:01 +00:00
|
|
|
} ms_radio_access_capa;
|
|
|
|
struct {
|
2010-05-02 09:26:34 +00:00
|
|
|
uint8_t buf[4]; /* 10.5.5.12 */
|
|
|
|
uint8_t len;
|
2010-03-14 07:45:01 +00:00
|
|
|
} ms_network_capa;
|
2010-05-02 09:26:34 +00:00
|
|
|
uint16_t drx_parms;
|
2010-03-14 07:45:01 +00:00
|
|
|
int mnrg; /* MS reported to HLR? */
|
|
|
|
int ngaf; /* MS reported to MSC/VLR? */
|
|
|
|
int ppf; /* paging for GPRS + non-GPRS? */
|
|
|
|
/* SMS Parameters */
|
|
|
|
int recovery;
|
2010-05-02 12:40:32 +00:00
|
|
|
uint8_t radio_prio_sms;
|
2010-03-14 07:45:01 +00:00
|
|
|
|
|
|
|
struct llist_head pdp_list;
|
|
|
|
|
|
|
|
/* Additional bits not present in the GSM TS */
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t tlli;
|
2010-03-14 07:45:01 +00:00
|
|
|
struct timer_list timer;
|
|
|
|
unsigned int T;
|
|
|
|
};
|
|
|
|
|
2010-05-17 20:58:03 +00:00
|
|
|
/* look-up a SGSN MM context based on TLLI + RAI */
|
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli,
|
|
|
|
const struct gprs_ra_id *raid);
|
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_by_ptmsi(uint32_t tmsi);
|
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_by_imsi(const char *imsi);
|
|
|
|
|
|
|
|
/* Allocate a new SGSN MM context */
|
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli,
|
|
|
|
const struct gprs_ra_id *raid);
|
|
|
|
|
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
enum pdp_ctx_state {
|
2010-05-17 20:58:03 +00:00
|
|
|
PDP_STATE_NONE,
|
2010-03-14 07:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum pdp_type {
|
|
|
|
PDP_TYPE_NONE,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sgsn_pdp_ctx {
|
2010-05-17 20:58:03 +00:00
|
|
|
struct llist_head list; /* list_head for mmctx->pdp_list */
|
|
|
|
struct llist_head g_list; /* list_head for global list */
|
|
|
|
struct sgsn_mm_ctx *mm; /* back pointer to MM CTX */
|
|
|
|
struct sgsn_ggsn_ctx *ggsn; /* which GGSN serves this PDP */
|
2010-03-14 07:45:01 +00:00
|
|
|
|
2010-05-17 20:58:03 +00:00
|
|
|
//unsigned int id;
|
|
|
|
struct pdp_t *lib; /* pointer to libgtp PDP ctx */
|
2010-03-14 07:45:01 +00:00
|
|
|
enum pdp_ctx_state state;
|
|
|
|
enum pdp_type type;
|
2010-05-16 22:44:57 +00:00
|
|
|
uint32_t address;
|
2010-03-14 07:45:01 +00:00
|
|
|
char *apn_subscribed;
|
2010-05-17 20:58:03 +00:00
|
|
|
//char *apn_used;
|
2010-05-02 09:26:34 +00:00
|
|
|
uint16_t nsapi;
|
2010-05-02 12:40:32 +00:00
|
|
|
uint8_t ti; /* transaction identifier */
|
2010-03-14 07:45:01 +00:00
|
|
|
int vplmn_allowed;
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t qos_profile_subscr;
|
2010-05-17 20:58:03 +00:00
|
|
|
//uint32_t qos_profile_req;
|
|
|
|
//uint32_t qos_profile_neg;
|
2010-05-02 12:40:32 +00:00
|
|
|
uint8_t radio_prio;
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t tx_npdu_nr;
|
|
|
|
uint32_t rx_npdu_nr;
|
|
|
|
uint32_t tx_gtp_snd;
|
|
|
|
uint32_t rx_gtp_snu;
|
2010-05-17 20:58:03 +00:00
|
|
|
//uint32_t charging_id;
|
2010-03-14 07:45:01 +00:00
|
|
|
int reordering_reqd;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-05-17 20:58:03 +00:00
|
|
|
struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_nsapi(const struct sgsn_mm_ctx *mm,
|
|
|
|
uint8_t nsapi);
|
|
|
|
struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
|
|
|
|
uint8_t nsapi);
|
|
|
|
void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp);
|
|
|
|
|
|
|
|
|
|
|
|
struct ggsn_ctx {
|
|
|
|
struct llist_head list;
|
|
|
|
uint32_t id;
|
|
|
|
unsigned int gtp_version;
|
|
|
|
struct in_addr remote_addr;
|
|
|
|
struct gsn_t *gsn;
|
|
|
|
};
|
|
|
|
struct ggsn_ctx *ggsn_ctx_alloc(uint32_t id);
|
|
|
|
struct ggsn_ctx *ggsn_ctx_by_id(uint32_t id);
|
|
|
|
struct ggsn_ctx *ggsn_ctx_find_alloc(uint32_t id);
|
|
|
|
|
|
|
|
struct apn_ctx {
|
|
|
|
struct llist_head list;
|
|
|
|
struct ggsn_ctx *ggsn;
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct llist_head sgsn_mm_ctxts;
|
|
|
|
extern struct llist_head sgsn_ggsn_ctxts;
|
|
|
|
extern struct llist_head sgsn_apn_ctxts;
|
|
|
|
extern struct llist_head sgsn_pdp_ctxts;
|
2010-03-14 07:45:01 +00:00
|
|
|
|
|
|
|
#endif /* _GPRS_SGSN_H */
|