示例#1
0
文件: ping.c 项目: deepfryed/RIOT
static int ping_send(const uip_ipaddr_t *dst, int payload_len)
{
    int len = payload_len;
    icmpv6_echo_t *ping = uip_icmp_buf();

    ping->id = byteorder_htons(ECHO_ID);

    if (payload_len > max_len()) {
        puts("Payload too long for buffer.");
        return -1;
    }

    for (network_uint16_t *payload = (network_uint16_t *)(ping + 1);
         len >= 0;
         payload++, len -= 2) {
        *payload = byteorder_htons(seq);
    }

    ping->seq = byteorder_htons(seq++);

    uip_icmp6_send((const uip_ipaddr_t *)dst, ICMPV6_ECHO_REQ, 0,
                   payload_len + (sizeof(icmpv6_echo_t) - sizeof(icmpv6_hdr_t)));

    return 0;
}
示例#2
0
/*---------------------------------------------------------------------------*/
static void
ping_parent(void)
{
    if(uip_ds6_get_global(ADDR_PREFERRED) == NULL) {
        return;
    }

    uip_icmp6_send(uip_ds6_defrt_choose(), ICMP6_ECHO_REQUEST, 0,
                   CC26XX_WEB_DEMO_ECHO_REQ_PAYLOAD_LEN);
}