Merge remote-tracking branch 'origin/master'

# Conflicts:
#	srcs/open_dhcp/query.cpp
This commit is contained in:
dongwenze 2022-11-23 15:02:41 +08:00
commit 876760acf6
16 changed files with 31 additions and 24 deletions

View File

@ -78,7 +78,8 @@ application:
# DHCP Server Config # DHCP Server Config
dhcp_server: { dhcp_server: {
listen_on = ["192.168.30.1", "192.168.100.1"]; listen_on = ["192.168.30.1", "192.168.100.1"];
http_client = ["192.168.30.1", "192.168.30.110", "192.168.100.1", "192.168.100.110"]; # 主备服务器设置
# replication = ["192.168.100.211", "192.168.100.215"];
range_set: ( range_set: (
{ dhcp_range = "192.168.30.110-192.168.30.120"; { dhcp_range = "192.168.30.110-192.168.30.120";

View File

@ -23,11 +23,10 @@ AUX_SOURCE_DIRECTORY(mq C_SRC)
AUX_SOURCE_DIRECTORY(cmdline C_SRC) AUX_SOURCE_DIRECTORY(cmdline C_SRC)
AUX_SOURCE_DIRECTORY(crypto C_SRC) AUX_SOURCE_DIRECTORY(crypto C_SRC)
AUX_SOURCE_DIRECTORY(hardware C_SRC) AUX_SOURCE_DIRECTORY(hardware C_SRC)
AUX_SOURCE_DIRECTORY(vector C_SRC)
SET(CMAKE_C_STANDARD 99) SET(CMAKE_C_STANDARD 99)
SET_SOURCE_FILES_PROPERTIES(vector/zvector.c PROPERTIES COMPILE_FLAGS "-Wall -Wextra -flto") SET_SOURCE_FILES_PROPERTIES(misc/zvector.c PROPERTIES COMPILE_FLAGS "-Wall -Wextra -flto")
ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE}) ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE})

View File

@ -6,7 +6,7 @@
#include <string.h> #include <string.h>
#include <uv.h> #include <uv.h>
#include <zlog.h> #include <zlog.h>
#include <sds.h> #include <sds/sds.h>
#include "uthash/uthash.h" #include "uthash/uthash.h"
#include "config.h" #include "config.h"
@ -14,7 +14,6 @@
#include "user_errno.h" #include "user_errno.h"
#include "crypto.h" #include "crypto.h"
#include "hardware.h" #include "hardware.h"
#include "zvector/zvector.h"
#define CFG_INT_VALUE(p) (p->value.longValue) #define CFG_INT_VALUE(p) (p->value.longValue)
#define CFG_BOOL_VALUE(p) (p->value.longValue == FALSE ? FALSE : TRUE) #define CFG_BOOL_VALUE(p) (p->value.longValue == FALSE ? FALSE : TRUE)
@ -67,7 +66,7 @@ do {
ADD_CFG_ITEM(CFG_HTTP_SVR_PORT, "application.http_svr.listen_port", VALUE_TYPE_INTEGRAL, "6789", "Network port to listen on"); \ ADD_CFG_ITEM(CFG_HTTP_SVR_PORT, "application.http_svr.listen_port", VALUE_TYPE_INTEGRAL, "6789", "Network port to listen on"); \
ADD_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "application.http_svr.tcp_nodelay", VALUE_TYPE_BOOL, "1", "TCP delay switch"); \ ADD_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "application.http_svr.tcp_nodelay", VALUE_TYPE_BOOL, "1", "TCP delay switch"); \
ADD_CFG_ITEM(CFG_DHCP_LISTEN_ON, "application.dhcp_server.listen_on", VALUE_TYPE_ARRAY_STR, "", "DHCP listen interface"); \ ADD_CFG_ITEM(CFG_DHCP_LISTEN_ON, "application.dhcp_server.listen_on", VALUE_TYPE_ARRAY_STR, "", "DHCP listen interface"); \
ADD_CFG_ITEM(CFG_DHCP_HTTP_CLIENT, "application.dhcp_server.http_client", VALUE_TYPE_ARRAY_STR, "", "DHCP http server client write list"); \ ADD_CFG_ITEM(CFG_DHCP_REPLICATION_SVR, "application.dhcp_server.replication", VALUE_TYPE_ARRAY_STR, "", "DHCP replication server master and secondary"); \
ADD_CFG_ITEM(CFG_DHCP_RANGE_SET, "application.dhcp_server.range_set", VALUE_TYPE_ARRAY_OBJ, "", "DHCP IP pool"); \ ADD_CFG_ITEM(CFG_DHCP_RANGE_SET, "application.dhcp_server.range_set", VALUE_TYPE_ARRAY_OBJ, "", "DHCP IP pool"); \
} while (0)// clang-format on } while (0)// clang-format on

View File

@ -7,6 +7,14 @@ const vector config_get_dhcp_server_range_set() {
return cfg_get_vector(CFG_DHCP_RANGE_SET); return cfg_get_vector(CFG_DHCP_RANGE_SET);
} }
const vector config_get_dhcp_listen_on() {
return cfg_get_vector(CFG_DHCP_LISTEN_ON);
}
const vector config_get_dhcp_replication_svr() {
return cfg_get_vector(CFG_DHCP_REPLICATION_SVR);
}
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

@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <uv.h> #include <uv.h>
#include <sds.h> #include <sds/sds.h>
#include "misc.h" #include "misc.h"
#include "user_errno.h" #include "user_errno.h"

View File

