1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

ndp: move type definitions out of ng_ context

This commit is contained in:
Martine Lenders 2015-08-10 15:26:55 +02:00 committed by Martine Lenders
parent 147bf75d5b
commit 618a765bdc
6 changed files with 112 additions and 91 deletions

View File

@ -7,9 +7,9 @@
*/
/**
* @defgroup net_ng_ndp_types Types for IPv6 neighbor discovery
* @ingroup net_ng_ndp
* @brief IPv6 neighbor discovery message types
* @defgroup net_ndp IPv6 neighbor discovery messages
* @ingroup net_ipv6
* @brief Provides IPv6 neighbor discovery message types
* @{
*
* @file
@ -17,8 +17,8 @@
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef NG_NDP_TYPES_H_
#define NG_NDP_TYPES_H_
#ifndef NDP_H_
#define NDP_H_
#include <stdint.h>
@ -29,46 +29,46 @@ extern "C" {
#endif
/**
* @{
* @name Flags for router advertisement messages
* @name Router advertisement flags
* @see <a href="https://tools.ietf.org/html/rfc4861#section-4.2">
* RFC 4861, section 4.2
* </a>
* @{
*/
#define NG_NDP_RTR_ADV_FLAGS_MASK (0xc0)
#define NG_NDP_RTR_ADV_FLAGS_M (0x80) /**< managed address configuration */
#define NG_NDP_RTR_ADV_FLAGS_O (0x40) /**< other configuration */
#define NDP_RTR_ADV_FLAGS_MASK (0xc0)
#define NDP_RTR_ADV_FLAGS_M (0x80) /**< managed address configuration */
#define NDP_RTR_ADV_FLAGS_O (0x40) /**< other configuration */
/**
* @}
*/
/**
* @{
* @name Flags for neighbor advertisement messages
* @name Neighbor advertisement flags
* @see <a href="https://tools.ietf.org/html/rfc4861#section-4.4">
* RFC 4861, section 4.2
* </a>
* @{
*/
#define NG_NDP_NBR_ADV_FLAGS_MASK (0xe0)
#define NG_NDP_NBR_ADV_FLAGS_R (0x80) /**< router */
#define NG_NDP_NBR_ADV_FLAGS_S (0x40) /**< solicited */
#define NG_NDP_NBR_ADV_FLAGS_O (0x20) /**< override */
#define NDP_NBR_ADV_FLAGS_MASK (0xe0)
#define NDP_NBR_ADV_FLAGS_R (0x80) /**< router */
#define NDP_NBR_ADV_FLAGS_S (0x40) /**< solicited */
#define NDP_NBR_ADV_FLAGS_O (0x20) /**< override */
/**
* @}
*/
/**
* @{
* @name NDP option types
* @{
* @see <a href="http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-5">
* IANA, IPv6 Neighbor Discovery Option Formats
* </a>
*/
#define NG_NDP_OPT_SL2A (1) /**< source link-layer address option */
#define NG_NDP_OPT_TL2A (2) /**< target link-layer address option */
#define NG_NDP_OPT_PI (3) /**< prefix information option */
#define NG_NDP_OPT_RH (4) /**< redirected option */
#define NG_NDP_OPT_MTU (5) /**< MTU option */
#define NDP_OPT_SL2A (1) /**< source link-layer address option */
#define NDP_OPT_TL2A (2) /**< target link-layer address option */
#define NDP_OPT_PI (3) /**< prefix information option */
#define NDP_OPT_RH (4) /**< redirected option */
#define NDP_OPT_MTU (5) /**< MTU option */
/**
* @}
*/
@ -77,9 +77,9 @@ extern "C" {
* @{
* @name Flags for prefix information option
*/
#define NG_NDP_OPT_PI_FLAGS_MASK (0xc0)
#define NG_NDP_OPT_PI_FLAGS_L (0x80) /**< on-link */
#define NG_NDP_OPT_PI_FLAGS_A (0x40) /**< autonomous address configuration */
#define NDP_OPT_PI_FLAGS_MASK (0xc0)
#define NDP_OPT_PI_FLAGS_L (0x80) /**< on-link */
#define NDP_OPT_PI_FLAGS_A (0x40) /**< autonomous address configuration */
/**
* @}
*/
@ -89,8 +89,8 @@ extern "C" {
* @name Lengths for fixed length options
* @brief Options don't use bytes as their length unit, but 8 bytes.
*/
#define NG_NDP_OPT_PI_LEN (4U)
#define NG_NDP_OPT_MTU_LEN (1U)
#define NDP_OPT_PI_LEN (4U)
#define NDP_OPT_MTU_LEN (1U)
/**
* @}
*/
@ -108,7 +108,7 @@ typedef struct __attribute__((packed)) {
uint8_t code; /**< message code */
network_uint16_t csum; /**< checksum */
network_uint32_t resv; /**< reserved field */
} ng_ndp_rtr_sol_t;
} ndp_rtr_sol_t;
/**
* @brief Router advertisement message format.
@ -127,7 +127,7 @@ typedef struct __attribute__((packed)) {
network_uint16_t ltime; /**< router lifetime */
network_uint32_t reach_time; /**< reachable time */
network_uint32_t retrans_timer; /**< retransmission timer */
} ng_ndp_rtr_adv_t;
} ndp_rtr_adv_t;
/**
* @brief Neighbor solicitation message format.
@ -143,7 +143,7 @@ typedef struct __attribute__((packed)) {
network_uint16_t csum; /**< checksum */
network_uint32_t resv; /**< reserved field */
ipv6_addr_t tgt; /**< target address */
} ng_ndp_nbr_sol_t;
} ndp_nbr_sol_t;
/**
* @brief Neighbor advertisement message format.
@ -160,7 +160,7 @@ typedef struct __attribute__((packed)) {
uint8_t flags; /**< flags */
uint8_t resv[3]; /**< reserved fields */
ipv6_addr_t tgt; /**< target address */
} ng_ndp_nbr_adv_t;
} ndp_nbr_adv_t;
/**
* @brief Neighbor advertisement message format.
@ -177,7 +177,7 @@ typedef struct __attribute__((packed)) {
network_uint32_t resv; /**< reserved field */
ipv6_addr_t tgt; /**< target address */
ipv6_addr_t dst; /**< destination address */
} ng_ndp_redirect_t;
} ndp_redirect_t;
/**
* @brief General NDP option format
@ -188,14 +188,14 @@ typedef struct __attribute__((packed)) {
typedef struct __attribute__((packed)) {
uint8_t type; /**< option type */
uint8_t len; /**< length in units of 8 octets */
} ng_ndp_opt_t;
} ndp_opt_t;
/* XXX: slla and tlla are just ng_ndp_opt_t with variable link layer address
/* XXX: slla and tlla are just ndp_opt_t with variable link layer address
* appended */
/**
* @brief Prefix information option format
* @extends ng_ndp_opt_t
* @extends ndp_opt_t
*
* @see <a href="https://tools.ietf.org/html/rfc4861#section-4.6.2">
* RFC 4861, section 4.6.2
@ -210,11 +210,11 @@ typedef struct __attribute__((packed)) {
network_uint32_t pref_ltime; /**< preferred lifetime */
network_uint32_t resv; /**< reserved field */
ipv6_addr_t prefix; /**< prefix */
} ng_ndp_opt_pi_t;
} ndp_opt_pi_t;
/**
* @brief Redirected header option format
* @extends ng_ndp_opt_t
* @extends ndp_opt_t
*
* @see <a href="https://tools.ietf.org/html/rfc4861#section-4.6.3">
* RFC 4861, section 4.6.3
@ -224,11 +224,11 @@ typedef struct __attribute__((packed)) {
uint8_t type; /**< option type */
uint8_t len; /**< length in units of 8 octets */
uint8_t resv[6]; /**< reserved field */
} ng_ndp_opt_rh_t;
} ndp_opt_rh_t;
/**
* @brief MTU option format
* @extends ng_ndp_opt_t
* @extends ndp_opt_t
*
* @see <a href="https://tools.ietf.org/html/rfc4861#section-4.6.4">
* RFC 4861, section 4.6.4
@ -239,12 +239,12 @@ typedef struct __attribute__((packed)) {
uint8_t len; /**< length in units of 8 octets */
network_uint16_t resv; /**< reserved field */
network_uint32_t mtu; /**< MTU */
} ng_ndp_opt_mtu_t;
} ndp_opt_mtu_t;
#ifdef __cplusplus
}
#endif
#endif /* NG_NDP_TYPES_H_ */
#endif /* NDP_H_ */
/** @} */

