NAS_HEADROOM is added in the packet buffer
This commit is contained in:
parent
d62a467057
commit
ba90ef661f
|
@ -341,6 +341,8 @@ status_t nas_encode_pdu(pkbuf_t **pkbuf, nas_message_t *message)
|
|||
|
||||
d_assert(message, return CORE_ERROR, "Null param");
|
||||
|
||||
/* The Packet Buffer(pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
*pkbuf = pkbuf_alloc(NAS_HEADROOM, MESSAGE_SDU_SIZE);
|
||||
d_assert(*pkbuf, return -1, "Null Param");
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* The Packet Buffer(pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
#define NAS_HEADROOM 16
|
||||
|
||||
#define NAS_SECURITY_HEADER_PLAIN_NAS_MESSAGE 0
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
#include "core_debug.h"
|
||||
|
||||
#include "s1ap_build.h"
|
||||
#include "s1ap_conv.h"
|
||||
#include "s1ap_path.h"
|
||||
|
||||
#include "sm.h"
|
||||
#include "context.h"
|
||||
#include "event.h"
|
||||
|
||||
#include "s1ap_build.h"
|
||||
#include "s1ap_conv.h"
|
||||
#include "s1ap_path.h"
|
||||
#include "nas_message.h"
|
||||
|
||||
static void enb_s1ap_handle_s1_setup_request(
|
||||
enb_ctx_t *enb, s1ap_message_t *message);
|
||||
static void enb_s1ap_handle_initial_ue_message(
|
||||
|
@ -17,6 +18,8 @@ static void enb_s1ap_handle_initial_ue_message(
|
|||
static void enb_s1ap_handle_uplink_nas_transport(
|
||||
enb_ctx_t *enb, s1ap_message_t *message);
|
||||
|
||||
static void enb_s1ap_send_to_ue(ue_ctx_t *ue, S1ap_NAS_PDU_t *nasPdu);
|
||||
|
||||
void enb_s1ap_state_initial(enb_s1ap_sm_t *s, event_t *e)
|
||||
{
|
||||
d_assert(s, return, "Null param");
|
||||
|
@ -213,9 +216,6 @@ static void enb_s1ap_handle_initial_ue_message(
|
|||
|
||||
ue_ctx_t *ue = NULL;
|
||||
S1ap_InitialUEMessage_IEs_t *ies = NULL;
|
||||
S1ap_NAS_PDU_t *nasPdu = NULL;
|
||||
event_t e;
|
||||
pkbuf_t *sendbuf = NULL;
|
||||
|
||||
d_assert(enb, return, "Null param");
|
||||
|
||||
|
@ -243,24 +243,13 @@ static void enb_s1ap_handle_initial_ue_message(
|
|||
INET_NTOP(&enb->s1ap_sock->remote.sin_addr.s_addr, buf),
|
||||
enb->enb_id);
|
||||
|
||||
nasPdu = &ies->nas_pdu;
|
||||
d_assert(nasPdu, mme_ctx_ue_remove(ue); return, "Null param");
|
||||
|
||||
sendbuf = pkbuf_alloc(0, nasPdu->size);
|
||||
d_assert(sendbuf, mme_ctx_ue_remove(ue); return, "Null param");
|
||||
memcpy(sendbuf->payload, nasPdu->buf, nasPdu->size);
|
||||
|
||||
fsm_create((fsm_t*)&ue->emm_sm,
|
||||
ue_emm_state_initial, ue_emm_state_final);
|
||||
ue->emm_sm.ctx = ue;
|
||||
|
||||
fsm_init((fsm_t*)&ue->emm_sm, 0);
|
||||
|
||||
event_set(&e, EVT_MSG_UE_EMM);
|
||||
event_set_param1(&e, (c_uintptr_t)ue);
|
||||
event_set_param2(&e, (c_uintptr_t)sendbuf);
|
||||
|
||||
event_send(mme_self()->queue_id, &e);
|
||||
enb_s1ap_send_to_ue(ue, &ies->nas_pdu);
|
||||
}
|
||||
|
||||
static void enb_s1ap_handle_uplink_nas_transport(
|
||||
|
@ -270,9 +259,6 @@ static void enb_s1ap_handle_uplink_nas_transport(
|
|||
|
||||
ue_ctx_t *ue = NULL;
|
||||
S1ap_UplinkNASTransport_IEs_t *ies = NULL;
|
||||
S1ap_NAS_PDU_t *nasPdu = NULL;
|
||||
event_t e;
|
||||
pkbuf_t *sendbuf = NULL;
|
||||
|
||||
ies = &message->s1ap_UplinkNASTransport_IEs;
|
||||
d_assert(ies, return, "Null param");
|
||||
|
@ -285,11 +271,20 @@ static void enb_s1ap_handle_uplink_nas_transport(
|
|||
INET_NTOP(&enb->s1ap_sock->remote.sin_addr.s_addr, buf),
|
||||
enb->enb_id);
|
||||
|
||||
nasPdu = &ies->nas_pdu;
|
||||
d_assert(nasPdu, mme_ctx_ue_remove(ue); return, "Null param");
|
||||
enb_s1ap_send_to_ue(ue, &ies->nas_pdu);
|
||||
}
|
||||
|
||||
sendbuf = pkbuf_alloc(0, nasPdu->size);
|
||||
d_assert(sendbuf, mme_ctx_ue_remove(ue); return, "Null param");
|
||||
static void enb_s1ap_send_to_ue(ue_ctx_t *ue, S1ap_NAS_PDU_t *nasPdu)
|
||||
{
|
||||
pkbuf_t *sendbuf = NULL;
|
||||
event_t e;
|
||||
|
||||
d_assert(nasPdu, return, "Null param");
|
||||
|
||||
/* The Packet Buffer(pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
sendbuf = pkbuf_alloc(NAS_HEADROOM, nasPdu->size);
|
||||
d_assert(sendbuf, return, "Null param");
|
||||
memcpy(sendbuf->payload, nasPdu->buf, nasPdu->size);
|
||||
|
||||
event_set(&e, EVT_MSG_UE_EMM);
|
||||
|
|
|
@ -20,7 +20,7 @@ static void ue_emm_handle_attach_request(
|
|||
static void ue_emm_handle_authentication_response(
|
||||
ue_ctx_t *ue, nas_authentication_response_t *authentication_response);
|
||||
|
||||
static void ue_emm_send_to_ue(ue_ctx_t *ue, pkbuf_t *pkbuf);
|
||||
static void ue_emm_send_to_enb(ue_ctx_t *ue, pkbuf_t *pkbuf);
|
||||
|
||||
void ue_emm_state_initial(ue_emm_sm_t *s, event_t *e)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ void ue_emm_state_operational(ue_emm_sm_t *s, event_t *e)
|
|||
case NAS_AUTHENTICATION_REQUEST:
|
||||
{
|
||||
pkbuf_t *pkbuf = pkbuf_copy(recvbuf);
|
||||
ue_emm_send_to_ue(ue, pkbuf);
|
||||
ue_emm_send_to_enb(ue, pkbuf);
|
||||
|
||||
d_assert(ue->imsi, return,);
|
||||
d_info("[NAS] Authentication request : UE[%s] <-- EMM",
|
||||
|
@ -258,13 +258,13 @@ static void ue_emm_handle_authentication_response(
|
|||
ue->kasme, ue->knas_enc);
|
||||
|
||||
d_assert(nas_encode_pdu(&sendbuf, &message) == CORE_OK && sendbuf,,);
|
||||
ue_emm_send_to_ue(ue, sendbuf);
|
||||
ue_emm_send_to_enb(ue, sendbuf);
|
||||
|
||||
d_assert(ue->imsi, return,);
|
||||
d_info("[NAS] Security mode command : UE[%s] <-- EMM", ue->imsi);
|
||||
}
|
||||
|
||||
static void ue_emm_send_to_ue(ue_ctx_t *ue, pkbuf_t *pkbuf)
|
||||
static void ue_emm_send_to_enb(ue_ctx_t *ue, pkbuf_t *pkbuf)
|
||||
{
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
||||
|
|
Loading…
Reference in New Issue