@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <uv.h> #include <uv.h>
#include <sds.h> #include <sds/sds.h>
#include "hardware.h" #include "hardware.h"
#include "user_errno.h" #include "user_errno.h"

View File

@ -4,7 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <uv.h> #include <uv.h>
#include <string.h> #include <string.h>
#include <sds.h> #include <sds/sds.h>
#include "hardware.h" #include "hardware.h"
#include "task_manager.h" #include "task_manager.h"

View File

@ -2,7 +2,7 @@
// Created by xajhu on 2021/7/1 0001. // Created by xajhu on 2021/7/1 0001.
// //
#include "zvector/zvector.h" #include <zvector/zvector.h>
#ifndef DAEMON_AGENT_INCLUDE_CONFIG_H #ifndef DAEMON_AGENT_INCLUDE_CONFIG_H
#define DAEMON_AGENT_INCLUDE_CONFIG_H #define DAEMON_AGENT_INCLUDE_CONFIG_H
@ -62,7 +62,7 @@ typedef enum {
CFG_HTTP_SVR_PORT = 30, CFG_HTTP_SVR_PORT = 30,
CFG_HTTP_SVR_TCP_NODELAY = 31, CFG_HTTP_SVR_TCP_NODELAY = 31,
CFG_DHCP_LISTEN_ON = 32, CFG_DHCP_LISTEN_ON = 32,
CFG_DHCP_HTTP_CLIENT = 33, CFG_DHCP_REPLICATION_SVR = 33,
CFG_DHCP_RANGE_SET = 34, CFG_DHCP_RANGE_SET = 34,
CONFIG_ITEM_ID_MAX CONFIG_ITEM_ID_MAX
} CONFIG_ITEM_ID; } CONFIG_ITEM_ID;
@ -114,6 +114,8 @@ 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();
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_replication_svr();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -36,9 +36,8 @@
#include <ctype.h> #include <ctype.h>
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
#include "sds.h" #include <sds/sds.h>
#include "sdsalloc.h" #include <sds/sdsalloc.h>
hiredisAllocFuncs hiredisAllocFns = { hiredisAllocFuncs hiredisAllocFns = {
.mallocFn = malloc, .mallocFn = malloc,

View File

@ -3,7 +3,7 @@
// //
#include <jemalloc/jemalloc.h> #include <jemalloc/jemalloc.h>
#include <uv.h> #include <uv.h>
#include <sds.h> #include <sds/sds.h>
#include "msg_queue.h" #include "msg_queue.h"
#include "s2j/s2j.h" #include "s2j/s2j.h"

View File

@ -33,7 +33,7 @@ static void sendUserList(data19 *req, const char *pRequest) {
char logBuff[512]; char logBuff[512];
dhcpMap::iterator p; dhcpMap::iterator p;
printf("Input: %s\n", pRequest); dzlog_debug("Input: %s\n", pRequest);
if (pRequest == nullptr || strlen(pRequest) == 0) { if (pRequest == nullptr || strlen(pRequest) == 0) {
sprintf(logBuff, "Requeset Json"); sprintf(logBuff, "Requeset Json");
@ -370,7 +370,7 @@ int getHwAddr(char *buff, char *mac) {
int arpSet(const char *ifname, char *ipStr, char *mac) { int arpSet(const char *ifname, char *ipStr, char *mac) {
if (ifname == nullptr || ipStr == nullptr || mac == nullptr) { if (ifname == nullptr || ipStr == nullptr || mac == nullptr) {
printf("para is null.\n"); dzlog_error("para is null.\n");
return -1; return -1;
} }
@ -388,19 +388,19 @@ int arpSet(const char *ifname, char *ipStr, char *mac) {
req.arp_flags = ATF_PERM | ATF_COM; req.arp_flags = ATF_PERM | ATF_COM;
if (getHwAddr((char *)req.arp_ha.sa_data, mac) < 0) { if (getHwAddr((char *)req.arp_ha.sa_data, mac) < 0) {
printf("get mac error.\n"); dzlog_error("get mac error.\n");
return -1; return -1;
} }
sock_fd = socket(AF_INET, SOCK_DGRAM, 0); sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (sock_fd < 0) { if (sock_fd < 0) {
printf("get socket error.\n"); dzlog_error("get socket error.\n");
return -1; return -1;
} }
ret = ioctl(sock_fd, SIOCSARP, &req); ret = ioctl(sock_fd, SIOCSARP, &req);
if (ret < 0) { if (ret < 0) {
printf("ioctl error.\n"); dzlog_error("ioctl error.\n");
close(sock_fd); close(sock_fd);
return -1; return -1;
} }

View File

@ -15,7 +15,6 @@
#ifdef OPENDHCPD_ON #ifdef OPENDHCPD_ON
#include "user_errno.h" #include "user_errno.h"
#include "libs/misc/sdsalloc.h"
#endif #endif
#ifdef OPENDHCPDDNS_ON #ifdef OPENDHCPDDNS_ON
@ -59,8 +58,7 @@ int main(int argc, char **argv) {
if(ret == ERR_MENU_EXIT) { if(ret == ERR_MENU_EXIT) {
user_uninit(); user_uninit();
exit(0); exit(0);
} } else if (ret != ERR_SUCCESS) {
if (ret != ERR_SUCCESS) {
printf("Application setup error(%d), please used --help to show usage, exited!!!\n", ret); printf("Application setup error(%d), please used --help to show usage, exited!!!\n", ret);
user_uninit(); user_uninit();
exit(0); exit(0);
@ -79,6 +77,7 @@ int main(int argc, char **argv) {
} }
user_uninit(); user_uninit();
return 0;
return ret;
#endif #endif
} }