uip-ds6.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __UIP_DS6_H__
00043 #define __UIP_DS6_H__
00044
00045 #include "net/uip.h"
00046 #include "sys/stimer.h"
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #define UIP_DS6_NBR_NBS 0
00058 #ifndef UIP_CONF_DS6_NBR_NBU
00059 #define UIP_DS6_NBR_NBU 4
00060 #else
00061 #define UIP_DS6_NBR_NBU UIP_CONF_DS6_NBR_NBU
00062 #endif
00063 #define UIP_DS6_NBR_NB UIP_DS6_NBR_NBS + UIP_DS6_NBR_NBU
00064
00065
00066 #define UIP_DS6_DEFRT_NBS 0
00067 #ifndef UIP_CONF_DS6_DEFRT_NBU
00068 #define UIP_DS6_DEFRT_NBU 2
00069 #else
00070 #define UIP_DS6_DEFRT_NBU UIP_CONF_DS6_DEFRT_NBU
00071 #endif
00072 #define UIP_DS6_DEFRT_NB UIP_DS6_DEFRT_NBS + UIP_DS6_DEFRT_NBU
00073
00074
00075 #define UIP_DS6_PREFIX_NBS 1
00076 #ifndef UIP_CONF_DS6_PREFIX_NBU
00077 #define UIP_DS6_PREFIX_NBU 2
00078 #else
00079 #define UIP_DS6_PREFIX_NBU UIP_CONF_DS6_PREFIX_NBU
00080 #endif
00081 #define UIP_DS6_PREFIX_NB UIP_DS6_PREFIX_NBS + UIP_DS6_PREFIX_NBU
00082
00083
00084 #define UIP_DS6_ROUTE_NBS 0
00085 #ifndef UIP_CONF_DS6_ROUTE_NBU
00086 #define UIP_DS6_ROUTE_NBU 4
00087 #else
00088 #define UIP_DS6_ROUTE_NBU UIP_CONF_DS6_ROUTE_NBU
00089 #endif
00090 #define UIP_DS6_ROUTE_NB UIP_DS6_ROUTE_NBS + UIP_DS6_ROUTE_NBU
00091
00092
00093 #define UIP_DS6_ADDR_NBS 1
00094 #ifndef UIP_CONF_DS6_ADDR_NBU
00095 #define UIP_DS6_ADDR_NBU 2
00096 #else
00097 #define UIP_DS6_ADDR_NBU UIP_CONF_DS6_ADDR_NBU
00098 #endif
00099 #define UIP_DS6_ADDR_NB UIP_DS6_ADDR_NBS + UIP_DS6_ADDR_NBU
00100
00101
00102 #if UIP_CONF_ROUTER
00103 #define UIP_DS6_MADDR_NBS 2 + UIP_DS6_ADDR_NB
00104 #else
00105 #define UIP_DS6_MADDR_NBS 1 + UIP_DS6_ADDR_NB
00106 #endif
00107 #ifndef UIP_CONF_DS6_MADDR_NBU
00108 #define UIP_DS6_MADDR_NBU 0
00109 #else
00110 #define UIP_DS6_MADDR_NBU UIP_CONF_DS6_MADDR_NBU
00111 #endif
00112 #define UIP_DS6_MADDR_NB UIP_DS6_MADDR_NBS + UIP_DS6_MADDR_NBU
00113
00114
00115 #if UIP_CONF_ROUTER
00116 #define UIP_DS6_AADDR_NBS UIP_DS6_PREFIX_NB - 1
00117 #else
00118 #define UIP_DS6_AADDR_NBS 0
00119 #endif
00120 #ifndef UIP_CONF_DS6_AADDR_NBU
00121 #define UIP_DS6_AADDR_NBU 0
00122 #else
00123 #define UIP_DS6_AADDR_NBU UIP_CONF_DS6_AADDR_NBU
00124 #endif
00125 #define UIP_DS6_AADDR_NB UIP_DS6_AADDR_NBS + UIP_DS6_AADDR_NBU
00126
00127
00128
00129
00130 #define NBR_INCOMPLETE 0
00131 #define NBR_REACHABLE 1
00132 #define NBR_STALE 2
00133 #define NBR_DELAY 3
00134 #define NBR_PROBE 4
00135
00136
00137 #define ADDR_TENTATIVE 0
00138 #define ADDR_PREFERRED 1
00139 #define ADDR_DEPRECATED 2
00140
00141
00142 #define ADDR_ANYTYPE 0
00143 #define ADDR_AUTOCONF 1
00144 #define ADDR_DHCP 2
00145 #define ADDR_MANUAL 3
00146
00147
00148 #define UIP_DS6_PERIOD (CLOCK_SECOND/10)
00149 #define FOUND 0
00150 #define FREESPACE 1
00151 #define NOSPACE 2
00152
00153
00154
00155 #if UIP_CONF_IPV6_QUEUE_PKT
00156 #include "net/uip-packetqueue.h"
00157 #endif
00158
00159 typedef struct uip_ds6_nbr {
00160 uint8_t isused;
00161 uip_ipaddr_t ipaddr;
00162 uip_lladdr_t lladdr;
00163 struct stimer reachable;
00164 struct stimer sendns;
00165 clock_time_t last_lookup;
00166 uint8_t nscount;
00167 uint8_t isrouter;
00168 uint8_t state;
00169 #if UIP_CONF_IPV6_QUEUE_PKT
00170 struct uip_packetqueue_handle packethandle;
00171 #define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
00172 #endif
00173 } uip_ds6_nbr_t;
00174
00175
00176 typedef struct uip_ds6_defrt {
00177 uint8_t isused;
00178 uip_ipaddr_t ipaddr;
00179 struct stimer lifetime;
00180 uint8_t isinfinite;
00181 } uip_ds6_defrt_t;
00182
00183
00184 #if UIP_CONF_ROUTER
00185 typedef struct uip_ds6_prefix {
00186 uint8_t isused;
00187 uip_ipaddr_t ipaddr;
00188 uint8_t length;
00189 uint8_t advertise;
00190 u32_t vlifetime;
00191 u32_t plifetime;
00192 uint8_t l_a_reserved;
00193 } uip_ds6_prefix_t;
00194 #else
00195 typedef struct uip_ds6_prefix {
00196 uint8_t isused;
00197 uip_ipaddr_t ipaddr;
00198 uint8_t length;
00199 struct stimer vlifetime;
00200 uint8_t isinfinite;
00201 } uip_ds6_prefix_t;
00202 #endif
00203
00204
00205 typedef struct uip_ds6_addr {
00206 uint8_t isused;
00207 uip_ipaddr_t ipaddr;
00208 uint8_t state;
00209 uint8_t type;
00210 uint8_t isinfinite;
00211 struct stimer vlifetime;
00212 struct timer dadtimer;
00213 uint8_t dadnscount;
00214 } uip_ds6_addr_t;
00215
00216
00217 typedef struct uip_ds6_aaddr {
00218 uint8_t isused;
00219 uip_ipaddr_t ipaddr;
00220 } uip_ds6_aaddr_t;
00221
00222
00223 typedef struct uip_ds6_maddr {
00224 uint8_t isused;
00225 uip_ipaddr_t ipaddr;
00226 } uip_ds6_maddr_t;
00227
00228
00229
00230 #ifndef UIP_DS6_ROUTE_STATE_TYPE
00231 #define UIP_DS6_ROUTE_STATE_TYPE rpl_route_entry_t
00232
00233 typedef struct rpl_route_entry {
00234 uint32_t lifetime;
00235 uint32_t saved_lifetime;
00236 void *dag;
00237 uint8_t learned_from;
00238 } rpl_route_entry_t;
00239 #endif
00240
00241
00242 #if UIP_CONF_IPV6_RPL
00243 #ifndef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
00244 #define UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED rpl_ipv6_neighbor_callback
00245 #endif
00246 #endif
00247
00248
00249
00250
00251 typedef struct uip_ds6_route {
00252 uint8_t isused;
00253 uip_ipaddr_t ipaddr;
00254 uint8_t length;
00255 uint8_t metric;
00256 uip_ipaddr_t nexthop;
00257 #ifdef UIP_DS6_ROUTE_STATE_TYPE
00258 UIP_DS6_ROUTE_STATE_TYPE state;
00259 #endif
00260 } uip_ds6_route_t;
00261
00262
00263 typedef struct uip_ds6_netif {
00264 uint32_t link_mtu;
00265 uint8_t cur_hop_limit;
00266 uint32_t base_reachable_time;
00267 uint32_t reachable_time;
00268 uint32_t retrans_timer;
00269 uint8_t maxdadns;
00270 uip_ds6_addr_t addr_list[UIP_DS6_ADDR_NB];
00271 uip_ds6_aaddr_t aaddr_list[UIP_DS6_AADDR_NB];
00272 uip_ds6_maddr_t maddr_list[UIP_DS6_MADDR_NB];
00273 } uip_ds6_netif_t;
00274
00275
00276 typedef struct uip_ds6_element {
00277 uint8_t isused;
00278 uip_ipaddr_t ipaddr;
00279 } uip_ds6_element_t;
00280
00281
00282
00283 extern uip_ds6_netif_t uip_ds6_if;
00284 extern struct etimer uip_ds6_timer_periodic;
00285
00286 #if UIP_CONF_ROUTER
00287 extern uip_ds6_prefix_t uip_ds6_prefix_list[UIP_DS6_PREFIX_NB];
00288 #else
00289 extern struct etimer uip_ds6_timer_rs;
00290 #endif
00291
00292
00293
00294
00295 void uip_ds6_init(void);
00296
00297
00298 void uip_ds6_periodic(void);
00299
00300
00301
00302 uint8_t uip_ds6_list_loop(uip_ds6_element_t *list, uint8_t size,
00303 uint16_t elementsize, uip_ipaddr_t *ipaddr,
00304 uint8_t ipaddrlen,
00305 uip_ds6_element_t **out_element);
00306
00307
00308
00309 uip_ds6_nbr_t *uip_ds6_nbr_add(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr,
00310 uint8_t isrouter, uint8_t state);
00311 void uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr);
00312 uip_ds6_nbr_t *uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr);
00313
00314
00315
00316
00317
00318 uip_ds6_defrt_t *uip_ds6_defrt_add(uip_ipaddr_t *ipaddr,
00319 unsigned long interval);
00320 void uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt);
00321 uip_ds6_defrt_t *uip_ds6_defrt_lookup(uip_ipaddr_t *ipaddr);
00322 uip_ipaddr_t *uip_ds6_defrt_choose(void);
00323
00324
00325
00326
00327
00328 #if UIP_CONF_ROUTER
00329 uip_ds6_prefix_t *uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t length,
00330 uint8_t advertise, uint8_t flags,
00331 unsigned long vtime,
00332 unsigned long ptime);
00333 #else
00334 uip_ds6_prefix_t *uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t length,
00335 unsigned long interval);
00336 #endif
00337 void uip_ds6_prefix_rm(uip_ds6_prefix_t *prefix);
00338 uip_ds6_prefix_t *uip_ds6_prefix_lookup(uip_ipaddr_t *ipaddr,
00339 uint8_t ipaddrlen);
00340 uint8_t uip_ds6_is_addr_onlink(uip_ipaddr_t *ipaddr);
00341
00342
00343
00344
00345
00346 uip_ds6_addr_t *uip_ds6_addr_add(uip_ipaddr_t *ipaddr,
00347 unsigned long vlifetime, uint8_t type);
00348 void uip_ds6_addr_rm(uip_ds6_addr_t *addr);
00349 uip_ds6_addr_t *uip_ds6_addr_lookup(uip_ipaddr_t *ipaddr);
00350 uip_ds6_addr_t *uip_ds6_get_link_local(int8_t state);
00351 uip_ds6_addr_t *uip_ds6_get_global(int8_t state);
00352
00353
00354
00355
00356
00357 uip_ds6_maddr_t *uip_ds6_maddr_add(uip_ipaddr_t *ipaddr);
00358 void uip_ds6_maddr_rm(uip_ds6_maddr_t *maddr);
00359 uip_ds6_maddr_t *uip_ds6_maddr_lookup(uip_ipaddr_t *ipaddr);
00360
00361
00362
00363
00364
00365 uip_ds6_aaddr_t *uip_ds6_aaddr_add(uip_ipaddr_t *ipaddr);
00366 void uip_ds6_aaddr_rm(uip_ds6_aaddr_t *aaddr);
00367 uip_ds6_aaddr_t *uip_ds6_aaddr_lookup(uip_ipaddr_t *ipaddr);
00368
00369
00370
00371
00372
00373
00374 uip_ds6_route_t *uip_ds6_route_lookup(uip_ipaddr_t *destipaddr);
00375 uip_ds6_route_t *uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
00376 uip_ipaddr_t *next_hop, uint8_t metric);
00377 void uip_ds6_route_rm(uip_ds6_route_t *route);
00378 void uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop);
00379
00380
00381
00382
00383 void uip_ds6_set_addr_iid(uip_ipaddr_t * ipaddr, uip_lladdr_t * lladdr);
00384
00385
00386 uint8_t get_match_length(uip_ipaddr_t * src, uip_ipaddr_t * dst);
00387
00388
00389 void uip_ds6_dad(uip_ds6_addr_t * ifaddr);
00390
00391
00392 int uip_ds6_dad_failed(uip_ds6_addr_t * ifaddr);
00393
00394
00395 void uip_ds6_select_src(uip_ipaddr_t * src, uip_ipaddr_t * dst);
00396
00397 #if UIP_CONF_ROUTER
00398 #if UIP_ND6_SEND_RA
00399
00400 void uip_ds6_send_ra_sollicited(void);
00401
00402
00403 void uip_ds6_send_ra_periodic(void);
00404 #endif
00405 #else
00406
00407 void uip_ds6_send_rs(void);
00408 #endif
00409
00410
00411 uint32_t uip_ds6_compute_reachable_time(void);
00412
00413
00414
00415 #define uip_ds6_is_my_addr(addr) (uip_ds6_addr_lookup(addr) != NULL)
00416 #define uip_ds6_is_my_maddr(addr) (uip_ds6_maddr_lookup(addr) != NULL)
00417 #define uip_ds6_is_my_aaddr(addr) (uip_ds6_aaddr_lookup(addr) != NULL)
00418
00419
00420
00421 #endif