diff options
Diffstat (limited to 'include/osmocom')
27 files changed, 425 insertions, 397 deletions
diff --git a/include/osmocom/Makefile.am b/include/osmocom/Makefile.am index 09db97a95..f5bc76a4f 100644 --- a/include/osmocom/Makefile.am +++ b/include/osmocom/Makefile.am @@ -1,3 +1,4 @@ SUBDIRS = \ + gtphub \ sgsn \ $(NULL) diff --git a/include/osmocom/gtphub/Makefile.am b/include/osmocom/gtphub/Makefile.am new file mode 100644 index 000000000..c61dad9d4 --- /dev/null +++ b/include/osmocom/gtphub/Makefile.am @@ -0,0 +1,3 @@ +noinst_HEADERS = \ + gtphub.h \ + $(NULL) diff --git a/include/osmocom/sgsn/gtphub.h b/include/osmocom/gtphub/gtphub.h index 6a439b576..dbf8469bc 100644 --- a/include/osmocom/sgsn/gtphub.h +++ b/include/osmocom/gtphub/gtphub.h @@ -27,9 +27,7 @@ #include <osmocom/core/select.h> #include <osmocom/core/timer.h> #include <osmocom/core/rate_ctr.h> - -#include <osmocom/sgsn/gprs_sgsn.h> - +#include <osmocom/gsm/apn.h> /* support */ @@ -428,7 +426,7 @@ struct gtphub_resolved_ggsn { /* The APN OI, the Operator Identifier, is the combined address, * including parts of the IMSI and APN NI, and ending with ".gprs". */ - char apn_oi_str[GSM_APN_LENGTH]; + char apn_oi_str[APN_MAXLEN+1]; /* Which address and port we resolved that to. */ struct gtphub_peer_port *peer; diff --git a/include/osmocom/sgsn/Makefile.am b/include/osmocom/sgsn/Makefile.am index 289f502e8..aa6cd0f0f 100644 --- a/include/osmocom/sgsn/Makefile.am +++ b/include/osmocom/sgsn/Makefile.am @@ -1,18 +1,19 @@ noinst_HEADERS = \ + apn.h \ + auth.h \ common.h \ crc24.h \ debug.h \ - gprs_gb.h \ - gprs_gb_parse.h \ + gprs_bssgp.h \ gprs_gmm.h \ gprs_gmm_fsm.h \ gprs_gmm_attach.h \ gprs_mm_state_gb_fsm.h \ gprs_mm_state_iu_fsm.h \ + gprs_ns.h \ gprs_llc.h \ gprs_llc_xid.h \ gprs_ranap.h \ - gprs_sgsn.h \ gprs_sm.h \ gprs_sndcp_comp.h \ gprs_sndcp_dcomp.h \ @@ -21,8 +22,11 @@ noinst_HEADERS = \ gprs_sndcp_xid.h \ gprs_subscriber.h \ gprs_utils.h \ - gtphub.h \ + gtp.h \ + gtp_ggsn.h \ gtp_mme.h \ + mmctx.h \ + pdpctx.h \ sgsn.h \ sgsn_rim.h \ signal.h \ diff --git a/include/osmocom/sgsn/apn.h b/include/osmocom/sgsn/apn.h new file mode 100644 index 000000000..3dc7a70ca --- /dev/null +++ b/include/osmocom/sgsn/apn.h @@ -0,0 +1,20 @@ +#pragma once + +#include <osmocom/core/linuxlist.h> + +struct sgsn_ggsn_ctx; + +#define GSM_APN_LENGTH 102 + +struct apn_ctx { + struct llist_head list; + struct sgsn_ggsn_ctx *ggsn; + char *name; + char *imsi_prefix; + char *description; +}; + +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); diff --git a/include/osmocom/sgsn/auth.h b/include/osmocom/sgsn/auth.h new file mode 100644 index 000000000..a46fb16bb --- /dev/null +++ b/include/osmocom/sgsn/auth.h @@ -0,0 +1,39 @@ +/* MS authorization and subscriber data handling */ +#pragma once + +#include <osmocom/core/linuxlist.h> + +struct sgsn_config; +struct sgsn_instance; +struct sgsn_mm_ctx; +struct gsm_auth_tuple; + +/* Authorization/ACL handling */ +enum sgsn_auth_state { + SGSN_AUTH_UNKNOWN, + SGSN_AUTH_AUTHENTICATE, + SGSN_AUTH_UMTS_RESYNC, + SGSN_AUTH_ACCEPTED, + SGSN_AUTH_REJECTED +}; + +extern const struct value_string *sgsn_auth_state_names; + +void sgsn_auth_init(struct sgsn_instance *sgsn); +/* Request authorization */ +enum sgsn_auth_state sgsn_auth_state(struct sgsn_mm_ctx *mm); +int sgsn_auth_request(struct sgsn_mm_ctx *mm); +void sgsn_auth_update(struct sgsn_mm_ctx *mm); +struct gsm_auth_tuple *sgsn_auth_get_tuple(struct sgsn_mm_ctx *mmctx, + unsigned key_seq); + +/* + * Authorization/ACL handling + */ +struct imsi_acl_entry { + struct llist_head list; + char imsi[OSMO_IMSI_BUF_SIZE]; +}; +struct imsi_acl_entry *sgsn_acl_lookup(const char *imsi, const struct sgsn_config *cfg); +int sgsn_acl_add(const char *imsi, struct sgsn_config *cfg); +int sgsn_acl_del(const char *imsi, struct sgsn_config *cfg); diff --git a/include/osmocom/sgsn/crc24.h b/include/osmocom/sgsn/crc24.h index 756638c03..c913eaf76 100644 --- a/include/osmocom/sgsn/crc24.h +++ b/include/osmocom/sgsn/crc24.h @@ -5,6 +5,6 @@ #define INIT_CRC24 0xffffff -uint32_t crc24_calc(uint32_t fcs, uint8_t *cp, unsigned int len); +uint32_t crc24_calc(uint32_t fcs, const uint8_t *cp, unsigned int len); #endif diff --git a/include/osmocom/sgsn/gprs_bssgp.h b/include/osmocom/sgsn/gprs_bssgp.h new file mode 100644 index 000000000..0feaa9762 --- /dev/null +++ b/include/osmocom/sgsn/gprs_bssgp.h @@ -0,0 +1,12 @@ +#pragma once + +#include <osmocom/core/msgb.h> + +/* Called by bssgp layer when a prim is received from lower layers. */ +int sgsn_bssgp_rx_prim(struct osmo_prim_hdr *oph); + +/* called by the bssgp layer to send NS PDUs */ +int sgsn_bssgp_dispatch_ns_unitdata_req_cb(void *ctx, struct msgb *msg); + +/* page a MS in its routing area */ +int sgsn_bssgp_page_ps_ra(struct sgsn_mm_ctx *mmctx); diff --git a/include/osmocom/sgsn/gprs_gb.h b/include/osmocom/sgsn/gprs_gb.h deleted file mode 100644 index 916236761..000000000 --- a/include/osmocom/sgsn/gprs_gb.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include <stdbool.h> - -#include <osmocom/core/msgb.h> -#include <osmocom/sgsn/gprs_llc.h> - -int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme, - bool drop_cipherable); -/* Has to be called whenever any PDU (signaling, data, ...) has been received */ -void gprs_gb_recv_pdu(struct sgsn_mm_ctx *mmctx, const struct msgb *msg); - -/* page a MS in its routing area */ -int gprs_gb_page_ps_ra(struct sgsn_mm_ctx *mmctx); - -/* called by the bssgp layer to send NS PDUs */ -int gprs_gb_send_cb(void *ctx, struct msgb *msg); - -/* called by the ns layer */ -int gprs_ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx); diff --git a/include/osmocom/sgsn/gprs_gb_parse.h b/include/osmocom/sgsn/gprs_gb_parse.h deleted file mode 100644 index 58de17f81..000000000 --- a/include/osmocom/sgsn/gprs_gb_parse.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include <osmocom/sgsn/gprs_llc.h> - -#include <sys/types.h> - -struct gprs_gb_parse_context { - /* Pointer to protocol specific parts */ - struct gsm48_hdr *g48_hdr; - struct bssgp_normal_hdr *bgp_hdr; - struct bssgp_ud_hdr *bud_hdr; - uint8_t *bssgp_data; - size_t bssgp_data_len; - uint8_t *llc; - size_t llc_len; - - /* Extracted information */ - struct gprs_llc_hdr_parsed llc_hdr_parsed; - struct tlv_parsed bssgp_tp; - int to_bss; - uint8_t *tlli_enc; - uint8_t *old_tlli_enc; - uint8_t *imsi; - size_t imsi_len; - uint8_t *apn_ie; - size_t apn_ie_len; - uint8_t *ptmsi_enc; - uint8_t *new_ptmsi_enc; - uint8_t *raid_enc; - uint8_t *old_raid_enc; - uint8_t *bssgp_raid_enc; - uint8_t *bssgp_ptmsi_enc; - - /* General info */ - const char *llc_msg_name; - int invalidate_tlli; - int await_reattach; - int need_decryption; - uint32_t tlli; - int pdu_type; - int old_raid_is_foreign; - int peer_nsei; -}; - -int gprs_gb_parse_dtap(uint8_t *data, size_t data_len, - struct gprs_gb_parse_context *parse_ctx); - -int gprs_gb_parse_llc(uint8_t *llc, size_t llc_len, - struct gprs_gb_parse_context *parse_ctx); - -int gprs_gb_parse_bssgp(uint8_t *bssgp, size_t bssgp_len, - struct gprs_gb_parse_context *parse_ctx); - -int gprs_gb_parse_tlli(const uint8_t *bssgp, size_t bssgp_len, uint32_t *tlli); - -const char *gprs_gb_message_name(const struct gprs_gb_parse_context *parse_ctx, - const char *default_msg_name); - -void gprs_gb_log_parse_context(int log_level, - struct gprs_gb_parse_context *parse_ctx, - const char *default_msg_name); diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h index e2b17d217..71dd1fa7f 100644 --- a/include/osmocom/sgsn/gprs_gmm.h +++ b/include/osmocom/sgsn/gprs_gmm.h @@ -1,10 +1,14 @@ #ifndef _GPRS_GMM_H #define _GPRS_GMM_H +#include <stdbool.h> + #include <osmocom/core/msgb.h> -#include <osmocom/sgsn/gprs_sgsn.h> +#include <osmocom/gsm/gsm48.h> +#include <osmocom/crypt/auth.h> -#include <stdbool.h> +struct sgsn_mm_ctx; +struct gprs_llc_llme; int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, const struct osmo_auth_vector *vec, @@ -28,6 +32,11 @@ int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli); int gprs_gmm_rx_resume(struct gprs_ra_id *raid, uint32_t tlli, uint8_t suspend_ref); +int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme, + bool drop_cipherable); +/* Has to be called whenever any PDU (signaling, data, ...) has been received */ +void gprs_gb_recv_pdu(struct sgsn_mm_ctx *mmctx, const struct msgb *msg); + time_t gprs_max_time_to_idle(void); int gsm48_tx_gmm_id_req(struct sgsn_mm_ctx *mm, uint8_t id_type); diff --git a/include/osmocom/sgsn/gprs_gmm_fsm.h b/include/osmocom/sgsn/gprs_gmm_fsm.h index f10851e5c..2f0e81a09 100644 --- a/include/osmocom/sgsn/gprs_gmm_fsm.h +++ b/include/osmocom/sgsn/gprs_gmm_fsm.h @@ -1,8 +1,10 @@ #pragma once #include <osmocom/core/fsm.h> -#include <osmocom/sgsn/gprs_sgsn.h> +#include <osmocom/sgsn/mmctx.h> + +struct gprs_llc_llme; /* 3GPP TS 24.008 ยง 4.1.3.3 GMM mobility management states on the network side */ enum gmm_fsm_states { diff --git a/include/osmocom/sgsn/gprs_llc.h b/include/osmocom/sgsn/gprs_llc.h index ce0e63c51..6f0e4922f 100644 --- a/include/osmocom/sgsn/gprs_llc.h +++ b/include/osmocom/sgsn/gprs_llc.h @@ -1,11 +1,16 @@ -#ifndef _GPRS_LLC_H -#define _GPRS_LLC_H +#pragma once #include <stdint.h> #include <stdbool.h> -#include <osmocom/sgsn/gprs_sgsn.h> + +#include <osmocom/core/timer.h> +#include <osmocom/gsm/tlv.h> +#include <osmocom/crypt/gprs_cipher.h> + #include <osmocom/sgsn/gprs_llc_xid.h> +struct sgsn_mm_ctx; + /* Section 4.7 LLC Layer Structure */ enum gprs_llc_sapi { GPRS_SAPI_GMM = 1, @@ -91,6 +96,7 @@ enum gprs_llc_lle_state { GPRS_LLES_LOCAL_REL = 6, /* Local Release */ GPRS_LLES_TIMER_REC = 7, /* Timer Recovery */ }; +extern const struct value_string gprs_llc_lle_state_names[]; enum gprs_llc_llme_state { GPRS_LLMS_UNASSIGNED = 1, /* No TLLI yet */ @@ -272,18 +278,15 @@ static inline int gprs_llc_is_retransmit(uint16_t nu, uint16_t vur) } /* LLC low level functions */ -void gprs_llme_copy_key(struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme); +void gprs_llme_copy_key(const struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme); /* parse a GPRS LLC header, also check for invalid frames */ int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp, uint8_t *llc_hdr, int len); void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph, struct gprs_llc_lle *lle); -int gprs_llc_fcs(uint8_t *data, unsigned int len); +int gprs_llc_fcs(const uint8_t *data, unsigned int len); /* LLME handling routines */ struct llist_head *gprs_llme_list(void); struct gprs_llc_lle *gprs_lle_get_or_create(const uint32_t tlli, uint8_t sapi); - - -#endif diff --git a/include/osmocom/sgsn/gprs_ns.h b/include/osmocom/sgsn/gprs_ns.h new file mode 100644 index 000000000..235b118ec --- /dev/null +++ b/include/osmocom/sgsn/gprs_ns.h @@ -0,0 +1,9 @@ +#pragma once + +#include <stdbool.h> + +#include <osmocom/core/msgb.h> +#include <osmocom/sgsn/gprs_llc.h> + +/* called by the ns layer */ +int gprs_ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx); diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index 62fdf6f2d..68f9115d7 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -1,13 +1,15 @@ #pragma once #include <osmocom/core/msgb.h> -#include <osmocom/sgsn/gprs_sgsn.h> #ifdef BUILD_IU #include <osmocom/ranap/ranap_ies_defs.h> #include <osmocom/ranap/ranap_msg_factory.h> #include <osmocom/ranap/iu_client.h> +struct sgsn_mm_ctx; +struct sgsn_pdp_ctx; + void activate_pdp_rabs(struct sgsn_mm_ctx *ctx); int sgsn_ranap_iu_event(struct ranap_ue_conn_ctx *ctx, enum ranap_iu_event_type type, void *data); int iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp); diff --git a/include/osmocom/sgsn/gprs_sm.h b/include/osmocom/sgsn/gprs_sm.h index 55c95b89d..78bb2d8c3 100644 --- a/include/osmocom/sgsn/gprs_sm.h +++ b/include/osmocom/sgsn/gprs_sm.h @@ -1,7 +1,10 @@ #pragma once #include <osmocom/core/msgb.h> -#include <osmocom/sgsn/gprs_sgsn.h> + +struct sgsn_mm_ctx; +struct sgsn_pdp_ctx; +struct gprs_llc_llme; int gsm48_tx_gsm_deact_pdp_req(struct sgsn_pdp_ctx *pdp, uint8_t sm_cause, bool teardown); int gsm48_tx_gsm_act_pdp_rej(struct sgsn_mm_ctx *mm, uint8_t tid, diff --git a/include/osmocom/sgsn/gprs_sndcp.h b/include/osmocom/sgsn/gprs_sndcp.h index d970240e4..30ea05308 100644 --- a/include/osmocom/sgsn/gprs_sndcp.h +++ b/include/osmocom/sgsn/gprs_sndcp.h @@ -3,6 +3,9 @@ #include <stdint.h> #include <osmocom/core/linuxlist.h> +#include <osmocom/gsm/gsm48.h> + +struct gprs_llc_lle; /* A fragment queue header, maintaining list of fragments for one N-PDU */ struct defrag_state { @@ -60,6 +63,8 @@ struct gprs_sndcp_entity { extern struct llist_head gprs_sndcp_entities; +int gprs_sndcp_vty_init(void); + /* Set of SNDCP-XID negotiation (See also: TS 144 065, * Section 6.8 XID parameter negotiation) */ int sndcp_sn_xid_req(struct gprs_llc_lle *lle, uint8_t nsapi); @@ -68,7 +73,7 @@ int sndcp_sn_xid_req(struct gprs_llc_lle *lle, uint8_t nsapi); * Section 6.8 XID parameter negotiation) */ int sndcp_sn_xid_ind(struct gprs_llc_xid_field *xid_field_indication, struct gprs_llc_xid_field *xid_field_response, - struct gprs_llc_lle *lle); + const struct gprs_llc_lle *lle); /* Process SNDCP-XID indication * (See also: TS 144 065, Section 6.8 XID parameter negotiation) */ @@ -76,4 +81,21 @@ int sndcp_sn_xid_conf(struct gprs_llc_xid_field *xid_field_conf, struct gprs_llc_xid_field *xid_field_request, struct gprs_llc_lle *lle); +/* Clean up all gprs_sndcp_entities related to llme (OS#4824) */ +void gprs_sndcp_sm_deactivate_ind_by_llme(const struct gprs_llc_llme *llme); + +/* Called by SNDCP when it has received/re-assembled a N-PDU */ +int sndcp_sn_unitdata_ind(struct gprs_sndcp_entity *sne, struct msgb *msg, + uint32_t npdu_len, uint8_t *npdu); +int sndcp_sn_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi, + void *mmcontext); + +/* Entry point for the SNSM-ACTIVATE.indication */ +int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi); +/* Entry point for the SNSM-DEACTIVATE.indication */ +int sndcp_sm_deactivate_ind(const struct gprs_llc_lle *lle, uint8_t nsapi); + +int sndcp_ll_unitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, + uint8_t *hdr, uint16_t len); + #endif /* INT_SNDCP_H */ diff --git a/include/osmocom/sgsn/gprs_subscriber.h b/include/osmocom/sgsn/gprs_subscriber.h index d36db7500..0d4a5947e 100644 --- a/include/osmocom/sgsn/gprs_subscriber.h +++ b/include/osmocom/sgsn/gprs_subscriber.h @@ -4,10 +4,70 @@ #include <stdint.h> #include <osmocom/core/linuxlist.h> +#include <osmocom/core/socket.h> #include <osmocom/gsm/protocol/gsm_23_003.h> +#include <osmocom/gsm/protocol/gsm_04_08_gprs.h> + +#include <osmocom/sgsn/apn.h> + +struct sgsn_instance; +struct sgsn_mm_ctx; extern struct llist_head * const gprs_subscribers; +#define GPRS_SUBSCRIBER_FIRST_CONTACT 0x00000001 +#define GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING (1 << 16) +#define GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING (1 << 17) +#define GPRS_SUBSCRIBER_CANCELLED (1 << 18) +#define GPRS_SUBSCRIBER_ENABLE_PURGE (1 << 19) + +#define GPRS_SUBSCRIBER_UPDATE_PENDING_MASK ( \ + GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING | \ + GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING \ +) + +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 */ + +struct sgsn_subscriber_data { + struct sgsn_mm_ctx *mm; + struct gsm_auth_tuple auth_triplets[5]; + int auth_triplets_updated; + struct llist_head pdp_list; + int error_cause; + + uint8_t msisdn[9]; + size_t msisdn_len; + + uint8_t hlr[9]; + size_t hlr_len; + + uint8_t pdp_charg[2]; + bool has_pdp_charg; +}; + +/* 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; + enum gsm48_pdp_type_org pdp_type_org; + enum gsm48_pdp_type_nr pdp_type_nr; + struct osmo_sockaddr pdp_address[2]; + char apn_str[GSM_APN_LENGTH]; + uint8_t qos_subscribed[20]; + size_t qos_subscribed_len; + uint8_t pdp_charg[2]; + bool has_pdp_charg; +}; + +struct sgsn_subscriber_pdp_data *sgsn_subscriber_pdp_data_alloc(struct sgsn_subscriber_data *sdata); + struct gprs_subscr { struct llist_head entry; int use_count; @@ -29,3 +89,22 @@ struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub, const char *file, int line); #define gprs_subscr_get(gsub) _gprs_subscr_get(gsub, __FILE__, __LINE__) #define gprs_subscr_put(gsub) _gprs_subscr_put(gsub, __FILE__, __LINE__) + +int gprs_subscr_init(struct sgsn_instance *sgi); +int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); +int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, + const uint8_t *auts, + const uint8_t *auts_rand); +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); +int gprs_subscr_rx_gsup_message(struct msgb *msg); + +#define LOGGSUBSCRP(level, subscr, fmt, args...) \ + LOGP(DGPRS, level, "SUBSCR(%s) " fmt, \ + (subscr) ? (subscr)->imsi : "---", \ + ## args) diff --git a/include/osmocom/sgsn/gprs_utils.h b/include/osmocom/sgsn/gprs_utils.h index eacaec7a2..1e6c8319c 100644 --- a/include/osmocom/sgsn/gprs_utils.h +++ b/include/osmocom/sgsn/gprs_utils.h @@ -29,15 +29,11 @@ struct msgb; struct gprs_ra_id; -int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str); - /* GSM 04.08, 10.5.7.3 GPRS Timer */ -int gprs_tmr_to_secs(uint8_t tmr); uint8_t gprs_secs_to_tmr_floor(int secs); int gprs_is_mi_tmsi(const uint8_t *value, size_t value_len); int gprs_is_mi_imsi(const uint8_t *value, size_t value_len); -int gprs_parse_mi_tmsi(const uint8_t *value, size_t value_len, uint32_t *tmsi); void gprs_parse_tmsi(const uint8_t *value, uint32_t *tmsi); int gprs_ra_id_equals(const struct gprs_ra_id *id1, const struct gprs_ra_id *id2); diff --git a/include/osmocom/sgsn/gtp.h b/include/osmocom/sgsn/gtp.h new file mode 100644 index 000000000..2aec55333 --- /dev/null +++ b/include/osmocom/sgsn/gtp.h @@ -0,0 +1,30 @@ +#pragma once + +#include <stddef.h> +#include <stdint.h> + +#include <osmocom/gsm/tlv.h> +#include <osmocom/gprs/gprs_bssgp_rim.h> + +struct gprs_ra_id; +struct sgsn_instance; +struct sgsn_ggsn_ctx; +struct sgsn_pdp_ctx; +struct sgsn_mm_ctx; +struct sgsn_mme_ctx; + +int sgsn_gtp_init(struct sgsn_instance *sgi); + +int sgsn_mme_ran_info_req(struct sgsn_mme_ctx *mme, const struct bssgp_ran_information_pdu *pdu); + +void sgsn_ggsn_echo_req(struct sgsn_ggsn_ctx *ggc); +struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn, + struct sgsn_mm_ctx *mmctx, + uint16_t nsapi, + struct tlv_parsed *tp); + +int sgsn_gtp_data_req(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi, + struct msgb *msg, uint32_t npdu_len, uint8_t *npdu); +int sgsn_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx); +void sgsn_pdp_upd_gtp_u(struct sgsn_pdp_ctx *pdp, void *addr, size_t alen); +int send_act_pdp_cont_acc(struct sgsn_pdp_ctx *pctx); diff --git a/include/osmocom/sgsn/gtp_ggsn.h b/include/osmocom/sgsn/gtp_ggsn.h new file mode 100644 index 000000000..6afb8664a --- /dev/null +++ b/include/osmocom/sgsn/gtp_ggsn.h @@ -0,0 +1,41 @@ +#pragma once + +#include <stdint.h> +#include <netinet/in.h> +#include <inttypes.h> + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/timer.h> +#include <osmocom/gprs/protocol/gsm_24_301.h> + +struct gsn_t; +struct sgsn_pdp_ctx; +struct sgsn_instance; + +struct sgsn_ggsn_ctx { + struct llist_head list; + uint32_t id; + unsigned int gtp_version; + struct in_addr remote_addr; + int remote_restart_ctr; + struct gsn_t *gsn; + struct llist_head pdp_list; /* list of associated pdp ctx (struct sgsn_pdp_ctx*) */ + struct osmo_timer_list echo_timer; + unsigned int echo_interval; +}; +struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_alloc(struct sgsn_instance *sgsn, uint32_t id); +void sgsn_ggsn_ctx_free(struct sgsn_ggsn_ctx *ggc); +struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_id(struct sgsn_instance *sgsn, uint32_t id); +struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_addr(struct sgsn_instance *sgsn, struct in_addr *addr); +struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_find_alloc(struct sgsn_instance *sgsn, uint32_t id); +void sgsn_ggsn_ctx_drop_pdp(struct sgsn_pdp_ctx *pctx); +int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pdp_ctx *except); +int sgsn_ggsn_ctx_drop_all_pdp(struct sgsn_ggsn_ctx *ggsn); +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); +void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc); + +#define LOGGGSN(ggc, level, fmt, args...) { \ + char _buf[INET_ADDRSTRLEN]; \ + LOGP(DGTP, level, "GGSN(%" PRIu32 ":%s): " fmt, (ggc)->id, inet_ntop(AF_INET, &(ggc)->remote_addr, _buf, sizeof(_buf)), ## args); \ + } while (0) diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/mmctx.h index c176494b1..c19f599c5 100644 --- a/include/osmocom/sgsn/gprs_sgsn.h +++ b/include/osmocom/sgsn/mmctx.h @@ -1,5 +1,4 @@ -#ifndef _GPRS_SGSN_H -#define _GPRS_SGSN_H +#pragma once #include <stdint.h> #include <netinet/in.h> @@ -14,12 +13,17 @@ #include <osmocom/gsm/protocol/gsm_23_003.h> #include <osmocom/crypt/auth.h> +#include <osmocom/sgsn/apn.h> +#include <osmocom/sgsn/auth.h> +#include <osmocom/sgsn/gprs_subscriber.h> + #define GSM_EXTENSION_LENGTH 15 -#define GSM_APN_LENGTH 102 struct gprs_llc_lle; struct ctrl_handle; struct gprs_subscr; +struct sgsn_ggsn_ctx; +struct sgsn_pdp_ctx; enum gsm48_gsm_cause; @@ -37,13 +41,6 @@ enum gprs_mm_ctr { GMM_CTR_RA_UPDATE, }; -enum gprs_pdp_ctx { - PDP_CTR_PKTS_UDATA_IN, - PDP_CTR_PKTS_UDATA_OUT, - PDP_CTR_BYTES_UDATA_IN, - PDP_CTR_BYTES_UDATA_OUT, -}; - enum gprs_t3350_mode { GMM_T3350_MODE_NONE, GMM_T3350_MODE_ATT, @@ -51,17 +48,6 @@ enum gprs_t3350_mode { GMM_T3350_MODE_PTMSI_REALL, }; -/* Authorization/ACL handling */ -enum sgsn_auth_state { - SGSN_AUTH_UNKNOWN, - SGSN_AUTH_AUTHENTICATE, - SGSN_AUTH_UMTS_RESYNC, - SGSN_AUTH_ACCEPTED, - SGSN_AUTH_REJECTED -}; - -#define MS_RADIO_ACCESS_CAPA - enum sgsn_ggsn_lookup_state { SGSN_GGSN_2DIGIT, SGSN_GGSN_3DIGIT, @@ -104,13 +90,6 @@ struct service_info { struct ranap_ue_conn_ctx; -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 */ - /* According to TS 03.60, Table 5: SGSN MM and PDP Contexts */ /* Extended by 3GPP TS 23.060, Table 6: SGSN MM and PDP Contexts */ struct sgsn_mm_ctx { @@ -295,64 +274,6 @@ struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx, enum gsm48_gsm_cause *gsm_cause, char *apn_str); -enum pdp_ctx_state { - PDP_STATE_NONE, - PDP_STATE_CR_REQ, - PDP_STATE_CR_CONF, - - /* 04.08 / Figure 6.2 / 6.1.2.2 */ - PDP_STATE_INACT_PEND, - PDP_STATE_INACTIVE = PDP_STATE_NONE, -}; - -enum pdp_type { - PDP_TYPE_NONE, - PDP_TYPE_ETSI_PPP, - PDP_TYPE_IANA_IPv4, - PDP_TYPE_IANA_IPv6, -}; - -struct sgsn_pdp_ctx { - 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 */ - int destroy_ggsn; /* destroy it on destruction */ - struct sgsn_ggsn_ctx *ggsn; /* which GGSN serves this PDP */ - struct llist_head ggsn_list; /* list_head for ggsn->pdp_list */ - struct rate_ctr_group *ctrg; - - //unsigned int id; - struct pdp_t *lib; /* pointer to libgtp PDP ctx */ - enum pdp_ctx_state state; - enum pdp_type type; - uint32_t address; - char *apn_subscribed; - //char *apn_used; - uint16_t nsapi; /* SNDCP */ - uint16_t sapi; /* LLC */ - uint8_t ti; /* transaction identifier */ - int vplmn_allowed; - uint32_t qos_profile_subscr; - //uint32_t qos_profile_req; - //uint32_t qos_profile_neg; - uint8_t radio_prio; - //uint32_t charging_id; - - struct osmo_timer_list timer; - unsigned int T; /* Txxxx number */ - unsigned int num_T_exp; /* number of consecutive T expirations */ - - 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; - uint32_t cdr_charging_id; -}; - -#define LOGPDPCTXP(level, pdp, fmt, args...) \ - LOGP(DGPRS, level, "PDP(%s/%u) " \ - fmt, (pdp)->mm ? (pdp)->mm->imsi : "---", (pdp)->ti, ## args) - /* look up PDP context by MM context and NSAPI */ struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_nsapi(const struct sgsn_mm_ctx *mm, uint8_t nsapi); @@ -360,168 +281,7 @@ struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_nsapi(const struct sgsn_mm_ctx *mm, struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tid(const struct sgsn_mm_ctx *mm, uint8_t tid); -struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm, - struct sgsn_ggsn_ctx *ggsn, - uint8_t nsapi); -void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp); -void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp); - - -struct sgsn_ggsn_ctx { - struct llist_head list; - uint32_t id; - unsigned int gtp_version; - struct in_addr remote_addr; - int remote_restart_ctr; - struct gsn_t *gsn; - struct llist_head pdp_list; /* list of associated pdp ctx (struct sgsn_pdp_ctx*) */ - struct osmo_timer_list echo_timer; - unsigned int echo_interval; -}; -struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_alloc(uint32_t id); -void sgsn_ggsn_ctx_free(struct sgsn_ggsn_ctx *ggc); -struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_id(uint32_t id); -struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_addr(struct in_addr *addr); -struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_find_alloc(uint32_t id); -void sgsn_ggsn_ctx_drop_pdp(struct sgsn_pdp_ctx *pctx); -int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pdp_ctx *except); -int sgsn_ggsn_ctx_drop_all_pdp(struct sgsn_ggsn_ctx *ggsn); -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); -void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc); - -#define LOGGGSN(ggc, level, fmt, args...) { \ - char _buf[INET_ADDRSTRLEN]; \ - LOGP(DGTP, level, "GGSN(%" PRIu32 ":%s): " fmt, (ggc)->id, inet_ntop(AF_INET, &(ggc)->remote_addr, _buf, sizeof(_buf)), ## args); \ - } while (0) - -struct apn_ctx { - struct llist_head list; - struct sgsn_ggsn_ctx *ggsn; - char *name; - char *imsi_prefix; - char *description; -}; - -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); - -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; - uint32_t sgsn_alloc_ptmsi(void); -struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx); -void sgsn_inst_init(struct sgsn_instance *sgsn); - -char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len); - -/* - * ctrl interface related work - */ -int sgsn_ctrl_cmds_install(void); - -/* - * Authorization/ACL handling - */ -struct imsi_acl_entry { - struct llist_head list; - char imsi[OSMO_IMSI_BUF_SIZE]; -}; - -/* 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]; - uint8_t qos_subscribed[20]; - size_t qos_subscribed_len; - uint8_t pdp_charg[2]; - bool has_pdp_charg; -}; - -struct sgsn_subscriber_data { - struct sgsn_mm_ctx *mm; - struct gsm_auth_tuple auth_triplets[5]; - int auth_triplets_updated; - struct llist_head pdp_list; - int error_cause; - - uint8_t msisdn[9]; - size_t msisdn_len; - - uint8_t hlr[9]; - size_t hlr_len; - - uint8_t pdp_charg[2]; - bool has_pdp_charg; -}; - -#define SGSN_ERROR_CAUSE_NONE (-1) - -#define LOGGSUBSCRP(level, subscr, fmt, args...) \ - LOGP(DGPRS, level, "SUBSCR(%s) " fmt, \ - (subscr) ? (subscr)->imsi : "---", \ - ## args) - -struct sgsn_config; -struct sgsn_instance; -extern const struct value_string *sgsn_auth_state_names; - -void sgsn_auth_init(struct sgsn_instance *sgsn); -struct imsi_acl_entry *sgsn_acl_lookup(const char *imsi, const struct sgsn_config *cfg); -int sgsn_acl_add(const char *imsi, struct sgsn_config *cfg); -int sgsn_acl_del(const char *imsi, struct sgsn_config *cfg); -/* Request authorization */ -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); -struct gsm_auth_tuple *sgsn_auth_get_tuple(struct sgsn_mm_ctx *mmctx, - unsigned key_seq); - -/* - * GPRS subscriber data - */ -#define GPRS_SUBSCRIBER_FIRST_CONTACT 0x00000001 -#define GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING (1 << 16) -#define GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING (1 << 17) -#define GPRS_SUBSCRIBER_CANCELLED (1 << 18) -#define GPRS_SUBSCRIBER_ENABLE_PURGE (1 << 19) - -#define GPRS_SUBSCRIBER_UPDATE_PENDING_MASK ( \ - GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING | \ - GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING \ -) - -int gprs_subscr_init(struct sgsn_instance *sgi); -int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); -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); -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); -int gprs_subscr_rx_gsup_message(struct msgb *msg); /* Called on subscriber data updates */ void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx); - -int gprs_sndcp_vty_init(void); -struct sgsn_instance; -int sgsn_gtp_init(struct sgsn_instance *sgi); - -void sgsn_rate_ctr_init(); - -#endif /* _GPRS_SGSN_H */ diff --git a/include/osmocom/sgsn/pdpctx.h b/include/osmocom/sgsn/pdpctx.h new file mode 100644 index 000000000..255a77d3f --- /dev/null +++ b/include/osmocom/sgsn/pdpctx.h @@ -0,0 +1,94 @@ +#pragma once + +#include <stdint.h> +#include <netinet/in.h> +#include <inttypes.h> + +#include <osmocom/core/timer.h> +#include <osmocom/core/rate_ctr.h> + +#include <osmocom/gsm/gsm48.h> + +#include <osmocom/crypt/gprs_cipher.h> +#include <osmocom/gsm/protocol/gsm_23_003.h> +#include <osmocom/crypt/auth.h> + +#include <osmocom/sgsn/apn.h> +#include <osmocom/sgsn/gprs_subscriber.h> + +struct sgsn_mm_ctx; +struct sgsn_ggsn_ctx; + +enum gprs_pdp_ctx { + PDP_CTR_PKTS_UDATA_IN, + PDP_CTR_PKTS_UDATA_OUT, + PDP_CTR_BYTES_UDATA_IN, + PDP_CTR_BYTES_UDATA_OUT, +}; + +enum pdp_ctx_state { + PDP_STATE_NONE, + PDP_STATE_CR_REQ, + PDP_STATE_CR_CONF, + + /* 04.08 / Figure 6.2 / 6.1.2.2 */ + PDP_STATE_INACT_PEND, + PDP_STATE_INACTIVE = PDP_STATE_NONE, +}; + +enum pdp_type { + PDP_TYPE_NONE, + PDP_TYPE_ETSI_PPP, + PDP_TYPE_IANA_IPv4, + PDP_TYPE_IANA_IPv6, +}; + +struct sgsn_pdp_ctx { + 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 */ + int destroy_ggsn; /* destroy it on destruction */ + struct sgsn_ggsn_ctx *ggsn; /* which GGSN serves this PDP */ + struct llist_head ggsn_list; /* list_head for ggsn->pdp_list */ + struct rate_ctr_group *ctrg; + + //unsigned int id; + struct pdp_t *lib; /* pointer to libgtp PDP ctx */ + enum pdp_ctx_state state; + enum pdp_type type; + uint32_t address; + char *apn_subscribed; + //char *apn_used; + uint16_t nsapi; /* SNDCP */ + uint16_t sapi; /* LLC */ + uint8_t ti; /* transaction identifier */ + int vplmn_allowed; + uint32_t qos_profile_subscr; + //uint32_t qos_profile_req; + //uint32_t qos_profile_neg; + uint8_t radio_prio; + //uint32_t charging_id; + + struct osmo_timer_list timer; + unsigned int T; /* Txxxx number */ + unsigned int num_T_exp; /* number of consecutive T expirations */ + + 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; + uint32_t cdr_charging_id; +}; + +#define LOGPDPCTXP(level, pdp, fmt, args...) \ + LOGP(DGPRS, level, "PDP(%s/%u) " \ + fmt, (pdp)->mm ? (pdp)->mm->imsi : "---", (pdp)->ti, ## args) + +struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm, + struct sgsn_ggsn_ctx *ggsn, + uint8_t nsapi); +void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp); +void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp); + +char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len, bool return_ipv6); + diff --git a/include/osmocom/sgsn/sgsn.h b/include/osmocom/sgsn/sgsn.h index 5b29873b6..6e93178af 100644 --- a/include/osmocom/sgsn/sgsn.h +++ b/include/osmocom/sgsn/sgsn.h @@ -8,13 +8,13 @@ #include <osmocom/gprs/gprs_ns2.h> #include <osmocom/gprs/gprs_bssgp.h> -#include <osmocom/sgsn/gprs_sgsn.h> +#include <osmocom/sgsn/auth.h> #include <osmocom/sgsn/gtp_mme.h> #include <osmocom/gsm/oap_client.h> #include <osmocom/gsupclient/gsup_client.h> #include <osmocom/sgsn/common.h> -#include "../../bscconfig.h" +#include "../../config.h" #if BUILD_IU #include <osmocom/ranap/iu_client.h> @@ -25,6 +25,8 @@ struct hostent; +#define SGSN_ERROR_CAUSE_NONE (-1) + enum sgsn_auth_policy { SGSN_AUTH_POLICY_OPEN, SGSN_AUTH_POLICY_CLOSED, @@ -75,8 +77,10 @@ struct sgsn_config { /* misc */ struct gprs_ns2_inst *nsi; + char *crypt_cipher_plugin_path; enum sgsn_auth_policy auth_policy; - uint8_t cipher_support_mask; + uint8_t gea_encryption_mask; + uint8_t uea_encryption_mask; struct llist_head imsi_acl; struct sockaddr_in gsup_server_addr; @@ -92,6 +96,7 @@ struct sgsn_config { /* Timer defintions */ struct osmo_tdef *T_defs; + struct osmo_tdef *T_defs_gtp; int dynamic_lookup; @@ -149,10 +154,22 @@ struct sgsn_instance { struct rate_ctr_group *rate_ctrs; + struct llist_head apn_list; /* list of struct sgsn_apn_ctx */ + struct llist_head ggsn_list; /* list of struct sgsn_ggsn_ctx */ struct llist_head mme_list; /* list of struct sgsn_mme_ctx */ + struct llist_head mm_list; /* list of struct sgsn_mm_ctx */ + struct llist_head pdp_list; /* list of struct sgsn_pdp_ctx */ + + struct ctrl_handle *ctrlh; }; extern struct sgsn_instance *sgsn; +extern void *tall_sgsn_ctx; + +/* + * ctrl interface related work (sgsn_ctrl.c) + */ +int sgsn_ctrl_cmds_install(void); /* sgsn_vty.c */ @@ -161,40 +178,13 @@ int sgsn_parse_config(const char *config_file); char *sgsn_gtp_ntoa(struct ul16_t *ul); /* sgsn.c */ - -/* Main input function for Gb proxy */ -int sgsn_rcvmsg(struct msgb *msg, struct gprs_ns2_vc *nsvc, uint16_t ns_bvci); - -/* sgsn_libgtp.c */ -struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn, - struct sgsn_mm_ctx *mmctx, - uint16_t nsapi, - struct tlv_parsed *tp); -int sgsn_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx); -void sgsn_pdp_upd_gtp_u(struct sgsn_pdp_ctx *pdp, void *addr, size_t alen); -void sgsn_ggsn_echo_req(struct sgsn_ggsn_ctx *ggc); -int send_act_pdp_cont_acc(struct sgsn_pdp_ctx *pctx); -int sgsn_mme_ran_info_req(struct sgsn_mme_ctx *mme, const struct bssgp_ran_information_pdu *pdu); - -/* gprs_sndcp.c */ - -/* Entry point for the SNSM-ACTIVATE.indication */ -int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi); -/* Entry point for the SNSM-DEACTIVATE.indication */ -int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi); -/* Called by SNDCP when it has received/re-assembled a N-PDU */ -int sgsn_rx_sndcp_ud_ind(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi, - struct msgb *msg, uint32_t npdu_len, uint8_t *npdu); -int sndcp_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi, - void *mmcontext); -int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, - uint8_t *hdr, uint16_t len); - - +struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx); +int sgsn_inst_init(struct sgsn_instance *sgsn); /* * CDR related functionality */ int sgsn_cdr_init(struct sgsn_instance *sgsn); +void sgsn_cdr_release(struct sgsn_instance *sgsn); /* diff --git a/include/osmocom/sgsn/sgsn_rim.h b/include/osmocom/sgsn/sgsn_rim.h index aa5a72664..fc87b468e 100644 --- a/include/osmocom/sgsn/sgsn_rim.h +++ b/include/osmocom/sgsn/sgsn_rim.h @@ -3,4 +3,4 @@ struct sgsn_mme_ctx; int sgsn_rim_rx_from_gb(struct osmo_bssgp_prim *bp, struct msgb *msg); -int sgsn_rim_rx_from_gtp(struct bssgp_ran_information_pdu *pdu, struct sgsn_mme_ctx *mme); +int sgsn_rim_rx_from_gtp(struct msgb *msg, struct bssgp_rim_routing_info *rim_routing_address); diff --git a/include/osmocom/sgsn/v42bis.h b/include/osmocom/sgsn/v42bis.h index b64c43e69..d782981b0 100644 --- a/include/osmocom/sgsn/v42bis.h +++ b/include/osmocom/sgsn/v42bis.h @@ -17,10 +17,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /*! \page v42bis_page V.42bis modem data compression diff --git a/include/osmocom/sgsn/v42bis_private.h b/include/osmocom/sgsn/v42bis_private.h index c6b675a1b..cc7e63448 100644 --- a/include/osmocom/sgsn/v42bis_private.h +++ b/include/osmocom/sgsn/v42bis_private.h @@ -17,10 +17,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #if !defined(_SPANDSP_PRIVATE_V42BIS_H_) |