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

Code cleanup

parent c63a4711
......@@ -69,7 +69,8 @@ void SMContextsCollectionApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(
*router, base + smf_cfg.sbi_api_version + NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL,
*router,
base + smf_cfg.sbi_api_version + NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL,
Routes::bind(&SMContextsCollectionApi::post_sm_contexts_handler, this));
// Default handler, called when a route is not found
......
......@@ -180,8 +180,8 @@ void IndividualSMContextApiImpl::update_sm_context(
* TS 23.502 */
// TODO: Existing PDU session, step 3, SUPI, DNN, S-NSSAIs, SM Context ID, AMF
// ID, Request Type, N1 SM Container (PDU Session Establishment Request), User
// location, Access Type, RAT Type, PEI step 15. (SM Context ID -> SCID, N2 SM,
// Request Type)(Initial Request)
// location, Access Type, RAT Type, PEI step 15. (SM Context ID -> SCID, N2
// SM, Request Type)(Initial Request)
// TODO: verify why Request Type is not define in smContextUpdateData
/* AMF-initiated with a release indication to request the release of the PDU
* Session (step 3.d, section 4.3.4.2@3GPP TS 23.502)*/
......
......@@ -32,7 +32,6 @@
* contact@openairinterface.org
*/
#include "IndividualSubscriptionDocumentApiImpl.h"
namespace oai {
......
......@@ -38,7 +38,6 @@
* contact@openairinterface.org
*/
#ifndef NF_STATUS_NOTIFY_API_IMPL_H_
#define NF_STATUS_NOTIFY_API_IMPL_H_
......
......@@ -32,7 +32,6 @@
* contact@openairinterface.org
*/
#include "PDUSessionsCollectionApiImpl.h"
namespace oai {
......
......@@ -225,7 +225,8 @@ void smf_http2_server::start() {
return;
}
} else if (method.compare("release") == 0) { // smContextReleaseData
} else if (
method.compare("release") == 0) { // smContextReleaseData
Logger::smf_api_server().info(
"Handle Release SM Context Request from AMF");
......@@ -293,7 +294,8 @@ void smf_http2_server::create_sm_contexts_handler(
// set api root to be used as location header in HTTP response
sm_context_req_msg.set_api_root(
// m_address + ":" + std::to_string(m_port) +
NSMF_PDU_SESSION_BASE + smf_cfg.sbi_api_version + NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
NSMF_PDU_SESSION_BASE + smf_cfg.sbi_api_version +
NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL);
// supi
supi_t supi = {.length = 0};
......@@ -474,8 +476,8 @@ void smf_http2_server::update_sm_context_handler(
* TS 23.502 */
// TODO: Existing PDU session, step 3, SUPI, DNN, S-NSSAIs, SM Context ID, AMF
// ID, Request Type, N1 SM Container (PDU Session Establishment Request), User
// location, Access Type, RAT Type, PEI step 15. (SM Context ID -> SCID, N2 SM,
// Request Type)(Initial Request)
// location, Access Type, RAT Type, PEI step 15. (SM Context ID -> SCID, N2
// SM, Request Type)(Initial Request)
// TODO: verify why Request Type is not define in smContextUpdateData
/* AMF-initiated with a release indication to request the release of the PDU
* Session (step 3.d, section 4.3.4.2@3GPP TS 23.502)*/
......
......@@ -45,7 +45,7 @@ typedef struct plmn_s {
#define INVALID_TMSI \
UINT32_MAX /*!< \brief The network shall not allocate a TMSI with all 32 \
bits equal to 1 (this is because the TMSI must be stored in \
bits equal to 1 (this is because the TMSI must be stored in \
the SIM, and the SIM uses 4 octets with all bits \
equal to 1 to indicate that no valid TMSI is \
available). */
......
......@@ -110,14 +110,14 @@ enum class n2_sm_info_type_e {
PDU_RES_NTY_REL = 10, // PDU Session Resource Notify Released Transfer
PDU_RES_MOD_IND = 11, // PDU Session Resource Modify Indication Transfer
PDU_RES_MOD_CFM = 12, // PDU Session Resource Modify Confirm Transfer
PATH_SWITCH_REQ = 13, // Path Switch Request Transfer
PATH_SWITCH_REQ = 13, // Path Switch Request Transfer
PATH_SWITCH_SETUP_FAIL = 14, // Path Switch Request Setup Failed Transfer
PATH_SWITCH_REQ_ACK = 15, // Path Switch Request Acknowledge Transfer
PATH_SWITCH_REQ_FAIL = 16, // Path Switch Request Unsuccessful Transfer
HANDOVER_REQUIRED = 17, // Handover Required Transfer
HANDOVER_CMD = 18, // Handover Command Transfer
HANDOVER_PREP_FAIL = 19, // Handover Preparation Unsuccessful Transfer
HANDOVER_REQ_ACK = 20, // Handover Request Acknowledge Transfer
HANDOVER_REQUIRED = 17, // Handover Required Transfer
HANDOVER_CMD = 18, // Handover Command Transfer
HANDOVER_PREP_FAIL = 19, // Handover Preparation Unsuccessful Transfer
HANDOVER_REQ_ACK = 20, // Handover Request Acknowledge Transfer
HANDOVER_RES_ALLOC_FAIL =
21, // Handover Resource Allocation Unsuccessful Transfer
SECONDARY_RAT_USAGE = 22 // Secondary RAT Data Usage Report Transfer
......
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -41,67 +41,50 @@ class endpoint {
struct sockaddr_storage addr_storage;
socklen_t addr_storage_len;
endpoint()
:
addr_storage(),
addr_storage_len(sizeof(struct sockaddr_storage)) {
}
;
endpoint(const endpoint &e)
:
addr_storage(e.addr_storage),
addr_storage_len(e.addr_storage_len) {
}
;
endpoint(const struct sockaddr_storage &addr, const socklen_t len)
:
addr_storage(addr),
addr_storage_len(len) {
}
;
endpoint(const struct in_addr &addr, const uint16_t port) {
struct sockaddr_in *addr_in = (struct sockaddr_in*) &addr_storage;
addr_in->sin_family = AF_INET;
addr_in->sin_port = htons(port);
addr_in->sin_addr.s_addr = addr.s_addr;
: addr_storage(), addr_storage_len(sizeof(struct sockaddr_storage)){};
endpoint(const endpoint& e)
: addr_storage(e.addr_storage), addr_storage_len(e.addr_storage_len){};
endpoint(const struct sockaddr_storage& addr, const socklen_t len)
: addr_storage(addr), addr_storage_len(len){};
endpoint(const struct in_addr& addr, const uint16_t port) {
struct sockaddr_in* addr_in = (struct sockaddr_in*) &addr_storage;
addr_in->sin_family = AF_INET;
addr_in->sin_port = htons(port);
addr_in->sin_addr.s_addr = addr.s_addr;
addr_storage_len = sizeof(struct sockaddr_in);
}
;
};
endpoint(const struct in6_addr &addr6, const uint16_t port) {
struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6*) &addr_storage;
addr_in6->sin6_family = AF_INET6;
addr_in6->sin6_port = htons(port);
addr_in6->sin6_flowinfo = 0;
endpoint(const struct in6_addr& addr6, const uint16_t port) {
struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*) &addr_storage;
addr_in6->sin6_family = AF_INET6;
addr_in6->sin6_port = htons(port);
addr_in6->sin6_flowinfo = 0;
memcpy(&addr_in6->sin6_addr, &addr6, sizeof(struct in6_addr));
addr_in6->sin6_scope_id = 0;
addr_storage_len = sizeof(struct sockaddr_in6);
}
;
};
uint16_t port() const {
return ntohs(((struct sockaddr_in*) &addr_storage)->sin_port);
}
sa_family_t family() const {
return addr_storage.ss_family;
}
sa_family_t family() const { return addr_storage.ss_family; }
std::string toString() const {
std::string str;
if (addr_storage.ss_family == AF_INET) {
struct sockaddr_in *addr_in = (struct sockaddr_in*) &addr_storage;
struct sockaddr_in* addr_in = (struct sockaddr_in*) &addr_storage;
str.append(conv::toString(addr_in->sin_addr));
str.append(":").append(std::to_string(ntohs(addr_in->sin_port)));
} else if (addr_storage.ss_family == AF_INET6) {
struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6*) &addr_storage;
struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*) &addr_storage;
str.append(conv::toString(addr_in6->sin6_addr));
str.append(":").append(std::to_string(ntohs(addr_in6->sin6_port)));
}
return str;
}
};
#endif
......@@ -21,144 +21,104 @@
#include <stdexcept>
#include <vector>
//#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" };
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info ", "start", "warn ", "error", "off " };
//#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error",
//"critical", "off" };
#define SPDLOG_LEVEL_NAMES \
{"trace", "debug", "info ", "start", "warn ", "error", "off "};
#define SPDLOG_ENABLE_SYSLOG
#include "spdlog/spdlog.h"
class LoggerException : public std::runtime_error {
public:
explicit LoggerException(const char *m)
:
std::runtime_error(m) {
}
explicit LoggerException(const std::string &m)
:
std::runtime_error(m) {
}
explicit LoggerException(const char* m) : std::runtime_error(m) {}
explicit LoggerException(const std::string& m) : std::runtime_error(m) {}
};
class _Logger {
public:
_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks,
const char *pattern);
void trace(const char *format, ...);
void trace(const std::string &format, ...);
void debug(const char *format, ...);
void debug(const std::string &format, ...);
void info(const char *format, ...);
void info(const std::string &format, ...);
void startup(const char *format, ...);
void startup(const std::string &format, ...);
void warn(const char *format, ...);
void warn(const std::string &format, ...);
void error(const char *format, ...);
void error(const std::string &format, ...);
_Logger(
const char* category, std::vector<spdlog::sink_ptr>& sinks,
const char* pattern);
void trace(const char* format, ...);
void trace(const std::string& format, ...);
void debug(const char* format, ...);
void debug(const std::string& format, ...);
void info(const char* format, ...);
void info(const std::string& format, ...);
void startup(const char* format, ...);
void startup(const std::string& format, ...);
void warn(const char* format, ...);
void warn(const std::string& format, ...);
void error(const char* format, ...);
void error(const std::string& format, ...);
private:
_Logger();
enum _LogType {
_ltTrace,
_ltDebug,
_ltInfo,
_ltStartup,
_ltWarn,
_ltError
};
enum _LogType { _ltTrace, _ltDebug, _ltInfo, _ltStartup, _ltWarn, _ltError };
void log(_LogType lt, const char *format, va_list &args);
void log(_LogType lt, const char* format, va_list& args);
spdlog::logger m_log;
};
class Logger {
public:
static void init(const char *app, const bool log_stdout,
const bool log_rot_file) {
static void init(
const char* app, const bool log_stdout, const bool log_rot_file) {
singleton()._init(app, log_stdout, log_rot_file);
}
static void init(const std::string &app, const bool log_stdout,
const bool log_rot_file) {
static void init(
const std::string& app, const bool log_stdout, const bool log_rot_file) {
init(app.c_str(), log_stdout, log_rot_file);
}
static _Logger& async_cmd() {
return *singleton().m_async_cmd;
}
static _Logger& itti() {
return *singleton().m_itti;
}
static _Logger& smf_app() {
return *singleton().m_smf_app;
}
static _Logger& system() {
return *singleton().m_system;
}
static _Logger& udp() {
return *singleton().m_udp;
}
static _Logger& pfcp() {
return *singleton().m_pfcp;
}
static _Logger& pfcp_switch() {
return *singleton().m_pfcp_switch;
}
static _Logger& async_cmd() { return *singleton().m_async_cmd; }
static _Logger& itti() { return *singleton().m_itti; }
static _Logger& smf_app() { return *singleton().m_smf_app; }
static _Logger& system() { return *singleton().m_system; }
static _Logger& udp() { return *singleton().m_udp; }
static _Logger& pfcp() { return *singleton().m_pfcp; }
static _Logger& pfcp_switch() { return *singleton().m_pfcp_switch; }
static _Logger& smf_n1() {
return *singleton().m_smf_n1;
}
static _Logger& smf_n2() {
return *singleton().m_smf_n2;
}
static _Logger& smf_n4() {
return *singleton().m_smf_n4;
}
static _Logger& smf_n10() {
return *singleton().m_smf_n10;
}
static _Logger& smf_n11() {
return *singleton().m_smf_n11;
}
static _Logger& smf_api_server() {
return *singleton().m_smf_api_server;
}
static _Logger& smf_n1() { return *singleton().m_smf_n1; }
static _Logger& smf_n2() { return *singleton().m_smf_n2; }
static _Logger& smf_n4() { return *singleton().m_smf_n4; }
static _Logger& smf_n10() { return *singleton().m_smf_n10; }
static _Logger& smf_n11() { return *singleton().m_smf_n11; }
static _Logger& smf_api_server() { return *singleton().m_smf_api_server; }
private:
static Logger *m_singleton;
static Logger* m_singleton;
static Logger& singleton() {
if (!m_singleton)
m_singleton = new Logger();
if (!m_singleton) m_singleton = new Logger();
return *m_singleton;
}
Logger() {
}
~Logger() {
}
Logger() {}
~Logger() {}
void _init(const char *app, const bool log_stdout, const bool log_rot_file);
void _init(const char* app, const bool log_stdout, const bool log_rot_file);
std::vector<spdlog::sink_ptr> m_sinks;
std::string m_pattern;
_Logger *m_async_cmd;
_Logger *m_itti;
_Logger *m_smf_app;
_Logger *m_system;
_Logger *m_udp;
_Logger *m_pfcp;
_Logger *m_pfcp_switch;
_Logger *m_smf_n1;
_Logger *m_smf_n2;
_Logger *m_smf_n4;
_Logger *m_smf_n10;
_Logger *m_smf_n11;
_Logger *m_smf_api_server;
_Logger* m_async_cmd;
_Logger* m_itti;
_Logger* m_smf_app;
_Logger* m_system;
_Logger* m_udp;
_Logger* m_pfcp;
_Logger* m_pfcp_switch;
_Logger* m_smf_n1;
_Logger* m_smf_n2;
_Logger* m_smf_n4;
_Logger* m_smf_n10;
_Logger* m_smf_n11;
_Logger* m_smf_api_server;
};
#endif // __LOGGER_H
#endif // __LOGGER_H
......@@ -34,9 +34,9 @@
class stream_serializable {
public:
virtual void dump_to(std::ostream &os) = 0;
virtual void load_from(std::istream &is) = 0;
//virtual ~serializable() = 0;
virtual void dump_to(std::ostream& os) = 0;
virtual void load_from(std::istream& is) = 0;
// virtual ~serializable() = 0;
};
#endif /* FILE_SERIALIZABLE_HPP_SEEN */
......@@ -148,7 +148,6 @@ void xgpp_conv::pco_core_to_nas(
void xgpp_conv::sm_context_create_data_from_openapi(
const oai::smf_server::model::SmContextMessage& scd,
smf::pdu_session_create_sm_context_request& pcr) {
Logger::smf_app().debug(
"Convert SmContextMessage (OpenAPI) to "
"pdu_session_create_sm_context_request");
......@@ -156,7 +155,7 @@ void xgpp_conv::sm_context_create_data_from_openapi(
oai::smf_server::model::SmContextCreateData context_data = scd.getJsonData();
std::string n1_sm_msg = scd.getBinaryDataN1SmMessage();
//N1 SM Message
// N1 SM Message
pcr.set_n1_sm_message(n1_sm_msg);
Logger::smf_app().debug("N1 SM message: %s", n1_sm_msg.c_str());
......
......@@ -20,65 +20,70 @@
static int bsafeShouldExit = 1;
char * strcpy (char *dst, const char *src);
char * strcat (char *dst, const char *src);
char* strcpy(char* dst, const char* src);
char* strcat(char* dst, const char* src);
char * strcpy (char *dst, const char *src) {
(void) dst;
(void) src;
fprintf (stderr, "bsafe error: strcpy() is not safe, use bstrcpy instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char* strcpy(char* dst, const char* src) {
(void) dst;
(void) src;
fprintf(stderr, "bsafe error: strcpy() is not safe, use bstrcpy instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
char * strcat (char *dst, const char *src) {
(void) dst;
(void) src;
fprintf (stderr, "bsafe error: strcat() is not safe, use bstrcat instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char* strcat(char* dst, const char* src) {
(void) dst;
(void) src;
fprintf(stderr, "bsafe error: strcat() is not safe, use bstrcat instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
#if !defined (__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
char * (gets) (char * buf) {
(void) buf;
fprintf (stderr, "bsafe error: gets() is not safe, use bgets.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
#if !defined(__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
char*(gets)(char* buf) {
(void) buf;
fprintf(stderr, "bsafe error: gets() is not safe, use bgets.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
#endif
char * (strncpy) (char *dst, const char *src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf (stderr, "bsafe error: strncpy() is not safe, use bmidstr instead.\n");
//if (bsafeShouldExit) exit (-1);
return NULL;
char*(strncpy)(char* dst, const char* src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf(stderr, "bsafe error: strncpy() is not safe, use bmidstr instead.\n");
// if (bsafeShouldExit) exit (-1);
return NULL;
}
char * (strncat) (char *dst, const char *src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf (stderr, "bsafe error: strncat() is not safe, use bstrcat then btrunc\n\tor cstr2tbstr, btrunc then bstrcat instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char*(strncat)(char* dst, const char* src, size_t n) {
(void) dst;
(void) src;
(void) n;
fprintf(
stderr,
"bsafe error: strncat() is not safe, use bstrcat then btrunc\n\tor "
"cstr2tbstr, btrunc then bstrcat instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
char * (strtok) (char *s1, const char *s2) {
(void) s1;
(void) s2;
fprintf (stderr, "bsafe error: strtok() is not safe, use bsplit or bsplits instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
char*(strtok)(char* s1, const char* s2) {
(void) s1;
(void) s2;
fprintf(
stderr,
"bsafe error: strtok() is not safe, use bsplit or bsplits instead.\n");
if (bsafeShouldExit) exit(-1);
return NULL;
}
/*
//TODO: temporary solution for Release mode
char * (strdup) (const char *s) {
(void) s;
fprintf (stderr, "bsafe error: strdup() is not safe, use bstrcpy.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
(void) s;
fprintf (stderr, "bsafe error: strdup() is not safe, use bstrcpy.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
}
*/
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2004, and is covered by the BSD open source
* license. Refer to the accompanying documentation for details on usage and
* written by Paul Hsieh in 2002-2004, and is covered by the BSD open source
* license. Refer to the accompanying documentation for details on usage and
* license.
*/
......@@ -21,20 +21,20 @@
extern "C" {
#endif
#if !defined (__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
#if !defined(__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
/* This is caught in the linker, so its not necessary for gcc. */
extern char * (gets) (char * buf);
extern char*(gets)(char* buf);
#endif
extern char * (strncpy) (char *dst, const char *src, size_t n);
extern char * (strncat) (char *dst, const char *src, size_t n);
extern char * (strtok) (char *s1, const char *s2);
//extern char * (strdup) (const char *s);
extern char*(strncpy)(char* dst, const char* src, size_t n);
extern char*(strncat)(char* dst, const char* src, size_t n);
extern char*(strtok)(char* s1, const char* s2);
// extern char * (strdup) (const char *s);
#undef strcpy
#undef strcat
#define strcpy(a,b) bsafe_strcpy(a,b)
#define strcat(a,b) bsafe_strcat(a,b)
#define strcpy(a, b) bsafe_strcpy(a, b)
#define strcat(a, b) bsafe_strcat(a, b)
#ifdef __cplusplus
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -22,16 +22,17 @@
extern "C" {
#endif
extern int buIsUTF8Content (const_bstring bu);
extern int buAppendBlkUcs4 (bstring b, const cpUcs4* bu, int len, cpUcs4 errCh);
extern int buIsUTF8Content(const_bstring bu);
extern int buAppendBlkUcs4(bstring b, const cpUcs4* bu, int len, cpUcs4 errCh);
/* For those unfortunate enough to be stuck supporting UTF16. */
extern int buGetBlkUTF16 (/* @out */ cpUcs2* ucs2, int len, cpUcs4 errCh, const_bstring bu, int pos);
extern int buAppendBlkUTF16 (bstring bu, const cpUcs2* utf16, int len, cpUcs2* bom, cpUcs4 errCh);
extern int buGetBlkUTF16(
/* @out */ cpUcs2* ucs2, int len, cpUcs4 errCh, const_bstring bu, int pos);
extern int buAppendBlkUTF16(
bstring bu, const cpUcs2* utf16, int len, cpUcs2* bom, cpUcs4 errCh);
#ifdef __cplusplus
}
#endif
#endif /* BSTRLIB_UNICODE_UTILITIES */
This diff is collapsed.
......@@ -21,39 +21,45 @@ extern "C" {
#endif
#if INT_MAX >= 0x7fffffffUL
typedef int cpUcs4;
typedef int cpUcs4;
#elif LONG_MAX >= 0x7fffffffUL
typedef long cpUcs4;
typedef long cpUcs4;
#else
#error This compiler is not supported
#endif
#if UINT_MAX == 0xFFFF
typedef unsigned int cpUcs2;
typedef unsigned int cpUcs2;
#elif USHRT_MAX == 0xFFFF
typedef unsigned short cpUcs2;
typedef unsigned short cpUcs2;
#elif UCHAR_MAX == 0xFFFF
typedef unsigned char cpUcs2;
typedef unsigned char cpUcs2;
#else
#error This compiler is not supported
#endif
#define isLegalUnicodeCodePoint(v) ((((v) < 0xD800L) || ((v) > 0xDFFFL)) && (((unsigned long)(v)) <= 0x0010FFFFL) && (((v)|0x1F0001) != 0x1FFFFFL))
#define isLegalUnicodeCodePoint(v) \
((((v) < 0xD800L) || ((v) > 0xDFFFL)) && \
(((unsigned long) (v)) <= 0x0010FFFFL) && (((v) | 0x1F0001) != 0x1FFFFFL))
struct utf8Iterator {
unsigned char* data;
int slen;
int start, next;
int error;
unsigned char* data;
int slen;
int start, next;
int error;
};
#define utf8IteratorNoMore(it) (!(it) || (it)->next >= (it)->slen)
extern void utf8IteratorInit (struct utf8Iterator* iter, unsigned char* data, int slen);
extern void utf8IteratorUninit (struct utf8Iterator* iter);
extern cpUcs4 utf8IteratorGetNextCodePoint (struct utf8Iterator* iter, cpUcs4 errCh);
extern cpUcs4 utf8IteratorGetCurrCodePoint (struct utf8Iterator* iter, cpUcs4 errCh);
extern int utf8ScanBackwardsForCodePoint (unsigned char* msg, int len, int pos, cpUcs4* out);
extern void utf8IteratorInit(
struct utf8Iterator* iter, unsigned char* data, int slen);
extern void utf8IteratorUninit(struct utf8Iterator* iter);
extern cpUcs4 utf8IteratorGetNextCodePoint(
struct utf8Iterator* iter, cpUcs4 errCh);
extern cpUcs4 utf8IteratorGetCurrCodePoint(
struct utf8Iterator* iter, cpUcs4 errCh);
extern int utf8ScanBackwardsForCodePoint(
unsigned char* msg, int len, int pos, cpUcs4* out);
#ifdef __cplusplus
}
......
......@@ -53,7 +53,7 @@ bool mime_parser::parse(const std::string& str) {
str.substr(content_type_pos + 14, crlf_pos - (content_type_pos + 14));
Logger::smf_app().debug("Content Type: %s", p.content_type.c_str());
crlf_pos = str.find(CRLF + CRLF, content_type_pos); // beginning of content
crlf_pos = str.find(CRLF + CRLF, content_type_pos); // beginning of content
boundary_pos = str.find(boundary_full, crlf_pos);
if (boundary_pos == std::string::npos) {
boundary_pos = str.find(last_boundary, crlf_pos);
......
......@@ -44,7 +44,8 @@ int decode_authentication_reject(
case AUTHENTICATION_REJECT_EAP_MESSAGE_IEI:
// if((decoded_result = decode_message_type
// (&authentication_reject->messagetype,
// AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
// AUTHENTICATION_REJECT_EAP_MESSAGE_IEI,
// buffer+decoded,len-decoded))<0)
if ((decoded_result = decode_eap_message(
&authentication_reject->eapmessage,
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer + decoded,
......
......@@ -222,8 +222,8 @@ int encode_pdu_session_establishment_accept(
else
encoded += encoded_result;
// TODO: In Wireshark Version 3.2.2 (Git commit a3efece3d640), SSC Mode (4
// bit) + PDU session type (4 bit) = 1 byte, so disable encode SSC Mode for the
// moment, Should be verified later
// bit) + PDU session type (4 bit) = 1 byte, so disable encode SSC Mode for
// the moment, Should be verified later
/* if((encoded_result = encode_ssc_mode
(pdu_session_establishment_accept->sscmode, 0,
buffer+encoded,len-encoded))<0) return encoded_result; else encoded +=
......
/*
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2017 Sprint
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "async_shell_cmd.hpp"
#include "common_defs.h"
......@@ -33,43 +32,43 @@
#include <thread>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
using namespace smf;
using namespace util;
using namespace std;
using namespace oai::smf_server::api;
itti_mw *itti_inst = nullptr;
async_shell_cmd *async_shell_cmd_inst = nullptr;
smf_app *smf_app_inst = nullptr;
itti_mw* itti_inst = nullptr;
async_shell_cmd* async_shell_cmd_inst = nullptr;
smf_app* smf_app_inst = nullptr;
smf_config smf_cfg;
SMFApiServer *smf_api_server_1 = nullptr;
smf_http2_server *smf_api_server_2 = nullptr;
SMFApiServer* smf_api_server_1 = nullptr;
smf_http2_server* smf_api_server_2 = nullptr;
void send_heartbeat_to_tasks(const uint32_t sequence);
//------------------------------------------------------------------------------
void send_heartbeat_to_tasks(const uint32_t sequence)
{
itti_msg_ping *itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
void send_heartbeat_to_tasks(const uint32_t sequence) {
itti_msg_ping* itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
std::shared_ptr<itti_msg_ping> i = std::shared_ptr<itti_msg_ping>(itti_msg);
int ret = itti_inst->send_broadcast_msg(i);
int ret = itti_inst->send_broadcast_msg(i);
if (RETURNok != ret) {
Logger::smf_app().error( "Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
}
}
//------------------------------------------------------------------------------
void my_app_signal_handler(int s)
{
void my_app_signal_handler(int s) {
std::cout << "Caught signal " << s << std::endl;
Logger::system().startup( "exiting" );
Logger::system().startup("exiting");
itti_inst->send_terminate_msg(TASK_SMF_APP);
itti_inst->wait_tasks_end();
std::cout << "Freeing Allocated memory..." << std::endl;
if (async_shell_cmd_inst) delete async_shell_cmd_inst; async_shell_cmd_inst = nullptr;
if (async_shell_cmd_inst) delete async_shell_cmd_inst;
async_shell_cmd_inst = nullptr;
std::cout << "Async Shell CMD memory done." << std::endl;
if (smf_api_server_1) {
smf_api_server_1->shutdown();
......@@ -82,29 +81,29 @@ void my_app_signal_handler(int s)
smf_api_server_2 = nullptr;
}
std::cout << "SMF API Server memory done." << std::endl;
if (itti_inst) delete itti_inst; itti_inst = nullptr;
if (itti_inst) delete itti_inst;
itti_inst = nullptr;
std::cout << "ITTI memory done." << std::endl;
if (smf_app_inst) delete smf_app_inst; smf_app_inst = nullptr;
if (smf_app_inst) delete smf_app_inst;
smf_app_inst = nullptr;
std::cout << "SMF APP memory done." << std::endl;
std::cout << "Freeing Allocated memory done" << std::endl;
exit(0);
}
//------------------------------------------------------------------------------
int main(int argc, char **argv)
{
srand (time(NULL));
int main(int argc, char** argv) {
srand(time(NULL));
// Command line options
if ( !Options::parse( argc, argv ) )
{
std::cout << "Options::parse() failed" << std::endl;
return 1;
if (!Options::parse(argc, argv)) {
std::cout << "Options::parse() failed" << std::endl;
return 1;
}
// 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;
sigIntHandler.sa_handler = my_app_signal_handler;
......@@ -121,36 +120,40 @@ int main(int argc, char **argv)
itti_inst->start(smf_cfg.itti.itti_timer_sched_params);
// system command
async_shell_cmd_inst = new async_shell_cmd(smf_cfg.itti.async_cmd_sched_params);
async_shell_cmd_inst =
new async_shell_cmd(smf_cfg.itti.async_cmd_sched_params);
// SMF application layer
smf_app_inst = new smf_app(Options::getlibconfigConfig());
// PID file
// Currently hard-coded value. TODO: add as config option.
string pid_file_name = get_exe_absolute_path("/var/run", smf_cfg.instance);
if (! is_pid_file_lock_success(pid_file_name.c_str())) {
Logger::smf_app().error( "Lock PID file %s failed\n", pid_file_name.c_str());
exit (-EDEADLK);
string pid_file_name = get_exe_absolute_path("/var/run", smf_cfg.instance);
if (!is_pid_file_lock_success(pid_file_name.c_str())) {
Logger::smf_app().error("Lock PID file %s failed\n", pid_file_name.c_str());
exit(-EDEADLK);
}
//SMF Pistache API server (HTTP1)
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.sbi.addr4))) , Pistache::Port(smf_cfg.sbi.port));
// SMF Pistache API server (HTTP1)
Pistache::Address addr(
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.sbi.addr4))),
Pistache::Port(smf_cfg.sbi.port));
smf_api_server_1 = new SMFApiServer(addr, smf_app_inst);
smf_api_server_1->init(2);
//smf_api_server_1->start();
// smf_api_server_1->start();
std::thread smf_http1_manager(&SMFApiServer::start, smf_api_server_1);
//SMF NGHTTP API server (HTTP2)
smf_api_server_2 = new smf_http2_server(conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst);
//smf_api_server_2->start();
// SMF NGHTTP API server (HTTP2)
smf_api_server_2 = new smf_http2_server(
conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst);
// smf_api_server_2->start();
std::thread smf_http2_manager(&smf_http2_server::start, smf_api_server_2);
smf_http1_manager.join();
smf_http2_manager.join();
FILE *fp = NULL;
FILE* fp = NULL;
std::string filename = fmt::format("/tmp/smf_{}.status", getpid());
fp = fopen(filename.c_str(), "w+");
fp = fopen(filename.c_str(), "w+");
fprintf(fp, "STARTED\n");
fflush(fp);
fclose(fp);
......
This diff is collapsed.
This diff is collapsed.
......@@ -53,9 +53,9 @@ int smf_app::pco_push_protocol_or_container_id(
pco_item.length_of_protocol_id_contents =
poc_id->length_of_protocol_id_contents;
pco_item.protocol_id_contents = poc_id->protocol_id_contents;
// assert(pco_item.length_of_protocol_id_contents ==
// pco_item.protocol_id_contents.size());
// pco_item.protocol_id_contents = nullptr;
// assert(pco_item.length_of_protocol_id_contents ==
// pco_item.protocol_id_contents.size());
// pco_item.protocol_id_contents = nullptr;
pco.protocol_or_container_ids.push_back(pco_item);
pco.num_protocol_or_container_id += 1;
......
......@@ -331,7 +331,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
smf_qos_flow default_qos_flow = {};
// flow_updated info will be used to construct N1,N2 container
qos_flow_context_updated flow_updated = {};
QOSRulesIE qos_rule = {};
QOSRulesIE qos_rule = {};
flow_updated.set_cause(REQUEST_ACCEPTED);
if (not sps->get_default_qos_flow(default_qos_flow)) {
......
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