Commit 76b14805 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

update NAS

parent 27b9f1d2
This diff is collapsed.
......@@ -6,30 +6,30 @@
#include "TLVDecoder.h"
#include "PDUSessionIdentity.h"
int encode_pdu_session_identity ( PDUSessionIdentity pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
int encode_pdu_session_identity ( PDUSessionIdentity pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len)
{
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PDU_SESSION_IDENTITY_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (pdusessionidentity, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, PDU_SESSION_IDENTITY_MINIMUM_LENGTH, len);
if(iei > 0){
bitStream = 0x00 | (iei & 0xf0) | (pdusessionidentity & 0x0f);
}
ENCODE_U8(buffer + encoded, bitStream, encoded);
return encoded;
}
int decode_pdu_session_identity ( PDUSessionIdentity * pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
int decode_pdu_session_identity ( PDUSessionIdentity * pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len)
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (pdusessionidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
int decoded = 0;
uint8_t bitStream = 0x0;
DECODE_U8(buffer + decoded, bitStream, decoded);
if(iei != (bitStream & 0xf0))
return -1;
*pdusessionidentity = bitStream & 0x0f;
return decoded;
}
......@@ -4,7 +4,7 @@
#define PDU_SESSION_IDENTITY_MINIMUM_LENGTH 1
#define PDU_SESSION_IDENTITY_MAXIMUM_LENGTH 1
typedef bstring PDUSessionIdentity;
typedef uint8_t PDUSessionIdentity;
int encode_pdu_session_identity ( PDUSessionIdentity pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_pdu_session_identity ( PDUSessionIdentity * pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
......
......@@ -18,8 +18,20 @@ int encode_procedure_transaction_identity ( ProcedureTransactionIdentity procedu
encoded += encode_result;
return encoded;
/*
uint32_t encoded = 0;
uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, PROCEDURE_TRANSACTION_IDENTITY_MINIMUM_LENGTH, len);
if(iei > 0){
bitStream = 0x00 | (iei & 0xf0) | (proceduretransactionidentity & 0x0f);
}
ENCODE_U8(buffer + encoded, bitStream, encoded);
return encoded;
*/
}
int decode_procedure_transaction_identity ( ProcedureTransactionIdentity * proceduretransactionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
......@@ -31,5 +43,15 @@ int decode_procedure_transaction_identity ( ProcedureTransactionIdentity * proce
else
decoded += decode_result;
return decoded;
/*
int decoded = 0;
uint8_t bitStream = 0x0;
DECODE_U8(buffer + decoded, bitStream, decoded);
if(iei != (bitStream & 0xf0))
return -1;
*proceduretransactionidentity = bitStream & 0x0f;
return decoded;
*/
}
......@@ -373,21 +373,19 @@ static int _nas_message_header_encode (
*/
//ENCODE_U8 (buffer, *(uint8_t *) (header), size);
ENCODE_U8 (buffer,header->extended_protocol_discriminator,size);
printf("extended_protocol_discriminator %d \n",header->extended_protocol_discriminator);
//Security header type associated with a spare half octet;
ENCODE_U8 (buffer+size, *((uint8_t *) (header)+1),size);
//ENCODE_U8 (buffer+size,header->security_header_type,size);
printf("security_header_type %d \n",header->security_header_type);
printf("extended_protocol_discriminator %d, security_header_type %d \n",header->extended_protocol_discriminator, header->security_header_type);
//printf("security_header_type size = %d\n",size);
//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 ||
header->extended_protocol_discriminator == EPD_5GS_SESSION_MANAGEMENT_MESSAGES) {
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
printf("header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
printf("security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
if (length < NAS_MESSAGE_SECURITY_HEADER_SIZE) {
/*
* The buffer is not big enough to contain security header
......@@ -406,7 +404,7 @@ static int _nas_message_header_encode (
*/
ENCODE_U8 (buffer + size, header->sequence_number, size);
}
printf("header->security_header_type == SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
printf("security_header_type: SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
}
return size;
//OAILOG_STREAM_HEX(OAILOG_LEVEL_DEBUG, LOG_NAS, "encode nas header Incoming NAS message: ", buffer, size)
......
......@@ -174,7 +174,7 @@ int encode_pdu_session_establishment_accept( pdu_session_establishment_accept_ms
uint32_t encoded = 0;
int encoded_result = 0;
printf ("\n******************* encode_pdu_session_establishment_accept*****************\n");
printf ("Encode PDU Session Establishment Accept\n");
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, PDU_SESSION_ESTABLISHMENT_ACCEPT_MINIMUM_LENGTH, len);
/*
......
......@@ -191,7 +191,6 @@ fivegsm_msg_encode (
uint8_t * buffer,
uint32_t len)
{
printf("fivegsm_msg_encode , start ----------------------\n");
//OAILOG_FUNC_IN (LOG_NAS);
int header_result = 0;
int encode_result = 0;
......@@ -211,7 +210,7 @@ fivegsm_msg_encode (
buffer += header_result;
len -= header_result;
printf("************************** msg type %d",msg->header.message_type );
printf("Msg type %d",msg->header.message_type );
switch (msg->header.message_type) {
case PDU_SESSION_ESTABLISHMENT_REQUEST:
encode_result = encode_pdu_session_establishment_request(&msg->pdu_session_establishment_request, buffer, len);
......@@ -404,14 +403,11 @@ _fivegsm_msg_encode_header (
* Encode the procedure transaction identity
*/
ENCODE_U8 (buffer + size, header->procedure_transaction_identity, size);
printf("*********** _fivegsm_msg_encode_header******** %d\n", header->procedure_transaction_identity);
printf("fivegsm_msg_encode_header, procedure transaction identity %d", header->procedure_transaction_identity);
/*
* Encode the message type
*/
ENCODE_U8 (buffer + size, header->message_type, size);
printf("*********** _fivegsm_msg_encode_header******** \n");
for(int i = 0; i < size; i++)
printf("%02x ", buffer[i]);
return (size);
}
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