Skip to content

Commit

Permalink
Fix the Security Command Reject (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
acetcom committed Jul 4, 2019
1 parent 0717b57 commit 334c678
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/ogslib
14 changes: 5 additions & 9 deletions src/mme/emm-handler.c
Expand Up @@ -116,12 +116,10 @@ int emm_handle_attach_request(
nas_tracking_area_identity_t *last_visited_registered_tai =
&attach_request->last_visited_registered_tai;

nas_to_plmn_id(&mme_ue->visited_plmn_id,
nas_to_plmn_id(&mme_ue->last_visited_plmn_id,
&last_visited_registered_tai->nas_plmn_id);
ogs_debug(" Visited_PLMN_ID:%06x",
plmn_id_hexdump(&mme_ue->visited_plmn_id));
} else {
memcpy(&mme_ue->visited_plmn_id, &mme_ue->tai.plmn_id, PLMN_ID_LEN);
plmn_id_hexdump(&mme_ue->last_visited_plmn_id));
}

memcpy(&mme_ue->ue_network_capability,
Expand Down Expand Up @@ -473,13 +471,11 @@ int emm_handle_tau_request(
nas_tracking_area_identity_t *last_visited_registered_tai =
&tau_request->last_visited_registered_tai;

nas_to_plmn_id(&mme_ue->visited_plmn_id,
nas_to_plmn_id(&mme_ue->last_visited_plmn_id,
&last_visited_registered_tai->nas_plmn_id);
ogs_debug(" Visited_PLMN_ID:%06x",
plmn_id_hexdump(&mme_ue->visited_plmn_id));
} else {
memcpy(&mme_ue->visited_plmn_id, &mme_ue->tai.plmn_id, PLMN_ID_LEN);
}
plmn_id_hexdump(&mme_ue->last_visited_plmn_id));
}

if (tau_request->presencemask &
NAS_TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_PRESENT) {
Expand Down
2 changes: 1 addition & 1 deletion src/mme/mme-context.h
Expand Up @@ -307,7 +307,7 @@ struct mme_ue_s {
/* UE Info */
tai_t tai;
e_cgi_t e_cgi;
plmn_id_t visited_plmn_id;
plmn_id_t last_visited_plmn_id;

#define SECURITY_CONTEXT_IS_VALID(__mME) \
((__mME) && \
Expand Down
4 changes: 2 additions & 2 deletions src/mme/mme-fd-path.c
Expand Up @@ -152,7 +152,7 @@ void mme_s6a_send_air(mme_ue_t *mme_ue,
/* Set the Visited-PLMN-Id AVP */
ret = fd_msg_avp_new(s6a_visited_plmn_id, 0, &avp);
ogs_assert(ret == 0);
val.os.data = nas_from_plmn_id(&nas_plmn_id, &mme_ue->visited_plmn_id);
val.os.data = nas_from_plmn_id(&nas_plmn_id, &mme_ue->tai.plmn_id);
val.os.len = PLMN_ID_LEN;
ret = fd_msg_avp_setvalue(avp, &val);
ogs_assert(ret == 0);
Expand Down Expand Up @@ -514,7 +514,7 @@ void mme_s6a_send_ulr(mme_ue_t *mme_ue)
/* Set the Visited-PLMN-Id */
ret = fd_msg_avp_new(s6a_visited_plmn_id, 0, &avp);
ogs_assert(ret == 0);
val.os.data = nas_from_plmn_id(&nas_plmn_id, &mme_ue->visited_plmn_id);
val.os.data = nas_from_plmn_id(&nas_plmn_id, &mme_ue->tai.plmn_id);
val.os.len = PLMN_ID_LEN;
ret = fd_msg_avp_setvalue(avp, &val);
ogs_assert(ret == 0);
Expand Down
4 changes: 2 additions & 2 deletions src/mme/mme-s11-build.c
Expand Up @@ -60,8 +60,8 @@ int mme_s11_build_create_session_request(
uli_buf, GTP_MAX_ULI_LEN);

req->serving_network.presence = 1;
req->serving_network.data = &mme_ue->visited_plmn_id;
req->serving_network.len = sizeof(mme_ue->visited_plmn_id);
req->serving_network.data = &mme_ue->tai.plmn_id;
req->serving_network.len = sizeof(mme_ue->tai.plmn_id);

req->rat_type.presence = 1;
req->rat_type.u8 = GTP_RAT_TYPE_EUTRAN;
Expand Down
4 changes: 2 additions & 2 deletions tests/common/test-packet.c
Expand Up @@ -766,9 +766,9 @@ int tests1ap_build_security_mode_complete(ogs_pkbuf_t **pkbuf, int i)
"",

/* 21 */
"000d403200000500 00000200d0000800 0200d0001a000908 475089bacd00075e"
"000d403200000500 00000200d0000800 0200d0001a000908 473c0c819e00075e"
"006440080064f013 0006401000434006 0064f0130002",
"000d403200000500 00000200d1000800 0200d1001a000908 4753a25a8000075e"
"000d403200000500 00000200d1000800 0200d1001a000908 47e68241c900075e"
"006440080064f013 0006401000434006 0064f0130002",
"",
};
Expand Down

0 comments on commit 334c678

Please sign in to comment.