vcpe/srcs/libs/include/config.h

155 lines
3.9 KiB
C

//
// Created by xajhu on 2021/7/1 0001.
//
#include <zvector/zvector.h>
#ifndef DAEMON_AGENT_INCLUDE_CONFIG_H
#define DAEMON_AGENT_INCLUDE_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#define DEFAULT_INTEGRAL_ERR_VALUE (0x0AFFFFAA)
typedef struct {
char rangAddr[256];
char subnet[20];
char dnsSvr[256];
char gateway[20];
unsigned int lease;
} OBJ_DHCP_RNG, *POBJ_DHCP_RNG;
typedef enum {
VAL_INT = 0,
VAL_FLOAT = 1,
VAL_STR = 2,
VAL_BOOL = 3,
VAL_ARRAY_STR = 4,
VAL_ARRAY_OBJ = 5,
} CONFIG_VALUE_TYPE;
typedef enum {
CFG_DIRECTORY,
CFG_CURL_CA_PATH,
CFG_BANNER_SHOW,
CFG_HARDWARE_WATCH,
CFG_HARDWARE_REFRESH,
CFG_AGENT_IPTV_POST_URL,
CFG_AGENT_MONITER_URL,
CFG_WATCH_CPU,
CFG_WATCH_MEMORY,
CFG_WATCH_DISK,
CFG_WATCH_SENSOR,
#ifdef USED_REDIS
CFG_DB_REDIS_SERVER,
CFG_DB_REDIS_PORT,
CFG_DB_REDIS_PASSWD,
#endif
#ifdef USED_MYSQL
CFG_DB_MYSQL_SERVER,
CFG_DB_MYSQL_PORT,
CFG_DB_MYSQL_USER,
CFG_DB_MYSQL_PASSWD,
CFG_DB_MYSQL_DB_NAME,
#endif
#ifdef USED_SQLITE
CFG_DB_SQLITE_DB_NAME,
CFG_DB_SQLITE_PASSWD,
#endif
#ifdef ZEROMQ_ON
CFG_MQ_SVR_PORT,
CFG_MQ_DATA_PATH,
#endif
CFG_VXLAN_NIC_NAME,
CFG_VXLAN_SUPPORT,
CFG_VXLAN_PEER_IP,
CFG_VXLAN_PEER_MAC,
CFG_VXLAN_PKG_FILTER,
#ifdef HTTPSERVER_ON
CFG_HTTP_SVR_URI,
#endif
CFG_PROTO_CRYPTO,
CFG_PROTO_CRYPTO_KEY,
#ifdef OPENDHCPD_ON
CFG_DHCP_LEASE_TIME,
CFG_DHCP_LISTEN_ON,
CFG_DHCP_REPLICATION_SVR,
CFG_DHCP_RANGE_SET,
CFG_DHCP_MAC_FILTER,
#endif
CONFIG_ITEM_ID_MAX
} CONFIG_ITEM_ID;
const char *config_get_ssl_ca_path();
const char *cfg_get_config_directory();
int cfg_get_banner_enable();
int cfg_get_hardware_watch_enable();
unsigned int cfg_get_hardware_refresh_period();
int cfg_get_watch_cpu();
int cfg_get_watch_memory();
int cfg_get_watch_disk();
int cfg_get_watch_sensor();
#ifdef USED_REDIS
const char *cfg_get_redis_server();
int cfg_get_redis_port();
const char *cfg_get_redis_passwd();
#endif
#ifdef USED_MYSQL
const char *cfg_get_mysql_server();
int cfg_get_mysql_port();
const char *cfg_get_mysql_user();
const char *cfg_get_mysql_passwd();
const char *cfg_get_mysql_database();
#endif
#ifdef USED_SQLITE
const char *cfg_get_sqlite_db_name();
const char *cfg_get_sqlite_passwd();
#endif
#ifdef ZEROMQ_ON
int cfg_get_zero_mq_port();
const char *cfg_get_zero_mq_data_path();
#endif
const char *cfg_get_string_value(CONFIG_ITEM_ID id);
c_vector cfg_get_vector(CONFIG_ITEM_ID id);
long double cfg_get_float_value(CONFIG_ITEM_ID id);
int cfg_get_bool_value(CONFIG_ITEM_ID id);
long long cfg_get_integral_value(CONFIG_ITEM_ID id);
int init_config_system(const char *pCfgFile, const char *pKey);
void uninit_config_system();
void config_item_dump(const char *titleMessage);
const char *config_item_dump_fmt(const char *titleMessage);
const char *get_config_key(const char *pKeygen);
const char *get_config_keygen();
int cfg_get_support_vxlan();
#ifdef LWIP_ON
const char *config_get_vxlan_nic_name();
const char *config_get_vxlan_peer_mac();
const char *config_get_vxlan_peer_ip();
const char *config_get_vxlan_pkg_filter();
#endif
const char *config_get_agent_iptv_report_url();
const char *config_get_agent_moniter_report_url();
#ifdef HTTPSERVER_ON
const char *config_get_http_server_addr();
#endif
unsigned int config_get_proto_crypto_type();
const char *config_get_proto_crypto_key();
#ifdef USERVNI_ON
void cfg_set_user_vni_id(int vni);
int cfg_get_user_vni_id();
#endif
#ifdef OPENDHCPD_ON
unsigned int config_get_dhcp_server_lease_time();
c_vector config_get_dhcp_server_range_set();
c_vector config_get_dhcp_listen_on();
c_vector config_get_dhcp_replication_svr();
c_vector config_get_dhcp_mac_filter();
#endif
#ifdef __cplusplus
}
#endif
#endif //DAEMON_AGENT_INCLUDE_CONFIG_H