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>
|
|
|
|
|
2018-05-22 16:29:14 +00:00
|
|
|
#include <osmocom/core/fsm.h>
|
2012-01-06 16:29:06 +00:00
|
|
|
#include <osmocom/core/timer.h>
|
|
|
|
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/gsm/gsm48.h>
|
2010-05-02 09:26:34 +00:00
|
|
|
|
2010-06-30 17:59:55 +00:00
|
|
|
#include <osmocom/crypt/gprs_cipher.h>
|
2016-04-20 15:50:17 +00:00
|
|
|
#include <osmocom/gsm/protocol/gsm_23_003.h>
|
2017-07-13 00:03:50 +00:00
|
|
|
#include <osmocom/crypt/auth.h>
|
2014-12-01 11:33:33 +00:00
|
|
|
|
2010-05-16 22:44:57 +00:00
|
|
|
#define GSM_EXTENSION_LENGTH 15
|
2014-12-17 13:03:35 +00:00
|
|
|
#define GSM_APN_LENGTH 102
|
2010-05-16 22:44:57 +00:00
|
|
|
|
2010-06-01 09:53:01 +00:00
|
|
|
struct gprs_llc_lle;
|
2014-03-23 17:08:26 +00:00
|
|
|
struct ctrl_handle;
|
2017-01-09 23:49:56 +00:00
|
|
|
struct gprs_subscr;
|
2010-06-01 09:53:01 +00:00
|
|
|
|
2015-02-02 17:03:05 +00:00
|
|
|
enum gsm48_gsm_cause;
|
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
/* TS 04.08 4.1.3.3 GMM mobility management states on the network side */
|
2016-05-20 22:00:51 +00:00
|
|
|
enum gprs_gmm_state {
|
2010-03-14 07:45:01 +00:00
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
2016-05-20 22:01:21 +00:00
|
|
|
/* TS 23.060 6.1.1 and 6.1.2 Mobility management states A/Gb and Iu mode */
|
|
|
|
enum gprs_pmm_state {
|
|
|
|
PMM_DETACHED,
|
|
|
|
PMM_CONNECTED,
|
|
|
|
PMM_IDLE,
|
2017-01-31 14:34:26 +00:00
|
|
|
MM_IDLE,
|
|
|
|
MM_READY,
|
|
|
|
MM_STANDBY,
|
2016-05-20 22:01:21 +00:00
|
|
|
};
|
|
|
|
|
2010-05-31 18:23:38 +00:00
|
|
|
enum gprs_mm_ctr {
|
2010-05-18 08:57:45 +00:00
|
|
|
GMM_CTR_PKTS_SIG_IN,
|
|
|
|
GMM_CTR_PKTS_SIG_OUT,
|
|
|
|
GMM_CTR_PKTS_UDATA_IN,
|
|
|
|
GMM_CTR_PKTS_UDATA_OUT,
|
|
|
|
GMM_CTR_BYTES_UDATA_IN,
|
|
|
|
GMM_CTR_BYTES_UDATA_OUT,
|
|
|
|
GMM_CTR_PDP_CTX_ACT,
|
|
|
|
GMM_CTR_SUSPEND,
|
|
|
|
GMM_CTR_PAGING_PS,
|
|
|
|
GMM_CTR_PAGING_CS,
|
|
|
|
GMM_CTR_RA_UPDATE,
|
|
|
|
};
|
|
|
|
|
2010-06-09 22:20:12 +00:00
|
|
|
enum gprs_pdp_ctx {
|
|
|
|
PDP_CTR_PKTS_UDATA_IN,
|
|
|
|
PDP_CTR_PKTS_UDATA_OUT,
|
|
|
|
PDP_CTR_BYTES_UDATA_IN,
|
|
|
|
PDP_CTR_BYTES_UDATA_OUT,
|
|
|
|
};
|
|
|
|
|
2010-05-31 18:23:38 +00:00
|
|
|
enum gprs_t3350_mode {
|
2014-10-28 11:23:29 +00:00
|
|
|
GMM_T3350_MODE_NONE,
|
2010-05-31 18:23:38 +00:00
|
|
|
GMM_T3350_MODE_ATT,
|
|
|
|
GMM_T3350_MODE_RAU,
|
|
|
|
GMM_T3350_MODE_PTMSI_REALL,
|
|
|
|
};
|
|
|
|
|
2014-10-24 16:09:54 +00:00
|
|
|
/* Authorization/ACL handling */
|
|
|
|
enum sgsn_auth_state {
|
|
|
|
SGSN_AUTH_UNKNOWN,
|
2014-12-02 08:47:26 +00:00
|
|
|
SGSN_AUTH_AUTHENTICATE,
|
2017-02-24 05:24:45 +00:00
|
|
|
SGSN_AUTH_UMTS_RESYNC,
|
2014-10-24 16:09:54 +00:00
|
|
|
SGSN_AUTH_ACCEPTED,
|
|
|
|
SGSN_AUTH_REJECTED
|
|
|
|
};
|
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
#define MS_RADIO_ACCESS_CAPA
|
|
|
|
|
2015-05-25 04:26:49 +00:00
|
|
|
enum sgsn_ggsn_lookup_state {
|
|
|
|
SGSN_GGSN_2DIGIT,
|
|
|
|
SGSN_GGSN_3DIGIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sgsn_ggsn_lookup {
|
|
|
|
int state;
|
|
|
|
|
|
|
|
struct sgsn_mm_ctx *mmctx;
|
|
|
|
|
|
|
|
/* APN string */
|
|
|
|
char apn_str[GSM_APN_LENGTH];
|
|
|
|
|
|
|
|
/* the original data */
|
|
|
|
struct msgb *orig_msg;
|
|
|
|
struct tlv_parsed tp;
|
|
|
|
|
|
|
|
/* for dealing with re-transmissions */
|
|
|
|
uint8_t nsapi;
|
|
|
|
uint8_t sapi;
|
|
|
|
uint8_t ti;
|
|
|
|
};
|
|
|
|
|
2015-12-25 18:12:21 +00:00
|
|
|
enum sgsn_ran_type {
|
|
|
|
/* GPRS/EDGE via Gb */
|
|
|
|
MM_CTX_T_GERAN_Gb,
|
|
|
|
/* UMTS via Iu */
|
|
|
|
MM_CTX_T_UTRAN_Iu,
|
2019-08-13 16:38:24 +00:00
|
|
|
#if 0
|
|
|
|
/* GPRS/EDGE via Iu, not supported */
|
2015-12-25 18:12:21 +00:00
|
|
|
MM_CTX_T_GERAN_Iu,
|
2019-08-13 16:38:24 +00:00
|
|
|
#endif
|
2015-12-25 18:12:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct service_info {
|
|
|
|
uint8_t type;
|
|
|
|
uint16_t pdp_status;
|
|
|
|
};
|
|
|
|
|
2017-07-05 13:19:52 +00:00
|
|
|
struct ranap_ue_conn_ctx;
|
2015-12-25 18:12:21 +00:00
|
|
|
|
2017-07-13 00:03:50 +00:00
|
|
|
struct gsm_auth_tuple {
|
|
|
|
int use_count;
|
|
|
|
int key_seq;
|
|
|
|
struct osmo_auth_vector vec;
|
|
|
|
};
|
|
|
|
#define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
|
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
/* 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;
|
|
|
|
|
2015-12-25 18:12:21 +00:00
|
|
|
enum sgsn_ran_type ran_type;
|
|
|
|
|
2016-04-20 15:50:17 +00:00
|
|
|
char imsi[GSM23003_IMSI_MAX_DIGITS+1];
|
2017-01-31 14:34:26 +00:00
|
|
|
enum gprs_gmm_state gmm_state;
|
2016-05-20 22:01:21 +00:00
|
|
|
enum gprs_pmm_state pmm_state; /* Iu: page when in PMM-IDLE mode */
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t p_tmsi;
|
2010-05-31 18:23:38 +00:00
|
|
|
uint32_t p_tmsi_old; /* old P-TMSI before new is confirmed */
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t p_tmsi_sig;
|
2016-04-20 15:50:17 +00:00
|
|
|
char imei[GSM23003_IMEISV_NUM_DIGITS+1];
|
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;
|
2015-12-25 18:12:21 +00:00
|
|
|
struct {
|
|
|
|
uint16_t cell_id; /* Gb only */
|
|
|
|
uint32_t cell_id_age; /* Gb only */
|
|
|
|
uint8_t radio_prio_sms;
|
|
|
|
|
|
|
|
/* Additional bits not present in the GSM TS */
|
|
|
|
uint16_t nsei;
|
|
|
|
uint16_t bvci;
|
|
|
|
struct gprs_llc_llme *llme;
|
|
|
|
uint32_t tlli;
|
|
|
|
uint32_t tlli_new;
|
|
|
|
} gb;
|
|
|
|
struct {
|
|
|
|
int new_key;
|
|
|
|
uint16_t sac; /* Iu: Service Area Code */
|
|
|
|
uint32_t sac_age; /* Iu: Service Area Code age */
|
|
|
|
/* CSG ID */
|
|
|
|
/* CSG Membership */
|
|
|
|
/* Access Mode */
|
|
|
|
/* Seelected CN Operator ID (TS 23.251) */
|
|
|
|
/* CSG Subscription Data */
|
|
|
|
/* LIPA Allowed */
|
|
|
|
/* Voice Support Match Indicator */
|
2017-07-05 13:19:52 +00:00
|
|
|
struct ranap_ue_conn_ctx *ue_ctx;
|
2015-12-25 18:12:21 +00:00
|
|
|
struct service_info service;
|
|
|
|
} iu;
|
2018-05-22 16:29:14 +00:00
|
|
|
struct {
|
|
|
|
struct osmo_fsm_inst *fsm;
|
|
|
|
|
|
|
|
/* when a second attach req arrives while in this procedure,
|
|
|
|
* the fsm needs to compare it against old to decide what to do */
|
|
|
|
struct msgb *attach_req;
|
|
|
|
uint32_t id_type;
|
2018-09-18 16:16:53 +00:00
|
|
|
unsigned int auth_reattempt; /* tracking UMTS resync auth attempts */
|
2018-05-22 16:29:14 +00:00
|
|
|
} gmm_att_req;
|
2010-03-14 07:45:01 +00:00
|
|
|
/* VLR number */
|
2010-05-02 09:26:34 +00:00
|
|
|
uint32_t new_sgsn_addr;
|
2014-12-01 11:33:33 +00:00
|
|
|
/* Authentication Triplet */
|
|
|
|
struct gsm_auth_tuple auth_triplet;
|
2010-03-14 07:45:01 +00:00
|
|
|
/* 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;
|
2016-07-05 13:19:12 +00:00
|
|
|
/* Auth & Ciphering Request reference from 3GPP TS 24.008 § 10.5.5.19: */
|
|
|
|
uint8_t ac_ref_nr_used;
|
2015-12-25 18:12:21 +00:00
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
struct {
|
2010-05-02 09:26:34 +00:00
|
|
|
uint8_t len;
|
2013-07-03 06:12:23 +00:00
|
|
|
uint8_t buf[50]; /* GSM 04.08 10.5.5.12a, extended in TS 24.008 */
|
2010-03-14 07:45:01 +00:00
|
|
|
} ms_radio_access_capa;
|
2015-12-25 18:12:21 +00:00
|
|
|
/* Supported Codecs (SRVCC) */
|
2010-03-14 07:45:01 +00:00
|
|
|
struct {
|
2010-05-02 09:26:34 +00:00
|
|
|
uint8_t len;
|
2013-07-03 06:12:23 +00:00
|
|
|
uint8_t buf[8]; /* GSM 04.08 10.5.5.12, extended in TS 24.008 */
|
2010-03-14 07:45:01 +00:00
|
|
|
} ms_network_capa;
|
2015-12-25 18:12:21 +00:00
|
|
|
/* UE Netowrk Capability (E-UTRAN) */
|
2010-05-02 09:26:34 +00:00
|
|
|
uint16_t drx_parms;
|
2015-12-25 18:12:21 +00:00
|
|
|
/* Active Time value for PSM */
|
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? */
|
2015-12-25 18:12:21 +00:00
|
|
|
/* Subscribed Charging Characteristics */
|
|
|
|
/* Trace Reference */
|
|
|
|
/* Trace Type */
|
|
|
|
/* Trigger ID */
|
|
|
|
/* OMC Identity */
|
2010-03-14 07:45:01 +00:00
|
|
|
/* SMS Parameters */
|
|
|
|
int recovery;
|
2015-12-25 18:12:21 +00:00
|
|
|
/* Access Restriction */
|
|
|
|
/* GPRS CSI (CAMEL) */
|
|
|
|
/* MG-CSI (CAMEL) */
|
|
|
|
/* Subscribed UE-AMBR */
|
|
|
|
/* UE-AMBR */
|
|
|
|
/* APN Subscribed */
|
2010-03-14 07:45:01 +00:00
|
|
|
|
|
|
|
struct llist_head pdp_list;
|
|
|
|
|
2010-05-18 08:57:45 +00:00
|
|
|
struct rate_ctr_group *ctrg;
|
2011-05-06 10:11:06 +00:00
|
|
|
struct osmo_timer_list timer;
|
2010-05-31 18:23:38 +00:00
|
|
|
unsigned int T; /* Txxxx number */
|
|
|
|
unsigned int num_T_exp; /* number of consecutive T expirations */
|
|
|
|
|
|
|
|
enum gprs_t3350_mode t3350_mode;
|
|
|
|
uint8_t t3370_id_type;
|
2014-10-28 11:23:29 +00:00
|
|
|
uint8_t pending_req; /* the request's message type */
|
|
|
|
/* TODO: There isn't much semantic difference between t3350_mode
|
|
|
|
* (refers to the timer) and pending_req (refers to the procedure),
|
|
|
|
* where mm->T == 3350 => mm->t3350_mode == f(mm->pending_req). Check
|
|
|
|
* whether one of them can be dropped. */
|
2014-10-29 21:12:20 +00:00
|
|
|
|
2014-10-24 16:09:54 +00:00
|
|
|
enum sgsn_auth_state auth_state;
|
2018-04-22 17:29:41 +00:00
|
|
|
enum osmo_sub_auth_type sec_ctx;
|
2014-11-12 08:53:45 +00:00
|
|
|
|
2015-05-18 08:00:03 +00:00
|
|
|
/* the string representation of the current hlr */
|
|
|
|
char hlr[GSM_EXTENSION_LENGTH];
|
|
|
|
|
2015-05-25 04:26:49 +00:00
|
|
|
/* the current GGSN look-up operation */
|
|
|
|
struct sgsn_ggsn_lookup *ggsn_lookup;
|
|
|
|
|
2017-01-09 23:49:56 +00:00
|
|
|
struct gprs_subscr *subscr;
|
2010-03-14 07:45:01 +00:00
|
|
|
};
|
|
|
|
|
2018-04-22 17:29:41 +00:00
|
|
|
static inline bool sgsn_mm_ctx_is_authenticated(struct sgsn_mm_ctx *ctx)
|
|
|
|
{
|
|
|
|
switch (ctx->sec_ctx) {
|
|
|
|
case OSMO_AUTH_TYPE_GSM:
|
|
|
|
case OSMO_AUTH_TYPE_UMTS:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-03 13:57:49 +00:00
|
|
|
#define LOGMMCTXP(level, mm, fmt, args...) \
|
2014-10-21 11:09:55 +00:00
|
|
|
LOGP(DMM, level, "MM(%s/%08x) " fmt, (mm) ? (mm)->imsi : "---", \
|
|
|
|
(mm) ? (mm)->p_tmsi : GSM_RESERVED_TMSI, ## args)
|
2014-09-03 13:57:49 +00:00
|
|
|
|
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);
|
2016-05-21 15:35:57 +00:00
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_by_ue_ctx(const void *uectx);
|
2010-05-17 20:58:03 +00:00
|
|
|
|
2016-01-04 17:43:38 +00:00
|
|
|
/* look-up by matching TLLI and P-TMSI (think twice before using this) */
|
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli_and_ptmsi(uint32_t tlli,
|
|
|
|
const struct gprs_ra_id *raid);
|
|
|
|
|
2010-05-17 20:58:03 +00:00
|
|
|
/* Allocate a new SGSN MM context */
|
2017-02-04 05:01:00 +00:00
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
|
2010-05-17 20:58:03 +00:00
|
|
|
const struct gprs_ra_id *raid);
|
2016-05-21 15:35:57 +00:00
|
|
|
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx);
|
|
|
|
|
2015-01-26 13:43:07 +00:00
|
|
|
void sgsn_mm_ctx_cleanup_free(struct sgsn_mm_ctx *ctx);
|
2010-05-17 20:58:03 +00:00
|
|
|
|
2015-02-02 17:03:05 +00:00
|
|
|
struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx,
|
|
|
|
struct tlv_parsed *tp,
|
2015-05-25 04:26:49 +00:00
|
|
|
enum gsm48_gsm_cause *gsm_cause,
|
|
|
|
char *apn_str);
|
2010-05-17 20:58:03 +00:00
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
enum pdp_ctx_state {
|
2010-05-17 20:58:03 +00:00
|
|
|
PDP_STATE_NONE,
|
2010-05-18 08:35:06 +00:00
|
|
|
PDP_STATE_CR_REQ,
|
|
|
|
PDP_STATE_CR_CONF,
|
2010-12-24 20:13:26 +00:00
|
|
|
|
|
|
|
/* 04.08 / Figure 6.2 / 6.1.2.2 */
|
|
|
|
PDP_STATE_INACT_PEND,
|
|
|
|
PDP_STATE_INACTIVE = PDP_STATE_NONE,
|
2010-03-14 07:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum pdp_type {
|
|
|
|
PDP_TYPE_NONE,
|
2010-05-18 08:35:06 +00:00
|
|
|
PDP_TYPE_ETSI_PPP,
|
|
|
|
PDP_TYPE_IANA_IPv4,
|
|
|
|
PDP_TYPE_IANA_IPv6,
|
2010-03-14 07:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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 */
|
2015-05-25 04:26:49 +00:00
|
|
|
int destroy_ggsn; /* destroy it on destruction */
|
2010-05-17 20:58:03 +00:00
|
|
|
struct sgsn_ggsn_ctx *ggsn; /* which GGSN serves this PDP */
|
2018-07-09 12:39:47 +00:00
|
|
|
struct llist_head ggsn_list; /* list_head for ggsn->pdp_list */
|
2010-06-09 22:20:12 +00:00
|
|
|
struct rate_ctr_group *ctrg;
|
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-18 08:35:06 +00:00
|
|
|
uint16_t nsapi; /* SNDCP */
|
|
|
|
uint16_t sapi; /* LLC */
|
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-17 20:58:03 +00:00
|
|
|
//uint32_t charging_id;
|
2010-12-24 20:13:26 +00:00
|
|
|
|
2011-05-06 10:11:06 +00:00
|
|
|
struct osmo_timer_list timer;
|
2010-12-24 20:13:26 +00:00
|
|
|
unsigned int T; /* Txxxx number */
|
|
|
|
unsigned int num_T_exp; /* number of consecutive T expirations */
|
2015-05-05 20:25:48 +00:00
|
|
|
|
|
|
|
struct osmo_timer_list cdr_timer; /* CDR record wird timer */
|
|
|
|
struct timespec cdr_start; /* The start of the CDR */
|
|
|
|
uint64_t cdr_bytes_in;
|
|
|
|
uint64_t cdr_bytes_out;
|
2015-05-12 19:08:42 +00:00
|
|
|
uint32_t cdr_charging_id;
|
2010-03-14 07:45:01 +00:00
|
|
|
};
|
|
|
|
|
2014-09-03 13:57:49 +00:00
|
|
|
#define LOGPDPCTXP(level, pdp, fmt, args...) \
|
2014-10-13 08:32:00 +00:00
|
|
|
LOGP(DGPRS, level, "PDP(%s/%u) " \
|
|
|
|
fmt, (pdp)->mm ? (pdp)->mm->imsi : "---", (pdp)->ti, ## args)
|
2010-03-14 07:45:01 +00:00
|
|
|
|
2010-06-03 04:37:26 +00:00
|
|
|
/* look up PDP context by MM context and NSAPI */
|
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);
|
2010-06-03 04:37:26 +00:00
|
|
|
/* look up PDP context by MM context and transaction ID */
|
2010-05-18 12:32:29 +00:00
|
|
|
struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tid(const struct sgsn_mm_ctx *mm,
|
|
|
|
uint8_t tid);
|
2010-06-03 04:37:26 +00:00
|
|
|
|
2010-05-17 20:58:03 +00:00
|
|
|
struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
|
2018-07-09 12:39:47 +00:00
|
|
|
struct sgsn_ggsn_ctx *ggsn,
|
2010-05-17 20:58:03 +00:00
|
|
|
uint8_t nsapi);
|
2014-10-13 08:32:00 +00:00
|
|
|
void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp);
|
2010-05-17 20:58:03 +00:00
|
|
|
void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp);
|
|
|
|
|
|
|
|
|
2010-05-18 12:32:29 +00:00
|
|
|
struct sgsn_ggsn_ctx {
|
2010-05-17 20:58:03 +00:00
|
|
|
struct llist_head list;
|
|
|
|
uint32_t id;
|
|
|
|
unsigned int gtp_version;
|
|
|
|
struct in_addr remote_addr;
|
2010-12-24 20:13:26 +00:00
|
|
|
int remote_restart_ctr;
|
2010-05-17 20:58:03 +00:00
|
|
|
struct gsn_t *gsn;
|
2018-07-09 12:39:47 +00:00
|
|
|
struct llist_head pdp_list; /* list of associated pdp ctx (struct sgsn_pdp_ctx*) */
|
2018-07-09 18:37:47 +00:00
|
|
|
struct osmo_timer_list echo_timer;
|
|
|
|
int echo_interval;
|
2010-05-17 20:58:03 +00:00
|
|
|
};
|
2010-05-18 15:20:49 +00:00
|
|
|
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_alloc(uint32_t id);
|
2015-02-03 18:53:15 +00:00
|
|
|
void sgsn_ggsn_ctx_free(struct sgsn_ggsn_ctx *ggc);
|
2010-05-18 15:20:49 +00:00
|
|
|
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_id(uint32_t id);
|
2010-12-24 20:13:26 +00:00
|
|
|
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_addr(struct in_addr *addr);
|
2010-05-18 15:20:49 +00:00
|
|
|
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_find_alloc(uint32_t id);
|
2018-07-16 09:31:23 +00:00
|
|
|
void sgsn_ggsn_ctx_drop_pdp(struct sgsn_pdp_ctx *pctx);
|
2018-07-17 13:56:53 +00:00
|
|
|
int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pdp_ctx *except);
|
2018-07-09 18:37:47 +00:00
|
|
|
void sgsn_ggsn_ctx_add_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp);
|
|
|
|
void sgsn_ggsn_ctx_remove_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp);
|
2018-09-18 18:07:37 +00:00
|
|
|
void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc);
|
2010-05-17 20:58:03 +00:00
|
|
|
|
|
|
|
struct apn_ctx {
|
|
|
|
struct llist_head list;
|
2010-05-18 12:32:29 +00:00
|
|
|
struct sgsn_ggsn_ctx *ggsn;
|
2010-05-17 20:58:03 +00:00
|
|
|
char *name;
|
2015-02-03 12:47:53 +00:00
|
|
|
char *imsi_prefix;
|
2010-05-17 20:58:03 +00:00
|
|
|
char *description;
|
|
|
|
};
|
|
|
|
|
2015-02-03 12:47:53 +00:00
|
|
|
struct apn_ctx *sgsn_apn_ctx_find_alloc(const char *name, const char *imsi_prefix);
|
|
|
|
void sgsn_apn_ctx_free(struct apn_ctx *actx);
|
|
|
|
struct apn_ctx *sgsn_apn_ctx_by_name(const char *name, const char *imsi_prefix);
|
|
|
|
struct apn_ctx *sgsn_apn_ctx_match(const char *name, const char *imsi_prefix);
|
|
|
|
|
2010-05-17 20:58:03 +00:00
|
|
|
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
|
|
|
|
2010-05-18 15:04:55 +00:00
|
|
|
uint32_t sgsn_alloc_ptmsi(void);
|
2018-10-30 17:00:57 +00:00
|
|
|
struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx);
|
|
|
|
void sgsn_inst_init(struct sgsn_instance *sgsn);
|
2010-05-18 15:04:55 +00:00
|
|
|
|
2014-03-23 17:08:26 +00:00
|
|
|
char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ctrl interface related work
|
|
|
|
*/
|
|
|
|
int sgsn_ctrl_cmds_install(void);
|
|
|
|
|
2014-04-04 10:40:34 +00:00
|
|
|
/*
|
2014-10-24 16:09:54 +00:00
|
|
|
* Authorization/ACL handling
|
2014-04-04 10:40:34 +00:00
|
|
|
*/
|
2014-10-24 13:11:03 +00:00
|
|
|
struct imsi_acl_entry {
|
|
|
|
struct llist_head list;
|
|
|
|
char imsi[16+1];
|
|
|
|
};
|
2014-10-24 16:09:54 +00:00
|
|
|
|
2014-12-17 13:03:35 +00:00
|
|
|
/* see GSM 09.02, 17.7.1, PDP-Context and GPRSSubscriptionData */
|
|
|
|
/* see GSM 09.02, B.1, gprsSubscriptionData */
|
|
|
|
struct sgsn_subscriber_pdp_data {
|
|
|
|
struct llist_head list;
|
|
|
|
|
|
|
|
unsigned int context_id;
|
|
|
|
uint16_t pdp_type;
|
|
|
|
char apn_str[GSM_APN_LENGTH];
|
2015-04-23 15:33:35 +00:00
|
|
|
uint8_t qos_subscribed[20];
|
|
|
|
size_t qos_subscribed_len;
|
2017-07-09 11:18:17 +00:00
|
|
|
uint8_t pdp_charg[2];
|
|
|
|
bool has_pdp_charg;
|
2014-12-17 13:03:35 +00:00
|
|
|
};
|
|
|
|
|
2014-10-24 16:09:54 +00:00
|
|
|
struct sgsn_subscriber_data {
|
2014-12-08 14:26:47 +00:00
|
|
|
struct sgsn_mm_ctx *mm;
|
2014-12-08 14:52:00 +00:00
|
|
|
struct gsm_auth_tuple auth_triplets[5];
|
|
|
|
int auth_triplets_updated;
|
2014-12-17 13:03:35 +00:00
|
|
|
struct llist_head pdp_list;
|
2015-01-05 16:51:17 +00:00
|
|
|
int error_cause;
|
2015-04-23 13:53:53 +00:00
|
|
|
|
|
|
|
uint8_t msisdn[9];
|
|
|
|
size_t msisdn_len;
|
2015-05-17 18:58:40 +00:00
|
|
|
|
|
|
|
uint8_t hlr[9];
|
|
|
|
size_t hlr_len;
|
2017-07-09 11:18:17 +00:00
|
|
|
|
|
|
|
uint8_t pdp_charg[2];
|
|
|
|
bool has_pdp_charg;
|
2014-10-24 16:09:54 +00:00
|
|
|
};
|
|
|
|
|
2015-01-19 10:10:04 +00:00
|
|
|
#define SGSN_ERROR_CAUSE_NONE (-1)
|
|
|
|
|
2015-01-08 11:02:12 +00:00
|
|
|
#define LOGGSUBSCRP(level, subscr, fmt, args...) \
|
2015-01-15 16:08:30 +00:00
|
|
|
LOGP(DGPRS, level, "SUBSCR(%s) " fmt, \
|
|
|
|
(subscr) ? (subscr)->imsi : "---", \
|
2015-01-08 11:02:12 +00:00
|
|
|
## args)
|
|
|
|
|
2014-10-24 13:11:03 +00:00
|
|
|
struct sgsn_config;
|
|
|
|
struct sgsn_instance;
|
2014-11-07 13:17:44 +00:00
|
|
|
extern const struct value_string *sgsn_auth_state_names;
|
2014-10-24 13:11:03 +00:00
|
|
|
|
2018-12-10 17:01:47 +00:00
|
|
|
void sgsn_auth_init(struct sgsn_instance *sgsn);
|
2018-12-10 17:17:21 +00:00
|
|
|
struct imsi_acl_entry *sgsn_acl_lookup(const char *imsi, const struct sgsn_config *cfg);
|
2014-10-24 13:11:03 +00:00
|
|
|
int sgsn_acl_add(const char *imsi, struct sgsn_config *cfg);
|
|
|
|
int sgsn_acl_del(const char *imsi, struct sgsn_config *cfg);
|
2014-10-24 16:09:54 +00:00
|
|
|
/* Request authorization */
|
2014-11-13 09:48:39 +00:00
|
|
|
int sgsn_auth_request(struct sgsn_mm_ctx *mm);
|
|
|
|
enum sgsn_auth_state sgsn_auth_state(struct sgsn_mm_ctx *mm);
|
|
|
|
void sgsn_auth_update(struct sgsn_mm_ctx *mm);
|
2014-12-08 14:52:00 +00:00
|
|
|
struct gsm_auth_tuple *sgsn_auth_get_tuple(struct sgsn_mm_ctx *mmctx,
|
|
|
|
unsigned key_seq);
|
2014-10-24 16:09:54 +00:00
|
|
|
|
2014-11-12 09:12:11 +00:00
|
|
|
/*
|
|
|
|
* GPRS subscriber data
|
|
|
|
*/
|
2017-01-09 23:49:56 +00:00
|
|
|
#define GPRS_SUBSCRIBER_FIRST_CONTACT 0x00000001
|
2014-11-28 13:55:25 +00:00
|
|
|
#define GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING (1 << 16)
|
|
|
|
#define GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING (1 << 17)
|
|
|
|
#define GPRS_SUBSCRIBER_CANCELLED (1 << 18)
|
2015-01-06 15:32:41 +00:00
|
|
|
#define GPRS_SUBSCRIBER_ENABLE_PURGE (1 << 19)
|
2014-11-28 13:55:25 +00:00
|
|
|
|
|
|
|
#define GPRS_SUBSCRIBER_UPDATE_PENDING_MASK ( \
|
|
|
|
GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING | \
|
|
|
|
GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING \
|
|
|
|
)
|
2014-11-12 09:12:11 +00:00
|
|
|
|
2014-12-18 11:46:47 +00:00
|
|
|
int gprs_subscr_init(struct sgsn_instance *sgi);
|
2014-11-28 13:55:25 +00:00
|
|
|
int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx);
|
2017-02-24 05:24:45 +00:00
|
|
|
int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx,
|
|
|
|
const uint8_t *auts,
|
|
|
|
const uint8_t *auts_rand);
|
|
|
|
int gprs_subscr_auth_sync(struct gprs_subscr *subscr,
|
|
|
|
const uint8_t *auts, const uint8_t *auts_rand);
|
2017-01-09 23:49:56 +00:00
|
|
|
void gprs_subscr_cleanup(struct gprs_subscr *subscr);
|
|
|
|
struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi);
|
|
|
|
struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx);
|
|
|
|
struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi);
|
|
|
|
void gprs_subscr_cancel(struct gprs_subscr *subscr);
|
|
|
|
void gprs_subscr_update(struct gprs_subscr *subscr);
|
|
|
|
void gprs_subscr_update_auth_info(struct gprs_subscr *subscr);
|
2014-12-12 14:01:37 +00:00
|
|
|
int gprs_subscr_rx_gsup_message(struct msgb *msg);
|
2014-11-12 09:12:11 +00:00
|
|
|
|
2014-10-24 16:09:54 +00:00
|
|
|
/* Called on subscriber data updates */
|
2015-01-26 12:52:42 +00:00
|
|
|
void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx);
|
2014-04-04 10:40:34 +00:00
|
|
|
|
2014-04-04 10:51:28 +00:00
|
|
|
int gprs_sndcp_vty_init(void);
|
|
|
|
struct sgsn_instance;
|
|
|
|
int sgsn_gtp_init(struct sgsn_instance *sgi);
|
|
|
|
|
2016-07-05 07:52:52 +00:00
|
|
|
void sgsn_rate_ctr_init();
|
|
|
|
|
2010-03-14 07:45:01 +00:00
|
|
|
#endif /* _GPRS_SGSN_H */
|