From df371f3b66aedf9922c704dbe7e8d9af3126030c Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 14 Jul 2017 20:46:15 +0900 Subject: [PATCH] update it --- src/mme/mme_context.c | 87 +++++++++++++++++++++++++++++++++++------ src/mme/mme_context.h | 7 +++- support/nextepc.conf.in | 14 ++----- test/tests1ap.c | 2 +- 4 files changed, 85 insertions(+), 25 deletions(-) diff --git a/src/mme/mme_context.c b/src/mme/mme_context.c index 3b3a8bafa..2f41f4fb8 100644 --- a/src/mme/mme_context.c +++ b/src/mme/mme_context.c @@ -60,8 +60,6 @@ status_t mme_context_init() /* MCC : 001, MNC : 01 */ plmn_id_build(&self.plmn_id, 1, 1, 2); self.tracking_area_code = 12345; - self.default_paging_drx = S1ap_PagingDRX_v64; - self.relative_capacity = 0xff; self.srvd_gummei.num_of_plmn_id = 1; /* MCC : 001, MNC : 01 */ @@ -82,6 +80,8 @@ status_t mme_context_init() static status_t mme_context_prepare() { + self.relative_capacity = 0xff; + self.s1ap_port = S1AP_SCTP_PORT; self.s11_port = GTPV2_C_UDP_PORT; @@ -121,6 +121,19 @@ static status_t mme_context_validation() sgw = mme_sgw_next(sgw); } + if (self.num_of_integrity_order == 0) + { + d_error("No MME.SECURITY.INTEGRITY_ORDER in '%s'", + context_self()->config.path); + return CORE_ERROR; + } + if (self.num_of_ciphering_order == 0) + { + d_error("No MME.SECURITY.CIPHERING_ORDER in '%s'", + context_self()->config.path); + return CORE_ERROR; + } + return CORE_OK; } @@ -196,13 +209,10 @@ status_t mme_context_parse_config() } case MME_ROOT: { - if (jsmntok_equal(json, t, "DEFAULT_PAGING_DRX") == 0) + if (jsmntok_equal(json, t, "RELATIVE_CAPACITY") == 0) { - printf("paging_drx : %s\n", jsmntok_to_string(json, t+1)); - } - else if (jsmntok_equal(json, t, "RELATIVE_CAPACITY") == 0) - { - printf("relative : %s\n", jsmntok_to_string(json, t+1)); + char *v = jsmntok_to_string(json, t+1); + if (v) self.relative_capacity = atoi(v); } else if (jsmntok_equal(json, t, "NETWORK") == 0) { @@ -329,8 +339,35 @@ status_t mme_context_parse_config() for (arr = 0; arr < size; arr++) { - printf("%s\n", - jsmntok_to_string(json, t+m+p)); + char *v = jsmntok_to_string(json, t+m+p); + if (v) + { + if (strcmp(v, "EIA0") == 0) + { + self.integrity_order[arr] = + NAS_SECURITY_ALGORITHMS_EIA0; + self.num_of_integrity_order++; + } + else if (strcmp(v, "EIA1") == 0) + { + self.integrity_order[arr] = + NAS_SECURITY_ALGORITHMS_128_EIA1; + self.num_of_integrity_order++; + } + else if (strcmp(v, "EIA2") == 0) + { + self.integrity_order[arr] = + NAS_SECURITY_ALGORITHMS_128_EIA2; + self.num_of_integrity_order++; + } + else if (strcmp(v, "EIA3") == 0) + { + self.integrity_order[arr] = + NAS_SECURITY_ALGORITHMS_128_EIA3; + self.num_of_integrity_order++; + } + } + p++; } } @@ -347,8 +384,34 @@ status_t mme_context_parse_config() for (arr = 0; arr < size; arr++) { - printf("%s\n", - jsmntok_to_string(json, t+m+p)); + char *v = jsmntok_to_string(json, t+m+p); + if (v) + { + if (strcmp(v, "EEA0") == 0) + { + self.ciphering_order[arr] = + NAS_SECURITY_ALGORITHMS_EEA0; + self.num_of_ciphering_order++; + } + else if (strcmp(v, "EEA1") == 0) + { + self.ciphering_order[arr] = + NAS_SECURITY_ALGORITHMS_128_EEA1; + self.num_of_ciphering_order++; + } + else if (strcmp(v, "EEA2") == 0) + { + self.ciphering_order[arr] = + NAS_SECURITY_ALGORITHMS_128_EEA2; + self.num_of_ciphering_order++; + } + else if (strcmp(v, "EEA3") == 0) + { + self.ciphering_order[arr] = + NAS_SECURITY_ALGORITHMS_128_EEA3; + self.num_of_ciphering_order++; + } + } p++; } } diff --git a/src/mme/mme_context.h b/src/mme/mme_context.h index 98d615e43..18730ef80 100644 --- a/src/mme/mme_context.h +++ b/src/mme/mme_context.h @@ -25,6 +25,8 @@ extern "C" { #define GRP_PER_MME 256 /* According to spec it is 65535 */ #define CODE_PER_MME 256 /* According to spec it is 256 */ +#define MAX_NUM_OF_ALGORITHM 8 + typedef struct _served_gummei { c_uint32_t num_of_plmn_id; plmn_id_t plmn_id[MAX_PLMN_ID]; @@ -56,17 +58,20 @@ typedef struct _mme_context_t { * #define NAS_SECURITY_ALGORITHMS_128_EEA1 1 * #define NAS_SECURITY_ALGORITHMS_128_EEA2 2 * #define NAS_SECURITY_ALGORITHMS_128_EEA3 3 */ + c_uint8_t num_of_ciphering_order; + c_uint8_t ciphering_order[MAX_NUM_OF_ALGORITHM]; c_uint8_t selected_enc_algorithm; /* defined in 'nas_ies.h' * #define NAS_SECURITY_ALGORITHMS_EIA0 0 * #define NAS_SECURITY_ALGORITHMS_128_EIA1 1 * #define NAS_SECURITY_ALGORITHMS_128_EIA1 2 * #define NAS_SECURITY_ALGORITHMS_128_EIA3 3 */ + c_uint8_t num_of_integrity_order; + c_uint8_t integrity_order[MAX_NUM_OF_ALGORITHM]; c_uint8_t selected_int_algorithm; /* S1SetupRequest */ c_uint16_t tracking_area_code; - c_uint16_t default_paging_drx; /* S1SetupResponse */ srvd_gummei_t srvd_gummei; diff --git a/support/nextepc.conf.in b/support/nextepc.conf.in index cbd564596..3a3dce874 100644 --- a/support/nextepc.conf.in +++ b/support/nextepc.conf.in @@ -12,14 +12,12 @@ S6A_CONFIG_PATH : "/Users/acetcom/Documents/git/nextepc/install/mme_fd.conf", DEFAULT_PAGING_DRX : "v64", - RELATIVE_CAPACITY : 255, +#RELATIVE_CAPACITY : 255, NETWORK : { S1AP_ADDR : "10.1.35.215", -#S1AP_PORT : 36412, S11_ADDR: "10.1.35.215", -#S11_PORT: 2123 } GUMMEI: [ @@ -51,14 +49,10 @@ [ { S11_ADDR: "10.1.35.216", -#S11_PORT: 2123, S1U_ADDR: "10.1.35.216", -#S1U_PORT: 2125, S5C_ADDR: "10.1.35.217", -#S5C_PORT: 2123, - S5U_ADDR: "10.1.35.217", -#S5U_PORT: 2125 + S5U_ADDR: "10.1.35.217" } ] } @@ -68,9 +62,7 @@ NETWORK : { S5C_ADDR: "10.1.35.219", -#S5C_PORT: 2123, - S5U_ADDR: "10.1.35.219", -#S5U_PORT: 2125 + S5U_ADDR: "10.1.35.219" } DNS : diff --git a/test/tests1ap.c b/test/tests1ap.c index 790ef981e..3a5962a41 100644 --- a/test/tests1ap.c +++ b/test/tests1ap.c @@ -95,7 +95,7 @@ status_t tests1ap_build_setup_req(pkbuf_t **pkbuf, c_uint32_t enb_id) ASN_SEQUENCE_ADD(&ies->supportedTAs, supportedTA); - ies->defaultPagingDRX = mme_self()->default_paging_drx; + ies->defaultPagingDRX = S1ap_PagingDRX_v64; message.direction = S1AP_PDU_PR_initiatingMessage; message.procedureCode = S1ap_ProcedureCode_id_S1Setup;