Commit 33e03007 authored by Niuhaiwen's avatar Niuhaiwen

fix some bug

parent 7221ebf8
/**
* NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "PatchItem.h"
namespace oai {
namespace udr {
namespace model {
PatchItem::PatchItem() {
m_Path = "";
m_From = "";
m_FromIsSet = false;
m_ValueIsSet = false;
}
PatchItem::~PatchItem() {}
void PatchItem::validate() {
// TODO: implement validation
}
void to_json(nlohmann::json& j, const PatchItem& o) {
j = nlohmann::json();
j["op"] = o.m_Op;
j["path"] = o.m_Path;
if (o.fromIsSet()) j["from"] = o.m_From;
if (o.valueIsSet()) j["value"] = o.m_Value;
}
void from_json(const nlohmann::json& j, PatchItem& o) {
j.at("op").get_to(o.m_Op);
j.at("path").get_to(o.m_Path);
if (j.find("from") != j.end()) {
j.at("from").get_to(o.m_From);
o.m_FromIsSet = true;
}
if (j.find("value") != j.end()) {
j.at("value").get_to(o.m_Value);
o.m_ValueIsSet = true;
}
}
std::string PatchItem::getOp() const {
return m_Op;
}
void PatchItem::setOp(std::string const& value) {
m_Op = value;
}
std::string PatchItem::getPath() const {
return m_Path;
}
void PatchItem::setPath(std::string const& value) {
m_Path = value;
}
std::string PatchItem::getFrom() const {
return m_From;
}
void PatchItem::setFrom(std::string const& value) {
m_From = value;
m_FromIsSet = true;
}
bool PatchItem::fromIsSet() const {
return m_FromIsSet;
}
void PatchItem::unsetFrom() {
m_FromIsSet = false;
}
std::string PatchItem::getValue() const {
return m_Value;
}
void PatchItem::setValue(std::string const& value) {
m_Value = value;
m_ValueIsSet = true;
}
bool PatchItem::valueIsSet() const {
return m_ValueIsSet;
}
void PatchItem::unsetValue() {
m_ValueIsSet = false;
}
} // namespace model
} // namespace smf_server
} // namespace oai
/**
* NRF NFManagement Service
* NRF NFManagement Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* PatchItem.h
*
*
*/
#ifndef PatchItem_H_
#define PatchItem_H_
#include <string>
#include <nlohmann/json.hpp>
namespace oai {
namespace udr {
namespace model {
/// <summary>
///
/// </summary>
class PatchItem {
public:
PatchItem();
virtual ~PatchItem();
void validate();
/////////////////////////////////////////////
/// PatchItem members
/// <summary>
///
/// </summary>
std::string getOp() const;
void setOp(std::string const& value);
/// <summary>
///
/// </summary>
std::string getPath() const;
void setPath(std::string const& value);
/// <summary>
///
/// </summary>
std::string getFrom() const;
void setFrom(std::string const& value);
bool fromIsSet() const;
void unsetFrom();
/// <summary>
///
/// </summary>
std::string getValue() const;
void setValue(std::string const& value);
bool valueIsSet() const;
void unsetValue();
friend void to_json(nlohmann::json& j, const PatchItem& o);
friend void from_json(const nlohmann::json& j, PatchItem& o);
protected:
std::string m_Op;
std::string m_Path;
std::string m_From;
bool m_FromIsSet;
std::string m_Value;
bool m_ValueIsSet;
};
} // namespace model
} // namespace smf_server
} // namespace oai
#endif /* PatchItem_H_ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* 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
*
* http://www.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file common_defs.h
\brief
\author Sebastien ROUX, Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_COMMON_DEFS_SEEN
#define FILE_COMMON_DEFS_SEEN
#include <arpa/inet.h>
#include <stdint.h>
#define RETURNclear (int)2
#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,
// RETURNerror = -1,
// RETURNok = 0,
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), \
(uint8_t)((addr & 0xFF000000) >> 24)
#define HIPADDR(addr) \
(uint8_t)((addr & 0xFF000000) >> 24),\
(uint8_t)((addr & 0x00FF0000) >> 16),\
(uint8_t)((addr & 0x0000FF00) >> 8), \
(uint8_t)(addr & 0x000000FF)
#define NIP6ADDR(addr) \
ntohs((addr)->s6_addr16[0]), \
ntohs((addr)->s6_addr16[1]), \
ntohs((addr)->s6_addr16[2]), \
ntohs((addr)->s6_addr16[3]), \
ntohs((addr)->s6_addr16[4]), \
ntohs((addr)->s6_addr16[5]), \
ntohs((addr)->s6_addr16[6]), \
ntohs((addr)->s6_addr16[7])
#define IN6_ARE_ADDR_MASKED_EQUAL(a,b,m) \
(((((__const uint32_t *) (a))[0] & (((__const uint32_t *) (m))[0])) == (((__const uint32_t *) (b))[0] & (((__const uint32_t *) (m))[0]))) \
&& ((((__const uint32_t *) (a))[1] & (((__const uint32_t *) (m))[1])) == (((__const uint32_t *) (b))[1] & (((__const uint32_t *) (m))[1]))) \
&& ((((__const uint32_t *) (a))[2] & (((__const uint32_t *) (m))[2])) == (((__const uint32_t *) (b))[2] & (((__const uint32_t *) (m))[2]))) \
&& ((((__const uint32_t *) (a))[3] & (((__const uint32_t *) (m))[3])) == (((__const uint32_t *) (b))[3] & (((__const uint32_t *) (m))[3]))))
////////////
#define IPV4_STR_ADDR_TO_INADDR(AdDr_StR,InAdDr,MeSsAgE ) do {\
if ( inet_aton(AdDr_StR, &InAdDr ) <= 0 ) {\
throw (MeSsAgE);\
}\
} while (0)
#ifndef UNUSED
#define UNUSED(x) (void)(x)
#endif
#endif /* FILE_COMMON_DEFS_SEEN */
...@@ -54,7 +54,7 @@ class itti_sbi_update_nf_instance_request : public itti_sbi_msg { ...@@ -54,7 +54,7 @@ class itti_sbi_update_nf_instance_request : public itti_sbi_msg {
http_version(1) {} http_version(1) {}
const char* get_msg_name() { return "SBI_UPDATE_NF_INSTANCE_REQUEST"; }; const char* get_msg_name() { return "SBI_UPDATE_NF_INSTANCE_REQUEST"; };
std::vector<oai::udr::model::PatchItem> patch_items; std::vector<org::openapitools::server::model::PatchItem> patch_items;
uint8_t http_version; uint8_t http_version;
std::string udr_instance_id; std::string udr_instance_id;
}; };
......
...@@ -13,9 +13,13 @@ include(ExternalProject) ...@@ -13,9 +13,13 @@ include(ExternalProject)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_OPENXGUDR_DIR}/build/ext) set(EXTERNAL_INSTALL_LOCATION ${CMAKE_OPENXGUDR_DIR}/build/ext)
set(SRC_DIR ${CMAKE_OPENXGUDR_DIR}/src) set(SRC_DIR ${CMAKE_OPENXGUDR_DIR}/src)
link_directories(${EXTERNAL_INSTALL_LOCATION}/pistache/lib)
include_directories(${EXTERNAL_INSTALL_LOCATION}/pistache/include)
include_directories(${EXTERNAL_INSTALL_LOCATION}/pistache/include/pistache)
include_directories(${EXTERNAL_INSTALL_LOCATION}/include) include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib) link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
include_directories(${EXTERNAL_INSTALL_LOCATION}/json/include)
include_directories(${SRC_DIR}/model) include_directories(${SRC_DIR}/model)
include_directories(${SRC_DIR}/api) include_directories(${SRC_DIR}/api)
...@@ -24,15 +28,19 @@ include_directories(${SRC_DIR}/common) ...@@ -24,15 +28,19 @@ include_directories(${SRC_DIR}/common)
include_directories(${SRC_DIR}/udr_app) include_directories(${SRC_DIR}/udr_app)
include_directories(${SRC_DIR}/itti) include_directories(${SRC_DIR}/itti)
# ${CMAKE_CURRENT_SOURCE_DIR} # ${CMAKE_CURRENT_SOURCE_DIR}
file(GLOB SRCS file(GLOB SRCS
${SRC_DIR}/udr_app/*.cpp
${SRC_DIR}/itti/*.cpp
${SRC_DIR}/api/*.cpp ${SRC_DIR}/api/*.cpp
${SRC_DIR}/impl/*.cpp ${SRC_DIR}/impl/*.cpp
${SRC_DIR}/model/*.cpp ${SRC_DIR}/model/*.cpp
${SRC_DIR}/common/*.cpp ${SRC_DIR}/common/*.cpp
${SRC_DIR}/udr_app/*.cpp #${SRC_DIR}/udr_app/*.cpp
${SRC_DIR}/itti/*.cpp #${SRC_DIR}/itti/*.cpp
) )
add_executable(${PROJECT_NAME} ${SRCS} ) add_executable(${PROJECT_NAME} ${SRCS} )
target_link_libraries(${PROJECT_NAME} pistache pthread mysqlclient config++) target_link_libraries(${PROJECT_NAME} pistache pthread mysqlclient config++ curl ${NETTLE_LIBRARIES})
...@@ -25,6 +25,7 @@ using namespace Pistache::Http::Mime; ...@@ -25,6 +25,7 @@ using namespace Pistache::Http::Mime;
using namespace udr_application; using namespace udr_application;
using namespace config; using namespace config;
using namespace std; using namespace std;
extern itti_mw *itti_inst; extern itti_mw *itti_inst;
extern udr_config udr_cfg; extern udr_config udr_cfg;
extern udr_app *udr_app_inst; extern udr_app *udr_app_inst;
...@@ -117,7 +118,10 @@ void udr_app::generate_udr_profile(){ ...@@ -117,7 +118,10 @@ void udr_app::generate_udr_profile(){
nf_instance_profile.set_nf_heartBeat_timer(10); nf_instance_profile.set_nf_heartBeat_timer(10);
nf_instance_profile.set_nf_priority(1); nf_instance_profile.set_nf_priority(1);
nf_instance_profile.set_nf_capacity(100); nf_instance_profile.set_nf_capacity(100);
nf_instance_profile.add_nf_ipv4_addresses(udr_cfg.sbi.addr4); struct in_addr IP;
const char *ipv4 = udr_cfg.sbi.addr4.c_str();
inet_aton(ipv4, &IP);
nf_instance_profile.add_nf_ipv4_addresses(IP);
nf_service_t nf_service = {}; nf_service_t nf_service = {};
nf_service.service_instance_id = "nudr_communication"; nf_service.service_instance_id = "nudr_communication";
...@@ -130,7 +134,7 @@ void udr_app::generate_udr_profile(){ ...@@ -130,7 +134,7 @@ void udr_app::generate_udr_profile(){
nf_service.nf_service_status = "REGISTERED"; nf_service.nf_service_status = "REGISTERED";
ip_endpoint_t endpoint = {}; ip_endpoint_t endpoint = {};
endpoint.ipv4_address = udr_cfg.sbi.addr4; endpoint.ipv4_address = IP;
endpoint.transport = "TCP"; endpoint.transport = "TCP";
endpoint.port = udr_cfg.sbi.port; endpoint.port = udr_cfg.sbi.port;
nf_service.ip_endpoints.push_back(endpoint); nf_service.ip_endpoints.push_back(endpoint);
...@@ -154,7 +158,7 @@ void udr_app::timer_nrf_heartbeat_timeout(timer_id_t timer_id, uint64_t arg2_use ...@@ -154,7 +158,7 @@ void udr_app::timer_nrf_heartbeat_timeout(timer_id_t timer_id, uint64_t arg2_use
std::make_shared<itti_sbi_update_nf_instance_request>( std::make_shared<itti_sbi_update_nf_instance_request>(
TASK_UDR_APP, TASK_UDR_APP); TASK_UDR_APP, TASK_UDR_APP);
oai::udr::model::PatchItem patch_item = {}; org::openapitools::server::model::PatchItem patch_item = {};
patch_item.setOp("replace"); patch_item.setOp("replace");
patch_item.setPath("/nfStatus"); patch_item.setPath("/nfStatus");
patch_item.setValue("REGISTERED"); patch_item.setValue("REGISTERED");
......
...@@ -9,22 +9,22 @@ ...@@ -9,22 +9,22 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <iostream> #include <iostream>
#include <libconfig.h++> #include <libconfig.h++>
#include <stdio.h>
#include <errno.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <iostream> #include <iostream>
#include <libconfig.h++> #include <libconfig.h++>
#include "string.hpp"
#include "logger.hpp"
extern "C" {
#include "common_defs.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
} #include <string>
#include "string.hpp"
#include "logger.hpp"
#include "common_defs.h"
using namespace libconfig; using namespace libconfig;
namespace config { namespace config {
...@@ -87,7 +87,7 @@ int udr_config::load(const std ::string &config_file) { ...@@ -87,7 +87,7 @@ int udr_config::load(const std ::string &config_file) {
const Setting &nnrf_cfg = new_if_cfg[UDR_CONFIG_STRING_INTERFACE_NNRF]; const Setting &nnrf_cfg = new_if_cfg[UDR_CONFIG_STRING_INTERFACE_NNRF];
load_nrf_interface(nnrf_cfg, nnrf); load_nrf_interface(nnrf_cfg, nnrf);
nnrf_cfg.lookupValue(UDR_CONFIG_STRING_API_VERSION, nnrf.API_version); nnrf_cfg.lookupValue(UDR_CONFIG_STRING_API_VERSION, nnrf.api_version);
} catch (const SettingNotFoundException &nfex) { } catch (const SettingNotFoundException &nfex) {
Logger::udr_app().error("%s : %s", nfex.what(), Logger::udr_app().error("%s : %s", nfex.what(),
nfex.getPath()); nfex.getPath());
...@@ -267,9 +267,9 @@ void udr_config::display() { ...@@ -267,9 +267,9 @@ void udr_config::display() {
Logger::config().info(""); Logger::config().info("");
Logger::config().info("- NNRF Networking:"); Logger::config().info("- NNRF Networking:");
Logger::config().info(" iface ................: %s", nnrf.if_name.c_str()); Logger::config().info(" iface ................: %s", nnrf.if_name.c_str());
Logger::config().info(" ip ...................: %s", nnrf.addr4.c_str()); Logger::config().info(" ip ...................: %s", inet_ntoa(nnrf.addr4));
Logger::config().info(" port .................: %d", nnrf.port); Logger::config().info(" port .................: %d", nnrf.port);
Logger::config().info(" Api_version ..........: %s", nnrf.API_version.c_str()); Logger::config().info(" Api_version ..........: %s", nnrf.api_version.c_str());
Logger::config().info("- Database Configuration:"); Logger::config().info("- Database Configuration:");
Logger::config().info( Logger::config().info(
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define UDR_CONFIG_STRING_PORT "PORT" #define UDR_CONFIG_STRING_PORT "PORT"
#define UDR_CONFIG_STRING_API_VERSION "API_VERSION" #define UDR_CONFIG_STRING_API_VERSION "API_VERSION"
#define UDR_CONFIG_STRING_NF_REGISTRATION "NF_REGISTRATION" #define UDR_CONFIG_STRING_NF_REGISTRATION "NF_REGISTRATION"
#define UDR_CONFIG_STRING_NNRF "NNRF" #define UDR_CONFIG_STRING_INTERFACE_NNRF "NNRF"
#define UDR_CONFIG_STRING_MYSQL "MYSQL" #define UDR_CONFIG_STRING_MYSQL "MYSQL"
......
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