Skip to content

Commit

Permalink
Add pfsend option 0
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Dec 21, 2023
1 parent 1930fc0 commit 3e9222d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion userland/examples/pfsend.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ void printHelp(void) {
printf("-o <num> Offset for generated IPs (-b) or packets in pcap (-f)\n");
printf("-W <ID>[,<ID>] Forge VLAN packets with the specified VLAN ID (and QinQ ID if specified after comma)\n");
printf("-L <num> Forge VLAN packets with <num> different ids\n");
printf("-0 <char> Fill packet payload with the specified character (default: 0)\n");
printf("-F Force flush for each packet (to avoid bursts, expect low performance)\n");
printf("-w <watermark> TX watermark (low value=low latency) [not effective on ZC]\n");
printf("-d Daemon mode\n");
Expand Down Expand Up @@ -466,7 +467,7 @@ int main(int argc, char* argv[]) {
srcaddr.s_addr = 0x0100000A /* 10.0.0.1 */;
dstaddr.s_addr = 0x0100A8C0 /* 192.168.0.1 */;

while((c = getopt(argc, argv, "A:b:B:c:dD:hi:n:g:G:l:L:o:Oaf:Fr:vm:M:p:P:S:t:V:w:W:z8:")) != -1) {
while((c = getopt(argc, argv, "A:b:B:c:dD:hi:n:g:G:l:L:o:Oaf:Fr:vm:M:p:P:S:t:V:w:W:z8:0:")) != -1) {
switch(c) {
case 'A':
uniq_pkts_per_sec = atoi(optarg);
Expand Down Expand Up @@ -605,6 +606,9 @@ int main(int argc, char* argv[]) {
case '8':
pkt_loop = atoi(optarg);
break;
case '0':
packet_content = optarg[0];
break;
default:
printHelp();
}
Expand Down
3 changes: 2 additions & 1 deletion userland/examples/pfutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ static int num_vlan = 1;
static int forge_payload = 0;
static char srcmac[6] = { 0 }, dstmac[6] = { 0 };
static struct in_addr srcaddr = { 0 }, dstaddr = { 0 };
static char packet_content = 0;

static void forge_udp_packet(u_char *buffer, u_int buffer_len, u_int idx, u_int ip_version) {
struct eth_vlan_hdr *vlan;
Expand All @@ -242,7 +243,7 @@ static void forge_udp_packet(u_char *buffer, u_int buffer_len, u_int idx, u_int
int l2_len, ip_len, addr_len, i, payload_off;

/* Reset packet */
memset(buffer, 0, buffer_len);
memset(buffer, packet_content, buffer_len);

l2_len = sizeof(struct ether_header);

Expand Down

0 comments on commit 3e9222d

Please sign in to comment.