plugin_config.hpp 1.74 KB
#ifndef _PLUGIN_CONFIG_H_
#define _PLUGIN_CONFIG_H_

#include <libconfig.h++>
#include <string>
#include <vector>

#define PLUGIN_CONFIG_STRING_PLUGIN_CONFIG "PLUGIN"

#define PLUGIN_CONFIG_STRING_INTERFACES "INTERFACES"
#define PLUGIN_CONFIG_STRING_INTERFACE_NGAP "NGAP"
#define PLUGIN_CONFIG_STRING_INTERFACE_SBI "SBI"
#define PLUGIN_CONFIG_STRING_INTERFACE_NRF "NRF"
#define PLUGIN_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#define PLUGIN_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define PLUGIN_CONFIG_STRING_PORT "PORT"

#define PLUGIN_CONFIG_STRING_AMF_INSTANCES_POOL "AMF_INSTANCES_POOL"
#define PLUGIN_CONFIG_STRING_AMF_INSTANCES_ID "AMF_INSTANCES_ID"
#define PLUGIN_CONFIG_STRING_AMF_INSTANCES_IPV4_ADDRESS "IPV4_ADDRESS"
#define PLUGIN_CONFIG_STRING_AMF_INSTANCES_PORT "PORT"
#define PLUGIN_CONFIG_STRING_AMF_INSTANCES_WEIGHT "WEIGHT"
#define PLUGIN_CONFIG_STRING_AMF_INSTANCES_SELECTED "SELECTED"

using namespace libconfig;
namespace config {

typedef struct {
  int id;
  std::string ipv4;
  unsigned int port;
  unsigned int weight;
  bool selected;
} amf_inst_t;


typedef struct interface_cfg_s {
  std::string if_name;
  std::string addr4;
  unsigned int port;
} interface_cfg_t;

class plugin_config {
public:
  plugin_config();
  ~plugin_config();

   int load(const std::string &config_file);
   int getip(std::string &ip, std::string &ifname);
   int load_interface(const Setting &if_cfg, interface_cfg_t &cfg);
   void display();

   unsigned int instance;
   std::string pid_dir;
   interface_cfg_t n2;
   interface_cfg_t sbi;
   interface_cfg_t nrf;
   bool is_wrr;
   bool is_rr;
   bool is_omf;
   int  rrRate;

   std::string timestamp_file;

   std::vector<amf_inst_t> amf_pool;
   std::vector<amf_inst_t> amf_pool_src;
};
} // namespace config

#endif