1 Subject: Fix "-N" command line argument
2 Author: Guillaume Delacour <gui@iroqwa.org>
3 Bug-Debian: http://bugs.debian.org/482844
4 Last-Update: 2009-05-13
8 @@ -343,7 +343,7 @@ options. If in doubt try
10 Set ip->id field. Default id is random but if fragmentation is turned on
11 and id isn't specified it will be
12 -.BR "getpid() & 0xFF" ,
13 +.BR "getpid() & 0xFFFF" ,
14 to implement a better solution is in TODO list.
17 @@ -714,4 +714,4 @@ On solaris hping does not work on the lo
18 a solaris problem, as stated in the tcpdump-workers mailing list,
19 so the libpcap can't do nothing to handle it properly.
21 -ping(8), traceroute(8), ifconfig(8), nmap(1)
22 \ No newline at end of file
23 +ping(8), traceroute(8), ifconfig(8), nmap(1)
26 @@ -352,7 +352,7 @@ options. If in doubt try
28 Set ip->id field. Default id is random but if fragmentation is turned on
29 and id isn't specified it will be
30 -.BR "getpid() & 0xFF" ,
31 +.BR "getpid() & 0xFFFF" ,
32 to implement a better solution is in TODO list.
38 #define DEFAULT_ICMP_IP_IHL (IPHDR_SIZE >> 2)
39 #define DEFAULT_ICMP_IP_TOS 0
40 #define DEFAULT_ICMP_IP_TOT_LEN 0 /* computed by send_icmp_*() */
41 -#define DEFAULT_ICMP_IP_ID 0 /* rand */
42 +#define DEFAULT_ICMP_IP_ID -1 /* rand */
43 #define DEFAULT_ICMP_CKSUM -1 /* -1 means compute the cksum */
44 #define DEFAULT_ICMP_IP_PROTOCOL 6 /* TCP */
45 #define DEFAULT_RAW_IP_PROTOCOL 6 /* TCP */
48 @@ -468,6 +468,10 @@ int parse_options(int argc, char **argv)
51 icmp_ip_id = strtol(ago_optarg, NULL, 0);
52 + if (icmp_ip_id < 0 || icmp_ip_id > 0xffff) {
53 + fprintf(stderr, "Bad ICMP IP ID, resetting to random.\n");
54 + icmp_ip_id = DEFAULT_ICMP_IP_ID;
57 case OPT_ICMP_IPPROTO:
58 icmp_ip_protocol = strtol(ago_optarg, NULL, 0);
61 @@ -83,7 +83,7 @@ void send_icmp_echo(void)
62 icmp->type = opt_icmptype; /* echo replay or echo request */
63 icmp->code = opt_icmpcode; /* should be indifferent */
65 - icmp->un.echo.id = getpid() & 0xffff;
66 + icmp->un.echo.id = icmp_ip_id == DEFAULT_ICMP_IP_ID ? getpid() & 0xffff : icmp_ip_id;
67 icmp->un.echo.sequence = _icmp_seq;