Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect the count option in flood mode. #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* $smu-mark$
* $name: main.c$
* $author: Salvatore Sanfilippo <[email protected]>$
* $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
* $license: This software is under GPL version 2 of license$
* $date: Fri Nov 5 11:55:48 MET 1999$
* $rev: 8$
*/
/*
* $smu-mark$
* $name: main.c$
* $author: Salvatore Sanfilippo <[email protected]>$
* $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
* $license: This software is under GPL version 2 of license$
* $date: Fri Nov 5 11:55:48 MET 1999$
* $rev: 8$
*/

/*
* hping official page at http://www.kyuzz.org/antirez
Expand Down Expand Up @@ -344,7 +344,7 @@ int main(int argc, char **argv)
if (setflags[0] == '\0') strcat(setflags, "NO FLAGS are");
hdr_size = IPHDR_SIZE + TCPHDR_SIZE;
}

printf("HPING %s (%s %s): %s set, %d headers + %d data bytes\n",
targetname,
ifname,
Expand All @@ -371,8 +371,17 @@ int main(int argc, char **argv)
if (opt_flood) {
fprintf(stderr,
"hping in flood mode, no replies will be shown\n");
while (1) {
send_packet(0);
/* Respect the count option in flood mode, but don't add the extra bookkeeping if it's not set.
* If this is too slow, maybe unroll the loop and send 10 or 1000 in each iteration. */
if(count != -1) {
long countdown = count - 1; /* Already sent one packet above. */
while(countdown--) {
send_packet(0);
}
} else {
while (1) {
send_packet(0);
}
}
}

Expand Down