1 | /**
|
---|
2 | * @file
|
---|
3 | *
|
---|
4 | * Neighbor discovery and stateless address autoconfiguration for IPv6.
|
---|
5 | * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862
|
---|
6 | * (Address autoconfiguration).
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (c) 2010 Inico Technologies Ltd.
|
---|
11 | * All rights reserved.
|
---|
12 | *
|
---|
13 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
14 | * are permitted provided that the following conditions are met:
|
---|
15 | *
|
---|
16 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
17 | * this list of conditions and the following disclaimer.
|
---|
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
19 | * this list of conditions and the following disclaimer in the documentation
|
---|
20 | * and/or other materials provided with the distribution.
|
---|
21 | * 3. The name of the author may not be used to endorse or promote products
|
---|
22 | * derived from this software without specific prior written permission.
|
---|
23 | *
|
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
---|
25 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
---|
27 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
---|
29 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
---|
32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
---|
33 | * OF SUCH DAMAGE.
|
---|
34 | *
|
---|
35 | * This file is part of the lwIP TCP/IP stack.
|
---|
36 | *
|
---|
37 | * Author: Ivan Delamer <delamer@inicotech.com>
|
---|
38 | *
|
---|
39 | *
|
---|
40 | * Please coordinate changes and requests with Ivan Delamer
|
---|
41 | * <delamer@inicotech.com>
|
---|
42 | */
|
---|
43 |
|
---|
44 | #ifndef LWIP_HDR_ND6_PRIV_H
|
---|
45 | #define LWIP_HDR_ND6_PRIV_H
|
---|
46 |
|
---|
47 | #include "lwip/opt.h"
|
---|
48 |
|
---|
49 | #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
|
---|
50 |
|
---|
51 | #include "lwip/pbuf.h"
|
---|
52 | #include "lwip/ip6_addr.h"
|
---|
53 | #include "lwip/netif.h"
|
---|
54 |
|
---|
55 |
|
---|
56 | #ifdef __cplusplus
|
---|
57 | extern "C" {
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | #if LWIP_ND6_QUEUEING
|
---|
61 | /** struct for queueing outgoing packets for unknown address
|
---|
62 | * defined here to be accessed by memp.h
|
---|
63 | */
|
---|
64 | struct nd6_q_entry {
|
---|
65 | struct nd6_q_entry *next;
|
---|
66 | struct pbuf *p;
|
---|
67 | };
|
---|
68 | #endif /* LWIP_ND6_QUEUEING */
|
---|
69 |
|
---|
70 | /** Struct for tables. */
|
---|
71 | struct nd6_neighbor_cache_entry {
|
---|
72 | ip6_addr_t next_hop_address;
|
---|
73 | struct netif *netif;
|
---|
74 | u8_t lladdr[NETIF_MAX_HWADDR_LEN];
|
---|
75 | /*u32_t pmtu;*/
|
---|
76 | #if LWIP_ND6_QUEUEING
|
---|
77 | /** Pointer to queue of pending outgoing packets on this entry. */
|
---|
78 | struct nd6_q_entry *q;
|
---|
79 | #else /* LWIP_ND6_QUEUEING */
|
---|
80 | /** Pointer to a single pending outgoing packet on this entry. */
|
---|
81 | struct pbuf *q;
|
---|
82 | #endif /* LWIP_ND6_QUEUEING */
|
---|
83 | u8_t state;
|
---|
84 | u8_t isrouter;
|
---|
85 | union {
|
---|
86 | u32_t reachable_time; /* in seconds */
|
---|
87 | u32_t delay_time; /* ticks (ND6_TMR_INTERVAL) */
|
---|
88 | u32_t probes_sent;
|
---|
89 | u32_t stale_time; /* ticks (ND6_TMR_INTERVAL) */
|
---|
90 | } counter;
|
---|
91 | };
|
---|
92 |
|
---|
93 | struct nd6_destination_cache_entry {
|
---|
94 | ip6_addr_t destination_addr;
|
---|
95 | ip6_addr_t next_hop_addr;
|
---|
96 | u16_t pmtu;
|
---|
97 | u32_t age;
|
---|
98 | };
|
---|
99 |
|
---|
100 | struct nd6_prefix_list_entry {
|
---|
101 | ip6_addr_t prefix;
|
---|
102 | struct netif *netif;
|
---|
103 | u32_t invalidation_timer; /* in seconds */
|
---|
104 | };
|
---|
105 |
|
---|
106 | struct nd6_router_list_entry {
|
---|
107 | struct nd6_neighbor_cache_entry *neighbor_entry;
|
---|
108 | u32_t invalidation_timer; /* in seconds */
|
---|
109 | u8_t flags;
|
---|
110 | };
|
---|
111 |
|
---|
112 | enum nd6_neighbor_cache_entry_state {
|
---|
113 | ND6_NO_ENTRY = 0,
|
---|
114 | ND6_INCOMPLETE,
|
---|
115 | ND6_REACHABLE,
|
---|
116 | ND6_STALE,
|
---|
117 | ND6_DELAY,
|
---|
118 | ND6_PROBE
|
---|
119 | };
|
---|
120 |
|
---|
121 | #define ND6_HOPLIM 255 /* maximum hop limit, required in all ND packets */
|
---|
122 |
|
---|
123 | #define ND6_2HRS 7200 /* two hours, expressed in number of seconds */
|
---|
124 |
|
---|
125 | /* Router tables. */
|
---|
126 | /* @todo make these static? and entries accessible through API? */
|
---|
127 | extern struct nd6_neighbor_cache_entry neighbor_cache[];
|
---|
128 | extern struct nd6_destination_cache_entry destination_cache[];
|
---|
129 | extern struct nd6_prefix_list_entry prefix_list[];
|
---|
130 | extern struct nd6_router_list_entry default_router_list[];
|
---|
131 |
|
---|
132 | /* Default values, can be updated by a RA message. */
|
---|
133 | extern u32_t reachable_time;
|
---|
134 | extern u32_t retrans_timer;
|
---|
135 |
|
---|
136 | #ifdef __cplusplus
|
---|
137 | }
|
---|
138 | #endif
|
---|
139 |
|
---|
140 | #endif /* LWIP_IPV6 */
|
---|
141 |
|
---|
142 | #endif /* LWIP_HDR_ND6_PRIV_H */
|
---|