pkgsrc/net/hping/patches/patch-aa
obache dca4ca3df8 * detection of endian in bytesex.h is not enough, use result of byteorder.h.
* replace hard coded user and mode for hping-suid option with SPECIAL_PERMS.
* replace remaining of hard coded "man" with ${PKGMANDIR}.
* add DESTDIR support.
* merge patch-a{e,g}, both for same file.
* patch to replace __sun__ with __sun for portability, pkglint(1) said.
* also regen other patches with mkpatches(1).
2009-02-11 08:06:17 +00:00

76 lines
1.7 KiB
Text

$NetBSD: patch-aa,v 1.4 2009/02/11 08:06:17 obache Exp $
--- main.c.orig 2003-08-07 23:55:55.000000000 +0000
+++ main.c
@@ -47,7 +47,8 @@ unsigned int
signlen,
lsr_length = 0,
ssr_length = 0,
- tcp_ack;
+ tcp_ack,
+ tcp_mss;
unsigned short int
@@ -65,6 +66,7 @@ int
recv_pkt = 0,
out_of_sequence_pkt = 0,
sending_wait = DEFAULT_SENDINGWAIT, /* see DEFAULT_SENDINGWAIT */
+ opt_flood = FALSE,
opt_rawipmode = FALSE,
opt_icmpmode = FALSE,
opt_udpmode = FALSE,
@@ -98,6 +100,7 @@ int
opt_tcpexitcode = FALSE,
opt_badcksum = FALSE,
opt_tr_keep_ttl = FALSE,
+ opt_tcp_mss = FALSE,
opt_tcp_timestamp = FALSE,
opt_tr_stop = FALSE,
opt_tr_no_rtt = FALSE,
@@ -179,6 +182,17 @@ int main(int argc, char **argv)
char setflags[1024] = {'\0'};
int c, hdr_size;
+ /* open raw socket */
+ sockraw = open_sockraw();
+ if (sockraw == -1) {
+ printf("[main] can't open raw socket\n");
+ exit(1);
+ }
+ if (getuid() && setuid(getuid()) == -1) {
+ printf("[main] can't drop privs\n");
+ exit(1);
+ }
+
if (parse_options(argc, argv) == -1) {
printf("hping2: missing host argument\n"
"Try `hping2 --help' for more information.\n");
@@ -219,13 +233,6 @@ int main(int argc, char **argv)
ifname, ifstraddr, h_if_mtu);
}
- /* open raw socket */
- sockraw = open_sockraw();
- if (sockraw == -1) {
- printf("[main] can't open raw socket\n");
- exit(1);
- }
-
/* set SO_BROADCAST option */
socket_broadcast(sockraw);
/* set SO_IPHDRINCL option */
@@ -355,6 +362,13 @@ int main(int argc, char **argv)
}
}
+ /* flood mode */
+ if (opt_flood) {
+ printf("Flooding...\n");
+ for (;;)
+ send_packet(0 /* dummy */);
+ }
+
/* start packet sending */
kill(getpid(), SIGALRM);