Commit 8fc1cc06 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

solve warnings (related to NAS) when compiling SMF

parent 1b31813a
......@@ -318,7 +318,8 @@ enum class pdu_session_status_e {
static const std::vector<std::string> pdu_session_status_e2str = {
"PDU_SESSION_INACTIVE", "PDU_SESSION_INACTIVE_PENDING",
"PDU_SESSION_MODIFICATION_PENDING", "PDU_SESSION_ACTIVE" };
"PDU_SESSION_MODIFICATION_PENDING", "PDU_SESSION_ESTABLISHMENT_PENDING",
"PDU_SESSION_ACTIVE" };
//see Table 9.11.4.12.1: QoS flow descriptions information element
typedef struct flow_bit_rate_type_s {
......
......@@ -6,36 +6,15 @@
#include "TLVDecoder.h"
#include "MessageType.h"
int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
/*
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MESSAGE_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (messagetype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
*/
int encode_message_type(MessageType messagetype, uint8_t iei, uint8_t *buffer,
uint32_t len) {
//we don't need this since it's done in encode header ENCODE_U8
return 0;
}
int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
/*
int decoded=0;
int decode_result;
if((decode_result = decode_bstring (messagetype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
*/
int decode_message_type(MessageType *messagetype, uint8_t iei, uint8_t *buffer,
uint32_t len) {
//we don't need this since it's done in decode header (DECODE_U8)
return 0;
}
......@@ -6,6 +6,7 @@
typedef uint8_t MessageType;
int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int encode_message_type(MessageType messagetype, uint8_t iei, uint8_t *buffer,
uint32_t len);
int decode_message_type(MessageType *messagetype, uint8_t iei, uint8_t *buffer,
uint32_t len);
......@@ -21,8 +21,9 @@ int encode_nssai ( NSSAI nssai, uint8_t iei, uint8_t * buffer, uint32_t len )
lenPtr = (buffer + encoded);
encoded++;
//TODO: fix it for MM
/*
if ((encode_result = encode_bstring (nssai, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
if ((encode_result = encode_bstring (nssai, buffer + encoded, len - encoded)) < 0)
return encode_result;
else
encoded += encode_result;
......@@ -35,7 +36,7 @@ int decode_nssai ( NSSAI * nssai, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
// int decode_result;
if (iei > 0)
{
......@@ -47,12 +48,13 @@ int decode_nssai ( NSSAI * nssai, uint8_t iei, uint8_t * buffer, uint32_t len )
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
//TODO: fix it for MM
/*
if((decode_result = decode_bstring (nssai, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
*/
return decoded;
}
......@@ -12,7 +12,6 @@ int encode_qos_rules ( QOSRules qosrules, uint8_t iei, uint8_t * buffer, uint32_
uint8_t *len_qosrulesie = NULL;
uint8_t len_pos_qos_rule = 0;
uint8_t bitstream = 0;
uint16_t lenqosrule_16 = 0;
uint32_t encoded = 0;
int encode_result = 0;
int i = 0,j = 0;
......@@ -102,7 +101,7 @@ int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint3
uint16_t ielen=0;
int decode_result = 0;
uint16_t numberrules = 0;
uint16_t lenqosrule = 0;
// uint16_t lenqosrule = 0;
uint8_t bitstream = 0;
int i=0,j=0;
......
......@@ -12,7 +12,7 @@ int encode_security_header_type ( SecurityHeaderType securityheadertype, uint8_t
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SECURITY_HEADER_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (securityheadertype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
if ((encode_result = encode_bstring (securityheadertype, buffer + encoded, len - encoded)) < 0)
return encode_result;
else
encoded += encode_result;
......
......@@ -8,50 +8,41 @@
int encode_time_zone ( TimeZone timezone, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,TIME_ZONE_MINIMUM_LENGTH , len);
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,TIME_ZONE_MINIMUM_LENGTH , len);
if( iei >0 )
{
*buffer=iei;
encoded++;
}
if( iei >0 )
{
*buffer=iei;
encoded++;
}
if ((encode_result = encode_bstring (timezone, buffer + encoded, len - encoded)) < 0)
return encode_result;
else
encoded += encode_result;
if ((encode_result = encode_bstring (timezone, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
return encoded;
}
int decode_time_zone ( TimeZone * timezone, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
if((decode_result = decode_bstring (timezone, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
if((decode_result = decode_bstring (timezone, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
}
......@@ -45,7 +45,6 @@ int decode__5gsm_capability ( _5GSMCapability * _5gsmcapability, uint8_t iei, ui
{
int decoded=0;
uint8_t ielen=0;
int decode_result = 0;
uint8_t _5gsmcapability_bits = 0;
......
......@@ -10,7 +10,7 @@ int encode__5gs_mobile_identity ( _5GSMobileIdentity _5gsmobileidentity, uint8_
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_MOBILE_IDENTITY_MINIMUM_LENGTH , len);
lenPtr = (buffer + encoded);
......
......@@ -9,7 +9,7 @@
int decode_deregistration_request( deregistration_request_msg *deregistration_request, uint8_t* buffer, uint32_t len)
{
uint32_t decoded = 0;
int decoded_result = 0;
// int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len);
......@@ -52,7 +52,7 @@ int decode_deregistration_request( deregistration_request_msg *deregistration_re
int encode_deregistration_request( deregistration_request_msg *deregistration_request, uint8_t* buffer, uint32_t len)
{
uint32_t encoded = 0;
int encoded_result = 0;
// int encoded_result = 0;
// 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, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len);
......
......@@ -375,7 +375,7 @@ int encode_registration_request( registration_request_msg *registration_request,
}
*/
//test
if(registration_request->presence & REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT
if((registration_request->presence & REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT)
== REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT){
if((encoded_result = encode_allowed_pdu_session_status (registration_request->allowedpdusessionstatus, REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
......
......@@ -9,7 +9,7 @@
int decode_service_request( service_request_msg *service_request, uint8_t* buffer, uint32_t len)
{
uint32_t decoded = 0;
int decoded_result = 0;
// int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, SERVICE_REQUEST_MINIMUM_LENGTH, len);
......@@ -72,7 +72,7 @@ int decode_service_request( service_request_msg *service_request, uint8_t* buffe
int encode_service_request( service_request_msg *service_request, uint8_t* buffer, uint32_t len)
{
uint32_t encoded = 0;
int encoded_result = 0;
// int encoded_result = 0;
// 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, SERVICE_REQUEST_MINIMUM_LENGTH, len);
......
......@@ -65,8 +65,8 @@ fivegmm_msg_encode (
//OAILOG_FUNC_IN (LOG_NAS_EMM);
int header_result;
int encode_result;
uint8_t *buffer_log = buffer;
bool is_down_link = true;
// uint8_t *buffer_log = buffer;
// bool is_down_link = true;
/*
* First encode the EMM message header
*/
......@@ -202,9 +202,9 @@ mm_msg_decode (
//OAILOG_FUNC_IN (LOG_NAS);
int header_result = 0;
int decode_result = 0;
uint8_t *buffer_log = buffer;
uint32_t len_log = len;
bool is_down_link = false;
// uint8_t *buffer_log = buffer;
// uint32_t len_log = len;
// bool is_down_link = false;
/*
* First decode the MM message header
......
......@@ -630,7 +630,7 @@ static uint32_t _nas_message_get_mac(
switch (fivegmm_security_context->selected_algorithms.integrity) {
case NAS_SECURITY_ALGORITHMS_NIA1: {
uint8_t mac[4];
nas_stream_cipher_t stream_cipher;
nas_stream_cipher_t stream_cipher = { 0 };
uint32_t count;
uint32_t *mac32;
......@@ -668,7 +668,7 @@ static uint32_t _nas_message_get_mac(
break;
case NAS_SECURITY_ALGORITHMS_NIA2: {
uint8_t mac[4];
nas_stream_cipher_t stream_cipher;
nas_stream_cipher_t stream_cipher = { 0 };
uint32_t count;
uint32_t *mac32;
......@@ -866,7 +866,7 @@ static int _nas_message_decrypt(
//stream_cipher.message = (uint8_t*)src;
uint8_t *src_encrypt = NULL;
src_encrypt = (uint8_t*) calloc(1, length + 3);
memset(src_encrypt, 0, sizeof(src_encrypt));
memset(src_encrypt, 0, sizeof(uint8_t));
memcpy(src_encrypt, src, length);
stream_cipher.message = (uint8_t*) src_encrypt;
......
......@@ -111,7 +111,7 @@ int decode_pdu_session_modification_command(
case PDU_SESSION_MODIFICATION_COMMAND_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(
&pdu_session_modification_command
->extendedprotocolconfigurationoptions,
->extendedprotocolconfigurationoptions,
PDU_SESSION_MODIFICATION_COMMAND_E_P_C_O_IEI, buffer + decoded,
len - decoded)) < 0)
return decoded_result;
......@@ -137,28 +137,6 @@ int encode_pdu_session_modification_command(
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, PDU_SESSION_MODIFICATION_COMMAND_MINIMUM_LENGTH, len);
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_modification_command->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_pdu_session_identity (pdu_session_modification_command->pdusessionidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_procedure_transaction_identity (pdu_session_modification_command->proceduretransactionidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_message_type (pdu_session_modification_command->messagetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
#endif
if ((pdu_session_modification_command->presence
& PDU_SESSION_MODIFICATION_COMMAND__5GSM_CAUSE_PRESENCE)
== PDU_SESSION_MODIFICATION_COMMAND__5GSM_CAUSE_PRESENCE) {
......
......@@ -50,9 +50,7 @@ static int _fivegsm_msg_encode_header(const sm_msg_header_t *header,
int sm_msg_decode(SM_msg *msg, uint8_t *buffer, uint32_t len) {
int header_result = 0;
int decode_result = 0;
uint8_t *buffer_log = buffer;
uint32_t len_log = len;
int down_link = 0;
//OAILOG_FUNC_IN (LOG_NAS);
/*
* First decode the SM message header
......@@ -165,8 +163,6 @@ int sm_msg_decode(SM_msg *msg, uint8_t *buffer, uint32_t len) {
int fivegsm_msg_encode(SM_msg *msg, uint8_t *buffer, uint32_t len) {
int header_result = 0;
int encode_result = 0;
uint8_t *buffer_log = buffer;
int down_link = 1;
/*
* First encode the ESM message header
*/
......
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