OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / user / hping / usage.c
1 /* 
2  * $smu-mark$ 
3  * $name: usage.c$ 
4  * $author: Salvatore Sanfilippo <antirez@invece.org>$ 
5  * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$ 
6  * $license: This software is under GPL version 2 of license$ 
7  * $date: Fri Nov  5 11:55:50 MET 1999$ 
8  * $rev: 8$ 
9  */ 
10
11 /* $Id: usage.c,v 1.2 2004/06/18 09:53:11 antirez Exp $ */
12
13 #include <stdlib.h>
14 #include <stdio.h>
15
16 void    show_usage(void)
17 {
18         printf(
19 "usage: hping host [options]\n"
20 "  -h  --help      show this help\n"
21 "  -v  --version   show version\n"
22 "  -c  --count     packet count\n"
23 "  -i  --interval  wait (uX for X microseconds, for example -i u1000)\n"
24 "      --fast      alias for -i u10000 (10 packets for second)\n"
25 "      --faster    alias for -i u1000 (100 packets for second)\n"
26 "      --flood     sent packets as fast as possible. Don't show replies.\n"
27 "  -n  --numeric   numeric output\n"
28 "  -q  --quiet     quiet\n"
29 "  -I  --interface interface name (otherwise default routing interface)\n"
30 "  -V  --verbose   verbose mode\n"
31 "  -D  --debug     debugging info\n"
32 "  -z  --bind      bind ctrl+z to ttl           (default to dst port)\n"
33 "  -Z  --unbind    unbind ctrl+z\n"
34 "      --beep      beep for every matching packet received\n"
35 "Mode\n"
36 "  default mode     TCP\n"
37 "  -0  --rawip      RAW IP mode\n"
38 "  -1  --icmp       ICMP mode\n"
39 "  -2  --udp        UDP mode\n"
40 "  -8  --scan       SCAN mode.\n"
41 "                   Example: hping --scan 1-30,70-90 -S www.target.host\n"
42 "  -9  --listen     listen mode\n"
43 "IP\n"
44 "  -a  --spoof      spoof source address\n"
45 "  --rand-dest      random destionation address mode. see the man.\n"
46 "  --rand-source    random source address mode. see the man.\n"
47 "  -t  --ttl        ttl (default 64)\n"
48 "  -N  --id         id (default random)\n"
49 "  -W  --winid      use win* id byte ordering\n"
50 "  -r  --rel        relativize id field          (to estimate host traffic)\n"
51 "  -f  --frag       split packets in more frag.  (may pass weak acl)\n"
52 "  -x  --morefrag   set more fragments flag\n"
53 "  -y  --dontfrag   set dont fragment flag\n"
54 "  -g  --fragoff    set the fragment offset\n"
55 "  -m  --mtu        set virtual mtu, implies --frag if packet size > mtu\n"
56 "  -o  --tos        type of service (default 0x00), try --tos help\n"
57 "  -G  --rroute     includes RECORD_ROUTE option and display the route buffer\n"
58 "  --lsrr           loose source routing and record route\n"
59 "  --ssrr           strict source routing and record route\n"
60 "  -H  --ipproto    set the IP protocol field, only in RAW IP mode\n"
61 "ICMP\n"
62 "  -C  --icmptype   icmp type (default echo request)\n"
63 "  -K  --icmpcode   icmp code (default 0)\n"
64 "      --force-icmp send all icmp types (default send only supported types)\n"
65 "      --icmp-gw    set gateway address for ICMP redirect (default 0.0.0.0)\n"
66 "      --icmp-ts    Alias for --icmp --icmptype 13 (ICMP timestamp)\n"
67 "      --icmp-addr  Alias for --icmp --icmptype 17 (ICMP address subnet mask)\n"
68 "      --icmp-help  display help for others icmp options\n"
69 "UDP/TCP\n"
70 "  -s  --baseport   base source port             (default random)\n"
71 "  -p  --destport   [+][+]<port> destination port(default 0) ctrl+z inc/dec\n"
72 "  -k  --keep       keep still source port\n"
73 "  -w  --win        winsize (default 64)\n"
74 "  -O  --tcpoff     set fake tcp data offset     (instead of tcphdrlen / 4)\n"
75 "  -Q  --seqnum     shows only tcp sequence number\n"
76 "  -b  --badcksum   (try to) send packets with a bad IP checksum\n"
77 "                   many systems will fix the IP checksum sending the packet\n"
78 "                   so you'll get bad UDP/TCP checksum instead.\n"
79 "  -M  --setseq     set TCP sequence number\n"
80 "  -L  --setack     set TCP ack\n"
81 "  -F  --fin        set FIN flag\n"
82 "  -S  --syn        set SYN flag\n"
83 "  -R  --rst        set RST flag\n"
84 "  -P  --push       set PUSH flag\n"
85 "  -A  --ack        set ACK flag\n"
86 "  -U  --urg        set URG flag\n"
87 "  -X  --xmas       set X unused flag (0x40)\n"
88 "  -Y  --ymas       set Y unused flag (0x80)\n"
89 "  --tcpexitcode    use last tcp->th_flags as exit code\n"
90 "  --tcp-timestamp  enable the TCP timestamp option to guess the HZ/uptime\n"
91 "Common\n"
92 "  -d  --data       data size                    (default is 0)\n"
93 "  -E  --file       data from file\n"
94 "  -e  --sign       add 'signature'\n"
95 "  -j  --dump       dump packets in hex\n"
96 "  -J  --print      dump printable characters\n"
97 "  -B  --safe       enable 'safe' protocol\n"
98 "  -u  --end        tell you when --file reached EOF and prevent rewind\n"
99 "  -T  --traceroute traceroute mode              (implies --bind and --ttl 1)\n"
100 "  --tr-stop        Exit when receive the first not ICMP in traceroute mode\n"
101 "  --tr-keep-ttl    Keep the source TTL fixed, useful to monitor just one hop\n"
102 "  --tr-no-rtt      Don't calculate/show RTT information in traceroute mode\n"
103 "ARS packet description (new, unstable)\n"
104 "  --apd-send       Send the packet described with APD (see docs/APD.txt)\n"
105         );
106         exit(0);
107 };
108
109 void tos_help(void)
110 {
111         printf(
112 "tos help:\n"
113 "          TOS Name                Hex Value           Typical Uses\n"
114 "\n"
115 "       Minimum Delay                 10               ftp, telnet\n"
116 "       Maximum Throughput            08               ftp-data\n"
117 "       Maximum Reliability           04               snmp\n"
118 "       Minimum Cost                  02               nntp\n"
119         );
120         exit(0);
121 }
122
123 void icmp_help(void)
124 {
125         printf(
126 "ICMP help:\n"
127 " ICMP concerned packet options:\n"
128 "  --icmp-ipver     set ip version               ( default 4 )\n"
129 "  --icmp-iphlen    set ip header lenght         ( default IPHDR_SIZE >> 2)\n"
130 "  --icmp-iplen     set ip total lengtht         ( default real lenght )\n"
131 "  --icmp-ipid      set ip id                    ( default random )\n"
132 "  --icmp-ipproto   set ip protocol              ( default IPPROTO_TCP )\n"
133 "  --icmp-ipsrc     set ip source                ( default 0.0.0.0 )\n"
134 "  --icmp-ipdst     set ip destination           ( default 0.0.0.0 )\n"
135 "  --icmp-srcport   set tcp/udp source port      ( default random )\n"
136 "  --icmp-dstport   set tcp/udp destination port ( default random )\n"
137 "  --icmp-cksum     set icmp checksum            ( default the right cksum)\n"
138         );
139         exit(0);
140 }
141
142 void route_help(void)
143 {
144     printf(
145 "route help:\n"
146 "       A route has the following format: [ptr:]IP1[/IP2[/IP3...]]\n"
147 "       where ptr is the exact value of the pointer that will be used for the IP\n"
148 "       option (be careful, no check is performed on this pointer), and defaults\n"
149 "       to 8, or 4 if provided route is too short for 8;\n"
150 "       and each IPx field is an IP address to include in the source route.\n");
151 }