parent
3078e84918
commit
ad06f31aea
|
@ -7,6 +7,7 @@ OPTION(VCPE_AGENT "Enable vCPE agent test application" OFF)
|
||||||
OPTION(USED_LWIP "PPPoE of LWIP support for vCPE" OFF)
|
OPTION(USED_LWIP "PPPoE of LWIP support for vCPE" OFF)
|
||||||
OPTION(USED_OPENDHCPD "DHCP server for vCPE" OFF)
|
OPTION(USED_OPENDHCPD "DHCP server for vCPE" OFF)
|
||||||
OPTION(USED_OPENDHCPDDNS "DHCP And DNS 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(USED_REDIS "Add redis database support for vCPE" OFF)
|
OPTION(USED_REDIS "Add redis database support for vCPE" OFF)
|
||||||
|
@ -64,44 +65,40 @@ CONFIGURE_FILE(prj_config.h.in prj_config.h)
|
||||||
|
|
||||||
MESSAGE("Git Tag: " ${VERSION_GIT_TAG})
|
MESSAGE("Git Tag: " ${VERSION_GIT_TAG})
|
||||||
|
|
||||||
|
IF (USED_USER_VNI)
|
||||||
|
LIST(APPEND COMMON_DEFINE "-DUSER_VNI")
|
||||||
|
MESSAGE("Select Option USED_USER_VNI")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF (USED_LWIP)
|
IF (USED_LWIP)
|
||||||
LIST(APPEND COMMON_DEFINE "-DLWIP_ON")
|
LIST(APPEND COMMON_DEFINE "-DLWIP_ON")
|
||||||
|
MESSAGE("Select Option USED_LWIP")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (USED_OPENDHCPD)
|
IF (USED_OPENDHCPD)
|
||||||
LIST(APPEND COMMON_DEFINE "-DOPENDHCPD_ON")
|
LIST(APPEND COMMON_DEFINE "-DOPENDHCPD_ON")
|
||||||
|
MESSAGE("Select Option USED_OPENDHCPD")
|
||||||
|
ADD_SUBDIRECTORY(srcs/open_dhcp)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (USED_OPENDHCPDDNS)
|
IF (USED_OPENDHCPDDNS)
|
||||||
LIST(APPEND COMMON_DEFINE "-DOPENDHCPDDNS_ON")
|
LIST(APPEND COMMON_DEFINE "-DOPENDHCPDDNS_ON")
|
||||||
|
MESSAGE("Select Option USED_OPENDHCPDDNS")
|
||||||
|
ADD_SUBDIRECTORY(srcs/dual_server)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (VCPE_AGENT)
|
IF (VCPE_AGENT)
|
||||||
MESSAGE("Select Option VCPE_AGENT")
|
MESSAGE("Select Option VCPE_AGENT")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (USED_LWIP)
|
|
||||||
MESSAGE("Select Option USED_LWIP")
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF (USED_SQLITE)
|
IF (USED_SQLITE)
|
||||||
MESSAGE("Select Option USED_SQLITE")
|
MESSAGE("Select Option USED_SQLITE")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (USED_OPENDHCPD)
|
|
||||||
MESSAGE("Select Option USED_OPENDHCPD")
|
|
||||||
ADD_SUBDIRECTORY(srcs/open_dhcp)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF (USED_OPENDHCPDDNS)
|
|
||||||
MESSAGE("Select Option USED_OPENDHCPDDNS")
|
|
||||||
ADD_SUBDIRECTORY(srcs/dual_server)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF (USED_LWIP OR VCPE_AGENT)
|
IF (USED_LWIP OR VCPE_AGENT)
|
||||||
ADD_SUBDIRECTORY(srcs/lwip)
|
ADD_SUBDIRECTORY(srcs/lwip)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(srcs)
|
ADD_SUBDIRECTORY(srcs)
|
||||||
ADD_SUBDIRECTORY(srcs/libs)
|
ADD_SUBDIRECTORY(srcs/libs)
|
||||||
ADD_SUBDIRECTORY(srcs/httpserver)
|
ADD_SUBDIRECTORY(srcs/httpserver)
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# sudo cp vcpe.service /lib/systemd/system/
|
||||||
|
# sudo ln -s /lib/systemd/system/vcpe.service /etc/systemd/system/multi-user.target.wants/vcpe.service
|
||||||
|
# sudo systemctl daemon-reload
|
||||||
|
# sudo systemctl enable vcpe
|
||||||
|
[Unit]
|
||||||
|
Description=vCPE Service
|
||||||
|
StartLimitIntervalSec=0
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
User=root
|
||||||
|
WorkingDirectory=/home/jw/vcpe/srcs
|
||||||
|
ExecStart=/usr/bin/env /home/jw/vcpe/srcs/vcpe_main dhcpd -m -n vxlan0 -c ./config/vcpe.cfg -d ./config/ -k pqwAQ81rxg70aoy3v+Jjrw==
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -401,20 +401,26 @@ static int on_cmd7(void *pTbl[], const char *pName, void *pInfo) {
|
||||||
const char *piniFile = ((arg_file_t *)pTbl[4])->filename[0];
|
const char *piniFile = ((arg_file_t *)pTbl[4])->filename[0];
|
||||||
const char *pstatFile = ((arg_file_t *)pTbl[5])->filename[0];
|
const char *pstatFile = ((arg_file_t *)pTbl[5])->filename[0];
|
||||||
const char *pIfName = ((arg_str_t *)pTbl[6])->sval[0];
|
const char *pIfName = ((arg_str_t *)pTbl[6])->sval[0];
|
||||||
int *pVni = ((arg_int_t *)pTbl[7])->ival;
|
#ifdef USER_VNI
|
||||||
const char *pKey = ((arg_str_t *)pTbl[8])->sval[0];
|
int *pVni = ((arg_int_t *)pTbl[7])->ival;
|
||||||
int help = get_help_cmd(pTbl, pArg)->count;
|
const char *pKey = ((arg_str_t *)pTbl[8])->sval[0];
|
||||||
|
#else
|
||||||
|
const char *pKey = ((arg_str_t *)pTbl[7])->sval[0];
|
||||||
|
#endif
|
||||||
|
int help = get_help_cmd(pTbl, pArg)->count;
|
||||||
|
|
||||||
if (pArg->pHelp && help > 0) {
|
if (pArg->pHelp && help > 0) {
|
||||||
pArg->pHelp(pArg->argTbl, pName, pTbl);
|
pArg->pHelp(pArg->argTbl, pName, pTbl);
|
||||||
return ERR_MENU_EXIT;
|
return ERR_MENU_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USER_VNI
|
||||||
if (pVni && *pVni > 0) {
|
if (pVni && *pVni > 0) {
|
||||||
cfg_set_user_vni_id(*pVni);
|
cfg_set_user_vni_id(*pVni);
|
||||||
} else {
|
} else {
|
||||||
cfg_set_user_vni_id(0);
|
cfg_set_user_vni_id(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((ret = user_init(pCfgFile, pCfgDir, pKey, 0)) != ERR_SUCCESS) {
|
if ((ret = user_init(pCfgFile, pCfgDir, pKey, 0)) != ERR_SUCCESS) {
|
||||||
printf("System init error: %d\n", ret);
|
printf("System init error: %d\n", ret);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
//
|
//
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef USER_VNI
|
||||||
static int g_user_vni_id = -1;
|
static int g_user_vni_id = -1;
|
||||||
|
|
||||||
void cfg_set_user_vni_id(int vni) {
|
void cfg_set_user_vni_id(int vni) {
|
||||||
|
@ -15,9 +16,10 @@ int cfg_get_user_vni_id() {
|
||||||
if (g_user_vni_id > 0xFFFFFF) {
|
if (g_user_vni_id > 0xFFFFFF) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_user_vni_id;
|
return g_user_vni_id;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned int config_get_proto_crypto_type() {
|
unsigned int config_get_proto_crypto_type() {
|
||||||
return cfg_get_integral_value(CFG_PROTO_CRYPTO);
|
return cfg_get_integral_value(CFG_PROTO_CRYPTO);
|
||||||
|
|
|
@ -141,8 +141,10 @@ unsigned int config_get_http_server_port();
|
||||||
int config_get_http_server_tcp_nodelay();
|
int config_get_http_server_tcp_nodelay();
|
||||||
unsigned int config_get_proto_crypto_type();
|
unsigned int config_get_proto_crypto_type();
|
||||||
const char *config_get_proto_crypto_key();
|
const char *config_get_proto_crypto_key();
|
||||||
void cfg_set_user_vni_id(int vni);
|
#ifdef USER_VNI
|
||||||
int cfg_get_user_vni_id();
|
void cfg_set_user_vni_id(int vni);
|
||||||
|
int cfg_get_user_vni_id();
|
||||||
|
#endif
|
||||||
#ifdef OPENDHCPD_ON
|
#ifdef OPENDHCPD_ON
|
||||||
unsigned int config_get_dhcp_server_lease_time();
|
unsigned int config_get_dhcp_server_lease_time();
|
||||||
c_vector config_get_dhcp_server_range_set();
|
c_vector config_get_dhcp_server_range_set();
|
||||||
|
|
|
@ -1264,8 +1264,9 @@ void opendhcp_init_http_server() {
|
||||||
uv_thread_create(&uvThread, iptvCacheCb, nullptr);
|
uv_thread_create(&uvThread, iptvCacheCb, nullptr);
|
||||||
|
|
||||||
added = TRUE;
|
added = TRUE;
|
||||||
|
#ifdef USER_VNI
|
||||||
dzlog_info("User VxLan Id: [%d]\n", cfg_get_user_vni_id());
|
dzlog_info("User VxLan Id: [%d]\n", cfg_get_user_vni_id());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,7 +1313,11 @@ int process_iptv_multicast(const unsigned char *p, int size, const char *mac) {
|
||||||
memset(pDev, 0, sizeof(IPTV_DEV_SET));
|
memset(pDev, 0, sizeof(IPTV_DEV_SET));
|
||||||
|
|
||||||
strcpy(pDev->iptvMAC, mac);
|
strcpy(pDev->iptvMAC, mac);
|
||||||
|
#ifdef USER_VNI
|
||||||
pDev->vni = cfg_get_user_vni_id();
|
pDev->vni = cfg_get_user_vni_id();
|
||||||
|
#else
|
||||||
|
pDev->vni = 0;
|
||||||
|
#endif
|
||||||
pDev->isReport = 0;
|
pDev->isReport = 0;
|
||||||
uv_rwlock_wrlock(&g_uvCacheLock);
|
uv_rwlock_wrlock(&g_uvCacheLock);
|
||||||
HASH_ADD_STR(g_iptvNewDevs, iptvMAC, pDev);
|
HASH_ADD_STR(g_iptvNewDevs, iptvMAC, pDev);
|
||||||
|
|
Loading…
Reference in New Issue