Merge pull request #19372 from cotequeiroz/libgd
[feed/packages.git] / net / hping3 / patches / 080_ip_id_field.patch
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
5
6 --- a/docs/hping2.8
7 +++ b/docs/hping2.8
8 @@ -343,7 +343,7 @@ options. If in doubt try
9 .I -N --id
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.
15 .TP
16 .I -H --ipproto
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.
20 .SH SEE ALSO
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)
24 --- a/docs/hping3.8
25 +++ b/docs/hping3.8
26 @@ -352,7 +352,7 @@ options. If in doubt try
27 .I -N --id
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.
33 .TP
34 .I -H --ipproto
35 --- a/hping2.h
36 +++ b/hping2.h
37 @@ -121,7 +121,7 @@
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 */
46 --- a/parseoptions.c
47 +++ b/parseoptions.c
48 @@ -468,6 +468,10 @@ int parse_options(int argc, char **argv)
49 break;
50 case OPT_ICMP_IPID:
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;
55 + }
56 break;
57 case OPT_ICMP_IPPROTO:
58 icmp_ip_protocol = strtol(ago_optarg, NULL, 0);
59 --- a/sendicmp.c
60 +++ b/sendicmp.c
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 */
64 icmp->checksum = 0;
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;
68
69 /* data */