View File

@ -18,9 +18,13 @@
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef NG_NDP_H_
#define NG_NDP_H_
#include <inttypes.h>
#include "byteorder.h"
#include "net/ndp.h"
#include "net/ng_pkt.h"
#include "net/ng_icmpv6.h"
#include "net/ipv6/addr.h"
@ -28,10 +32,6 @@
#include "net/ng_ipv6/netif.h"
#include "net/ng_ndp/node.h"
#include "net/ng_ndp/types.h"
#ifndef NG_NDP_H_
#define NG_NDP_H_
#ifdef __cplusplus
extern "C" {
@ -116,7 +116,7 @@ extern "C" {
* @param[in] icmpv6_size The overall size of the neighbor solicitation.
*/
void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
ipv6_hdr_t *ipv6, ng_ndp_nbr_sol_t *nbr_sol,
ipv6_hdr_t *ipv6, ndp_nbr_sol_t *nbr_sol,
size_t icmpv6_size);
/**
@ -129,7 +129,7 @@ void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
* @param[in] icmpv6_size The overall size of the neighbor advertisement.
*/
void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
ipv6_hdr_t *ipv6, ng_ndp_nbr_adv_t *nbr_adv,
ipv6_hdr_t *ipv6, ndp_nbr_adv_t *nbr_adv,
size_t icmpv6_size);
/**
@ -168,6 +168,27 @@ void ng_ndp_netif_add(ng_ipv6_netif_t *iface);
*/
void ng_ndp_netif_remove(ng_ipv6_netif_t *iface);
/**
* @brief Get link-layer address and interface for next hop to destination
* IPv6 address.
*
* @param[out] l2addr The link-layer for the next hop to @p dst.
* @param[out] l2addr_len Length of @p l2addr.
* @param[in] iface The interface to search the next hop on.
* May be @ref KERNEL_PID_UNDEF if not specified.
* @param[in] dst An IPv6 address to search the next hop for.
* @param[in] pkt Packet to send to @p dst. Leave NULL if you
* just want to get the addresses.
*
* @return The PID of the interface, on success.
* @return -EHOSTUNREACH, if @p dst is not reachable.
* @return -ENOBUFS, if @p l2addr_len was smaller than the resulting @p l2addr
* would be long.
*/
kernel_pid_t ng_ndp_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
kernel_pid_t iface, ipv6_addr_t *dst,
ng_pktsnip_t *pkt);
/**
* @brief Builds a neighbor solicitation message for sending.
*
@ -190,13 +211,13 @@ ng_pktsnip_t *ng_ndp_nbr_sol_build(ipv6_addr_t *tgt, ng_pktsnip_t *options);
* RFC 4861, section 4.4
* </a>
*
* @param[in] flags Flags as defined above.
* @ref NG_NDP_NBR_ADV_FLAGS_R == 1 indicates, that the
* @param[in] flags Neighbor advertisement flags:
* @ref NDP_NBR_ADV_FLAGS_R == 1 indicates, that the
* sender is a router,
* @ref NG_NDP_NBR_ADV_FLAGS_S == 1 indicates that the
* @ref NDP_NBR_ADV_FLAGS_S == 1 indicates that the
* advertisement was sent in response to a neighbor
* solicitation,
* @ref NG_NDP_NBR_ADV_FLAGS_O == 1 indicates that the
* @ref NDP_NBR_ADV_FLAGS_O == 1 indicates that the
* advertisement should override an existing cache entry
* and update the cached link-layer address.
* @param[in] tgt For solicited advertisements, the Target Address field

View File

@ -24,7 +24,7 @@
#include "net/ipv6/addr.h"
#include "net/ipv6/hdr.h"
#include "net/ng_ndp/types.h"
#include "net/ndp.h"
#ifdef __cplusplus
extern "C" {
@ -98,7 +98,7 @@ void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
*/
bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
ipv6_hdr_t *ipv6, uint8_t icmpv6_type,
ng_ndp_opt_t *sl2a_opt);
ndp_opt_t *sl2a_opt);
/**
* @brief Handles a TL2A option.
@ -114,7 +114,7 @@ bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
* @return -EINVAL, if TL2A was not valid.
*/
int ng_ndp_internal_tl2a_opt_handle(ng_pktsnip_t *pkt, ipv6_hdr_t *ipv6,
uint8_t icmpv6_type, ng_ndp_opt_t *tl2a_opt,
uint8_t icmpv6_type, ndp_opt_t *tl2a_opt,
uint8_t *l2addr);
#ifdef __cplusplus

