gnrc/ndp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for
6  * more details.
7  */
8 
21 #ifndef NET_GNRC_NDP_H
22 #define NET_GNRC_NDP_H
23 
24 #include <inttypes.h>
25 #include <stdlib.h>
26 
27 #include "byteorder.h"
28 #include "net/ndp.h"
29 #include "net/gnrc/pkt.h"
30 #include "net/gnrc/icmpv6.h"
31 #include "net/ipv6/addr.h"
32 #include "net/gnrc/ipv6/nc.h"
33 #include "net/gnrc/ipv6/netif.h"
34 
35 #include "net/gnrc/ndp/host.h"
36 #include "net/gnrc/ndp/internal.h"
37 #include "net/gnrc/ndp/router.h"
38 #include "net/gnrc/ndp/node.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
45 #define GNRC_NDP_MSG_RTR_TIMEOUT (0x0210)
46 
47 #define GNRC_NDP_MSG_ADDR_TIMEOUT (0x0211)
48 
49 #define GNRC_NDP_MSG_NBR_SOL_RETRANS (0x0212)
50 
51 #define GNRC_NDP_MSG_RTR_ADV_RETRANS (0x0213)
52 
53 #define GNRC_NDP_MSG_RTR_ADV_DELAY (0x0214)
54 
57 #define GNRC_NDP_MSG_RTR_ADV_SIXLOWPAN_DELAY (0x0215)
58 
59 #define GNRC_NDP_MSG_RTR_SOL_RETRANS (0x0216)
60 
61 #define GNRC_NDP_MSG_NC_STATE_TIMEOUT (0x0217)
62 
74 #define GNRC_NDP_MAX_RTR_SOL_DELAY (1U)
75 
80 #define GNRC_NDP_MAX_RTR_SOL_INT (4U)
81 
85 #define GNRC_NDP_MAX_RTR_SOL_NUMOF (3U)
86 
99 #define GNRC_NDP_MAX_MC_NBR_SOL_NUMOF (3U)
100 
105 #define GNRC_NDP_MAX_UC_NBR_SOL_NUMOF (3U)
106 
111 #define GNRC_NDP_MAX_AC_TGT_DELAY (1U)
112 
117 #define GNRC_NDP_MAX_NBR_ADV_NUMOF (3U)
118 
123 #define GNRC_NDP_REACH_TIME (30U * US_PER_SEC)
124 
129 #define GNRC_NDP_RETRANS_TIMER (1U * US_PER_SEC)
130 
136 #define GNRC_NDP_FIRST_PROBE_DELAY (5U)
137 
141 #define GNRC_NDP_MIN_RAND (5U)
142 
146 #define GNRC_NDP_MAX_RAND (15U)
147 
159 #define GNRC_NDP_MAX_INIT_RTR_ADV_INT (16U)
160 
164 #define GNRC_NDP_MAX_INIT_RTR_ADV_NUMOF (3U)
165 
169 #define GNRC_NDP_MAX_FIN_RTR_ADV_NUMOF (3U)
170 
175 #define GNRC_NDP_MIN_RTR_ADV_DELAY (3U)
176 
182 #define GNRC_NDP_MAX_RTR_ADV_DELAY (500U * US_PER_MS)
183 
195  ipv6_hdr_t *ipv6, ndp_nbr_sol_t *nbr_sol,
196  size_t icmpv6_size);
197 
208  ipv6_hdr_t *ipv6, ndp_nbr_adv_t *nbr_adv,
209  size_t icmpv6_size);
210 
211 #if (defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_ROUTER))
212 
222  ipv6_hdr_t *ipv6, ndp_rtr_sol_t *rtr_sol,
223  size_t icmpv6_size);
224 #else
225 
234 #define gnrc_ndp_rtr_sol_handle(iface, pkt, ipv6, rtr_sol, size)
235 #endif
236 
249  ipv6_hdr_t *ipv6, ndp_rtr_adv_t *rtr_adv,
250  size_t icmpv6_size);
251 
266 
272 void gnrc_ndp_state_timeout(gnrc_ipv6_nc_t *nc_entry);
273 
280 
287 
305 kernel_pid_t gnrc_ndp_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
306  kernel_pid_t iface, ipv6_addr_t *dst,
307  gnrc_pktsnip_t *pkt);
308 
323 
351  gnrc_pktsnip_t *options);
352 
366 
380 
381 #if (defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_ROUTER))
382 
410 gnrc_pktsnip_t *gnrc_ndp_rtr_adv_build(uint8_t cur_hl, uint8_t flags, uint16_t ltime,
411  uint32_t reach_time, uint32_t retrans_timer,
412  gnrc_pktsnip_t *options);
413 #else
414 
423 #define gnrc_ndp_rtr_adv_build(cur_hl, flags, ltime, reach_time, retrans_timer, options) (NULL)
424 #endif
425 
437 gnrc_pktsnip_t *gnrc_ndp_opt_build(uint8_t type, size_t size, gnrc_pktsnip_t *next);
438 
457 gnrc_pktsnip_t *gnrc_ndp_opt_sl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
458  gnrc_pktsnip_t *next);
459 
478 gnrc_pktsnip_t *gnrc_ndp_opt_tl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
479  gnrc_pktsnip_t *next);
480 
481 #if (defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_ROUTER))
482 
511 gnrc_pktsnip_t *gnrc_ndp_opt_pi_build(uint8_t prefix_len, uint8_t flags,
512  uint32_t valid_ltime, uint32_t pref_ltime,
513  ipv6_addr_t *prefix, gnrc_pktsnip_t *next);
514 
532 #else
533 
542 #define gnrc_ndp_opt_pi_build(prefix_len, flags, valid_ltime, pref_ltime, prefix, next) (NULL)
543 
553 #define gnrc_ndp_opt_mtu_build(mtu, next) (NULL)
554 #endif
555 
556 #ifdef __cplusplus
557 }
558 #endif
559 
560 #endif /* NET_GNRC_NDP_H */
561 
gnrc_pktsnip_t * gnrc_ndp_opt_pi_build(uint8_t prefix_len, uint8_t flags, uint32_t valid_ltime, uint32_t pref_ltime, ipv6_addr_t *prefix, gnrc_pktsnip_t *next)
Builds the prefix information option.
Definition of IPv6 interface type.
Definition: ipv6/netif.h:279
gnrc_pktsnip_t * gnrc_ndp_rtr_adv_build(uint8_t cur_hl, uint8_t flags, uint16_t ltime, uint32_t reach_time, uint32_t retrans_timer, gnrc_pktsnip_t *options)
Builds a router advertisement message for sending.
Definitions for IPv6 addresses.
IPv6-node neighbor discovery definitions.
Neighbor solicitation message format.
Definition: ndp.h:203
gnrc_pktsnip_t * gnrc_ndp_rtr_sol_build(gnrc_pktsnip_t *options)
Builds a router solicitation message for sending.
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
General definitions for network packets and their helper functions.
Neighbor advertisement message format.
Definition: ndp.h:217
Data type to represent an IPv6 packet header.
Definition: ipv6/hdr.h:68
Definitions for GNRC&#39;s ICMPv6 implementation.
void gnrc_ndp_netif_add(gnrc_ipv6_netif_t *iface)
NDP interface initialization.
void gnrc_ndp_rtr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, ndp_rtr_sol_t *rtr_sol, size_t icmpv6_size)
Handles received router solicitations.
void gnrc_ndp_netif_remove(gnrc_ipv6_netif_t *iface)
NDP interface removal.
Definitions for IPv6 specific information of network interfaces.
void gnrc_ndp_nbr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, ndp_nbr_sol_t *nbr_sol, size_t icmpv6_size)
Handles received neighbor solicitations.
gnrc_pktsnip_t * gnrc_ndp_nbr_sol_build(ipv6_addr_t *tgt, gnrc_pktsnip_t *options)
Builds a neighbor solicitation message for sending.
Neighbor cache definitions.
Router-specific router discovery definitions.
kernel_pid_t gnrc_ndp_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len, kernel_pid_t iface, ipv6_addr_t *dst, gnrc_pktsnip_t *pkt)
Get link-layer address and interface for next hop to destination IPv6 address.
Router advertisement message format.
Definition: ndp.h:186
Host-specific router discovery definitions.
void gnrc_ndp_rtr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, ndp_rtr_adv_t *rtr_adv, size_t icmpv6_size)
Handles received router advertisements.
gnrc_pktsnip_t * gnrc_ndp_opt_sl2a_build(const uint8_t *l2addr, uint8_t l2addr_len, gnrc_pktsnip_t *next)
Builds the source link-layer address option.
gnrc_pktsnip_t * gnrc_ndp_opt_tl2a_build(const uint8_t *l2addr, uint8_t l2addr_len, gnrc_pktsnip_t *next)
Builds the target link-layer address option.
void gnrc_ndp_nbr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, ndp_nbr_adv_t *nbr_adv, size_t icmpv6_size)
Handles received neighbor advertisements.
Functions to work with different byte orders.
Adds include for missing inttype definitions.
Router solicitation message format.
Definition: ndp.h:173
void gnrc_ndp_state_timeout(gnrc_ipv6_nc_t *nc_entry)
Event handler for a neighbor cache state timeout.
gnrc_pktsnip_t * gnrc_ndp_opt_mtu_build(uint32_t mtu, gnrc_pktsnip_t *next)
Builds the MTU option.
Type to represent parts (either headers or payload) of a packet, called snips.
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
IPv6 neighbor discovery message type definitions.
stdlib.h wrapper for MSP430
Neighbor cache entry as defined in RFC 4861, section 5.1 .
Definition: nc.h:122
gnrc_pktsnip_t * gnrc_ndp_opt_build(uint8_t type, size_t size, gnrc_pktsnip_t *next)
Builds a generic NDP option.
gnrc_pktsnip_t * gnrc_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt, gnrc_pktsnip_t *options)
Builds a neighbor advertisement message for sending.
void gnrc_ndp_retrans_nbr_sol(gnrc_ipv6_nc_t *nc_entry)
Retransmits a multicast neighbor solicitation for an incomplete or probing neighbor cache entry nc_en...