-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ng_ndp/ng_sixlowpan: import 6LoWPAN-ND host behavior
- Loading branch information
Showing
25 changed files
with
1,702 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @defgroup net_ng_sixlowpan_nd Neighbor Discovery Optimization for 6LoWPAN | ||
* @ingroup net_ng_sixlowpan | ||
* @brief Implements Neighbor Discovery Optimization for 6LoWPAN. | ||
* @see <a href="https://tools.ietf.org/html/rfc6775"> | ||
* RFC 6775 | ||
* </a> | ||
* @{ | ||
* | ||
* @file | ||
* @brief 6LoWPAN Neighbor Discovery definitions. | ||
* | ||
* @author Martine Lenders <mlenders@inf.fu-berlin.de> | ||
*/ | ||
#ifndef NG_SIXLOWPAN_ND_H_ | ||
#define NG_SIXLOWPAN_ND_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#include "net/eui64.h" | ||
#include "net/ng_ipv6/addr.h" | ||
#include "net/ng_netapi.h" | ||
#include "net/ng_netconf.h" | ||
|
||
#include "net/ng_sixlowpan/nd/rtr.h" | ||
#include "net/ng_sixlowpan/nd/types.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Message type for next unicast router solicitation. | ||
*/ | ||
#define NG_SIXLOWPAN_ND_MSG_UC_RTR_SOL (0x0221) | ||
|
||
/** | ||
* @brief Registration Lifetime of an address in minutes. | ||
* This lifetime is highly depenent on the sleep cycles of the node and should | ||
* be set to a value bigger than these sleep cycles. | ||
* | ||
* @see <a href="https://tools.ietf.org/html/rfc6775#section-5.8.1"> | ||
* RFC 6775, section 5.8.1 | ||
* </a> | ||
*/ | ||
#ifndef NG_SIXLOWPAN_ND_REG_LTIME | ||
#define NG_SIXLOWPAN_ND_REG_LTIME (5U) | ||
#endif | ||
|
||
/** | ||
* @brief Interval in seconds between initial router solicitation | ||
* transmissions | ||
* | ||
* @see @ref NG_NDP_MAX_RTR_SOL_INT | ||
*/ | ||
#define NG_SIXLOWPAN_ND_MAX_RTR_SOL_INT (10U) | ||
|
||
/** | ||
* @brief Truncation for truncated binary exponential backoff after initial | ||
* resends. | ||
* | ||
* @note The RFC is a little ambiguous since the truncation should be a | ||
* binary exponent, while the | ||
* | ||
* @see <a href="https://tools.ietf.org/html/rfc6775#section-5.3"> | ||
* RFC 6775, section 5.3 | ||
* </a> | ||
*/ | ||
#define NG_SIXLOWPAN_ND_MAX_RTR_SOL_INT_TRUNC (6U) | ||
|
||
/** | ||
* @brief Binary exponential backoff for router solicitation | ||
* re-sends. | ||
* | ||
* @param[in] base_sec Base time in seconds for the backoff. | ||
* @param[in] exp Exponent for the factor of the backoff. | ||
* | ||
* @return The resulting backoff time in seconds. | ||
*/ | ||
uint32_t ng_sixlowpan_nd_beb(uint32_t base_sec, uint8_t exp); | ||
|
||
void ng_sixlowpan_nd_l2addr_resolution(uint8_t *l2addr, uint8_t *l2addr_len, | ||
ng_ipv6_addr_t *next_hop_ip); | ||
|
||
/** | ||
* @brief Handles 6LoWPAN context option. | ||
* | ||
* @param[in] icmpv6_type Message type of the ICMPv6 message that contained. | ||
* this message. | ||
* @param[in] 6ctx_opt The 6LoWPAN context option. | ||
* | ||
* @return true, when 6LoWPAN context option was correct. | ||
* @return false, when it was incorrect. | ||
*/ | ||
bool ng_sixlowpan_nd_opt_6ctx_handle(uint8_t icmpv6_type, | ||
ng_sixlowpan_nd_opt_6ctx_t *ctx_opt, | ||
uint16_t rtr_ltime); | ||
|
||
uint8_t ng_sixlowpan_nd_opt_ar_handle(kernel_pid_t iface, ng_ipv6_hdr_t *ipv6, | ||
uint8_t icmpv6_type, | ||
ng_sixlowpan_nd_opt_ar_t *ar_opt, | ||
ng_ndp_opt_t *sl2a_opt); | ||
|
||
ng_pktsnip_t *ng_sixlowpan_nd_opt_ar_build(uint8_t status, uint16_t ltime, | ||
eui64_t *eui64, | ||
ng_pktsnip_t *next); | ||
|
||
static inline ng_pktsnip_t *ng_sixlowpan_nd_opt_ar_iface_build(kernel_pid_t iface, | ||
uint8_t status, ng_pktsnip_t *next) | ||
{ | ||
eui64_t eui64; | ||
|
||
if (ng_netapi_get(iface, NETCONF_OPT_ADDRESS_LONG, 0, &eui64, | ||
sizeof(eui64)) < 0) { | ||
return NULL; | ||
} | ||
|
||
return ng_sixlowpan_nd_opt_ar_build(0, NG_SIXLOWPAN_ND_REG_LTIME, &eui64, | ||
next); | ||
} | ||
|
||
/* TODO: wake-up behavior */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* NG_SIXLOWPAN_ND_H_ */ | ||
/** @} */ |
Oops, something went wrong.