]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/ip/icmp.h
snoopy(8): avoid extra spaces in dhcp filter output
[plan9front.git] / sys / src / cmd / ip / icmp.h
1 /* ICMP for IP v4 and v6 */
2 enum
3 {
4         /* Packet Types, icmp v4 (rfc 792) */
5         EchoReply       = 0,
6         Unreachable     = 3,
7         SrcQuench       = 4,
8         Redirect        = 5,
9         EchoRequest     = 8,
10         TimeExceed      = 11,
11         InParmProblem   = 12,
12         Timestamp       = 13,
13         TimestampReply  = 14,
14         InfoRequest     = 15,
15         InfoReply       = 16,
16         AddrMaskRequest = 17,
17         AddrMaskReply   = 18,
18         Traceroute      = 30,
19         IPv6WhereAreYou = 33,
20         IPv6IAmHere     = 34,
21
22         /* packet types, icmp v6 (rfc 2463) */
23
24         /* error messages */
25         UnreachableV6   = 1,
26         PacketTooBigV6  = 2,
27         TimeExceedV6    = 3,
28         ParamProblemV6  = 4,
29
30         /* informational messages (rfc 2461 also) */
31         EchoRequestV6   = 128,
32         EchoReplyV6     = 129,
33         RouterSolicit   = 133,
34         RouterAdvert    = 134,
35         NbrSolicit      = 135,
36         NbrAdvert       = 136,
37         RedirectV6      = 137,
38
39         Maxtype6        = 137,
40
41         ICMP_HDRSIZE    = 8,
42 };
43
44 typedef struct Ip4hdr Ip4hdr;
45 struct Ip4hdr
46 {
47         uchar   vihl;           /* Version and header length */
48         uchar   tos;            /* Type of service */
49         uchar   length[2];      /* packet length */
50         uchar   id[2];          /* Identification */
51         uchar   frag[2];        /* Fragment information */
52         uchar   ttl;            /* Time to live */
53         uchar   proto;          /* Protocol */
54         uchar   ipcksum[2];     /* Header checksum */
55         uchar   src[4];         /* Ipv4 source */
56         uchar   dst[4];         /* Ipv4 destination */
57
58         uchar   data[];
59 };
60
61 // #define IP4HDRSZ offsetof(Ip4hdr, data[0])
62
63 /* the icmp payload has the same format in v4 and v6 */
64 typedef struct Icmphdr Icmphdr;
65 struct Icmphdr {
66         uchar   type;
67         uchar   code;
68         uchar   cksum[2];
69         uchar   icmpid[2];
70         uchar   seq[2];
71         uchar   data[];
72 };
73
74 // #define ICMPHDRSZ offsetof(Icmphdr, data[0])