Merge remote-tracking branch 'origin/master'

# Conflicts:
#	srcs/open_dhcp/query.cpp
This commit is contained in:
dongwenze 2022-12-09 17:10:21 +08:00
commit 9efa161728
4 changed files with 127 additions and 112 deletions

View File

@ -4,10 +4,23 @@ AccessModifierOffset: -4
InsertBraces: true
AlignArrayOfStructures: Left
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
PadOperators: true
AlignCompound: true
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: Consecutive
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
PadOperators: true
AlignCompound: true
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments: true
@ -195,6 +208,7 @@ StatementMacros:
TabWidth: 4
UseCRLF: false
UseTab: Never
SeparateDefinitionBlocks: Always
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE

View File

@ -166,6 +166,7 @@ typedef struct {
void *headers;
hw_string *body;
size_t body_length;
enum {
OK,
SIZE_EXCEEDED,
@ -174,7 +175,8 @@ typedef struct {
} state;
} http_request;
typedef void(HAYWIRE_CALLING_CONVENTION *http_request_callback)(http_request *request, hw_http_response *response,
typedef void(HAYWIRE_CALLING_CONVENTION *http_request_callback)(http_request *request,
hw_http_response *response,
void *user_data);
typedef void(HAYWIRE_CALLING_CONVENTION *http_response_complete_callback)(void *user_data);
@ -190,7 +192,8 @@ HAYWIRE_EXTERN void hw_set_http_version(hw_http_response *response, unsigned sho
HAYWIRE_EXTERN void hw_set_response_status_code(hw_http_response *response, hw_string *status_code);
HAYWIRE_EXTERN void hw_set_response_header(hw_http_response *response, hw_string *name, hw_string *value);
HAYWIRE_EXTERN void hw_set_body(hw_http_response *response, hw_string *body);
HAYWIRE_EXTERN void hw_http_response_send(hw_http_response *response, void *user_data,
HAYWIRE_EXTERN void hw_http_response_send(hw_http_response *response,
void *user_data,
http_response_complete_callback callback);
HAYWIRE_EXTERN void hw_http_response_send_error(hw_http_response *response, const char *error, const char *err_msg);
HAYWIRE_EXTERN void hw_print_request_headers(http_request *request);

View File

@ -4999,10 +4999,10 @@ void getInterfaces(data1 *pNetwork) {
Ifc.ifc_buf = (char *)IfcBuf;
if (ioctl(cfig.fixedSocket, SIOCGIFCONF, &Ifc) >= 0) {
struct ifreq pIfr {};
MYDWORD addr, mask;
short flags;
struct ifreq pIfr {};
MYBYTE numInterfaces = Ifc.ifc_len / sizeof(ifreq);
for (MYBYTE i = 0; i < numInterfaces; i++) {

View File

@ -563,8 +563,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
static void revert(unsigned int *num) {
unsigned int v = *num;
v = ((v & 0x000000FF) << 24) | ((v & 0x0000FF00) << 8) |
((v & 0x00FF0000) >> 8) | ((v & 0xFF000000) >> 24) ;
v = ((v & 0x000000FF) << 24) | ((v & 0x0000FF00) << 8) | ((v & 0x00FF0000) >> 8) | ((v & 0xFF000000) >> 24);
*num = v;
}
@ -667,6 +666,7 @@ static int query_dhcpd_rangeset(data19 *req){
#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c"
int getHwAddr(char *buff, char *mac) {
if (buff == nullptr || mac == nullptr) {
return -1;
@ -685,6 +685,7 @@ int getHwAddr(char *buff, char *mac) {
return 0;
}
#pragma clang diagnostic pop
int arpSet(const char *ifname, char *ipStr, char *mac) {
@ -860,7 +861,6 @@ static void opendhcp_http_get_alluser(http_request *request, hw_http_response *r
hw_string keep_alive_name;
hw_string keep_alive_value;
int ret;
auto *req = (data19 *)malloc(sizeof(struct data19));
if (req == nullptr) {
@ -908,16 +908,15 @@ static void opendhcp_http_add_rangeset(http_request *request, hw_http_response *
hw_string keep_alive_name;
hw_string keep_alive_value;
int ret;
auto *req = (data19 *)malloc(sizeof(struct data19));
if (req == nullptr) {
hw_http_response_send_error(response, HTTP_STATUS_500, "memory error");
proto_response_error(response, 500, HTTP_STATUS_500, ERR_MALLOC_MEMORY);
return;
}
if (request->method != HW_HTTP_POST) {
hw_http_response_send_error(response, HTTP_STATUS_405, HTTP_STATUS_405);
proto_response_error(response, 405, HTTP_STATUS_405, ERR_HTTP_UNSUP_METHOD);
return;
}
@ -956,16 +955,15 @@ static void opendhcp_http_delete_rangeset(http_request *request, hw_http_respons
hw_string keep_alive_name;
hw_string keep_alive_value;
int ret;
auto *req = (data19 *)malloc(sizeof(struct data19));
if (req == nullptr) {
hw_http_response_send_error(response, HTTP_STATUS_500, "memory error");
proto_response_error(response, 500, HTTP_STATUS_500, ERR_MALLOC_MEMORY);
return;
}
if (request->method != HW_HTTP_POST) {
hw_http_response_send_error(response, HTTP_STATUS_405, HTTP_STATUS_405);
proto_response_error(response, 405, HTTP_STATUS_405, ERR_HTTP_UNSUP_METHOD);
return;
}
@ -1004,16 +1002,15 @@ static void opendhcp_http_query_rangeset(http_request *request, hw_http_response
hw_string keep_alive_name;
hw_string keep_alive_value;
int ret;
auto *req = (data19 *)malloc(sizeof(struct data19));
if (req == nullptr) {
hw_http_response_send_error(response, HTTP_STATUS_500, "memory error");
proto_response_error(response, 500, HTTP_STATUS_500, ERR_MALLOC_MEMORY);
return;
}
if (request->method != HW_HTTP_GET) {
hw_http_response_send_error(response, HTTP_STATUS_405, HTTP_STATUS_405);
proto_response_error(response, 405, HTTP_STATUS_405, ERR_HTTP_UNSUP_METHOD);
return;
}
@ -1043,6 +1040,7 @@ static void opendhcp_http_query_rangeset(http_request *request, hw_http_response
hw_http_response_send(response, req, response_complete);
}
/**
*
* @return