示例#1
0
static void test_ipv6_netif_add_addr__despite_free_entry(void)
{
    /* Tests for possible duplicates as described in http://github.com/RIOT-OS/RIOT/issues/2965 */
    ipv6_addr_t *entry_1;
    ipv6_addr_t *entry_2;

    ipv6_addr_t default_addr = DEFAULT_TEST_IPV6_ADDR;
    ipv6_addr_t ll_addr;

    test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */

    /* add addresses to the interface */
    TEST_ASSERT_NOT_NULL((entry_1 = ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &default_addr, DEFAULT_TEST_PREFIX_LEN, 0)));

    /* remove default_addr, but not the others (corresponding lla, solicited-node addr)
     * that came with it */
    ng_ipv6_netif_remove_addr(DEFAULT_TEST_NETIF, &default_addr);

    /* create and re-add corresponding lla and check that it hasn't taken
     * the old place of default_addr*/
    ll_addr.u64[1] = default_addr.u64[1];
    ipv6_addr_set_link_local_prefix(&ll_addr);
    TEST_ASSERT_NOT_NULL((entry_2 = ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &ll_addr, DEFAULT_TEST_PREFIX_LEN, 0)));

    TEST_ASSERT(entry_1 != entry_2);
}
示例#2
0
static void test_ipv6_netif_remove_addr__success(void)
{
    ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;

    test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
                                          * DEFAULT_TEST_NETIF */

    ng_ipv6_netif_remove_addr(DEFAULT_TEST_NETIF, &addr);

    TEST_ASSERT_NULL(ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr));
}
示例#3
0
static void test_ipv6_netif_remove_addr__not_allocated(void)
{
    ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
    ng_ipv6_addr_t other_addr = OTHER_TEST_IPV6_ADDR;

    test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
                                          * DEFAULT_TEST_NETIF */

    ng_ipv6_netif_remove_addr(DEFAULT_TEST_NETIF, &other_addr);

    TEST_ASSERT_NULL(ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &other_addr));
    TEST_ASSERT_NOT_NULL(ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr));
}
示例#4
0
static int _netif_del(kernel_pid_t dev, char *addr_str)
{
#ifdef MODULE_NG_IPV6_NETIF
    ng_ipv6_addr_t addr;

    if (ng_ipv6_addr_from_str(&addr, addr_str) == NULL) {
        puts("error: unable to parse IPv6 address.");
        return 1;
    }

    ng_ipv6_netif_remove_addr(dev, &addr);

    printf("success: removed %s to interface %" PRIkernel_pid "\n", addr_str,
           dev);

    return 0;
#else
    (void)dev;
    (void)addr_str;
    puts("error: unable to delete IPv6 address.");
    return 1;
#endif
}
示例#5
0
文件: ng_ipv6.c 项目: jferreir/RIOT
/* internal functions */
static void *_event_loop(void *args)
{
    msg_t msg, reply, msg_q[NG_IPV6_MSG_QUEUE_SIZE];
    ng_netreg_entry_t me_reg;

    (void)args;
    msg_init_queue(msg_q, NG_IPV6_MSG_QUEUE_SIZE);

    me_reg.demux_ctx = NG_NETREG_DEMUX_CTX_ALL;
    me_reg.pid = thread_getpid();

    /* register interest in all IPv6 packets */
    ng_netreg_register(NG_NETTYPE_IPV6, &me_reg);

    /* preinitialize ACK */
    reply.type = NG_NETAPI_MSG_TYPE_ACK;

    /* start event loop */
    while (1) {
        DEBUG("ipv6: waiting for incoming message.\n");
        msg_receive(&msg);

        switch (msg.type) {
            case NG_NETAPI_MSG_TYPE_RCV:
                DEBUG("ipv6: NG_NETAPI_MSG_TYPE_RCV received\n");
                _receive((ng_pktsnip_t *)msg.content.ptr);
                break;

            case NG_NETAPI_MSG_TYPE_SND:
                DEBUG("ipv6: NG_NETAPI_MSG_TYPE_SND received\n");
                _send((ng_pktsnip_t *)msg.content.ptr, true);
                break;

            case NG_NETAPI_MSG_TYPE_GET:
            case NG_NETAPI_MSG_TYPE_SET:
                DEBUG("ipv6: reply to unsupported get/set\n");
                reply.content.value = -ENOTSUP;
                msg_reply(&msg, &reply);
                break;

            case NG_NDP_MSG_RTR_TIMEOUT:
                DEBUG("ipv6: Router timeout received\n");
                ((ng_ipv6_nc_t *)msg.content.ptr)->flags &= ~NG_IPV6_NC_IS_ROUTER;
                break;

            case NG_NDP_MSG_ADDR_TIMEOUT:
                DEBUG("ipv6: Router advertisement timer event received\n");
                ng_ipv6_netif_remove_addr(KERNEL_PID_UNDEF,
                                          (ng_ipv6_addr_t *)msg.content.ptr);
                break;

            case NG_NDP_MSG_NBR_SOL_RETRANS:
                DEBUG("ipv6: Neigbor solicitation retransmission timer event received\n");
                ng_ndp_retrans_nbr_sol((ng_ipv6_nc_t *)msg.content.ptr);
                break;

            case NG_NDP_MSG_NC_STATE_TIMEOUT:
                DEBUG("ipv6: Neigbor cace state timeout received\n");
                ng_ndp_state_timeout((ng_ipv6_nc_t *)msg.content.ptr);
                break;

            default:
                break;
        }
    }

    return NULL;
}