mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #1606 from OlegHahm/sixlowpan_ignore_unconfigured
sixlowpan: ignore incoming packets if unconfigured
This commit is contained in:
commit
6de01af08b
@ -1523,7 +1523,10 @@ int ndp_addr_is_on_link(ipv6_addr_t *dest_addr)
|
||||
int if_id = -1;
|
||||
|
||||
if ((nce = ndp_neighbor_cache_search(dest_addr))) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
char addr_str[IPV6_MAX_ADDR_STR_LEN];
|
||||
DEBUG("INFO: %s is in nbr cache\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, dest_addr));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -307,12 +307,23 @@ uint8_t ipv6_get_addr_match(const ipv6_addr_t *src,
|
||||
return val;
|
||||
}
|
||||
|
||||
int is_our_address(ipv6_addr_t *addr)
|
||||
/**
|
||||
* @brief Check if the given IPv6 address is assigned to any configured
|
||||
* interface
|
||||
*
|
||||
* @param[in] addr The IPv6 address to check
|
||||
*
|
||||
* @return 1 If *addr* is assigned to at least one interface
|
||||
* @return 0 If *addr* is not assigned to any interface
|
||||
* @return -1 If no IPv6 address is configured to any interface
|
||||
*/
|
||||
static int is_our_address(ipv6_addr_t *addr)
|
||||
{
|
||||
ipv6_net_if_ext_t *net_if_ext;
|
||||
ipv6_net_if_addr_t *myaddr;
|
||||
uint8_t prefix, suffix;
|
||||
int if_id = -1;
|
||||
unsigned counter = 0;
|
||||
|
||||
DEBUGF("Is this my addres: %s?\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, addr));
|
||||
while ((if_id = net_if_iter_interfaces(if_id)) >= 0) {
|
||||
@ -323,6 +334,7 @@ int is_our_address(ipv6_addr_t *addr)
|
||||
|
||||
while ((myaddr = (ipv6_net_if_addr_t *)net_if_iter_addresses(if_id,
|
||||
(net_if_addr_t **) &myaddr)) != NULL) {
|
||||
counter++;
|
||||
DEBUGF("\tCompare with: %s?\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, (ipv6_addr_t*) myaddr->addr_data));
|
||||
if ((ipv6_get_addr_match(myaddr->addr_data, addr) >= net_if_ext->prefix) &&
|
||||
(memcmp(&addr->uint8[prefix], &myaddr->addr_data->uint8[prefix], suffix) == 0)) {
|
||||
@ -331,7 +343,11 @@ int is_our_address(ipv6_addr_t *addr)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (!counter) {
|
||||
counter = -1;
|
||||
}
|
||||
/* return negative value if no address is configured so far */
|
||||
return counter;
|
||||
}
|
||||
|
||||
void *ipv6_process(void *arg)
|
||||
@ -362,8 +378,15 @@ void *ipv6_process(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
int addr_match = is_our_address(&ipv6_buf->destaddr);
|
||||
|
||||
/* no address configured for this node so far, exit early */
|
||||
if (addr_match < 1) {
|
||||
msg_reply(&m_recv_lowpan, &m_send_lowpan);
|
||||
continue;
|
||||
}
|
||||
/* destination is our address */
|
||||
if (is_our_address(&ipv6_buf->destaddr)) {
|
||||
else if (addr_match) {
|
||||
switch (*nextheader) {
|
||||
case (IPV6_PROTO_NUM_ICMPV6): {
|
||||
icmp_buf = get_icmpv6_buf(ipv6_ext_hdr_len);
|
||||
|
Loading…
Reference in New Issue
Block a user