Commit 5ecea9bc authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Code cleanup

parent 827a7546
......@@ -12,7 +12,7 @@ UDR =
IPV4_ADDRESS = "read";
PORT = 80; # YOUR NETWORK CONFIG HERE
HTTP2_PORT = 8080; # YOUR NETWORK CONFIG HERE
API_VERSION = "v1"; # YOUR SMF API VERSION CONFIG HERE
API_VERSION = "v1"; # YOUR NUDR API VERSION CONFIG HERE
};
};
......
......@@ -36,78 +36,6 @@
#define RETURNerror (int)1
#define RETURNok (int)0
typedef enum {
/* Fatal errors - received message should not be processed */
TLV_MAC_MISMATCH = -14,
TLV_BUFFER_NULL = -13,
TLV_BUFFER_TOO_SHORT = -12,
TLV_PROTOCOL_NOT_SUPPORTED = -11,
TLV_WRONG_MESSAGE_TYPE = -10,
TLV_OCTET_STRING_TOO_LONG_FOR_IEI = -9,
TLV_VALUE_DOESNT_MATCH = -4,
TLV_MANDATORY_FIELD_NOT_PRESENT = -3,
TLV_UNEXPECTED_IEI = -2,
TLV_ERROR_OK = RETURNok,
/* Defines error code limit below which received message should be discarded
* because it cannot be further processed */
TLV_FATAL_ERROR = TLV_VALUE_DOESNT_MATCH
} error_code_e;
//------------------------------------------------------------------------------
#define DECODE_U8(bUFFER, vALUE, sIZE) \
vALUE = *(uint8_t*)(bUFFER); \
sIZE += sizeof(uint8_t)
#define DECODE_U16(bUFFER, vALUE, sIZE) \
vALUE = ntohs(*(uint16_t*)(bUFFER)); \
sIZE += sizeof(uint16_t)
#define DECODE_U24(bUFFER, vALUE, sIZE) \
vALUE = ntohl(*(uint32_t*)(bUFFER)) >> 8; \
sIZE += sizeof(uint8_t) + sizeof(uint16_t)
#define DECODE_U32(bUFFER, vALUE, sIZE) \
vALUE = ntohl(*(uint32_t*)(bUFFER)); \
sIZE += sizeof(uint32_t)
#if (BYTE_ORDER == LITTLE_ENDIAN)
#define DECODE_LENGTH_U16(bUFFER, vALUE, sIZE) \
vALUE = ((*(bUFFER)) << 8) | (*((bUFFER) + 1)); \
sIZE += sizeof(uint16_t)
#else
#define DECODE_LENGTH_U16(bUFFER, vALUE, sIZE) \
vALUE = (*(bUFFER)) | (*((bUFFER) + 1) << 8); \
sIZE += sizeof(uint16_t)
#endif
#define ENCODE_U8(buffer, value, size) \
*(uint8_t*)(buffer) = value; \
size += sizeof(uint8_t)
#define ENCODE_U16(buffer, value, size) \
*(uint16_t*)(buffer) = htons(value); \
size += sizeof(uint16_t)
#define ENCODE_U24(buffer, value, size) \
*(uint32_t*)(buffer) = htonl(value); \
size += sizeof(uint8_t) + sizeof(uint16_t)
#define ENCODE_U32(buffer, value, size) \
*(uint32_t*)(buffer) = htonl(value); \
size += sizeof(uint32_t)
#define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR, NwBo, MeSsAgE) \
do { \
struct in_addr inp; \
if (inet_aton(AdDr_StR, &inp) < 0) { \
AssertFatal(0, MeSsAgE); \
} else { \
NwBo = inp.s_addr; \
} \
} while (0)
#define NIPADDR(addr) \
(uint8_t)(addr & 0x000000FF), (uint8_t)((addr & 0x0000FF00) >> 8), \
(uint8_t)((addr & 0x00FF0000) >> 16), \
......
......@@ -39,6 +39,7 @@ namespace config {
udr_config::udr_config() {}
udr_config::~udr_config() {}
//------------------------------------------------------------------------------
int udr_config::load(const std ::string &config_file) {
Logger::udr_app().debug("\nLoad UDR system configuration file(%s)",
config_file.c_str());
......@@ -117,6 +118,7 @@ int udr_config::load(const std ::string &config_file) {
return RETURNok;
}
//------------------------------------------------------------------------------
int udr_config::load_interface(const libconfig::Setting &if_cfg,
interface_cfg_t &cfg) {
if_cfg.lookupValue(UDR_CONFIG_STRING_INTERFACE_NAME, cfg.if_name);
......@@ -162,6 +164,7 @@ int udr_config::load_interface(const libconfig::Setting &if_cfg,
return RETURNok;
}
//------------------------------------------------------------------------------
void udr_config::display() {
Logger::config().info(
"====================== UDR =====================");
......@@ -176,10 +179,9 @@ void udr_config::display() {
Logger::config().info(" Interface name ......: %s", nudr.if_name.c_str());
Logger::config().info(" IPv4 Addr ...........: %s", inet_ntoa(nudr.addr4));
Logger::config().info(" Port ................: %d", nudr.port);
// Logger::config().info(" HTTP2 port ..........: %d", nudr_http2_port);
/* Logger::config().info(
" API version..........: %s", sbi_api_version.c_str());
*/
Logger::config().info(" HTTP2 port ..........: %d", nudr_http2_port);
Logger::config().info(" API version..........: %s",
nudr_api_version.c_str());
Logger::config().info(
"- MYSQL Server Addr...................................: %s",
......
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