Skip to content

Commit

Permalink
Clean up more code.
Browse files Browse the repository at this point in the history
  • Loading branch information
gamemann committed May 13, 2024
1 parent ae1adba commit 491793d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "main.h"

struct config *cfg = NULL;
config_t *cfg = NULL;

/**
* Signal handler to shut down the program.
Expand All @@ -24,7 +24,7 @@ int main(int argc, char *argv[])
{
// Create command line structure.
opterr = 0;
struct cmd_line cmd = {0};
cmd_line_t cmd = {0};

// Parse command line and store values into cmd.
parse_cmd_line(argc, argv, &cmd);
Expand All @@ -38,7 +38,7 @@ int main(int argc, char *argv[])
}

// Create AF_XDP-specific command line variable and set defaults.
struct cmd_line_af_xdp cmd_af_xdp = {0};
cmd_line_af_xdp_t cmd_af_xdp = {0};
cmd_af_xdp.batch_size = 1;

// Parse AF_XDP-specific command line.
Expand All @@ -62,7 +62,7 @@ int main(int argc, char *argv[])
}

// Create config structure.
cfg = malloc(sizeof(struct config));
cfg = malloc(sizeof(config_t));
memset(cfg, 0, sizeof(*cfg));

int seq_cnt = 0;
Expand Down
14 changes: 7 additions & 7 deletions src/sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void *thread_hdl(void *temp)
// Perform payload checks.
for (int i = 0; i < ti->seq.pl_cnt; i++)
{
struct payload_opt *pl = &ti->seq.pls[i];
payload_opt_t *pl = &ti->seq.pls[i];
u8 *pl_buff = payloads[i];

if (pl->exact != NULL)
Expand Down Expand Up @@ -361,7 +361,7 @@ void *thread_hdl(void *temp)
{
ti->seq.pl_cnt = 1;

struct payload_opt *pl = &ti->seq.pls[0];
payload_opt_t *pl = &ti->seq.pls[0];
pl->is_static = 1;

// Calculate lengths.
Expand Down Expand Up @@ -523,7 +523,7 @@ void *thread_hdl(void *temp)
for (int i = 0; i < ti->seq.pl_cnt; i++)
{
// Retrieve payload at index.
struct payload_opt *pl = &ti->seq.pls[i];
payload_opt_t *pl = &ti->seq.pls[i];

// Check if we need to calculate random payload.
if (pl->is_static)
Expand Down Expand Up @@ -702,7 +702,7 @@ void *thread_hdl(void *temp)
*
* @return Void
**/
void seq_send(const char *interface, struct sequence seq, u16 seq_cnt2, struct cmd_line cmd)
void seq_send(const char *interface, sequence_t seq, u16 seq_cnt2, cmd_line_t cmd)
{
// First, let's check if the destination IP is set.
if (seq.ip.dst_ip == NULL)
Expand All @@ -717,7 +717,7 @@ void seq_send(const char *interface, struct sequence seq, u16 seq_cnt2, struct c

// Assign correct values to thread info.
strcpy((char *)&ti.device, interface);
memcpy(&ti.seq, &seq, sizeof(struct sequence));
memcpy(&ti.seq, &seq, sizeof(sequence_t));

// Copy command line.
ti.cmd = cmd;
Expand Down Expand Up @@ -761,7 +761,7 @@ void seq_send(const char *interface, struct sequence seq, u16 seq_cnt2, struct c
*
* @return Void
*/
void shutdown_prog(struct config *cfg)
void shutdown_prog(config_t *cfg)
{
for (int i = 0; i < thread_cnt; i++)
{
Expand All @@ -773,7 +773,7 @@ void shutdown_prog(struct config *cfg)
// Check if we need to print tracked stats.
for (int i = 0; i < seq_cnt; i++)
{
struct sequence *seq = &cfg->seq[i];
sequence_t *seq = &cfg->seq[i];

if (seq->track)
{
Expand Down

0 comments on commit 491793d

Please sign in to comment.