OCT 1. 增加 OpenDHCPD 配置项编译宏开关

This commit is contained in:
huangxin 2022-11-30 17:57:52 +08:00
parent 2447a88a70
commit 167000ba47
4 changed files with 11 additions and 4 deletions

View File

@ -73,8 +73,8 @@ static CFG_ITEM g_cfgItem[] = {
DEF_CFG_ITEM(CFG_MEM_REFRESH, "watch_params.mem_refresh", VAL_INT, "10", "Memory information refresh frequency"), DEF_CFG_ITEM(CFG_MEM_REFRESH, "watch_params.mem_refresh", VAL_INT, "10", "Memory information refresh frequency"),
DEF_CFG_ITEM(CFG_DISK_REFRESH, "watch_params.disk_refresh", VAL_INT, "10", "Disk information refresh frequency"), DEF_CFG_ITEM(CFG_DISK_REFRESH, "watch_params.disk_refresh", VAL_INT, "10", "Disk information refresh frequency"),
DEF_CFG_ITEM(CFG_SENSOR_REFRESH, "watch_params.sensor_refresh", VAL_INT, "10", "Sensor information refresh frequency"), DEF_CFG_ITEM(CFG_SENSOR_REFRESH, "watch_params.sensor_refresh", VAL_INT, "10", "Sensor information refresh frequency"),
/* 数据库相配置 */ /* 数据库相配置 */
/* Redis配置 */ /* Redis配置 */
#ifdef USED_REDIS #ifdef USED_REDIS
DEF_CFG_ITEM(CFG_DB_REDIS_SERVER, "database.redis_server", VAL_STR, "127.0.0.1", "Redis database server ip address"), DEF_CFG_ITEM(CFG_DB_REDIS_SERVER, "database.redis_server", VAL_STR, "127.0.0.1", "Redis database server ip address"),
DEF_CFG_ITEM(CFG_DB_REDIS_PORT, "database.redis_port", VAL_INT, "6379", "Redis database server port"), DEF_CFG_ITEM(CFG_DB_REDIS_PORT, "database.redis_port", VAL_INT, "6379", "Redis database server port"),
@ -88,7 +88,7 @@ static CFG_ITEM g_cfgItem[] = {
DEF_CFG_ITEM(CFG_DB_MYSQL_PASSWD, "database.mysql_passwd", VAL_STR, "", "MySQL database server password"), DEF_CFG_ITEM(CFG_DB_MYSQL_PASSWD, "database.mysql_passwd", VAL_STR, "", "MySQL database server password"),
DEF_CFG_ITEM(CFG_DB_MYSQL_DB_NAME, "database.mysql_database", VAL_STR, ".main", "MySQL database used"), DEF_CFG_ITEM(CFG_DB_MYSQL_DB_NAME, "database.mysql_database", VAL_STR, ".main", "MySQL database used"),
#endif #endif
/* SQLite3配置 */ /* SQLite3配置 */
#ifdef USED_SQLITE #ifdef USED_SQLITE
DEF_CFG_ITEM(CFG_DB_SQLITE_DB_NAME, "database.sqlite_dbname", VAL_STR, "", "SQLite3 database file name"), DEF_CFG_ITEM(CFG_DB_SQLITE_DB_NAME, "database.sqlite_dbname", VAL_STR, "", "SQLite3 database file name"),
DEF_CFG_ITEM(CFG_DB_SQLITE_PASSWD, "database.sqlite_passwd", VAL_STR, ".main", "SQLite3 database password"), DEF_CFG_ITEM(CFG_DB_SQLITE_PASSWD, "database.sqlite_passwd", VAL_STR, ".main", "SQLite3 database password"),
@ -107,9 +107,12 @@ static CFG_ITEM g_cfgItem[] = {
DEF_CFG_ITEM(CFG_HTTP_SVR_ADDR, "http_svr.listen_addr", VAL_STR, "0.0.0.0", "Network address to listen on"), DEF_CFG_ITEM(CFG_HTTP_SVR_ADDR, "http_svr.listen_addr", VAL_STR, "0.0.0.0", "Network address to listen on"),
DEF_CFG_ITEM(CFG_HTTP_SVR_PORT, "http_svr.listen_port", VAL_INT, "6789", "Network port to listen on"), DEF_CFG_ITEM(CFG_HTTP_SVR_PORT, "http_svr.listen_port", VAL_INT, "6789", "Network port to listen on"),
DEF_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "http_svr.tcp_nodelay", VAL_BOOL, "1", "TCP delay switch"), DEF_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "http_svr.tcp_nodelay", VAL_BOOL, "1", "TCP delay switch"),
#ifdef OPENDHCPD_ON
// 配置DHCP服务器
DEF_CFG_ITEM(CFG_DHCP_LISTEN_ON, "dhcp_server.listen_on", VAL_ARRAY_STR, "", "DHCP listen interface"), DEF_CFG_ITEM(CFG_DHCP_LISTEN_ON, "dhcp_server.listen_on", VAL_ARRAY_STR, "", "DHCP listen interface"),
DEF_CFG_ITEM(CFG_DHCP_REPLICATION_SVR, "dhcp_server.replication", VAL_ARRAY_STR, "", "DHCP replication server configure"), DEF_CFG_ITEM(CFG_DHCP_REPLICATION_SVR, "dhcp_server.replication", VAL_ARRAY_STR, "", "DHCP replication server configure"),
DEF_CFG_ITEM(CFG_DHCP_RANGE_SET, "dhcp_server.range_set", VAL_ARRAY_OBJ, "", "DHCP IP pool"), DEF_CFG_ITEM(CFG_DHCP_RANGE_SET, "dhcp_server.range_set", VAL_ARRAY_OBJ, "", "DHCP IP pool"),
#endif
}; };
static int cfg_is_upgrade(PCONFIG_ITEM pItem) { static int cfg_is_upgrade(PCONFIG_ITEM pItem) {

View File

@ -3,6 +3,7 @@
// //
#include "config.h" #include "config.h"
#ifdef OPENDHCPD_ON
const vector config_get_dhcp_server_range_set() { const vector config_get_dhcp_server_range_set() {
return cfg_get_vector(CFG_DHCP_RANGE_SET); return cfg_get_vector(CFG_DHCP_RANGE_SET);
} }
@ -14,6 +15,7 @@ const vector config_get_dhcp_listen_on() {
const vector config_get_dhcp_replication_svr() { const vector config_get_dhcp_replication_svr() {
return cfg_get_vector(CFG_DHCP_REPLICATION_SVR); return cfg_get_vector(CFG_DHCP_REPLICATION_SVR);
} }
#endif
const char* config_get_http_server_addr() { const char* config_get_http_server_addr() {
return cfg_get_string_value(CFG_HTTP_SVR_ADDR); return cfg_get_string_value(CFG_HTTP_SVR_ADDR);

View File

@ -129,9 +129,11 @@ const char *config_get_vxlan_pkg_filter();
const char *config_get_http_server_addr(); const char *config_get_http_server_addr();
unsigned int config_get_http_server_port(); unsigned int config_get_http_server_port();
int config_get_http_server_tcp_nodelay(); int config_get_http_server_tcp_nodelay();
#ifdef OPENDHCPD_ON
const vector config_get_dhcp_server_range_set(); const vector config_get_dhcp_server_range_set();
const vector config_get_dhcp_listen_on(); const vector config_get_dhcp_listen_on();
const vector config_get_dhcp_replication_svr(); const vector config_get_dhcp_replication_svr();
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES(../libs/include ./ ../httpserver/include)
FILE(GLOB DHCPD_HEADS ./*.h) FILE(GLOB DHCPD_HEADS ./*.h)
ADD_DEFINITIONS(-Wno-format-overflow -std=c++11) ADD_DEFINITIONS(-Wno-format-overflow -std=c++11 ${COMMON_DEFINE})
#ADD_EXECUTABLE(${PROJECT_TARGET} opendhcpd.cpp ${DHCPD_HEADS}) #ADD_EXECUTABLE(${PROJECT_TARGET} opendhcpd.cpp ${DHCPD_HEADS})
ADD_LIBRARY(${DHCPD_PROJECT_TARGET} opendhcpd.cpp ${DHCPD_HEADS} query.cpp) ADD_LIBRARY(${DHCPD_PROJECT_TARGET} opendhcpd.cpp ${DHCPD_HEADS} query.cpp)