Commit b8865508 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix warning at building time

parent 02871149
...@@ -118,7 +118,7 @@ void SMContextsCollectionApi::post_sm_contexts_handler( ...@@ -118,7 +118,7 @@ void SMContextsCollectionApi::post_sm_contexts_handler(
} catch (nlohmann::detail::exception& e) { } catch (nlohmann::detail::exception& e) {
Logger::smf_api_server().warn( Logger::smf_api_server().warn(
"Can not parse the json data (error: %s)!", e.what()); "Cannot parse the json data (error: %s)!", e.what());
response.send(Pistache::Http::Code::Bad_Request, e.what()); response.send(Pistache::Http::Code::Bad_Request, e.what());
return; return;
} catch (std::exception& e) { } catch (std::exception& e) {
......
...@@ -34,23 +34,6 @@ ...@@ -34,23 +34,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
//------------------------------------------------------------------------------
// 10.5.1.3 Location Area Identification
//------------------------------------------------------------------------------
#define LOCATION_AREA_IDENTIFICATION_IE_TYPE 3
#define LOCATION_AREA_IDENTIFICATION_IE_MIN_LENGTH 6
#define LOCATION_AREA_IDENTIFICATION_IE_MAX_LENGTH 6
#define INVALID_LAC_0000 \
(uint16_t) 0x0000 /*!< \brief This LAC can be coded using a full \
hexadecimal representation except for the following \
reserved hexadecimal values: 0000, and FFFE. */
#define INVALID_LAC_FFFE \
(uint16_t) 0xFFFE /*!< \brief This LAC can be coded using a full \
hexadecimal representation except for the following \
reserved hexadecimal values: 0000, and FFFE. */
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// 10.5.6.3 Protocol configuration options // 10.5.6.3 Protocol configuration options
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -214,8 +214,8 @@ int decode_qos_rules( ...@@ -214,8 +214,8 @@ int decode_qos_rules(
qosrulesie->packetfilterlist.create_modifyandadd_modifyandreplace[j] qosrulesie->packetfilterlist.create_modifyandadd_modifyandreplace[j]
.packetfilteridentifier = bitstream & 0x0f; .packetfilteridentifier = bitstream & 0x0f;
uint8_t* lenghtofpacketfiltercontents = uint8_t lenghtofpacketfiltercontents =
(uint8_t*) (*(buffer + decoded) - 1); *(buffer + decoded) - 1;
decoded++; decoded++;
DECODE_U8(buffer + decoded, bitstream, decoded); DECODE_U8(buffer + decoded, bitstream, decoded);
...@@ -306,8 +306,8 @@ int decode_qos_rules( ...@@ -306,8 +306,8 @@ int decode_qos_rules(
.packetfilterlist.create_modifyandadd_modifyandreplace[j] .packetfilterlist.create_modifyandadd_modifyandreplace[j]
.packetfilteridentifier = bitstream & 0x0f; .packetfilteridentifier = bitstream & 0x0f;
uint8_t* lenghtofpacketfiltercontents = uint8_t lenghtofpacketfiltercontents =
(uint8_t*) (*(buffer + decoded) - 1); *(buffer + decoded) - 1;
decoded++; decoded++;
DECODE_U8(buffer + decoded, bitstream, decoded); DECODE_U8(buffer + decoded, bitstream, decoded);
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "secu_defs.h" #include "secu_defs.h"
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
/* L O C A L D E F I N I T I O N S */
#define SR_MAC_SIZE_BYTES 2 #define SR_MAC_SIZE_BYTES 2
/* Functions used to decode layer 3 NAS messages */ /* Functions used to decode layer 3 NAS messages */
...@@ -169,9 +168,7 @@ int nas_message_encode( ...@@ -169,9 +168,7 @@ int nas_message_encode(
/* /*
* Compute the NAS message authentication code * Compute the NAS message authentication code
*/ */
// OAILOG_DEBUG (LOG_NAS, "offset %d = %d - %lu, hdr encode = %d, length =
// %lu bytes = %d\n", offset, size, sizeof (uint8_t), size, length,
// bytes);
uint32_t mac = _nas_message_get_mac( uint32_t mac = _nas_message_get_mac(
buffer + offset, bytes + size - offset, buffer + offset, bytes + size - offset,
#if TEST_MAC_ENCRYPT_DECRYPT__ #if TEST_MAC_ENCRYPT_DECRYPT__
...@@ -208,9 +205,6 @@ int nas_message_encode( ...@@ -208,9 +205,6 @@ int nas_message_encode(
fivegmm_security_context->dl_count.overflow += 1; fivegmm_security_context->dl_count.overflow += 1;
} }
#endif #endif
// OAILOG_DEBUG (LOG_NAS, "Incremented
// fivegmm_security_context.dl_count.seq_num -> %u\n",
// fivegmm_security_context->dl_count.seq_num);
} else { } else {
// OAILOG_DEBUG (LOG_NAS, "Did not increment // OAILOG_DEBUG (LOG_NAS, "Did not increment
// fivegmm_security_context.dl_count.seq_num because no security // fivegmm_security_context.dl_count.seq_num because no security
...@@ -338,8 +332,6 @@ int nas_message_decode( ...@@ -338,8 +332,6 @@ int nas_message_decode(
return RETURNok; return RETURNok;
} }
/* L O C A L F U N C T I O N S */
static int _nas_message_header_encode( static int _nas_message_header_encode(
unsigned char* buffer, const nas_message_security_header_t* header, unsigned char* buffer, const nas_message_security_header_t* header,
size_t length) { size_t length) {
...@@ -361,8 +353,6 @@ static int _nas_message_header_encode( ...@@ -361,8 +353,6 @@ static int _nas_message_header_encode(
#endif #endif
if (header->extended_protocol_discriminator == if (header->extended_protocol_discriminator ==
EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) { 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 (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
#if DEBUG_IS_ON #if DEBUG_IS_ON
printf("security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED\n"); printf("security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
...@@ -449,8 +439,6 @@ static int _nas_message_plain_encode( ...@@ -449,8 +439,6 @@ static int _nas_message_plain_encode(
/* /*
* Discard L3 messages with not supported protocol discriminator * Discard L3 messages with not supported protocol discriminator
*/ */
// OAILOG_WARNING(LOG_NAS, "NET-API - Extended Protocol discriminator 0x%x
// is " "not supported\n", header->extended_protocol_discriminator);
} }
return bytes; return bytes;
} }
...@@ -489,13 +477,7 @@ static int _nas_message_encrypt( ...@@ -489,13 +477,7 @@ static int _nas_message_encrypt(
<< 8) | << 8) |
(fivegmm_security_context->dl_count.seq_num & 0x000000FF); (fivegmm_security_context->dl_count.seq_num & 0x000000FF);
} }
// OAILOG_DEBUG (LOG_NAS,
// "NAS_SECURITY_ALGORITHMS_EEA1 dir %s count.seq_num %u
// count %u\n", (direction == SECU_DIRECTION_UPLINK) ?
// "UPLINK" : "DOWNLINK", (direction ==
// SECU_DIRECTION_UPLINK) ?
// fivegmm_security_context->ul_count.seq_num :
// fivegmm_security_context->dl_count.seq_num, count);
stream_cipher.key = fivegmm_security_context->knas_enc; stream_cipher.key = fivegmm_security_context->knas_enc;
stream_cipher.key_length = AUTH_KNAS_ENC_SIZE; stream_cipher.key_length = AUTH_KNAS_ENC_SIZE;
stream_cipher.count = count; stream_cipher.count = count;
...@@ -528,13 +510,6 @@ static int _nas_message_encrypt( ...@@ -528,13 +510,6 @@ static int _nas_message_encrypt(
(fivegmm_security_context->dl_count.seq_num & 0x000000FF); (fivegmm_security_context->dl_count.seq_num & 0x000000FF);
} }
// OAILOG_DEBUG (LOG_NAS,
// "NAS_SECURITY_ALGORITHMS_EEA2 dir %s count.seq_num %u
// count %u\n", (direction == SECU_DIRECTION_UPLINK) ?
// "UPLINK" : "DOWNLINK", (direction ==
// SECU_DIRECTION_UPLINK) ?
// fivegmm_security_context->ul_count.seq_num :
// fivegmm_security_context->dl_count.seq_num, count);
stream_cipher.key = fivegmm_security_context->knas_enc; stream_cipher.key = fivegmm_security_context->knas_enc;
stream_cipher.key_length = AUTH_KNAS_ENC_SIZE; stream_cipher.key_length = AUTH_KNAS_ENC_SIZE;
stream_cipher.count = count; stream_cipher.count = count;
...@@ -549,10 +524,6 @@ static int _nas_message_encrypt( ...@@ -549,10 +524,6 @@ static int _nas_message_encrypt(
// OAILOG_FUNC_RETURN (LOG_NAS, length); // OAILOG_FUNC_RETURN (LOG_NAS, length);
} break; } break;
case NAS_SECURITY_ALGORITHMS_NEA0: { case NAS_SECURITY_ALGORITHMS_NEA0: {
// OAILOG_DEBUG (LOG_NAS, "NAS_SECURITY_ALGORITHMS_EEA0 dir %d
// ul_count.seq_num %d dl_count.seq_num %d\n", direction,
// fivegmm_security_context->ul_count.seq_num,
// fivegmm_security_context->dl_count.seq_num);
memcpy(dest, src, length); memcpy(dest, src, length);
// OAILOG_FUNC_RETURN (LOG_NAS, length); // OAILOG_FUNC_RETURN (LOG_NAS, length);
} break; } break;
...@@ -600,12 +571,6 @@ static uint32_t _nas_message_get_mac( ...@@ -600,12 +571,6 @@ static uint32_t _nas_message_get_mac(
(fivegmm_security_context->dl_count.seq_num & 0x000000FF); (fivegmm_security_context->dl_count.seq_num & 0x000000FF);
} }
// OAILOG_DEBUG (LOG_NAS,
// "NAS_SECURITY_ALGORITHMS_EIA1 dir %s count.seq_num %u count
// %u\n", (direction == SECU_DIRECTION_UPLINK) ? "UPLINK" :
// "DOWNLINK", (direction == SECU_DIRECTION_UPLINK) ?
// fivegmm_security_context->ul_count.seq_num :
// fivegmm_security_context->dl_count.seq_num, count);
stream_cipher.key = fivegmm_security_context->knas_int; stream_cipher.key = fivegmm_security_context->knas_int;
stream_cipher.key_length = AUTH_KNAS_INT_SIZE; stream_cipher.key_length = AUTH_KNAS_INT_SIZE;
stream_cipher.count = count; stream_cipher.count = count;
...@@ -617,10 +582,6 @@ static uint32_t _nas_message_get_mac( ...@@ -617,10 +582,6 @@ static uint32_t _nas_message_get_mac(
*/ */
stream_cipher.blength = length << 3; stream_cipher.blength = length << 3;
nas_stream_encrypt_nia1(&stream_cipher, mac); nas_stream_encrypt_nia1(&stream_cipher, mac);
// OAILOG_DEBUG (LOG_NAS, "NAS_SECURITY_ALGORITHMS_EIA1 returned MAC
// %x.%x.%x.%x(%u) for length %lu direction %d, count %d\n",
// mac[0], mac[1], mac[2], mac[3], *((uint32_t *) & mac), length,
// direction, count);
mac32 = (uint32_t*) &mac; mac32 = (uint32_t*) &mac;
return ntohl(*mac32); return ntohl(*mac32);
} break; } break;
...@@ -642,12 +603,6 @@ static uint32_t _nas_message_get_mac( ...@@ -642,12 +603,6 @@ static uint32_t _nas_message_get_mac(
(fivegmm_security_context->dl_count.seq_num & 0x000000FF); (fivegmm_security_context->dl_count.seq_num & 0x000000FF);
} }
// OAILOG_DEBUG (LOG_NAS,
// "NAS_SECURITY_ALGORITHMS_EIA2 dir %s count.seq_num %u count
// %u\n", (direction == SECU_DIRECTION_UPLINK) ? "UPLINK" :
// "DOWNLINK", (direction == SECU_DIRECTION_UPLINK) ?
// fivegmm_security_context->ul_count.seq_num :
// fivegmm_security_context->dl_count.seq_num, count);
stream_cipher.key = fivegmm_security_context->knas_int; stream_cipher.key = fivegmm_security_context->knas_int;
stream_cipher.key_length = AUTH_KNAS_INT_SIZE; stream_cipher.key_length = AUTH_KNAS_INT_SIZE;
stream_cipher.count = count; stream_cipher.count = count;
...@@ -659,20 +614,10 @@ static uint32_t _nas_message_get_mac( ...@@ -659,20 +614,10 @@ static uint32_t _nas_message_get_mac(
*/ */
stream_cipher.blength = length << 3; stream_cipher.blength = length << 3;
// nas_stream_encrypt_nia2 (&stream_cipher, mac); // nas_stream_encrypt_nia2 (&stream_cipher, mac);
// OAILOG_DEBUG (LOG_NAS, "NAS_SECURITY_ALGORITHMS_EIA2 returned MAC
// %x.%x.%x.%x(%u) for length %lu direction %d, count %d\n",
// mac[0], mac[1], mac[2], mac[3], *((uint32_t *) & mac), length,
// direction, count);
mac32 = (uint32_t*) &mac; mac32 = (uint32_t*) &mac;
// OAILOG_FUNC_RETURN (LOG_NAS, ntohl (*mac32)); // OAILOG_FUNC_RETURN (LOG_NAS, ntohl (*mac32));
} break; } break;
case NAS_SECURITY_ALGORITHMS_NIA0: { case NAS_SECURITY_ALGORITHMS_NIA0: {
// OAILOG_DEBUG (LOG_NAS,
// "NAS_SECURITY_ALGORITHMS_EIA0 dir %s count.seq_num %u\n",
// (direction == SECU_DIRECTION_UPLINK) ? "UPLINK" : "DOWNLINK",
// (direction == SECU_DIRECTION_UPLINK) ?
// fivegmm_security_context->ul_count.seq_num :
// fivegmm_security_context->dl_count.seq_num);
// OAILOG_FUNC_RETURN (LOG_NAS, 0); // OAILOG_FUNC_RETURN (LOG_NAS, 0);
} break; } break;
default: default:
...@@ -727,9 +672,6 @@ static int _nas_message_header_decode( ...@@ -727,9 +672,6 @@ static int _nas_message_header_decode(
/* /*
* The buffer is not big enough to contain security header * The buffer is not big enough to contain security header
*/ */
// OAILOG_WARNING(LOG_NAS, "NET-API - The size of the header (%u) "
// "exceeds the buffer length (%lu)\n",
// NAS_MESSAGE_SECURITY_HEADER_SIZE, length);
return RETURNerror; return RETURNerror;
} }
// Decode the message authentication code // Decode the message authentication code
...@@ -816,12 +758,6 @@ static int _nas_message_decrypt( ...@@ -816,12 +758,6 @@ static int _nas_message_decrypt(
(fivegmm_security_context->dl_count.seq_num & 0x000000FF); (fivegmm_security_context->dl_count.seq_num & 0x000000FF);
} }
// OAILOG_DEBUG (LOG_NAS,
// "NAS_SECURITY_ALGORITHMS_EEA1 dir %s count.seq_num %u count
// %u\n", (direction == SECU_DIRECTION_UPLINK) ? "UPLINK" :
// "DOWNLINK", (direction == SECU_DIRECTION_UPLINK) ?
// fivegmm_security_context->ul_count.seq_num :
// fivegmm_security_context->dl_count.seq_num, count);
stream_cipher.key = fivegmm_security_context->knas_enc; stream_cipher.key = fivegmm_security_context->knas_enc;
stream_cipher.key_length = AUTH_KNAS_ENC_SIZE; stream_cipher.key_length = AUTH_KNAS_ENC_SIZE;
stream_cipher.count = count; stream_cipher.count = count;
...@@ -870,12 +806,6 @@ static int _nas_message_decrypt( ...@@ -870,12 +806,6 @@ static int _nas_message_decrypt(
(fivegmm_security_context->dl_count.seq_num & 0x000000FF); (fivegmm_security_context->dl_count.seq_num & 0x000000FF);
} }
// OAILOG_DEBUG (LOG_NAS,
// "NAS_SECURITY_ALGORITHMS_EEA2 dir %s count.seq_num %u count
// %u\n", (direction == SECU_DIRECTION_UPLINK) ? "UPLINK" :
// "DOWNLINK", (direction == SECU_DIRECTION_UPLINK) ?
// fivegmm_security_context->ul_count.seq_num :
// fivegmm_security_context->dl_count.seq_num, count);
stream_cipher.key = fivegmm_security_context->knas_enc; stream_cipher.key = fivegmm_security_context->knas_enc;
stream_cipher.key_length = AUTH_KNAS_ENC_SIZE; stream_cipher.key_length = AUTH_KNAS_ENC_SIZE;
stream_cipher.count = count; stream_cipher.count = count;
...@@ -889,8 +819,7 @@ static int _nas_message_decrypt( ...@@ -889,8 +819,7 @@ static int _nas_message_decrypt(
// nas_stream_encrypt_nea2 (&stream_cipher, (uint8_t*)dest); // nas_stream_encrypt_nea2 (&stream_cipher, (uint8_t*)dest);
/* /*
* Decode the first octet (security header type or EPS bearer * Decode the first octet (security header type or EPS bearer
* identity, * identity, and protocol discriminator)
* * * * and protocol discriminator)
*/ */
DECODE_U8(dest, header.extended_protocol_discriminator, size); DECODE_U8(dest, header.extended_protocol_discriminator, size);
DECODE_U8(dest + size, header.security_header_type, size); DECODE_U8(dest + size, header.security_header_type, size);
...@@ -905,8 +834,7 @@ static int _nas_message_decrypt( ...@@ -905,8 +834,7 @@ static int _nas_message_decrypt(
memcpy(dest, src, length); memcpy(dest, src, length);
/* /*
* Decode the first octet (security header type or EPS bearer * Decode the first octet (security header type or EPS bearer
* identity, * identity, and protocol discriminator)
* * * * and protocol discriminator)
*/ */
DECODE_U8(dest, header.extended_protocol_discriminator, size); DECODE_U8(dest, header.extended_protocol_discriminator, size);
DECODE_U8(dest + size, header.security_header_type, size); DECODE_U8(dest + size, header.security_header_type, size);
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "sm_msg.h" #include "sm_msg.h"
#include "common_types.h" #include "common_types.h"
// test mac and encrypt/decrypt
#define DIRECTION__ 1 // SECU_DIRECTION_DOWNLINK #define DIRECTION__ 1 // SECU_DIRECTION_DOWNLINK
#define TEST_MAC_ENCRYPT_DECRYPT__ 0 #define TEST_MAC_ENCRYPT_DECRYPT__ 0
#define NAS_MESSAGE_SECURITY_HEADER_SIZE 7 #define NAS_MESSAGE_SECURITY_HEADER_SIZE 7
......
...@@ -102,7 +102,6 @@ int main(int argc, char** argv) { ...@@ -102,7 +102,6 @@ int main(int argc, char** argv) {
// Logger // Logger
Logger::init("smf", Options::getlogStdout(), Options::getlogRotFilelog()); Logger::init("smf", Options::getlogStdout(), Options::getlogRotFilelog());
Logger::smf_app().startup("Options parsed"); Logger::smf_app().startup("Options parsed");
struct sigaction sigIntHandler; struct sigaction sigIntHandler;
...@@ -115,7 +114,7 @@ int main(int argc, char** argv) { ...@@ -115,7 +114,7 @@ int main(int argc, char** argv) {
smf_cfg.load(Options::getlibconfigConfig()); smf_cfg.load(Options::getlibconfigConfig());
smf_cfg.display(); smf_cfg.display();
// Inter task Interface // Inter-task Interface
itti_inst = new itti_mw(); itti_inst = new itti_mw();
itti_inst->start(smf_cfg.itti.itti_timer_sched_params); itti_inst->start(smf_cfg.itti.itti_timer_sched_params);
......
...@@ -77,7 +77,7 @@ void smf_qos_flow::mark_as_released() { ...@@ -77,7 +77,7 @@ void smf_qos_flow::mark_as_released() {
std::string smf_qos_flow::toString() const { std::string smf_qos_flow::toString() const {
std::string s = {}; std::string s = {};
s.append("QoS Flow:\n"); s.append("QoS Flow:\n");
s.append("\tFQI:\t\t\t\t") s.append("\tQFI:\t\t\t\t")
.append(std::to_string((uint8_t) qfi.qfi)) .append(std::to_string((uint8_t) qfi.qfi))
.append("\n"); .append("\n");
s.append("\tUL FTEID:\t\t").append(ul_fteid.toString()).append("\n"); s.append("\tUL FTEID:\t\t").append(ul_fteid.toString()).append("\n");
......
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