forked from acouzens/open5gs
fix indentation in MME
This commit is contained in:
parent
cd814afcff
commit
cb369daaea
|
@ -2,14 +2,14 @@
|
|||
* Kasumi.h
|
||||
*---------------------------------------------------------*/
|
||||
|
||||
#ifndef __KASUMI__
|
||||
#define __KASUMI__
|
||||
#ifndef KASUMI_H
|
||||
#define KASUMI_H
|
||||
|
||||
#include "ogs-core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
|
@ -59,6 +59,6 @@ u8* kasumi_f9( u8 *key, u32 count, u32 fresh, u32 dir, u8 *data, int length );
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __KASUMI__ */
|
||||
#endif /* KASUMI_H */
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
#ifndef __MME_S11_PATH_H__
|
||||
#define __MME_S11_PATH_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MME_S11_PATH_H
|
||||
#define MME_S11_PATH_H
|
||||
|
||||
#include "mme-context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
int mme_gtp_open();
|
||||
void mme_gtp_close();
|
||||
|
@ -27,6 +46,6 @@ int mme_gtp_send_delete_indirect_data_forwarding_tunnel_request(
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __MME_S11_PATH_H__ */
|
||||
#endif /* MME_S11_PATH_H */
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ogs-sctp.h"
|
||||
|
||||
#include "gtp/gtp-xact.h"
|
||||
|
@ -69,15 +88,13 @@ static void mme_main(void *data)
|
|||
ogs_fsm_create(&mme_sm, mme_state_initial, mme_state_final);
|
||||
ogs_fsm_init(&mme_sm, 0);
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
for ( ;; ) {
|
||||
ogs_pollset_poll(mme_self()->pollset,
|
||||
ogs_timer_mgr_next(mme_self()->timer_mgr));
|
||||
|
||||
ogs_timer_mgr_expire(mme_self()->timer_mgr);
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
for ( ;; ) {
|
||||
mme_event_t *e = NULL;
|
||||
|
||||
rv = ogs_queue_trypop(mme_self()->queue, (void**)&e);
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ogs-crypt.h"
|
||||
|
||||
void mme_kdf_nas(uint8_t algorithm_type_distinguishers,
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
#ifndef __MME_KDF_H__
|
||||
#define __MME_KDF_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MME_KDF_H
|
||||
#define MME_KDF_H
|
||||
|
||||
#include "nas/nas-ies.h"
|
||||
|
||||
|
@ -21,4 +40,4 @@ void mme_kdf_enb(uint8_t *kasme, uint32_t ul_count, uint8_t *kenb);
|
|||
|
||||
void mme_kdf_nh(uint8_t *kasme, uint8_t *sync_input, uint8_t *kenb);
|
||||
|
||||
#endif /* __MME_KDF_H__ */
|
||||
#endif /* MME_KDF_H */
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "s1ap-path.h"
|
||||
#include "nas-path.h"
|
||||
#include "mme-gtp-path.h"
|
||||
|
@ -9,13 +28,10 @@ int mme_send_delete_session_or_detach(mme_ue_t *mme_ue)
|
|||
|
||||
ogs_assert(mme_ue);
|
||||
|
||||
if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue))
|
||||
{
|
||||
if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) {
|
||||
rv = mme_gtp_send_delete_all_sessions(mme_ue);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rv = nas_send_detach_accept(mme_ue);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
@ -30,13 +46,10 @@ int mme_send_delete_session_or_ue_context_release(
|
|||
|
||||
ogs_assert(enb_ue);
|
||||
|
||||
if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue))
|
||||
{
|
||||
if (SESSION_CONTEXT_IS_AVAILABLE(mme_ue)) {
|
||||
rv = mme_gtp_send_delete_all_sessions(mme_ue);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rv = s1ap_send_ue_context_release_command(enb_ue,
|
||||
S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
|
||||
S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0);
|
||||
|
@ -53,13 +66,10 @@ int mme_send_release_access_bearer_or_ue_context_release(
|
|||
|
||||
ogs_assert(enb_ue);
|
||||
|
||||
if (BEARER_CONTEXT_IS_ACTIVE(mme_ue))
|
||||
{
|
||||
if (BEARER_CONTEXT_IS_ACTIVE(mme_ue)) {
|
||||
rv = mme_gtp_send_release_access_bearers_request(mme_ue);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rv = s1ap_send_ue_context_release_command(enb_ue,
|
||||
S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
|
||||
S1AP_UE_CTX_REL_S1_NORMAL_RELEASE, 0);
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
#ifndef __MME_PATH_H__
|
||||
#define __MME_PATH_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MME_PATH_H
|
||||
#define MME_PATH_H
|
||||
|
||||
#include "mme-context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
int mme_send_delete_session_or_detach(mme_ue_t *mme_ue);
|
||||
int mme_send_delete_session_or_ue_context_release(
|
||||
|
@ -15,6 +34,6 @@ int mme_send_release_access_bearer_or_ue_context_release(
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __MME_PATH_H__ */
|
||||
#endif /* MME_PATH_H */
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "gtp/gtp-types.h"
|
||||
#include "gtp/gtp-conv.h"
|
||||
#include "gtp/gtp-message.h"
|
||||
|
@ -87,14 +106,12 @@ int mme_s11_build_create_session_request(
|
|||
sizeof pdn->pgw_ip.both.addr6);
|
||||
req->pgw_s5_s8_address_for_control_plane_or_pmip.len =
|
||||
GTP_F_TEID_IPV4V6_LEN;
|
||||
}
|
||||
else if (pgw_s5c_teid.ipv4) {
|
||||
} else if (pgw_s5c_teid.ipv4) {
|
||||
/* pdn->pgw_ip always uses both ip address memory */
|
||||
pgw_s5c_teid.addr = pdn->pgw_ip.both.addr;
|
||||
req->pgw_s5_s8_address_for_control_plane_or_pmip.len =
|
||||
GTP_F_TEID_IPV4_LEN;
|
||||
}
|
||||
else if (pgw_s5c_teid.ipv6) {
|
||||
} else if (pgw_s5c_teid.ipv6) {
|
||||
/* pdn->pgw_ip always uses both ip address memory */
|
||||
memcpy(pgw_s5c_teid.addr6, pdn->pgw_ip.both.addr6,
|
||||
sizeof pdn->pgw_ip.both.addr6);
|
||||
|
@ -104,8 +121,7 @@ int mme_s11_build_create_session_request(
|
|||
req->pgw_s5_s8_address_for_control_plane_or_pmip.presence = 1;
|
||||
req->pgw_s5_s8_address_for_control_plane_or_pmip.data =
|
||||
&pgw_s5c_teid;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ogs_sockaddr_t *pgw_addr = NULL;
|
||||
ogs_sockaddr_t *pgw_addr6 = NULL;
|
||||
|
||||
|
@ -144,11 +160,9 @@ int mme_s11_build_create_session_request(
|
|||
pdn->pdn_type == HSS_PDN_TYPE_IPV4V6) {
|
||||
req->pdn_type.u8 = ((pdn->pdn_type + 1) & sess->request_type.pdn_type);
|
||||
ogs_assert(req->pdn_type.u8 != 0);
|
||||
}
|
||||
else if (pdn->pdn_type == HSS_PDN_TYPE_IPV4_OR_IPV6) {
|
||||
} else if (pdn->pdn_type == HSS_PDN_TYPE_IPV4_OR_IPV6) {
|
||||
req->pdn_type.u8 = sess->request_type.pdn_type;
|
||||
}
|
||||
else
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
req->pdn_type.presence = 1;
|
||||
|
||||
|
@ -202,9 +216,7 @@ int mme_s11_build_create_session_request(
|
|||
ogs_localtime(now.tv_sec, &time_exp);
|
||||
if (time_exp.tm_gmtoff >= 0) {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD(time_exp.tm_gmtoff / 900);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD((-time_exp.tm_gmtoff) / 900);
|
||||
ue_timezone.timezone |= 0x08;
|
||||
}
|
||||
|
@ -427,8 +439,7 @@ int mme_s11_build_create_bearer_response(
|
|||
ogs_localtime(now.tv_sec, &time_exp);
|
||||
if (time_exp.tm_gmtoff >= 0) {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD(time_exp.tm_gmtoff / 900);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD((-time_exp.tm_gmtoff) / 900);
|
||||
ue_timezone.timezone |= 0x08;
|
||||
}
|
||||
|
@ -507,8 +518,7 @@ int mme_s11_build_update_bearer_response(
|
|||
ogs_localtime(now.tv_sec, &time_exp);
|
||||
if (time_exp.tm_gmtoff >= 0) {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD(time_exp.tm_gmtoff / 900);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD((-time_exp.tm_gmtoff) / 900);
|
||||
ue_timezone.timezone |= 0x08;
|
||||
}
|
||||
|
@ -587,8 +597,7 @@ int mme_s11_build_delete_bearer_response(
|
|||
ogs_localtime(now.tv_sec, &time_exp);
|
||||
if (time_exp.tm_gmtoff >= 0) {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD(time_exp.tm_gmtoff / 900);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ue_timezone.timezone = GTP_TIME_TO_BCD((-time_exp.tm_gmtoff) / 900);
|
||||
ue_timezone.timezone |= 0x08;
|
||||
}
|
||||
|
@ -685,7 +694,7 @@ int mme_s11_build_create_indirect_data_forwarding_tunnel_request(
|
|||
sess = mme_sess_first(mme_ue);
|
||||
while (sess != NULL) {
|
||||
bearer = mme_bearer_first(sess);
|
||||
while(bearer != NULL) {
|
||||
while (bearer != NULL) {
|
||||
if (MME_HAVE_ENB_DL_INDIRECT_TUNNEL(bearer)) {
|
||||
memset(&dl_teid[i], 0, sizeof(gtp_f_teid_t));
|
||||
dl_teid[i].interface_type =
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
#ifndef __MME_S11_BUILD_H__
|
||||
#define __MME_S11_BUILD_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MME_S11_BUILD_H
|
||||
#define MME_S11_BUILD_H
|
||||
|
||||
#include "gtp/gtp-message.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
int mme_s11_build_create_session_request(
|
||||
ogs_pkbuf_t **pkbuf, uint8_t type, mme_sess_t *sess);
|
||||
|
@ -28,6 +47,6 @@ int mme_s11_build_create_indirect_data_forwarding_tunnel_request(
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __MME_S11_BUILD_H__ */
|
||||
#endif /* MME_S11_BUILD_H */
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
#ifndef __MME_S11_HANDLER_H__
|
||||
#define __MME_S11_HANDLER_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MME_S11_HANDLER_H
|
||||
#define MME_S11_HANDLER_H
|
||||
|
||||
#include "gtp/gtp-message.h"
|
||||
|
||||
|
@ -7,7 +26,7 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
void mme_s11_handle_create_session_response(
|
||||
gtp_xact_t *xact, mme_ue_t *mme_ue, gtp_create_session_response_t *rsp);
|
||||
|
@ -37,6 +56,6 @@ void mme_s11_handle_delete_indirect_data_forwarding_tunnel_response(
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __MME_S11_HANDLER_H__ */
|
||||
#endif /* MME_S11_HANDLER_H */
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "fd/s6a/s6a-message.h"
|
||||
#include "nas-path.h"
|
||||
#include "s1ap-path.h"
|
||||
|
|
|
@ -1,18 +1,37 @@
|
|||
#ifndef __MME_S6A_HANDLER_H__
|
||||
#define __MME_S6A_HANDLER_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MME_S6A_HANDLER_H
|
||||
#define MME_S6A_HANDLER_H
|
||||
|
||||
#include "fd/s6a/s6a-message.h"
|
||||
#include "mme-context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
void mme_s6a_handle_aia(mme_ue_t *mme_ue, s6a_aia_message_t *aia_message);
|
||||
void mme_s6a_handle_ula(mme_ue_t *mme_ue, s6a_ula_message_t *ula_message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __MME_S6A_HANDLER_H__ */
|
||||
#endif /* MME_S6A_HANDLER_H */
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "nas-conv.h"
|
||||
|
||||
void nas_imsi_to_bcd(
|
||||
|
@ -22,8 +41,7 @@ void nas_imsi_to_bcd(
|
|||
bcd[14] = '0' + imsi->digit15;
|
||||
|
||||
bcd_len = imsi_len * 2 - 1;
|
||||
if (!imsi->odd_even) /* if bcd length is even */
|
||||
{
|
||||
if (!imsi->odd_even) { /* if bcd length is even */
|
||||
if (bcd[bcd_len] != 0xf)
|
||||
ogs_warn("Spec warning : bcd[%d] = 0x%x", bcd_len, bcd[bcd_len]);
|
||||
(bcd_len)--;
|
||||
|
@ -53,8 +71,7 @@ void nas_imsi_to_buffer(
|
|||
buf[7] = ((('0' + imsi->digit15)) & 0x0f);
|
||||
|
||||
*buf_len = imsi_len;
|
||||
if (!imsi->odd_even) /* if imsi length is even */
|
||||
{
|
||||
if (!imsi->odd_even) { /* if imsi length is even */
|
||||
(*buf_len)--;
|
||||
if ((buf[*buf_len] & 0xf) != 0xf)
|
||||
ogs_warn("Spec warning : buf[%d] = 0x%x", *buf_len, buf[*buf_len]);
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
#ifndef __NAS_CONV_H__
|
||||
#define __NAS_CONV_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NAS_CONV_H
|
||||
#define NAS_CONV_H
|
||||
|
||||
#include "nas/nas-message.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
void nas_imsi_to_buffer(
|
||||
nas_mobile_identity_imsi_t *imsi, uint8_t imsi_len,
|
||||
|
@ -16,7 +35,7 @@ void nas_imsi_to_bcd(
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __NAS_CONV_H__ */
|
||||
#endif /* NAS_CONV_H */
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "s1ap-path.h"
|
||||
#include "s1ap-build.h"
|
||||
#include "esm-build.h"
|
||||
|
@ -106,8 +125,7 @@ int nas_send_attach_reject(mme_ue_t *mme_ue,
|
|||
ogs_debug(" IMSI[%s] Cause[%d]", mme_ue->imsi_bcd, emm_cause);
|
||||
|
||||
sess = mme_sess_first(mme_ue);
|
||||
if (sess)
|
||||
{
|
||||
if (sess) {
|
||||
rv = esm_build_pdn_connectivity_reject(&esmbuf, sess, esm_cause);
|
||||
ogs_assert(rv == OGS_OK && esmbuf);
|
||||
}
|
||||
|
@ -187,8 +205,7 @@ int nas_send_detach_accept(mme_ue_t *mme_ue)
|
|||
ogs_assert(enb_ue);
|
||||
|
||||
/* reply with detach accept */
|
||||
if (mme_ue->nas_eps.detach.switch_off == 0)
|
||||
{
|
||||
if (mme_ue->nas_eps.detach.switch_off == 0) {
|
||||
rv = emm_build_detach_accept(&emmbuf, mme_ue);
|
||||
ogs_assert(rv == OGS_OK && emmbuf);
|
||||
|
||||
|
@ -309,8 +326,7 @@ int nas_send_activate_all_dedicated_bearers(mme_bearer_t *default_bearer)
|
|||
ogs_assert(default_bearer);
|
||||
|
||||
mme_bearer_t *dedicated_bearer = mme_bearer_next(default_bearer);
|
||||
while(dedicated_bearer)
|
||||
{
|
||||
while (dedicated_bearer) {
|
||||
rv = nas_send_activate_dedicated_bearer_context_request(
|
||||
dedicated_bearer);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
|
@ -337,16 +353,13 @@ int nas_send_modify_bearer_context_request(
|
|||
&esmbuf, bearer, qos_presence, tft_presence);
|
||||
ogs_assert(rv == OGS_OK && esmbuf);
|
||||
|
||||
if (qos_presence == 1)
|
||||
{
|
||||
if (qos_presence == 1) {
|
||||
rv = s1ap_build_e_rab_modify_request(&s1apbuf, bearer, esmbuf);
|
||||
ogs_assert(rv == OGS_OK && s1apbuf);
|
||||
|
||||
rv = nas_send_to_enb(mme_ue, s1apbuf);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
rv = nas_send_to_downlink_nas_transport(mme_ue, esmbuf);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
@ -393,21 +406,17 @@ int nas_send_tau_accept(
|
|||
rv = emm_build_tau_accept(&emmbuf, mme_ue);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
|
||||
if (procedureCode == S1AP_ProcedureCode_id_InitialContextSetup)
|
||||
{
|
||||
if (procedureCode == S1AP_ProcedureCode_id_InitialContextSetup) {
|
||||
ogs_pkbuf_t *s1apbuf = NULL;
|
||||
rv = s1ap_build_initial_context_setup_request(&s1apbuf, mme_ue, emmbuf);
|
||||
ogs_assert(rv == OGS_OK && s1apbuf);
|
||||
|
||||
rv = nas_send_to_enb(mme_ue, s1apbuf);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
else if (procedureCode == S1AP_ProcedureCode_id_downlinkNASTransport)
|
||||
{
|
||||
} else if (procedureCode == S1AP_ProcedureCode_id_downlinkNASTransport) {
|
||||
rv = nas_send_to_downlink_nas_transport(mme_ue, emmbuf);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
else
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -1,11 +1,30 @@
|
|||
#ifndef __NAS_PATH_H__
|
||||
#define __NAS_PATH_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NAS_PATH_H
|
||||
#define NAS_PATH_H
|
||||
|
||||
#include "mme-context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
int nas_send_to_enb(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf);
|
||||
int nas_send_emm_to_esm(
|
||||
|
@ -43,6 +62,6 @@ int nas_send_cs_service_notification(mme_ue_t *mme_ue);
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __NAS_PATH_H__ */
|
||||
#endif /* NAS_PATH_H */
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "nas/nas-message.h"
|
||||
#include "nas-security.h"
|
||||
|
||||
|
@ -11,34 +30,32 @@ int nas_security_encode(
|
|||
ogs_assert(mme_ue);
|
||||
ogs_assert(message);
|
||||
|
||||
switch(message->h.security_header_type)
|
||||
{
|
||||
case NAS_SECURITY_HEADER_PLAIN_NAS_MESSAGE:
|
||||
return nas_plain_encode(pkbuf, message);
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED:
|
||||
integrity_protected = 1;
|
||||
break;
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHERED:
|
||||
integrity_protected = 1;
|
||||
ciphered = 1;
|
||||
break;
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_NEW_SECURITY_CONTEXT:
|
||||
integrity_protected = 1;
|
||||
new_security_context = 1;
|
||||
break;
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHTERD_WITH_NEW_INTEGRITY_CONTEXT:
|
||||
integrity_protected = 1;
|
||||
new_security_context = 1;
|
||||
ciphered = 1;
|
||||
break;
|
||||
default:
|
||||
ogs_warn("Not implemented(securiry header type:0x%x)",
|
||||
message->h.security_header_type);
|
||||
return OGS_ERROR;
|
||||
switch (message->h.security_header_type) {
|
||||
case NAS_SECURITY_HEADER_PLAIN_NAS_MESSAGE:
|
||||
return nas_plain_encode(pkbuf, message);
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED:
|
||||
integrity_protected = 1;
|
||||
break;
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHERED:
|
||||
integrity_protected = 1;
|
||||
ciphered = 1;
|
||||
break;
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_NEW_SECURITY_CONTEXT:
|
||||
integrity_protected = 1;
|
||||
new_security_context = 1;
|
||||
break;
|
||||
case NAS_SECURITY_HEADER_INTEGRITY_PROTECTED_AND_CIPHTERD_WITH_NEW_INTEGRITY_CONTEXT:
|
||||
integrity_protected = 1;
|
||||
new_security_context = 1;
|
||||
ciphered = 1;
|
||||
break;
|
||||
default:
|
||||
ogs_warn("Not implemented(securiry header type:0x%x)",
|
||||
message->h.security_header_type);
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
if (new_security_context)
|
||||
{
|
||||
if (new_security_context) {
|
||||
mme_ue->dl_count = 0;
|
||||
mme_ue->ul_count.i32 = 0;
|
||||
}
|
||||
|
@ -48,8 +65,7 @@ int nas_security_encode(
|
|||
if (mme_ue->selected_int_algorithm == 0)
|
||||
integrity_protected = 0;
|
||||
|
||||
if (ciphered || integrity_protected)
|
||||
{
|
||||
if (ciphered || integrity_protected) {
|
||||
nas_security_header_t h;
|
||||
ogs_pkbuf_t *new = NULL;
|
||||
|
||||
|
@ -60,8 +76,7 @@ int nas_security_encode(
|
|||
|
||||
ogs_assert(nas_plain_encode(&new, message) == OGS_OK);
|
||||
|
||||
if (ciphered)
|
||||
{
|
||||
if (ciphered) {
|
||||
/* encrypt NAS message */
|
||||
nas_encrypt(mme_ue->selected_enc_algorithm,
|
||||
mme_ue->knas_enc, mme_ue->dl_count, NAS_SECURITY_BEARER,
|
||||
|
@ -72,8 +87,7 @@ int nas_security_encode(
|
|||
ogs_assert(ogs_pkbuf_push(new, 1));
|
||||
*(uint8_t *)(new->data) = h.sequence_number;
|
||||
|
||||
if (integrity_protected)
|
||||
{
|
||||
if (integrity_protected) {
|
||||
uint8_t mac[NAS_SECURITY_MAC_SIZE];
|
||||
|
||||
/* calculate NAS MAC(message authentication code) */
|
||||
|
@ -105,8 +119,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
ogs_assert(pkbuf);
|
||||
ogs_assert(pkbuf->data);
|
||||
|
||||
if (security_header_type.service_request)
|
||||
{
|
||||
if (security_header_type.service_request) {
|
||||
#define SHORT_MAC_SIZE 2
|
||||
nas_ksi_and_sequence_number_t *ksi_and_sequence_number =
|
||||
pkbuf->data + 1;
|
||||
|
@ -115,8 +128,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
uint8_t sequence_number_high_3bit;
|
||||
uint8_t mac[NAS_SECURITY_MAC_SIZE];
|
||||
|
||||
if (mme_ue->selected_int_algorithm == 0)
|
||||
{
|
||||
if (mme_ue->selected_int_algorithm == 0) {
|
||||
ogs_warn("integrity algorithm is not defined");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
@ -126,8 +138,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
ksi_and_sequence_number->sequence_number;
|
||||
|
||||
sequence_number_high_3bit = mme_ue->ul_count.sqn & 0xe0;
|
||||
if ((mme_ue->ul_count.sqn & 0x1f) > estimated_sequence_number)
|
||||
{
|
||||
if ((mme_ue->ul_count.sqn & 0x1f) > estimated_sequence_number) {
|
||||
sequence_number_high_3bit += 0x20;
|
||||
}
|
||||
estimated_sequence_number += sequence_number_high_3bit;
|
||||
|
@ -144,8 +155,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
NAS_SECURITY_UPLINK_DIRECTION, pkbuf, mac);
|
||||
|
||||
ogs_pkbuf_put_data(pkbuf, original_mac, SHORT_MAC_SIZE);
|
||||
if (memcmp(mac + 2, pkbuf->data + 2, 2) != 0)
|
||||
{
|
||||
if (memcmp(mac + 2, pkbuf->data + 2, 2) != 0) {
|
||||
ogs_warn("NAS MAC verification failed");
|
||||
mme_ue->mac_failed = 1;
|
||||
}
|
||||
|
@ -153,15 +163,13 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
if (!mme_ue->security_context_available)
|
||||
{
|
||||
if (!mme_ue->security_context_available) {
|
||||
security_header_type.integrity_protected = 0;
|
||||
security_header_type.new_security_context = 0;
|
||||
security_header_type.ciphered = 0;
|
||||
}
|
||||
|
||||
if (security_header_type.new_security_context)
|
||||
{
|
||||
if (security_header_type.new_security_context) {
|
||||
mme_ue->ul_count.i32 = 0;
|
||||
}
|
||||
|
||||
|
@ -171,8 +179,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
security_header_type.integrity_protected = 0;
|
||||
|
||||
if (security_header_type.ciphered ||
|
||||
security_header_type.integrity_protected)
|
||||
{
|
||||
security_header_type.integrity_protected) {
|
||||
nas_security_header_t *h = NULL;
|
||||
|
||||
/* NAS Security Header */
|
||||
|
@ -187,8 +194,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
mme_ue->ul_count.overflow++;
|
||||
mme_ue->ul_count.sqn = h->sequence_number;
|
||||
|
||||
if (security_header_type.integrity_protected)
|
||||
{
|
||||
if (security_header_type.integrity_protected) {
|
||||
uint8_t mac[NAS_SECURITY_MAC_SIZE];
|
||||
uint32_t mac32;
|
||||
uint32_t original_mac = h->message_authentication_code;
|
||||
|
@ -200,8 +206,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
h->message_authentication_code = original_mac;
|
||||
|
||||
memcpy(&mac32, mac, NAS_SECURITY_MAC_SIZE);
|
||||
if (h->message_authentication_code != mac32)
|
||||
{
|
||||
if (h->message_authentication_code != mac32) {
|
||||
ogs_warn("NAS MAC verification failed(0x%x != 0x%x)",
|
||||
ntohl(h->message_authentication_code), ntohl(mac32));
|
||||
mme_ue->mac_failed = 1;
|
||||
|
@ -211,8 +216,7 @@ int nas_security_decode(mme_ue_t *mme_ue,
|
|||
/* NAS EMM Header or ESM Header */
|
||||
ogs_assert(ogs_pkbuf_pull(pkbuf, 1));
|
||||
|
||||
if (security_header_type.ciphered)
|
||||
{
|
||||
if (security_header_type.ciphered) {
|
||||
/* decrypt NAS message */
|
||||
nas_encrypt(mme_ue->selected_enc_algorithm,
|
||||
mme_ue->knas_enc, mme_ue->ul_count.i32, NAS_SECURITY_BEARER,
|
||||
|
@ -227,6 +231,10 @@ void nas_mac_calculate(uint8_t algorithm_identity,
|
|||
uint8_t *knas_int, uint32_t count, uint8_t bearer,
|
||||
uint8_t direction, ogs_pkbuf_t *pkbuf, uint8_t *mac)
|
||||
{
|
||||
uint8_t *ivec = NULL;;
|
||||
uint8_t cmac[16];
|
||||
uint32_t mac32;
|
||||
|
||||
ogs_assert(knas_int);
|
||||
ogs_assert(bearer >= 0 && bearer <= 0x1f);
|
||||
ogs_assert(direction == 0 || direction == 1);
|
||||
|
@ -235,54 +243,39 @@ void nas_mac_calculate(uint8_t algorithm_identity,
|
|||
ogs_assert(pkbuf->len);
|
||||
ogs_assert(mac);
|
||||
|
||||
switch(algorithm_identity)
|
||||
{
|
||||
case NAS_SECURITY_ALGORITHMS_128_EIA1:
|
||||
{
|
||||
snow_3g_f9(knas_int, count, (bearer << 27), direction,
|
||||
pkbuf->data, (pkbuf->len << 3), mac);
|
||||
break;
|
||||
}
|
||||
case NAS_SECURITY_ALGORITHMS_128_EIA2:
|
||||
{
|
||||
count = htonl(count);
|
||||
uint8_t *ivec = NULL;;
|
||||
uint8_t cmac[16];
|
||||
switch (algorithm_identity) {
|
||||
case NAS_SECURITY_ALGORITHMS_128_EIA1:
|
||||
snow_3g_f9(knas_int, count, (bearer << 27), direction,
|
||||
pkbuf->data, (pkbuf->len << 3), mac);
|
||||
break;
|
||||
case NAS_SECURITY_ALGORITHMS_128_EIA2:
|
||||
count = htonl(count);
|
||||
|
||||
ogs_pkbuf_push(pkbuf, 8);
|
||||
ogs_pkbuf_push(pkbuf, 8);
|
||||
|
||||
ivec = pkbuf->data;
|
||||
memset(ivec, 0, 8);
|
||||
memcpy(ivec + 0, &count, sizeof(count));
|
||||
ivec[4] = (bearer << 3) | (direction << 2);
|
||||
ivec = pkbuf->data;
|
||||
memset(ivec, 0, 8);
|
||||
memcpy(ivec + 0, &count, sizeof(count));
|
||||
ivec[4] = (bearer << 3) | (direction << 2);
|
||||
|
||||
ogs_aes_cmac_calculate(cmac, knas_int, pkbuf->data, pkbuf->len);
|
||||
memcpy(mac, cmac, 4);
|
||||
ogs_aes_cmac_calculate(cmac, knas_int, pkbuf->data, pkbuf->len);
|
||||
memcpy(mac, cmac, 4);
|
||||
|
||||
ogs_pkbuf_pull(pkbuf, 8);
|
||||
ogs_pkbuf_pull(pkbuf, 8);
|
||||
|
||||
break;
|
||||
}
|
||||
case NAS_SECURITY_ALGORITHMS_128_EIA3:
|
||||
{
|
||||
uint32_t mac32;
|
||||
|
||||
zuc_eia3(knas_int, count, bearer, direction,
|
||||
(pkbuf->len << 3), pkbuf->data, &mac32);
|
||||
mac32 = ntohl(mac32);
|
||||
memcpy(mac, &mac32, sizeof(uint32_t));
|
||||
break;
|
||||
}
|
||||
case NAS_SECURITY_ALGORITHMS_EIA0:
|
||||
{
|
||||
ogs_error("Invalid identity : NAS_SECURITY_ALGORITHMS_EIA0");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ogs_assert_if_reached();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NAS_SECURITY_ALGORITHMS_128_EIA3:
|
||||
zuc_eia3(knas_int, count, bearer, direction,
|
||||
(pkbuf->len << 3), pkbuf->data, &mac32);
|
||||
mac32 = ntohl(mac32);
|
||||
memcpy(mac, &mac32, sizeof(uint32_t));
|
||||
break;
|
||||
case NAS_SECURITY_ALGORITHMS_EIA0:
|
||||
ogs_error("Invalid identity : NAS_SECURITY_ALGORITHMS_EIA0");
|
||||
break;
|
||||
default:
|
||||
ogs_assert_if_reached();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,6 +283,8 @@ void nas_encrypt(uint8_t algorithm_identity,
|
|||
uint8_t *knas_enc, uint32_t count, uint8_t bearer,
|
||||
uint8_t direction, ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
uint8_t ivec[16];
|
||||
|
||||
ogs_assert(knas_enc);
|
||||
ogs_assert(bearer >= 0 && bearer <= 0x1f);
|
||||
ogs_assert(direction == 0 || direction == 1);
|
||||
|
@ -297,41 +292,29 @@ void nas_encrypt(uint8_t algorithm_identity,
|
|||
ogs_assert(pkbuf->data);
|
||||
ogs_assert(pkbuf->len);
|
||||
|
||||
switch(algorithm_identity)
|
||||
{
|
||||
case NAS_SECURITY_ALGORITHMS_128_EEA1:
|
||||
{
|
||||
snow_3g_f8(knas_enc, count, bearer, direction,
|
||||
pkbuf->data, (pkbuf->len << 3));
|
||||
break;
|
||||
}
|
||||
case NAS_SECURITY_ALGORITHMS_128_EEA2:
|
||||
{
|
||||
count = htonl(count);
|
||||
uint8_t ivec[16];
|
||||
switch (algorithm_identity) {
|
||||
case NAS_SECURITY_ALGORITHMS_128_EEA1:
|
||||
snow_3g_f8(knas_enc, count, bearer, direction,
|
||||
pkbuf->data, (pkbuf->len << 3));
|
||||
break;
|
||||
case NAS_SECURITY_ALGORITHMS_128_EEA2:
|
||||
count = htonl(count);
|
||||
|
||||
memset(ivec, 0, 16);
|
||||
memcpy(ivec + 0, &count, sizeof(count));
|
||||
ivec[4] = (bearer << 3) | (direction << 2);
|
||||
ogs_aes_ctr128_encrypt(knas_enc, ivec,
|
||||
pkbuf->data, pkbuf->len, pkbuf->data);
|
||||
break;
|
||||
}
|
||||
case NAS_SECURITY_ALGORITHMS_128_EEA3:
|
||||
{
|
||||
zuc_eea3(knas_enc, count, bearer, direction,
|
||||
(pkbuf->len << 3), pkbuf->data, pkbuf->data);
|
||||
break;
|
||||
}
|
||||
case NAS_SECURITY_ALGORITHMS_EEA0:
|
||||
{
|
||||
ogs_error("Invalid identity : NAS_SECURITY_ALGORITHMS_EEA0");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ogs_assert_if_reached();
|
||||
break;
|
||||
}
|
||||
memset(ivec, 0, 16);
|
||||
memcpy(ivec + 0, &count, sizeof(count));
|
||||
ivec[4] = (bearer << 3) | (direction << 2);
|
||||
ogs_aes_ctr128_encrypt(knas_enc, ivec,
|
||||
pkbuf->data, pkbuf->len, pkbuf->data);
|
||||
break;
|
||||
case NAS_SECURITY_ALGORITHMS_128_EEA3:
|
||||
zuc_eea3(knas_enc, count, bearer, direction,
|
||||
(pkbuf->len << 3), pkbuf->data, pkbuf->data);
|
||||
break;
|
||||
case NAS_SECURITY_ALGORITHMS_EEA0:
|
||||
ogs_error("Invalid identity : NAS_SECURITY_ALGORITHMS_EEA0");
|
||||
break;
|
||||
default:
|
||||
ogs_assert_if_reached();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
#ifndef __NAS_SECURITY_H__
|
||||
#define __NAS_SECURITY_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NAS_SECURITY_H
|
||||
#define NAS_SECURITY_H
|
||||
|
||||
#include "ogs-crypt.h"
|
||||
|
||||
|
@ -15,7 +34,7 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
typedef struct _nas_security_header_type_t {
|
||||
union {
|
||||
|
@ -45,7 +64,7 @@ void nas_encrypt(uint8_t algorithm_identity,
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __NAS_SECURITY_H__ */
|
||||
#endif /* NAS_SECURITY_H */
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef __SNOW_3G__
|
||||
#define __SNOW_3G__
|
||||
#ifndef SNOW_3G_H
|
||||
#define SNOW_3G_H
|
||||
|
||||
#include "ogs-core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint32_t u32;
|
||||
|
@ -63,6 +63,6 @@ void snow_3g_f9( u8* key, u32 count, u32 fresh, u32 dir,
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __SNOW_3G__ */
|
||||
#endif /* SNOW_3G_H */
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
* available on the GSMA website
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ZUC_H__
|
||||
#define __ZUC_H__
|
||||
#ifndef ZUC_H
|
||||
#define ZUC_H
|
||||
|
||||
#include "ogs-core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
/* type definition from */
|
||||
typedef uint8_t u8;
|
||||
|
@ -53,6 +53,6 @@ void zuc_eia3(u8* IK, u32 COUNT, u32 BEARER, u32 DIRECTION,
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __ZUC_H__ */
|
||||
#endif /* ZUC_H */
|
||||
|
|
Loading…
Reference in New Issue