Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Aug 12, 2024
1 parent 0b0b829 commit 0b8b534
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
11 changes: 6 additions & 5 deletions tunnels/adapters/device/capture/caputre_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef struct capture_device_state_s
{
capture_device_t *cdev;
line_t **thread_lines;
char *ip;
char *name;
char *exitcmd;
uint32_t queue_number;
Expand Down Expand Up @@ -163,8 +164,8 @@ tunnel_t *newCaptureDevice(node_instance_context_t *instance_info)
return NULL;
}
state->queue_number = 200 + (fastRand() % 200);
char *ipbuf = NULL;
if (! getStringFromJsonObject(&ipbuf, settings, "ip"))
state->ip = NULL;
if (! getStringFromJsonObject(&state->ip, settings, "ip"))
{
LOGF("JSON Error: CaptureDevice->settings->ip (string field) : mode is not specified or invalid");
}
Expand All @@ -176,20 +177,20 @@ tunnel_t *newCaptureDevice(node_instance_context_t *instance_info)
{
if ((int) fmode.status == kDvsSourceIp)
{
snprintf(cmdbuf, 100, ip_tables_enable_queue_mi, ipbuf, (int) state->queue_number);
snprintf(cmdbuf, 100, ip_tables_enable_queue_mi, state->ip, (int) state->queue_number);
if (execCmd(cmdbuf).exit_code != 0)
{
LOGF("CaptureDevicer: command failed: %s", cmdbuf);
return NULL;
}

state->exitcmd = cmdbuf;
snprintf(cmdbuf, 100, ip_tables_disable_queue_mi, ipbuf, (int) state->queue_number);
snprintf(cmdbuf, 100, ip_tables_disable_queue_mi, state->ip, (int) state->queue_number);
registerAtExitCallback(exitHook, t);
}
else
{
//todo
// todo
}
}

Expand Down
13 changes: 5 additions & 8 deletions ww/devices/capture/capture_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ static void distributePacketPayload(capture_device_t *cdev, tid_t target_tid, sh
static bool netfilterSendMessage(int netfilter_socket, uint16_t nl_type, int nfa_type, uint16_t res_id, bool ack,
void *msg, size_t size)
{
size_t nl_size = NLMSG_ALIGN(NLMSG_LENGTH(sizeof(struct nfgenmsg))) + NFA_ALIGN(NFA_LENGTH(size));
uint8_t buff[nl_size];
size_t nl_size = NLMSG_ALIGN(NLMSG_LENGTH(sizeof(struct nfgenmsg))) + NFA_ALIGN(NFA_LENGTH(size));
uint8_t buff[nl_size];
memset(buff, 0, nl_size);
struct nlmsghdr *nl_hdr = (struct nlmsghdr *) buff;

nl_hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg));
Expand Down Expand Up @@ -146,9 +147,7 @@ static bool netfilterSendMessage(int netfilter_socket, uint16_t nl_type, int nfa
*/
static bool netfilterSetConfig(int netfilter_socket, uint8_t cmd, uint16_t qnum, uint16_t pf)
{
struct nfqnl_msg_config_cmd nl_cmd;
nl_cmd.command = cmd;
nl_cmd.pf = htons(pf);
struct nfqnl_msg_config_cmd nl_cmd = {.command = cmd, .pf = htons(pf)};
return netfilterSendMessage(netfilter_socket, NFQNL_MSG_CONFIG, NFQA_CFG_CMD, qnum, true, &nl_cmd, sizeof(nl_cmd));
}

Expand All @@ -157,9 +156,7 @@ static bool netfilterSetConfig(int netfilter_socket, uint8_t cmd, uint16_t qnum,
*/
static bool netfilterSetParams(int netfilter_socket, uint16_t qnumber, uint8_t mode, uint32_t range)
{
struct nfqnl_msg_config_params nl_params;
nl_params.copy_mode = mode;
nl_params.copy_range = htonl(range);
struct nfqnl_msg_config_params nl_params = {.copy_mode = mode, .copy_range = htonl(range)};
return netfilterSendMessage(netfilter_socket, NFQNL_MSG_CONFIG, NFQA_CFG_PARAMS, qnumber, true, &nl_params,
sizeof(nl_params));
}
Expand Down

0 comments on commit 0b8b534

Please sign in to comment.