1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #2735 from authmillenon/ipv6_netif/feat/hl

ipv6_netif: expand interface
This commit is contained in:
Martine Lenders 2015-04-08 12:18:26 +02:00
commit b8fea1a2c7
3 changed files with 33 additions and 18 deletions

View File

@ -29,15 +29,6 @@
extern "C" {
#endif
/**
* @brief Default maximum transition unit
*
* @see <a href="https://tools.ietf.org/html/rfc2460#section-5">
* RFC 2460, section 5
* </a>
*/
#define NG_IPV6_DEFAULT_MTU (1280)
#ifdef __cplusplus
}
#endif

View File

@ -47,6 +47,27 @@ extern "C" {
#endif
#endif
/**
* @brief Default MTU
*
* @see <a href="https://tools.ietf.org/html/rfc2460#section-5">
* RFC 2460, section 5
* </a>
*/
#define NG_IPV6_NETIF_DEFAULT_MTU (1280)
/**
* @brief Default hop limit
*
* @see <a href="https://tools.ietf.org/html/rfc4861#section-6.3.2">
* RFC 4861, section 6.3.2
* </a>
* @see <a href="http://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ip-parameters-2">
* IANA, IP TIME TO LIVE PARAMETER
* </a>
*/
#define NG_IPV6_NETIF_DEFAULT_HL (64)
/**
* @{
* @name Flags for a registered IPv6 address.
@ -56,8 +77,8 @@ extern "C" {
* RFC 4291, section 2.6
* </a>
*/
#define NG_IPV6_NETIF_FLAGS_UNICAST (0x00) /**< unicast address */
#define NG_IPV6_NETIF_FLAGS_NON_UNICAST (0x01) /**< non-unicast address */
#define NG_IPV6_NETIF_ADDR_FLAGS_UNICAST (0x00) /**< unicast address */
#define NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST (0x01) /**< non-unicast address */
/**
* @}
*/
@ -80,6 +101,8 @@ typedef struct {
mutex_t mutex; /**< mutex for the interface */
kernel_pid_t pid; /**< PID of the interface */
uint16_t mtu; /**< Maximum Transmission Unit (MTU) of the interface */
uint8_t cur_hl; /**< current hop limit for the interface */
uint8_t flags; /**< flags for 6LoWPAN and Neighbor Discovery */
} ng_ipv6_netif_t;
/**
@ -244,7 +267,7 @@ ng_ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ng_ipv6
static inline bool ng_ipv6_netif_addr_is_non_unicast(const ng_ipv6_addr_t *addr)
{
return (bool)(container_of(addr, ng_ipv6_netif_addr_t, addr)->flags &
NG_IPV6_NETIF_FLAGS_NON_UNICAST);
NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST);
}

View File

@ -20,7 +20,6 @@
#include "kernel_types.h"
#include "mutex.h"
#include "net/ng_ipv6.h"
#include "net/ng_ipv6/addr.h"
#include "net/ng_netif.h"
@ -55,12 +54,12 @@ static int _add_addr_to_entry(ng_ipv6_netif_t *entry, const ng_ipv6_addr_t *addr
entry->addrs[i].prefix_len = NG_IPV6_ADDR_BIT_LEN;
}
entry->addrs[i].flags = NG_IPV6_NETIF_FLAGS_NON_UNICAST;
entry->addrs[i].flags = NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST;
}
else {
entry->addrs[i].prefix_len = prefix_len;
entry->addrs[i].flags = NG_IPV6_NETIF_FLAGS_UNICAST;
entry->addrs[i].flags = NG_IPV6_NETIF_ADDR_FLAGS_UNICAST;
}
return 0;
@ -99,9 +98,11 @@ void ng_ipv6_netif_add(kernel_pid_t pid)
DEBUG("Add IPv6 interface %" PRIkernel_pid " (i = %d)\n", pid, i);
ipv6_ifs[i].pid = pid;
DEBUG(" * pid = %" PRIkernel_pid "\n", ipv6_ifs[i].pid);
ipv6_ifs[i].mtu = NG_IPV6_DEFAULT_MTU;
DEBUG(" * mtu = %d\n", ipv6_ifs[i].mtu);
DEBUG(" * pid = %" PRIkernel_pid " ", ipv6_ifs[i].pid);
ipv6_ifs[i].mtu = NG_IPV6_NETIF_DEFAULT_MTU;
DEBUG("mtu = %d ", ipv6_ifs[i].mtu);
ipv6_ifs[i].cur_hl = NG_IPV6_NETIF_DEFAULT_HL;
DEBUG("cur_hl = %d ", ipv6_ifs[i].cur_hl);
_add_addr_to_entry(&ipv6_ifs[i], &addr, NG_IPV6_ADDR_BIT_LEN, 0);