From f7198d7dbb84d038a82eec5ad0b86f7f29ca411e Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Tue, 22 May 2018 18:29:14 +0200 Subject: gprs_gmm: introduce a GMM Attach Request FSM The old GMM Attach Request handling used a recursive function which can not handle certain states and is quite complex and hard to extend. The new FSM handles such request in a FSM and can be called multiple times. Change-Id: I58b9c17be9776a03bb2a5b21e99135cfefc8c912 --- include/osmocom/sgsn/Makefile.am | 1 + include/osmocom/sgsn/gprs_gmm.h | 2 ++ include/osmocom/sgsn/gprs_gmm_attach.h | 37 ++++++++++++++++++++++++++++++++++ include/osmocom/sgsn/gprs_sgsn.h | 10 +++++++++ 4 files changed, 50 insertions(+) create mode 100644 include/osmocom/sgsn/gprs_gmm_attach.h (limited to 'include') diff --git a/include/osmocom/sgsn/Makefile.am b/include/osmocom/sgsn/Makefile.am index 269cebcd6..3b563c401 100644 --- a/include/osmocom/sgsn/Makefile.am +++ b/include/osmocom/sgsn/Makefile.am @@ -5,6 +5,7 @@ noinst_HEADERS = \ gb_proxy.h \ gprs_gb_parse.h \ gprs_gmm.h \ + gprs_gmm_attach.h \ gprs_llc.h \ gprs_llc_xid.h \ gprs_sgsn.h \ diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h index d12eaf9bb..ffcebd353 100644 --- a/include/osmocom/sgsn/gprs_gmm.h +++ b/include/osmocom/sgsn/gprs_gmm.h @@ -40,6 +40,8 @@ int gsm48_tx_gmm_att_rej(struct sgsn_mm_ctx *mm, uint8_t gmm_cause); int gsm48_tx_gmm_att_ack(struct sgsn_mm_ctx *mm); +int gprs_gmm_attach_req_ies(struct msgb *a, struct msgb *b); + /* TODO: move extract_subscr_* when gsm48_gmm_authorize() got removed */ void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx); void extract_subscr_hlr(struct sgsn_mm_ctx *ctx); diff --git a/include/osmocom/sgsn/gprs_gmm_attach.h b/include/osmocom/sgsn/gprs_gmm_attach.h new file mode 100644 index 000000000..22fbd6f9d --- /dev/null +++ b/include/osmocom/sgsn/gprs_gmm_attach.h @@ -0,0 +1,37 @@ +#ifndef GPRS_GMM_ATTACH_H +#define GPRS_GMM_ATTACH_H + +#include + +struct sgsn_mm_ctx; + +enum gmm_attach_req_fsm_states { + ST_INIT, + ST_IDENTIY, + ST_RETRIEVE_AUTH, + ST_AUTH, + ST_ASK_VLR, + ST_ACCEPT, + ST_REJECT +}; + +enum gmm_attach_req_fsm_events { + E_ATTACH_REQ_RECV, + E_IDEN_RESP_RECV, + E_AUTH_RESP_RECV_SUCCESS, + E_AUTH_RESP_RECV_RESYNC, + E_ATTACH_ACCEPTED, + E_ATTACH_ACCEPT_SENT, + E_ATTACH_COMPLETE_RECV, + E_REJECT, + E_VLR_ANSWERED, +}; + +#define GMM_DISCARD_MS_WITHOUT_REJECT -1 + +extern const struct value_string gmm_attach_req_fsm_event_names[]; +extern struct osmo_fsm gmm_attach_req_fsm; + +void gmm_att_req_free(struct sgsn_mm_ctx *mm); + +#endif // GPRS_GMM_ATTACH_H diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h index 6f16dc75f..a5ca959a4 100644 --- a/include/osmocom/sgsn/gprs_sgsn.h +++ b/include/osmocom/sgsn/gprs_sgsn.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -168,6 +169,15 @@ struct sgsn_mm_ctx { struct ranap_ue_conn_ctx *ue_ctx; struct service_info service; } iu; + 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; + bool auth_reattempt; + } gmm_att_req; /* VLR number */ uint32_t new_sgsn_addr; /* Authentication Triplet */ -- cgit v1.2.3