From a9cb373f47ef87f489184ea9ecd747165fc2c191 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Tue, 11 Apr 2017 23:55:21 +0900 Subject: [PATCH] update it --- lib/3gpp/3gpp_common.h | 4 ++-- lib/gtp/gtp_xact.c | 3 ++- src/hss/hss_context.c | 8 ++++++-- src/hss/hss_context.h | 7 +++++++ src/hss/hss_init.c | 2 ++ src/mme/mme_context.c | 13 ++++++++++--- src/mme/mme_context.h | 10 ++++++++-- src/mme/mme_s11_build.c | 2 +- src/mme/mme_s6a_handler.c | 2 ++ 9 files changed, 40 insertions(+), 11 deletions(-) diff --git a/lib/3gpp/3gpp_common.h b/lib/3gpp/3gpp_common.h index 8df5d1145..89d3b6c4f 100644 --- a/lib/3gpp/3gpp_common.h +++ b/lib/3gpp/3gpp_common.h @@ -33,8 +33,8 @@ extern "C" { #define MAX_APN_LEN 100 -#define NEXT_ID(__id, __max) \ - ((__id) = ((__id) == (__max) ? 1 : ((__id) + 1))) +#define NEXT_ID(__id, __min, __max) \ + ((__id) = ((__id) == (__max) ? (__min) : ((__id) + 1))) #define COMPARE_ID(__id1, __id2, __max) \ ((__id2) > (__id1) ? ((__id2) - (__id1) < ((__max)-1) ? -1 : 1) : \ (__id1) > (__id2) ? ((__id1) - (__id2) < ((__max)-1) ? 1 : -1) : 0) diff --git a/lib/gtp/gtp_xact.c b/lib/gtp/gtp_xact.c index 79e560756..a3e93a255 100644 --- a/lib/gtp/gtp_xact.c +++ b/lib/gtp/gtp_xact.c @@ -7,6 +7,7 @@ #include "gtp_xact.h" #define SIZE_OF_GTP_XACT_POOL 32 +#define GTP_MIN_XACT_ID 1 #define GTP_MAX_XACT_ID 0x800000 #define GTP_XACT_LOCAL_DURATION 3000 /* 3 seconds */ @@ -165,7 +166,7 @@ gtp_xact_t *gtp_xact_local_create( gtp_xact_ctx_t *context, net_sock_t *sock, gtp_node_t *gnode) { return gtp_xact_create(context, sock, gnode, GTP_LOCAL_ORIGINATOR, - NEXT_ID(context->g_xact_id, GTP_MAX_XACT_ID), + NEXT_ID(context->g_xact_id, GTP_MIN_XACT_ID, GTP_MAX_XACT_ID), GTP_XACT_LOCAL_DURATION, GTP_XACT_LOCAL_RETRY_COUNT); } diff --git a/src/hss/hss_context.c b/src/hss/hss_context.c index 45021d4b8..aa4413173 100644 --- a/src/hss/hss_context.c +++ b/src/hss/hss_context.c @@ -52,11 +52,13 @@ status_t hss_context_init(void) memcpy(profile->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN); profile->sqn = 64; - profile->access_restriction_data = 5; + profile->access_restriction_data = 0; profile->subscriber_status = HSS_SUBSCRIBER_STATUS_SERVICE_GRANTED; profile->network_access_mode = HSS_NETWORK_ACCESS_MODE_ONLY_PACKET; +#if HSS_DISABLE_MAX_BANDWIDTH_PER_UE == 0 profile->max_bandwidth_ul = 102400; /* Kbps */ profile->max_bandwidth_dl = 102400; /* Kbps */ +#endif profile->subscribed_rau_tau_timer = 12; /* minutes */ @@ -130,7 +132,7 @@ pdn_t* hss_pdn_add() memset(pdn, 0, sizeof(pdn_t)); - pdn->id = NEXT_ID(self.pdn_id, 0xffffffff); + pdn->id = NEXT_ID(self.pdn_id, 1, 0xffffffff); list_append(&self.pdn_list, pdn); @@ -301,8 +303,10 @@ hss_ue_t* hss_ue_add(hss_profile_id_t id, c_int8_t *imsi_bcd) ue->access_restriction_data = profile->access_restriction_data; ue->subscriber_status = profile->subscriber_status; ue->network_access_mode = profile->network_access_mode; +#if HSS_DISABLE_MAX_BANDWIDTH_PER_UE == 0 ue->max_bandwidth_ul = profile->max_bandwidth_ul; ue->max_bandwidth_dl = profile->max_bandwidth_dl; +#endif ue->subscribed_rau_tau_timer = profile->subscribed_rau_tau_timer; diff --git a/src/hss/hss_context.h b/src/hss/hss_context.h index aa4c3937b..1939b123d 100644 --- a/src/hss/hss_context.h +++ b/src/hss/hss_context.h @@ -14,6 +14,9 @@ extern "C" { #define HSS_KEY_LEN 16 #define HSS_AMF_LEN 2 +/* FIXME : Does it needed? */ +#define HSS_DISABLE_MAX_BANDWIDTH_PER_UE 1 + typedef c_uint32_t hss_profile_id_t; typedef struct _hss_profile_t { lnode_t node; /**< A node of list_t */ @@ -31,8 +34,10 @@ typedef struct _hss_profile_t { c_uint32_t subscriber_status; c_uint32_t network_access_mode; +#if HSS_DISABLE_MAX_BANDWIDTH_PER_UE == 0 c_uint32_t max_bandwidth_ul; /* Kbps */ c_uint32_t max_bandwidth_dl; /* Kbps */ +#endif c_uint32_t subscribed_rau_tau_timer; /* minutes */ } hss_profile_t; @@ -65,8 +70,10 @@ typedef struct _hss_ue_t { #define HSS_NETWORK_ACCESS_MODE_ONLY_PACKET 2 c_uint32_t network_access_mode; +#if HSS_DISABLE_MAX_BANDWIDTH_PER_UE == 0 c_uint32_t max_bandwidth_ul; /* Kbps */ c_uint32_t max_bandwidth_dl; /* Kbps */ +#endif c_uint32_t subscribed_rau_tau_timer; /* minutes */ diff --git a/src/hss/hss_init.c b/src/hss/hss_init.c index 300a649a5..f0de2a165 100644 --- a/src/hss/hss_init.c +++ b/src/hss/hss_init.c @@ -257,6 +257,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp, avp_network_access_mode) == 0, goto out,); /* Set the AMBR */ +#if HSS_DISABLE_MAX_BANDWIDTH_PER_UE == 0 d_assert(fd_msg_avp_new(s6a_ambr, 0, &avp_ambr) == 0, goto out,); d_assert(fd_msg_avp_new(s6a_max_bandwidth_ul, 0, &avp_max_bandwidth_ul) == 0, goto out,); @@ -274,6 +275,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp, avp_max_bandwidth_dl) == 0, goto out,); d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_ambr) == 0, goto out,); +#endif if (ue->num_of_pdn && ue->pdn[0]) { diff --git a/src/mme/mme_context.c b/src/mme/mme_context.c index 72fb2188b..52fce31ee 100644 --- a/src/mme/mme_context.c +++ b/src/mme/mme_context.c @@ -16,6 +16,9 @@ #define S1AP_SCTP_PORT 36412 +#define MIN_EPS_BEARER_ID 5 +#define MAX_EPS_BEARER_ID 15 + static mme_context_t self; pool_declare(mme_sgw_pool, mme_sgw_t, MAX_NUM_OF_SGW); @@ -383,10 +386,12 @@ mme_ue_t* mme_ue_add(mme_enb_t *enb) index_alloc(&mme_ue_pool, &ue); d_assert(ue, return NULL, "Null param"); - ue->mme_ue_s1ap_id = NEXT_ID(self.mme_ue_s1ap_id, 0xffffffff); + ue->mme_ue_s1ap_id = NEXT_ID(self.mme_ue_s1ap_id, 1, 0xffffffff); hash_set(self.mme_ue_s1ap_id_hash, &ue->mme_ue_s1ap_id, sizeof(ue->mme_ue_s1ap_id), ue); + ue->ebi = MIN_EPS_BEARER_ID - 1; + ue->enb = enb; list_init(&ue->esm_list); list_append(&enb->ue_list, ue); @@ -520,10 +525,12 @@ mme_esm_t* mme_esm_add(mme_ue_t *ue, c_uint8_t pti) index_alloc(&mme_esm_pool, &esm); d_assert(esm, return NULL, "Null param"); - esm->teid = esm->index; esm->pti = pti; - esm->ue = ue; + esm->ebi = NEXT_ID(ue->ebi, MIN_EPS_BEARER_ID, MAX_EPS_BEARER_ID); + esm->teid = esm->index; + + esm->ue = ue; list_append(&ue->esm_list, esm); fsm_create(&esm->sm, esm_state_initial, esm_state_final); diff --git a/src/mme/mme_context.h b/src/mme/mme_context.h index 20e5e12b9..f7b4ae5d3 100644 --- a/src/mme/mme_context.h +++ b/src/mme/mme_context.h @@ -18,6 +18,8 @@ extern "C" { #endif /* __cplusplus */ +#define MME_DISABLE_MAX_BANDWIDTH_PER_UE 1 + #define MAX_PLMN_ID 6 #define GRP_PER_MME 256 /* According to spec it is 65535 */ #define CODE_PER_MME 256 /* According to spec it is 256 */ @@ -140,14 +142,17 @@ typedef struct _mme_ue_t { /* HSS Info */ c_uint32_t ula_flags; +#if MME_DISABLE_MAX_BANDWIDTH_PER_UE == 0 c_uint32_t max_bandwidth_ul; /* bits per seconds */ c_uint32_t max_bandwidth_dl; /* bits per seconds */ +#endif pdn_t *pdn[MAX_NUM_OF_PDN]; int num_of_pdn; c_uint32_t subscribed_rau_tau_timer; /* seconds */ + c_uint8_t ebi; /* EPS Bearer ID generator */ list_t esm_list; mme_enb_t *enb; @@ -158,14 +163,15 @@ typedef struct _mme_esm_t { index_t index; /**< An index of this node */ fsm_t sm; + c_uint8_t pti; /** Procedure Trasaction Identity */ + c_uint8_t ebi; /** EPS Bearer ID */ + /* IMPORTANT! * MME-S11-F-TEID is same with an index */ c_uint32_t teid; c_uint32_t sgw_addr; /* SGW-S11-F-TEID IPv4 Address */ c_uint32_t sgw_teid; /* SGW-S11-F-TEID */ - c_uint8_t pti; /** Procedure Trasaction Identity */ - c_uint8_t pco[MAX_PCO_LEN]; int pco_len; diff --git a/src/mme/mme_s11_build.c b/src/mme/mme_s11_build.c index b8895cda4..e2c19c945 100644 --- a/src/mme/mme_s11_build.c +++ b/src/mme/mme_s11_build.c @@ -120,7 +120,7 @@ status_t mme_s11_build_create_session_req(pkbuf_t **pkbuf, mme_esm_t *esm) req->bearer_contexts_to_be_created.presence = 1; req->bearer_contexts_to_be_created.eps_bearer_id.presence = 1; - req->bearer_contexts_to_be_created.eps_bearer_id.u8 = 5; + req->bearer_contexts_to_be_created.eps_bearer_id.u8 = esm->ebi; memset(&bearer_qos, 0, sizeof(bearer_qos)); bearer_qos.pre_emption_vulnerability = pdn->pre_emption_vulnerability; diff --git a/src/mme/mme_s6a_handler.c b/src/mme/mme_s6a_handler.c index 86e4163cd..bbd958ea9 100644 --- a/src/mme/mme_s6a_handler.c +++ b/src/mme/mme_s6a_handler.c @@ -300,6 +300,7 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg) ue->msisdn_len = hdr->avp_value->os.len; memcpy(ue->msisdn, hdr->avp_value->os.data, ue->msisdn_len); +#if MME_DISABLE_MAX_BANDWIDTH_PER_UE == 0 d_assert(fd_avp_search_avp(avp, s6a_ambr, &avpch1) == 0 && avpch1, error++; goto out,); d_assert(fd_avp_search_avp(avpch1, s6a_max_bandwidth_ul, &avpch2) == 0 && @@ -310,6 +311,7 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg) avpch2, error++; goto out,); d_assert(fd_msg_avp_hdr(avpch2, &hdr) == 0 && hdr, error++; goto out,); ue->max_bandwidth_dl = hdr->avp_value->i32; +#endif d_assert(fd_avp_search_avp(avp, s6a_apn_configuration_profile, &avpch1) == 0 && avpch1, error++; goto out,);