OCT 1. 增加内置HTTP Service配置以及编译开关
This commit is contained in:
parent
14daf5f945
commit
b7b886bd4a
|
@ -1,5 +1,7 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
INCLUDE(CMakeDependentOption)
|
||||
|
||||
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/depend)
|
||||
IF (BUILD_TESTING)
|
||||
INCLUDE(doctest_framework)
|
||||
|
@ -15,6 +17,7 @@ OPTION(USED_OPENDHCPD "DHCP server for vCPE" OFF)
|
|||
OPTION(USED_OPENDHCPDDNS "DHCP And DNS server for vCPE" OFF)
|
||||
OPTION(USED_USER_VNI "Support pass user vni id from console command line" OFF)
|
||||
OPTION(BUILD_TESTING "Enable tests" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(USED_HTTP_SVR "Build-in http(s) server support" ON "USED_OPENDHCPD OR USED_OPENDHCPDDNS" OFF)
|
||||
|
||||
# 数据库开关
|
||||
OPTION(USED_REDIS "Add redis database support for vCPE" OFF)
|
||||
|
@ -84,6 +87,11 @@ IF (USED_USER_VNI)
|
|||
MESSAGE("Select Option USED_USER_VNI")
|
||||
ENDIF ()
|
||||
|
||||
IF (USED_HTTP_SVR)
|
||||
LIST(APPEND COMMON_DEFINE "-DHTTPSERVER_ON")
|
||||
MESSAGE("Select Option USED_HTTP_SVR")
|
||||
ENDIF ()
|
||||
|
||||
IF (USED_LWIP)
|
||||
LIST(APPEND COMMON_DEFINE "-DLWIP_ON")
|
||||
MESSAGE("Select Option USED_LWIP")
|
||||
|
@ -113,9 +121,12 @@ IF (USED_LWIP OR VCPE_AGENT)
|
|||
ADD_SUBDIRECTORY(srcs/lwip)
|
||||
ENDIF ()
|
||||
|
||||
IF (USED_HTTP_SVR)
|
||||
ADD_SUBDIRECTORY(srcs/httpserver)
|
||||
ENDIF ()
|
||||
|
||||
ADD_SUBDIRECTORY(srcs)
|
||||
ADD_SUBDIRECTORY(srcs/libs)
|
||||
ADD_SUBDIRECTORY(srcs/httpserver)
|
||||
|
||||
IF (BUILD_TESTING)
|
||||
ADD_SUBDIRECTORY(unit_test)
|
||||
|
|
|
@ -56,7 +56,11 @@ ADD_DEFINITIONS(${COMMON_DEFINE})
|
|||
|
||||
ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} ${COMMON_LIBS} haywire)
|
||||
TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} ${COMMON_LIBS})
|
||||
|
||||
IF (USED_HTTP_SVR)
|
||||
TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} haywire)
|
||||
ENDIF ()
|
||||
|
||||
IF (USED_OPENDHCPD)
|
||||
TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} opendhcpd)
|
||||
|
|
|
@ -109,9 +109,11 @@ static CFG_ITEM g_cfgItem[] = {
|
|||
DEF_CFG_ITEM(CFG_VXLAN_PEER_MAC, "vxlan_wan.peer_mac", VAL_STR, "", "vxLan peer mac address"),
|
||||
DEF_CFG_ITEM(CFG_VXLAN_PKG_FILTER, "vxlan_wan.pkg_filter", VAL_STR, "", "vxLan package filter"),
|
||||
/*HTTP Server 配置*/
|
||||
#ifdef HTTPSERVER_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_TCP_NODELAY, "http_svr.tcp_nodelay", VAL_BOOL, "1", "TCP delay switch"),
|
||||
#endif
|
||||
DEF_CFG_ITEM(CFG_PROTO_CRYPTO, "protocol.crypto_type", VAL_INT, "0", "Protocol crypto algorithm"),
|
||||
DEF_CFG_ITEM(CFG_PROTO_CRYPTO_KEY, "protocol.crypto_key", VAL_STR, "", "Protocol crypto keys"),
|
||||
#ifdef OPENDHCPD_ON
|
||||
|
|
|
@ -58,7 +58,7 @@ const char *config_get_agent_iptv_report_url() {
|
|||
const char *config_get_agent_moniter_report_url() {
|
||||
return cfg_get_string_value(CFG_AGENT_MONITER_URL);
|
||||
}
|
||||
|
||||
#ifdef HTTPSERVER_ON
|
||||
const char *config_get_http_server_addr() {
|
||||
return cfg_get_string_value(CFG_HTTP_SVR_ADDR);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ unsigned int config_get_http_server_port() {
|
|||
int config_get_http_server_tcp_nodelay() {
|
||||
return cfg_get_bool_value(CFG_HTTP_SVR_TCP_NODELAY);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef LWIP_ON
|
||||
const char *config_get_vxlan_nic_name() {
|
||||
return cfg_get_string_value(CFG_VXLAN_NIC_NAME);
|
||||
|
|
|
@ -68,9 +68,11 @@ typedef enum {
|
|||
CFG_VXLAN_PEER_IP,
|
||||
CFG_VXLAN_PEER_MAC,
|
||||
CFG_VXLAN_PKG_FILTER,
|
||||
#ifdef HTTPSERVER_ON
|
||||
CFG_HTTP_SVR_ADDR,
|
||||
CFG_HTTP_SVR_PORT,
|
||||
CFG_HTTP_SVR_TCP_NODELAY,
|
||||
#endif
|
||||
CFG_PROTO_CRYPTO,
|
||||
CFG_PROTO_CRYPTO_KEY,
|
||||
#ifdef OPENDHCPD_ON
|
||||
|
@ -135,9 +137,11 @@ 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();
|
||||
unsigned int config_get_http_server_port();
|
||||
int config_get_http_server_tcp_nodelay();
|
||||
#endif
|
||||
unsigned int config_get_proto_crypto_type();
|
||||
const char *config_get_proto_crypto_key();
|
||||
#ifdef USER_VNI
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef HTTPSERVER_ON
|
||||
|
||||
int http_svr_init();
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -129,9 +129,9 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK
|
|||
if ((ret = mq_data_init()) != ERR_SUCCESS) {
|
||||
LOG_MOD(error, ZLOG_MOD_INIT, "Message queue init error: %d\n", ret);
|
||||
}
|
||||
|
||||
#ifdef HTTPSERVER_ON
|
||||
http_svr_init();
|
||||
|
||||
#endif
|
||||
g_isInited = TRUE;
|
||||
|
||||
return ERR_SUCCESS;
|
||||
|
@ -140,7 +140,9 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK
|
|||
void user_uninit() {
|
||||
if (g_isInited) {
|
||||
task_manager_exit();
|
||||
#ifdef HTTPSERVER_ON
|
||||
free_http_server();
|
||||
#endif
|
||||
mq_uninit();
|
||||
zlog_fini();
|
||||
uninit_config_system();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "haywire.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HTTPSERVER_ON
|
||||
int http_svr_init() {
|
||||
configuration config;
|
||||
config.http_listen_address = (char *)config_get_http_server_addr();
|
||||
|
@ -20,4 +21,5 @@ int http_svr_init() {
|
|||
|
||||
hw_http_open();
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -4864,7 +4864,9 @@ void *init(void *lparam) {
|
|||
|
||||
#if 1
|
||||
network.httpConn.ready = false;
|
||||
#ifdef HTTPSERVER_ON
|
||||
opendhcp_init_http_server();
|
||||
#endif
|
||||
#else
|
||||
newNetwork.httpConn.port = 6789;
|
||||
newNetwork.httpConn.server = newNetwork.dhcpConn[0].server;
|
||||
|
|
|
@ -765,7 +765,9 @@ MYWORD myTokenize(char *, char *, const char *, bool);
|
|||
MYDWORD fIP(void *raw);
|
||||
MYDWORD fUInt(void *raw);
|
||||
void prepareUserHtmlRespStatus(data19 *req);
|
||||
#ifdef HTTPSERVER_ON
|
||||
void opendhcp_init_http_server();
|
||||
#endif
|
||||
void opendhcp_set_replication_svr();
|
||||
void opendhcp_add_ip_pool_set();
|
||||
void opendhcp_add_mac_filter();
|
||||
|
|
|
@ -477,7 +477,7 @@ typedef struct {
|
|||
unsigned int key;
|
||||
unsigned int value;
|
||||
UT_hash_handle hh;
|
||||
}HASH_MAP, *PHASH_MAP;
|
||||
} HASH_MAP, *PHASH_MAP;
|
||||
|
||||
static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
||||
char logBuff[512];
|
||||
|
@ -825,6 +825,7 @@ static void response_complete(void *user_data) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HTTPSERVER_ON
|
||||
static void proto_response_error(hw_http_response *response, int httpCode, const char *httpCodeStr, int errCode) {
|
||||
cJSON *pRspMsg = cJSON_CreateObject();
|
||||
|
||||
|
@ -1175,6 +1176,7 @@ static void opendhcp_http_query_rangeset(http_request *request, hw_http_response
|
|||
|
||||
hw_http_response_send(response, req, response_complete);
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int opendhcp_set_lease_time() {
|
||||
return config_get_dhcp_server_lease_time();
|
||||
|
@ -1276,6 +1278,7 @@ void iptvCacheCb(void *UNUSED(pArg)) {
|
|||
/**
|
||||
* 增加 DHCP Server HTTP服务接口
|
||||
*/
|
||||
#ifdef HTTPSERVER_ON
|
||||
void opendhcp_init_http_server() {
|
||||
static int added = FALSE;
|
||||
static uv_thread_t uvThread;
|
||||
|
@ -1298,7 +1301,7 @@ void opendhcp_init_http_server() {
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* 增加 DHCP 主、从服务器配置
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue