iproute.c compiles
[akaros.git] / kern / src / net / ipv6.h
1 #define MIN(a, b) ((a) <= (b) ? (a) : (b))
2
3 /* rfc 3513 defines the address prefices */
4 #define isv6mcast(addr)   ((addr)[0] == 0xff)
5 #define islinklocal(addr) ((addr)[0] == 0xfe && ((addr)[1] & 0xc0) == 0x80)
6 #define issitelocal(addr) ((addr)[0] == 0xfe && ((addr)[1] & 0xc0) == 0xc0)
7 #define isv6global(addr) (((addr)[0] & 0xe0) == 0x20)
8
9 #define optexsts(np) (nhgets((np)->ploadlen) > 24)
10 #define issmcast(addr) (memcmp((addr), v6solicitednode, 13) == 0)
11
12 /* from RFC 2460 */
13
14 typedef struct Ip6hdr     Ip6hdr;
15 typedef struct Opthdr     Opthdr;
16 typedef struct Routinghdr Routinghdr;
17 typedef struct Fraghdr6    Fraghdr6;
18
19 struct Ip6hdr {
20         uchar vcf[4];           // version:4, traffic class:8, flow label:20
21         uchar ploadlen[2];      // payload length: packet length - 40
22         uchar proto;            // next header type
23         uchar ttl;              // hop limit
24         uchar src[IPaddrlen];
25         uchar dst[IPaddrlen];
26 };
27
28 struct Opthdr {
29         uchar nexthdr;
30         uchar len;
31 };
32
33 struct Routinghdr {
34         uchar nexthdr;
35         uchar len;
36         uchar rtetype;
37         uchar segrem;
38 };
39
40 struct Fraghdr6 {
41         uchar nexthdr;
42         uchar res;
43         uchar offsetRM[2];      // Offset, Res, M flag
44         uchar id[4];
45 };
46
47
48 enum {                  /* Header Types */
49         HBH             = 0,    //?
50         ICMP            = 1,
51         IGMP            = 2,
52         GGP             = 3,
53         IPINIP          = 4,
54         ST              = 5,
55         TCP             = 6,
56         UDP             = 17,
57         ISO_TP4         = 29,
58         RH              = 43,
59         FH              = 44,
60         IDRP            = 45,
61         RSVP            = 46,
62         AH              = 51,
63         ESP             = 52,
64         ICMPv6          = 58,
65         NNH             = 59,
66         DOH             = 60,
67         ISO_IP          = 80,
68         IGRP            = 88,
69         OSPF            = 89,
70
71         Maxhdrtype      = 256,
72 };
73
74
75 enum {
76         //      multicast flgs and scop
77
78         well_known_flg                          = 0,
79         transient_flg                           = 1,
80
81         node_local_scop                         = 1,
82         link_local_scop                         = 2,
83         site_local_scop                         = 5,
84         org_local_scop                          = 8,
85         global_scop                             = 14,
86
87         //      various prefix lengths
88
89         SOLN_PREF_LEN                           = 13,
90
91         //      icmpv6 unreach codes
92         icmp6_no_route                          = 0,
93         icmp6_ad_prohib                         = 1,
94         icmp6_unassigned                        = 2,
95         icmp6_adr_unreach                       = 3,
96         icmp6_port_unreach                      = 4,
97         icmp6_unkn_code                         = 5,
98
99         //      various flags & constants
100
101         v6MINTU                                 = 1280,
102         HOP_LIMIT                               = 255,
103         ETHERHDR_LEN                            = 14,
104         IPV6HDR_LEN                             = 40,
105         IPV4HDR_LEN                             = 20,
106
107         //      option types
108
109         SRC_LLADDRESS                           = 1,
110         TARGET_LLADDRESS                        = 2,
111         PREFIX_INFO                             = 3,
112         REDIR_HEADER                            = 4,
113         MTU_OPTION                              = 5,
114
115         SRC_UNSPEC                              = 0,
116         SRC_UNI                                 = 1,
117         TARG_UNI                                = 2,
118         TARG_MULTI                              = 3,
119
120         t_unitent                               = 1,
121         t_uniproxy                              = 2,
122         t_unirany                               = 3,
123
124         //      Router constants (all times in milliseconds)
125
126         MAX_INITIAL_RTR_ADVERT_INTERVAL         = 16000,
127         MAX_INITIAL_RTR_ADVERTISEMENTS          = 3,
128         MAX_FINAL_RTR_ADVERTISEMENTS            = 3,
129         MIN_DELAY_BETWEEN_RAS                   = 3000,
130         MAX_RA_DELAY_TIME                       = 500,
131
132         //      Host constants
133
134         MAX_RTR_SOLICITATION_DELAY              = 1000,
135         RTR_SOLICITATION_INTERVAL               = 4000,
136         MAX_RTR_SOLICITATIONS                   = 3,
137
138         //      Node constants
139
140         MAX_MULTICAST_SOLICIT                   = 3,
141         MAX_UNICAST_SOLICIT                     = 3,
142         MAX_ANYCAST_DELAY_TIME                  = 1000,
143         MAX_NEIGHBOR_ADVERTISEMENT              = 3,
144         REACHABLE_TIME                          = 30000,
145         RETRANS_TIMER                           = 1000,
146         DELAY_FIRST_PROBE_TIME                  = 5000,
147
148 };
149
150 extern void ipv62smcast(uchar *, uchar *);
151 extern void icmpns(Fs *f, uchar* src, int suni, uchar* targ, int tuni, uchar* mac);
152 extern void icmpna(Fs *f, uchar* src, uchar* dst, uchar* targ, uchar* mac, uchar flags);
153 extern void icmpttlexceeded6(Fs *f, Ipifc *ifc, Block *bp);
154 extern void icmppkttoobig6(Fs *f, Ipifc *ifc, Block *bp);
155 extern void icmphostunr(Fs *f, Ipifc *ifc, Block *bp, int code, int free);
156
157 extern uchar v6allnodesN[IPaddrlen];
158 extern uchar v6allnodesL[IPaddrlen];
159 extern uchar v6allroutersN[IPaddrlen];
160 extern uchar v6allroutersL[IPaddrlen];
161 extern uchar v6allnodesNmask[IPaddrlen];
162 extern uchar v6allnodesLmask[IPaddrlen];
163 extern uchar v6allroutersS[IPaddrlen];
164 extern uchar v6solicitednode[IPaddrlen];
165 extern uchar v6solicitednodemask[IPaddrlen];
166 extern uchar v6Unspecified[IPaddrlen];
167 extern uchar v6loopback[IPaddrlen];
168 extern uchar v6loopbackmask[IPaddrlen];
169 extern uchar v6linklocal[IPaddrlen];
170 extern uchar v6linklocalmask[IPaddrlen];
171 extern uchar v6sitelocal[IPaddrlen];
172 extern uchar v6sitelocalmask[IPaddrlen];
173 extern uchar v6glunicast[IPaddrlen];
174 extern uchar v6multicast[IPaddrlen];
175 extern uchar v6multicastmask[IPaddrlen];
176
177 extern int v6llpreflen;
178 extern int v6slpreflen;
179 extern int v6lbpreflen;
180 extern int v6mcpreflen;
181 extern int v6snpreflen;
182 extern int v6aNpreflen;
183 extern int v6aLpreflen;
184
185 extern int ReTransTimer;