Commit da7a9288 authored by yunshou-yang's avatar yunshou-yang

sm: update nas_message

parent 2c0f33bc
......@@ -18,6 +18,7 @@
extern "C" {
#include "nas_message.h"
#include "mmData.h"
#include "NasMain.h"
}
namespace oai {
......@@ -52,7 +53,8 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//bsafe (disable temporarily warning for strncpy)
//std::strncpy((char *)data, n1SmMessage.c_str(), sizeof(data));
memcpy ((void *)data, (void *)n1SmMessage.c_str(),sizeof(data));
memcpy ((void *)data, (void *)n1SmMessage.c_str(),strlen(n1SmMessage.c_str()));
//establishment_request(data);
//use a temporary security mechanism
fivegmm_security_context_t * security = ( fivegmm_security_context_t *) std::calloc(1,sizeof(fivegmm_security_context_t));
......
......@@ -120,6 +120,7 @@ int nas_message_encode (
//printf("_nas_message_header_encode, size:%d\n", size);
if (size < 0) {
//OAILOG_FUNC_RETURN (LOG_NAS, TLV_BUFFER_TOO_SHORT);
return TLV_BUFFER_TOO_SHORT;
} else if (size > 2) {
/*
* Encode security protected NAS message
......@@ -348,7 +349,8 @@ static int _nas_message_header_encode (
//printf("encoded nas security header type: %x\n",buffer[size-1]);
//printf("encoded nas security header type: %x\n",header->security_header_type);
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES ||
header->extended_protocol_discriminator == EPD_5GS_SESSION_MANAGEMENT_MESSAGES) {
//printf("header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES\n");
//printf("%x\n",header->security_header_type);
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
......@@ -359,16 +361,17 @@ static int _nas_message_header_encode (
*/
//OAILOG_WARNING(LOG_NAS, "NET-API - The size of the header (%u) " "exceeds the buffer length (%lu)\n", NAS_MESSAGE_SECURITY_HEADER_SIZE, length);
//OAILOG_FUNC_RETURN (LOG_NAS, RETURNerror);
return RETURNerror;
}
/*
* Encode the message authentication code
*/
//ENCODE_U32 (buffer + size, header->message_authentication_code, size);
ENCODE_U32 (buffer + size, header->message_authentication_code, size);
/*
* Encode the sequence number
*/
//ENCODE_U8 (buffer + size, header->sequence_number, size);
ENCODE_U8 (buffer + size, header->sequence_number, size);
}
}
return size;
......@@ -754,7 +757,8 @@ static int _nas_message_header_decode (
DECODE_U8 (buffer + size, header->security_header_type , size);
//OAILOG_DEBUG(LOG_NAS,"security header type(%x)\n",header->security_header_type&0x0f);
*is_sr = false;
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->extended_protocol_discriminator == EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES ||
header->extended_protocol_discriminator == EPD_5GS_SESSION_MANAGEMENT_MESSAGES) {
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
if (status) {
switch (header->security_header_type) {
......@@ -785,11 +789,12 @@ static int _nas_message_header_decode (
*/
//OAILOG_WARNING(LOG_NAS, "NET-API - The size of the header (%u) " "exceeds the buffer length (%lu)\n", NAS_MESSAGE_SECURITY_HEADER_SIZE, length);
//OAILOG_FUNC_RETURN (LOG_NAS, RETURNerror);
return RETURNerror;
}
// Decode the message authentication code
//DECODE_U32 (buffer + size, header->message_authentication_code, size);
DECODE_U32 (buffer + size, header->message_authentication_code, size);
// Decode the sequence number
//DECODE_U8 (buffer + size, header->sequence_number, size);
DECODE_U8 (buffer + size, header->sequence_number, size);
#if 0
printf("decode size:%d, message_authentication_code:0x%x,sequence_number:0x%x\n",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment