Skip to content

Commit

Permalink
Fix on the fly packets generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed May 10, 2024
1 parent 50ec42b commit 0d18b18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions userland/examples/pfsend.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ int main(int argc, char* argv[]) {
int randomize = 0;
int reforging_idx;
int stdin_packet_len = 0;
int num_ports = 1;
u_int ip_v = 4;
int flush = 0;
char *bpfFilter = NULL;
Expand Down Expand Up @@ -943,8 +942,9 @@ int main(int argc, char* argv[]) {
i = 0;
reforging_idx = 0;

if (uniq_pkts_per_sec) /* init limit */
if (uniq_pkts_per_sec) { /* init limit */
uniq_pkts_limit = uniq_pkts_per_sec;
}

pfring_set_application_stats(pd, "Statistics not yet computed: please try again...");
if(pfring_get_appl_stats_file_name(pd, path, sizeof(path)) != NULL)
Expand Down
3 changes: 2 additions & 1 deletion userland/examples/pfutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static u_int32_t wrapsum (u_int32_t sum) {

static int compute_csum = 1;
static int num_ips = 1;
static int num_ports = 1;
static int balance_source_ips = 1;

static u_char matrix_buffer[
Expand Down Expand Up @@ -309,7 +310,7 @@ static void forge_udp_packet(u_char *buffer, u_int buffer_len, u_int idx, u_int
}

udp = (struct compact_udp_hdr *)(buffer + l2_len + ip_len);
udp->sport = htons(2012 + (idx / num_ips));
udp->sport = htons(2012 + ((num_ports > 1) ? (idx / num_ips) : 0));
udp->dport = htons(3000);
udp->len = htons(buffer_len - l2_len - ip_len);
udp->check = 0; /* It must be 0 to compute the checksum */
Expand Down

0 comments on commit 0d18b18

Please sign in to comment.