[ipv6] Implement EUI-64 generation as a function
[gpxe.git] / src / include / gpxe / ip6.h
blob6204b030b683655429d04c081305444d8ad3c891
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>
15 /* IP6 constants */
17 #define IP6_VERSION 0x6
18 #define IP6_HOP_LIMIT 255
20 /**
21 * I/O buffer contents
22 * This is duplicated in tcp.h and here. Ideally it should go into iobuf.h
24 #define MAX_HDR_LEN 100
25 #define MAX_IOB_LEN 1500
26 #define MIN_IOB_LEN MAX_HDR_LEN + 100 /* To account for padding by LL */
28 #define IP6_EQUAL( in6_addr1, in6_addr2 ) \
29 ( memcmp ( ( char* ) &( in6_addr1 ), ( char* ) &( in6_addr2 ),\
30 sizeof ( struct in6_addr ) ) == 0 )
32 #define IS_UNSPECIFIED( addr ) \
33 ( ( (addr).in6_u.u6_addr32[0] == 0x00000000 ) && \
34 ( (addr).in6_u.u6_addr32[1] == 0x00000000 ) && \
35 ( (addr).in6_u.u6_addr32[2] == 0x00000000 ) && \
36 ( (addr).in6_u.u6_addr32[3] == 0x00000000 ) )
37 /* IP6 header */
38 struct ip6_header {
39 uint32_t ver_traffic_class_flow_label;
40 uint16_t payload_len;
41 uint8_t nxt_hdr;
42 uint8_t hop_limit;
43 struct in6_addr src;
44 struct in6_addr dest;
47 /* IP6 pseudo header */
48 struct ipv6_pseudo_header {
49 struct in6_addr src;
50 struct in6_addr dest;
51 uint8_t zero_padding;
52 uint8_t nxt_hdr;
53 uint16_t len;
56 /* Next header numbers */
57 #define IP6_HOPBYHOP 0x00
58 #define IP6_ICMP6 0x3A
59 #define IP6_ROUTING 0x43
60 #define IP6_FRAGMENT 0x44
61 #define IP6_AUTHENTICATION 0x51
62 #define IP6_DEST_OPTS 0x60
63 #define IP6_ESP 0x50
64 #define IP6_NO_HEADER 0x59
66 struct io_buffer;
67 struct net_device;
68 struct net_protocol;
70 extern struct net_protocol ipv6_protocol;
71 extern struct tcpip_net_protocol ipv6_tcpip_protocol;
72 extern char * inet6_ntoa ( struct in6_addr in6 );
73 extern int inet6_aton ( const char *cp, struct in6_addr *inp );
75 void ipv6_generate_eui64 ( uint8_t *out, uint8_t *ll );
77 extern int add_ipv6_address ( struct net_device *netdev,
78 struct in6_addr prefix, int prefix_len,
79 struct in6_addr address,
80 struct in6_addr gateway );
81 extern void del_ipv6_address ( struct net_device *netdev );
83 #endif /* _GPXE_IP6_H */