[ipv6] Fix router solicitation struct and flag checking
[gpxe.git] / src / include / gpxe / ndp.h
blob30b4f7ad2fc6d88d973400b501b120749e94df84
1 #ifndef _GPXE_NDP_H
2 #define _GPXE_NDP_H
4 #include <stdint.h>
5 #include <byteswap.h>
6 #include <string.h>
7 #include <gpxe/ip6.h>
8 #include <gpxe/in.h>
9 #include <gpxe/netdevice.h>
10 #include <gpxe/iobuf.h>
11 #include <gpxe/tcpip.h>
13 struct icmp6_net_protocol;
14 struct job_interface;
16 #define NDP_STATE_INVALID 0
17 #define NDP_STATE_INCOMPLETE 1
18 #define NDP_STATE_REACHABLE 2
19 #define NDP_STATE_DELAY 3
20 #define NDP_STATE_PROBE 4
21 #define NDP_STATE_STALE 5
23 #define RSOLICIT_STATE_INVALID 0
24 #define RSOLICIT_STATE_PENDING 1
25 #define RSOLICIT_STATE_COMPLETE 2
26 #define RSOLICIT_STATE_ALMOST 3
28 #define RSOLICIT_CODE_NONE 0
29 #define RSOLICIT_CODE_MANAGED 1
30 #define RSOLICIT_CODE_OTHERCONF 2
32 #define NDP_OPTION_SOURCE_LL 1
33 #define NDP_OPTION_TARGET_LL 2
34 #define NDP_OPTION_PREFIX_INFO 3
35 #define NDP_OPTION_REDIRECT 4
36 #define NDP_OPTION_MTU 5
38 struct rsolicit_info {
39 struct in6_addr router;
40 struct in6_addr prefix;
41 int prefix_length;
42 int no_address; /* No address assignment takes place via this adv. */
45 struct neighbour_solicit {
46 uint8_t type;
47 uint8_t code;
48 uint16_t csum;
49 uint32_t reserved;
50 struct in6_addr target;
53 struct neighbour_advert {
54 uint8_t type;
55 uint8_t code;
56 uint16_t csum;
57 uint8_t flags;
58 uint8_t reserved;
59 struct in6_addr target;
62 struct router_solicit {
63 uint8_t type;
64 uint8_t code;
65 uint16_t csum;
66 uint32_t reserved;
69 struct router_advert {
70 uint8_t type;
71 uint8_t code;
72 uint16_t csum;
73 uint8_t hop_limit;
74 uint8_t rsvd_flags;
75 uint16_t lifetime;
76 uint32_t reachable_time;
77 uint32_t retrans_time;
80 struct ndp_option
82 uint8_t type;
83 uint8_t length;
86 struct ll_option
88 uint8_t type;
89 uint8_t length;
90 uint8_t address[6];
93 struct prefix_option
95 uint8_t type;
96 uint8_t length;
97 uint8_t prefix_len;
98 uint8_t flags_rsvd;
99 uint32_t lifetime;
100 uint32_t pref_lifetime;
101 uint32_t rsvd2;
102 uint8_t prefix[16];
105 #define RADVERT_MANAGED ( 1 << 7 )
106 #define RADVERT_OTHERCONF ( 1 << 6 )
108 int ndp_resolve ( struct net_device *netdev, struct in6_addr *src,
109 struct in6_addr *dest, void *dest_ll_addr );
111 int ndp_send_rsolicit ( struct net_device *netdev,
112 struct job_interface *job,
113 struct rsolicit_info *meta );
115 int ndp_process_radvert ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
116 struct sockaddr_tcpip *st_dest, struct net_device *netdev,
117 struct icmp6_net_protocol *net_protocol );
119 int ndp_process_nadvert ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
120 struct sockaddr_tcpip *st_dest,
121 struct icmp6_net_protocol *net_protocol );
123 int ndp_process_nsolicit ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
124 struct sockaddr_tcpip *st_dest, struct net_device *netdev,
125 struct icmp6_net_protocol *net_protocol );
127 #endif