[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / include / gpxe / ip6.h
blob90240ef01be70aebcb79cc1351e24b182873662d
1 #ifndef _GPXE_IP6_H
2 #define _GPXE_IP6_H
4 /** @file
6 * IP6 protocol
8 */
10 FILE_LICENCE ( GPL2_OR_LATER );
12 #include <stdint.h>
13 #include <gpxe/in.h>
14 #include <gpxe/tcpip.h>
15 #include <gpxe/retry.h>
17 /* IP6 constants */
19 #define IP6_VERSION 0x6
20 #define IP6_HOP_LIMIT 255
22 #define IP6_FRAG_IOB_SIZE 2000
23 #define IP6_FRAG_TIMEOUT 50
25 #define IP6_MORE_FRAGMENTS 0x01
27 /**
28 * I/O buffer contents
29 * This is duplicated in tcp.h and here. Ideally it should go into iobuf.h
31 #define MAX_HDR_LEN 100
32 #define MAX_IOB_LEN 1500
33 #define MIN_IOB_LEN MAX_HDR_LEN + 100 /* To account for padding by LL */
35 #define IP6_EQUAL( in6_addr1, in6_addr2 ) \
36 ( memcmp ( ( char* ) &( in6_addr1 ), ( char* ) &( in6_addr2 ),\
37 sizeof ( struct in6_addr ) ) == 0 )
39 #define IS_UNSPECIFIED( addr ) \
40 ( ( (addr).in6_u.u6_addr32[0] == 0x00000000 ) && \
41 ( (addr).in6_u.u6_addr32[1] == 0x00000000 ) && \
42 ( (addr).in6_u.u6_addr32[2] == 0x00000000 ) && \
43 ( (addr).in6_u.u6_addr32[3] == 0x00000000 ) )
45 /* IP6 header */
46 struct ip6_header {
47 uint32_t ver_traffic_class_flow_label;
48 uint16_t payload_len;
49 uint8_t nxt_hdr;
50 uint8_t hop_limit;
51 struct in6_addr src;
52 struct in6_addr dest;
55 /* IP6 pseudo header */
56 struct ipv6_pseudo_header {
57 struct in6_addr src;
58 struct in6_addr dest;
59 uint8_t zero_padding;
60 uint8_t nxt_hdr;
61 uint16_t len;
64 /* IP6 option header */
65 struct ip6_opt_hdr {
66 uint8_t type;
67 uint8_t len;
70 /* IP6 fragment header */
71 struct ip6_frag_hdr {
72 uint8_t next_hdr;
73 uint8_t rsvd;
74 uint16_t offset_flags;
75 uint32_t ident;
78 /* Fragment reassembly buffer */
79 struct frag_buffer {
80 /* "Next Header" for the packet. */
81 uint8_t next_hdr;
82 /* Identification number */
83 uint32_t ident;
84 /* Source network address */
85 struct in6_addr src;
86 /* Destination network address */
87 struct in6_addr dest;
88 /* Reassembled I/O buffer */
89 struct io_buffer *frag_iob;
90 /* Reassembly timer */
91 struct retry_timer frag_timer;
92 /* List of fragment reassembly buffers */
93 struct list_head list;
96 /* Next header numbers */
97 #define IP6_HOPBYHOP_FIRST 0x00
98 #define IP6_HOPBYHOP 0xFE
99 #define IP6_PAD 0x00
100 #define IP6_PADN 0x01
101 #define IP6_ICMP6 0x3A
102 #define IP6_ROUTING 0x2B
103 #define IP6_FRAGMENT 0x2C
104 #define IP6_AUTHENTICATION 0x33
105 #define IP6_DEST_OPTS 0x3C
106 #define IP6_ESP 0x32
107 #define IP6_NO_HEADER 0x3B
109 struct io_buffer;
110 struct net_device;
111 struct net_protocol;
113 extern struct net_protocol ipv6_protocol;
114 extern struct tcpip_net_protocol ipv6_tcpip_protocol;
115 extern char * inet6_ntoa ( struct in6_addr in6 );
116 extern int inet6_aton ( const char *cp, struct in6_addr *inp );
118 void ipv6_generate_eui64 ( uint8_t *out, uint8_t *ll );
120 int ipv6_match_prefix ( struct in6_addr *p1, struct in6_addr *p2, size_t len );
122 extern int add_ipv6_address ( struct net_device *netdev,
123 struct in6_addr prefix, int prefix_len,
124 struct in6_addr address,
125 struct in6_addr gateway );
126 extern void del_ipv6_address ( struct net_device *netdev );
128 extern int ipv6_tx ( struct io_buffer *iobuf,
129 struct tcpip_protocol *tcpip,
130 struct sockaddr_tcpip *st_src,
131 struct sockaddr_tcpip *st_dest,
132 struct net_device *netdev,
133 uint16_t *trans_csum );
135 #endif /* _GPXE_IP6_H */