View File

@ -99,13 +99,13 @@ void ng_icmpv6_demux(kernel_pid_t iface, ng_pktsnip_t *pkt)
case ICMPV6_NBR_SOL:
DEBUG("icmpv6: neighbor solicitation received\n");
ng_ndp_nbr_sol_handle(iface, pkt, ipv6->data, (ng_ndp_nbr_sol_t *)hdr,
ng_ndp_nbr_sol_handle(iface, pkt, ipv6->data, (ndp_nbr_sol_t *)hdr,
icmpv6->size);
break;
case ICMPV6_NBR_ADV:
DEBUG("icmpv6: neighbor advertisement received\n");
ng_ndp_nbr_adv_handle(iface, pkt, ipv6->data, (ng_ndp_nbr_adv_t *)hdr,
ng_ndp_nbr_adv_handle(iface, pkt, ipv6->data, (ndp_nbr_adv_t *)hdr,
icmpv6->size);
break;

View File

@ -161,14 +161,14 @@ void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)), supply_tl2a);
if (ng_ipv6_netif_get(iface)->flags & NG_IPV6_NETIF_FLAGS_ROUTER) {
adv_flags |= NG_NDP_NBR_ADV_FLAGS_R;
adv_flags |= NDP_NBR_ADV_FLAGS_R;
}
if (ipv6_addr_is_unspecified(dst)) {
ipv6_addr_set_all_nodes_multicast(dst, IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
}
else {
adv_flags |= NG_NDP_NBR_ADV_FLAGS_S;
adv_flags |= NDP_NBR_ADV_FLAGS_S;
}
if (supply_tl2a) {
@ -192,7 +192,7 @@ void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
/* TODO: also check if the node provides proxy servies for tgt */
if ((pkt != NULL) && !ng_ipv6_netif_addr_is_non_unicast(tgt)) {
/* TL2A is not supplied and tgt is not anycast */
adv_flags |= NG_NDP_NBR_ADV_FLAGS_O;
adv_flags |= NDP_NBR_ADV_FLAGS_O;
}
hdr = ng_ndp_nbr_adv_build(adv_flags, tgt, pkt);
@ -313,7 +313,7 @@ void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
ipv6_hdr_t *ipv6, uint8_t icmpv6_type,
ng_ndp_opt_t *sl2a_opt)
ndp_opt_t *sl2a_opt)
{
ng_ipv6_nc_t *nc_entry = NULL;
uint8_t sl2a_len = 0;
@ -334,7 +334,7 @@ bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
}
if (sl2a_len == 0) { /* in case there was no source address in l2 */
sl2a_len = (sl2a_opt->len / 8) - sizeof(ng_ndp_opt_t);
sl2a_len = (sl2a_opt->len / 8) - sizeof(ndp_opt_t);
/* ignore all zeroes at the end for length */
for (; sl2a[sl2a_len - 1] == 0x00; sl2a_len--);
@ -372,7 +372,7 @@ bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
}
int ng_ndp_internal_tl2a_opt_handle(ng_pktsnip_t *pkt, ipv6_hdr_t *ipv6,
uint8_t icmpv6_type, ng_ndp_opt_t *tl2a_opt,
uint8_t icmpv6_type, ndp_opt_t *tl2a_opt,
uint8_t *l2addr)
{
uint8_t tl2a_len = 0;
@ -395,7 +395,7 @@ int ng_ndp_internal_tl2a_opt_handle(ng_pktsnip_t *pkt, ipv6_hdr_t *ipv6,
}
if (tl2a_len == 0) { /* in case there was no source address in l2 */
tl2a_len = (tl2a_opt->len / 8) - sizeof(ng_ndp_opt_t);
tl2a_len = (tl2a_opt->len / 8) - sizeof(ndp_opt_t);
/* ignore all zeroes at the end for length */
for (; tl2a[tl2a_len - 1] == 0x00; tl2a_len--);

View File

@ -45,11 +45,11 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN];
/* random helper function */
void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
ipv6_hdr_t *ipv6, ng_ndp_nbr_sol_t *nbr_sol,
ipv6_hdr_t *ipv6, ndp_nbr_sol_t *nbr_sol,
size_t icmpv6_size)
{
uint16_t opt_offset = 0;
uint8_t *buf = ((uint8_t *)nbr_sol) + sizeof(ng_ndp_nbr_sol_t);
uint8_t *buf = ((uint8_t *)nbr_sol) + sizeof(ndp_nbr_sol_t);
ipv6_addr_t *tgt;
int sicmpv6_size = (int)icmpv6_size;
@ -62,7 +62,7 @@ void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
/* check validity */
if ((ipv6->hl != 255) || (nbr_sol->code != 0) ||
(icmpv6_size < sizeof(ng_ndp_nbr_sol_t)) ||
(icmpv6_size < sizeof(ndp_nbr_sol_t)) ||
ipv6_addr_is_multicast(&nbr_sol->tgt) ||
(ipv6_addr_is_unspecified(&ipv6->src) &&
ipv6_addr_is_solicited_node(&ipv6->dst))) {
@ -78,13 +78,13 @@ void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
return;
}
sicmpv6_size -= sizeof(ng_ndp_nbr_sol_t);
sicmpv6_size -= sizeof(ndp_nbr_sol_t);
while (sicmpv6_size > 0) {
ng_ndp_opt_t *opt = (ng_ndp_opt_t *)(buf + opt_offset);
ndp_opt_t *opt = (ndp_opt_t *)(buf + opt_offset);
switch (opt->type) {
case NG_NDP_OPT_SL2A:
case NDP_OPT_SL2A:
if (!ng_ndp_internal_sl2a_opt_handle(iface, pkt, ipv6, nbr_sol->type, opt)) {
/* invalid source link-layer address option */
return;
@ -114,11 +114,11 @@ static inline bool _pkt_has_l2addr(ng_netif_hdr_t *netif_hdr)
}
void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
ipv6_hdr_t *ipv6, ng_ndp_nbr_adv_t *nbr_adv,
ipv6_hdr_t *ipv6, ndp_nbr_adv_t *nbr_adv,
size_t icmpv6_size)
{
uint16_t opt_offset = 0;
uint8_t *buf = ((uint8_t *)nbr_adv) + sizeof(ng_ndp_nbr_adv_t);
uint8_t *buf = ((uint8_t *)nbr_adv) + sizeof(ndp_nbr_adv_t);
int l2tgt_len = 0;
uint8_t l2tgt[NG_IPV6_NC_L2_ADDR_MAX];
int sicmpv6_size = (int)icmpv6_size;
@ -135,7 +135,7 @@ void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
/* check validity */
if ((ipv6->hl != 255) || (nbr_adv->code != 0) ||
(icmpv6_size < sizeof(ng_ndp_nbr_adv_t)) ||
(icmpv6_size < sizeof(ndp_nbr_adv_t)) ||
ipv6_addr_is_multicast(&nbr_adv->tgt)) {
DEBUG("ndp: neighbor advertisement was invalid.\n");
/* ipv6 releases */
@ -149,13 +149,13 @@ void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
return;
}
sicmpv6_size -= sizeof(ng_ndp_nbr_adv_t);
sicmpv6_size -= sizeof(ndp_nbr_adv_t);
while (sicmpv6_size > 0) {
ng_ndp_opt_t *opt = (ng_ndp_opt_t *)(buf + opt_offset);
ndp_opt_t *opt = (ndp_opt_t *)(buf + opt_offset);
switch (opt->type) {
case NG_NDP_OPT_TL2A:
case NDP_OPT_TL2A:
if ((l2tgt_len = ng_ndp_internal_tl2a_opt_handle(pkt, ipv6, nbr_adv->type, opt, l2tgt)) < 0) {
/* invalid target link-layer address option */
return;
@ -191,14 +191,14 @@ void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
nc_entry->l2_addr_len = l2tgt_len;
memcpy(nc_entry->l2_addr, l2tgt, l2tgt_len);
if (nbr_adv->flags & NG_NDP_NBR_ADV_FLAGS_S) {
if (nbr_adv->flags & NDP_NBR_ADV_FLAGS_S) {
ng_ndp_internal_set_state(nc_entry, NG_IPV6_NC_STATE_REACHABLE);
}
else {
ng_ndp_internal_set_state(nc_entry, NG_IPV6_NC_STATE_STALE);
}
if (nbr_adv->flags & NG_NDP_NBR_ADV_FLAGS_R) {
if (nbr_adv->flags & NDP_NBR_ADV_FLAGS_R) {
nc_entry->flags |= NG_IPV6_NC_IS_ROUTER;
}
else {
@ -226,7 +226,7 @@ void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
(memcmp(nc_entry->l2_addr, l2tgt, l2tgt_len) == 0);
}
if ((nbr_adv->flags & NG_NDP_NBR_ADV_FLAGS_O) || !l2tgt_changed ||
if ((nbr_adv->flags & NDP_NBR_ADV_FLAGS_O) || !l2tgt_changed ||
(l2tgt_len == 0)) {
if (l2tgt_len != 0) {
nc_entry->iface = iface;
@ -234,14 +234,14 @@ void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
memcpy(nc_entry->l2_addr, l2tgt, l2tgt_len);
}
if (nbr_adv->flags & NG_NDP_NBR_ADV_FLAGS_S) {
if (nbr_adv->flags & NDP_NBR_ADV_FLAGS_S) {
ng_ndp_internal_set_state(nc_entry, NG_IPV6_NC_STATE_REACHABLE);
}
else if (l2tgt_changed && (l2tgt_len != 0)) {
ng_ndp_internal_set_state(nc_entry, NG_IPV6_NC_STATE_STALE);
}
if (nbr_adv->flags & NG_NDP_NBR_ADV_FLAGS_R) {
if (nbr_adv->flags & NDP_NBR_ADV_FLAGS_R) {
nc_entry->flags |= NG_IPV6_NC_IS_ROUTER;
}
else {
@ -365,10 +365,10 @@ ng_pktsnip_t *ng_ndp_nbr_sol_build(ipv6_addr_t *tgt, ng_pktsnip_t *options)
return NULL;
}
pkt = ng_icmpv6_build(options, ICMPV6_NBR_SOL, 0, sizeof(ng_ndp_nbr_sol_t));
pkt = ng_icmpv6_build(options, ICMPV6_NBR_SOL, 0, sizeof(ndp_nbr_sol_t));
if (pkt != NULL) {
ng_ndp_nbr_sol_t *nbr_sol = pkt->data;
ndp_nbr_sol_t *nbr_sol = pkt->data;
nbr_sol->resv.u32 = 0;
nbr_sol->tgt.u64[0].u64 = tgt->u64[0].u64;
nbr_sol->tgt.u64[1].u64 = tgt->u64[1].u64;
@ -389,11 +389,11 @@ ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt,
return NULL;
}
pkt = ng_icmpv6_build(options, ICMPV6_NBR_ADV, 0, sizeof(ng_ndp_nbr_adv_t));
pkt = ng_icmpv6_build(options, ICMPV6_NBR_ADV, 0, sizeof(ndp_nbr_adv_t));
if (pkt != NULL) {
ng_ndp_nbr_adv_t *nbr_adv = pkt->data;
nbr_adv->flags = (flags & NG_NDP_NBR_ADV_FLAGS_MASK);
ndp_nbr_adv_t *nbr_adv = pkt->data;
nbr_adv->flags = (flags & NDP_NBR_ADV_FLAGS_MASK);
nbr_adv->resv[0] = nbr_adv->resv[1] = nbr_adv->resv[2] = 0;
nbr_adv->tgt.u64[0].u64 = tgt->u64[0].u64;
nbr_adv->tgt.u64[1].u64 = tgt->u64[1].u64;
@ -410,7 +410,7 @@ static inline size_t _ceil8(uint8_t length)
ng_pktsnip_t *ng_ndp_opt_build(uint8_t type, size_t size, ng_pktsnip_t *next)
{
ng_ndp_opt_t *opt;
ndp_opt_t *opt;
ng_pktsnip_t *pkt = ng_pktbuf_add(next, NULL, _ceil8(size), NG_NETTYPE_UNDEF);
if (pkt == NULL) {
@ -429,13 +429,13 @@ ng_pktsnip_t *ng_ndp_opt_build(uint8_t type, size_t size, ng_pktsnip_t *next)
static inline ng_pktsnip_t *_opt_l2a_build(uint8_t type, const uint8_t *l2addr,
uint8_t l2addr_len, ng_pktsnip_t *next)
{
ng_pktsnip_t *pkt = ng_ndp_opt_build(type, sizeof(ng_ndp_opt_t) + l2addr_len,
ng_pktsnip_t *pkt = ng_ndp_opt_build(type, sizeof(ndp_opt_t) + l2addr_len,
next);
if (pkt != NULL) {
ng_ndp_opt_t *l2a_opt = pkt->data;
ndp_opt_t *l2a_opt = pkt->data;
memset(l2a_opt + 1, 0, pkt->size - sizeof(ng_ndp_opt_t));
memset(l2a_opt + 1, 0, pkt->size - sizeof(ndp_opt_t));
memcpy(l2a_opt + 1, l2addr, l2addr_len);
}
@ -448,7 +448,7 @@ ng_pktsnip_t *ng_ndp_opt_sl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
DEBUG("ndp: building source link-layer address option (l2addr: %s)\n",
ng_netif_addr_to_str(addr_str, sizeof(addr_str), l2addr, l2addr_len));
return _opt_l2a_build(NG_NDP_OPT_SL2A, l2addr, l2addr_len, next);
return _opt_l2a_build(NDP_OPT_SL2A, l2addr, l2addr_len, next);
}
ng_pktsnip_t *ng_ndp_opt_tl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
@ -457,7 +457,7 @@ ng_pktsnip_t *ng_ndp_opt_tl2a_build(const uint8_t *l2addr, uint8_t l2addr_len,
DEBUG("ndp: building target link-layer address option (l2addr: %s)\n",
ng_netif_addr_to_str(addr_str, sizeof(addr_str), l2addr, l2addr_len));
return _opt_l2a_build(NG_NDP_OPT_TL2A, l2addr, l2addr_len, next);
return _opt_l2a_build(NDP_OPT_TL2A, l2addr, l2addr_len, next);
}
/**