OCT 1. 更新接口错误返回JSON数据
This commit is contained in:
parent
9794acc41d
commit
92cf406294
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
//
|
||||
#include <string>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
@ -25,6 +23,8 @@ using namespace std;
|
|||
#include "user_errno.h"
|
||||
#include "uthash/uthash.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern data2 cfig;
|
||||
extern bool kRunning;
|
||||
extern dhcpMap dhcpCache;
|
||||
|
@ -491,8 +491,8 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
|||
sprintf(del_range, "%s-%s", saddr, eaddr);
|
||||
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
|
||||
//judge whether the input has error
|
||||
if(delRange->key && delRange->value &&
|
||||
(delRange->key == cfig.dhcpRanges[i].rangeStart) && (delRange->value == cfig.dhcpRanges[i].rangeEnd)){
|
||||
if (delRange->key && delRange->value && (delRange->key == cfig.dhcpRanges[i].rangeStart) &&
|
||||
(delRange->value == cfig.dhcpRanges[i].rangeEnd)) {
|
||||
cJSON_AddNumberToObject(pdel_Item, "status", ERR_SUCCESS);
|
||||
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_SUCCESS));
|
||||
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
||||
|
@ -534,8 +534,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;
|
||||
}
|
||||
|
||||
|
@ -638,6 +637,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;
|
||||
|
@ -656,6 +656,7 @@ int getHwAddr(char *buff, char *mac) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
int arpSet(const char *ifname, char *ipStr, char *mac) {
|
||||
|
@ -831,7 +832,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) {
|
||||
|
@ -879,16 +879,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;
|
||||
}
|
||||
|
||||
|
@ -927,16 +926,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;
|
||||
}
|
||||
|
||||
|
@ -975,16 +973,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;
|
||||
}
|
||||
|
||||
|
@ -1014,6 +1011,7 @@ static void opendhcp_http_query_rangeset(http_request *request, hw_http_response
|
|||
|
||||
hw_http_response_send(response, req, response_complete);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加配置文件监听接口
|
||||
* @return
|
||||
|
|
Loading…
Reference in New Issue