31 #include "contiki-lib.h"
32 #include "contiki-net.h"
44 #define PRINTF(...) printf(__VA_ARGS__)
45 #define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
46 #define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x ",lladdr->addr[0], lladdr->addr[1], lladdr->addr[2], lladdr->addr[3],lladdr->addr[4], lladdr->addr[5])
49 #define PRINT6ADDR(addr)
53 #define PING6_DATALEN 16
55 #define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
56 #define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
58 static struct etimer ping6_periodic_timer;
59 static uint8_t count = 0;
60 static char command[20];
61 static uint16_t addr[8];
62 uip_ipaddr_t dest_addr;
64 PROCESS(ping6_process,
"PING6 process");
65 AUTOSTART_PROCESSES(&ping6_process);
70 ping6handler(process_event_t ev, process_data_t data)
81 addr[3],addr[4],addr[5],addr[6],addr[7]);
84 memcpy(command, (
void *)
"ping6", 5);
94 if(strcmp(command,
"ping6") != 0){
95 PRINTF(
"> invalid command\n");
99 if(scanf(
" %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
100 &addr[0],&addr[1],&addr[2],&addr[3],
101 &addr[4],&addr[5],&addr[6],&addr[7]) == 8){
104 addr[3],addr[4],addr[5],addr[6],addr[7]);
106 PRINTF(
"> invalid ipv6 address format\n");
113 if((strcmp(command,
"ping6") == 0) && (count < PING6_NB)){
129 count, PING6_DATALEN);
140 PRINTF(
"Sending Echo Request to");
163 PRINTF(
"In Process PING6\n");
164 PRINTF(
"Wait for DAD\n");
170 cont = ping6handler(ev, data);
173 PRINTF(
"END PING6\n");
uip_len
The length of the packet in the uip_buf buffer.
void tcpip_ipv6_output(void)
This function does address resolution and then calls tcpip_output.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define UIP_STAT(s)
The uIP TCP/IP statistics.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define UIP_IP_BUF
Pointer to IP header.
#define PROCESS_END()
Define the end of a process.
uint16_t uip_icmp6chksum(void)
Calculate the ICMP checksum of the packet in uip_buf.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
#define ICMP6_ECHO_REQUEST
Echo request.
#define PROCESS(name, strname)
Declare a process.
void uip_ds6_select_src(uip_ipaddr_t *src, uip_ipaddr_t *dst)
Source address selection, see RFC 3484.
#define UIP_ICMP_BUF
Pointer to ICMP header.
#define PROCESS_YIELD()
Yield the currently running process.
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
Construct an IPv6 address from eight 16-bit words.
#define UIP_ICMP6_ECHO_REQUEST_LEN
Echo Request constant part length.
#define CLOCK_SECOND
A second, measured in system clock time.