vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

ipv6.h (4530B)


      1 /*
      2  * Internet Protocol Version 6
      3  *
      4  * rfc2460 defines the protocol, rfc2461 neighbour discovery, and
      5  * rfc2462 address autoconfiguration.  rfc4443 defines ICMP; was rfc2463.
      6  * rfc4291 defines the address architecture (including prefices), was rfc3513.
      7  * rfc4007 defines the scoped address architecture.
      8  *
      9  * global unicast is anything but unspecified (::), loopback (::1),
     10  * multicast (ff00::/8), and link-local unicast (fe80::/10).
     11  *
     12  * site-local (fec0::/10) is now deprecated, originally by rfc3879.
     13  *
     14  * Unique Local IPv6 Unicast Addresses are defined by rfc4193.
     15  * prefix is fc00::/7, scope is global, routing is limited to roughly a site.
     16  */
     17 #define isv6mcast(addr)	  ((addr)[0] == 0xff)
     18 #define islinklocal(addr) ((addr)[0] == 0xfe && ((addr)[1] & 0xc0) == 0x80)
     19 
     20 #define optexsts(np)	(nhgets((np)->ploadlen) > 24)
     21 #define issmcast(addr)	(memcmp((addr), v6solicitednode, 13) == 0)
     22 
     23 #ifndef MIN
     24 #define MIN(a, b) ((a) <= (b)? (a): (b))
     25 #endif
     26 
     27 #undef ESP
     28 
     29 enum {				/* Header Types */
     30 	HBH		= 0,	/* hop-by-hop multicast routing protocol */
     31 	ICMP		= 1,
     32 	IGMP		= 2,
     33 	GGP		= 3,
     34 	IPINIP		= 4,
     35 	ST		= 5,
     36 	TCP		= 6,
     37 	UDP		= 17,
     38 	ISO_TP4		= 29,
     39 	RH		= 43,
     40 	FH		= 44,
     41 	IDRP		= 45,
     42 	RSVP		= 46,
     43 	AH		= 51,
     44 	ESP		= 52,
     45 	ICMPv6		= 58,
     46 	NNH		= 59,
     47 	DOH		= 60,
     48 	ISO_IP		= 80,
     49 	IGRP		= 88,
     50 	OSPF		= 89,
     51 
     52 	Maxhdrtype	= 256,
     53 };
     54 
     55 enum {
     56 	/* multicast flags and scopes */
     57 
     58 //	Well_known_flg	= 0,
     59 //	Transient_flg	= 1,
     60 
     61 //	Interface_local_scop = 1,
     62 	Link_local_scop	= 2,
     63 //	Site_local_scop	= 5,
     64 //	Org_local_scop	= 8,
     65 	Global_scop	= 14,
     66 
     67 	/* various prefix lengths */
     68 	SOLN_PREF_LEN	= 13,
     69 
     70 	/* icmpv6 unreachability codes */
     71 	Icmp6_no_route		= 0,
     72 	Icmp6_ad_prohib		= 1,
     73 	Icmp6_out_src_scope	= 2,
     74 	Icmp6_adr_unreach	= 3,
     75 	Icmp6_port_unreach	= 4,
     76 	Icmp6_gress_src_fail	= 5,
     77 	Icmp6_rej_route		= 6,
     78 	Icmp6_unknown		= 7,  /* our own invention for internal use */
     79 
     80 	/* various flags & constants */
     81 	v6MINTU		= 1280,
     82 	HOP_LIMIT	= 255,
     83 	IP6HDR		= 20,		/* sizeof(Ip6hdr) */
     84 
     85 	/* option types */
     86 
     87 	/* neighbour discovery */
     88 	SRC_LLADDR	= 1,
     89 	TARGET_LLADDR	= 2,
     90 	PREFIX_INFO	= 3,
     91 	REDIR_HEADER	= 4,
     92 	MTU_OPTION	= 5,
     93 	/* new since rfc2461; see iana.org/assignments/icmpv6-parameters */
     94 	V6nd_home	= 8,
     95 	V6nd_srcaddrs	= 9,		/* rfc3122 */
     96 	V6nd_ip		= 17,
     97 	/* /lib/rfc/drafts/draft-jeong-dnsop-ipv6-dns-discovery-12.txt */
     98 	V6nd_rdns	= 25,
     99 	/* plan 9 extensions */
    100 	V6nd_9fs	= 250,
    101 	V6nd_9auth	= 251,
    102 
    103 	SRC_UNSPEC	= 0,
    104 	SRC_UNI		= 1,
    105 	TARG_UNI	= 2,
    106 	TARG_MULTI	= 3,
    107 
    108 	Tunitent	= 1,
    109 	Tuniproxy	= 2,
    110 	Tunirany	= 3,
    111 
    112 	/* Node constants */
    113 	MAX_MULTICAST_SOLICIT	= 3,
    114 	RETRANS_TIMER		= 1000,
    115 };
    116 
    117 typedef struct Ip6hdr	Ip6hdr;
    118 typedef struct Opthdr	Opthdr;
    119 typedef struct Routinghdr Routinghdr;
    120 typedef struct Fraghdr6	Fraghdr6;
    121 
    122 struct	Ip6hdr {
    123 	uchar	vcf[4];		/* version:4, traffic class:8, flow label:20 */
    124 	uchar	ploadlen[2];	/* payload length: packet length - 40 */
    125 	uchar	proto;		/* next header type */
    126 	uchar	ttl;		/* hop limit */
    127 	uchar	src[IPaddrlen];
    128 	uchar	dst[IPaddrlen];
    129 };
    130 
    131 struct	Opthdr {
    132 	uchar	nexthdr;
    133 	uchar	len;
    134 };
    135 
    136 /*
    137  * Beware routing header type 0 (loose source routing); see
    138  * http://www.secdev.org/conf/IPv6_RH_security-csw07.pdf.
    139  * Type 1 is unused.  Type 2 is for MIPv6 (mobile IPv6) filtering
    140  * against type 0 header.
    141  */
    142 struct	Routinghdr {
    143 	uchar	nexthdr;
    144 	uchar	len;
    145 	uchar	rtetype;
    146 	uchar	segrem;
    147 };
    148 
    149 struct	Fraghdr6 {
    150 	uchar	nexthdr;
    151 	uchar	res;
    152 	uchar	offsetRM[2];	/* Offset, Res, M flag */
    153 	uchar	id[4];
    154 };
    155 
    156 extern uchar v6allnodesN[IPaddrlen];
    157 extern uchar v6allnodesL[IPaddrlen];
    158 extern uchar v6allroutersN[IPaddrlen];
    159 extern uchar v6allroutersL[IPaddrlen];
    160 extern uchar v6allnodesNmask[IPaddrlen];
    161 extern uchar v6allnodesLmask[IPaddrlen];
    162 extern uchar v6solicitednode[IPaddrlen];
    163 extern uchar v6solicitednodemask[IPaddrlen];
    164 extern uchar v6Unspecified[IPaddrlen];
    165 extern uchar v6loopback[IPaddrlen];
    166 extern uchar v6loopbackmask[IPaddrlen];
    167 extern uchar v6linklocal[IPaddrlen];
    168 extern uchar v6linklocalmask[IPaddrlen];
    169 extern uchar v6multicast[IPaddrlen];
    170 extern uchar v6multicastmask[IPaddrlen];
    171 
    172 extern int v6llpreflen;
    173 extern int v6mcpreflen;
    174 extern int v6snpreflen;
    175 extern int v6aNpreflen;
    176 extern int v6aLpreflen;
    177 
    178 extern int ReTransTimer;
    179 
    180 void ipv62smcast(uchar *, uchar *);
    181 void icmpns(Fs *f, uchar* src, int suni, uchar* targ, int tuni, uchar* mac);
    182 void icmpna(Fs *f, uchar* src, uchar* dst, uchar* targ, uchar* mac, uchar flags);
    183 void icmpttlexceeded6(Fs *f, Ipifc *ifc, Block *bp);
    184 void icmppkttoobig6(Fs *f, Ipifc *ifc, Block *bp);
    185 void icmphostunr(Fs *f, Ipifc *ifc, Block *bp, int code, int free);