forked from shenango/caladan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_ping.c
49 lines (38 loc) · 777 Bytes
/
test_ping.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* test_ping.c - sends ping echo requests
*/
#include <stdio.h>
#include <base/log.h>
#include <net/ping.h>
#include <runtime/runtime.h>
#include <runtime/timer.h>
#define N_PINGS 10
#define DEST_IP_ADDR 3232235778 // 192.168.1.2
static void main_handler(void *arg)
{
int i, ret;
ret = net_ping_init();
if (ret) {
log_err("failed to init ping");
return;
}
for (i = 0; i < N_PINGS; i++) {
net_send_ping(i, DEST_IP_ADDR);
/* wait 1 second before sending next ping */
timer_sleep(1000*1000);
}
}
int main(int argc, char *argv[])
{
int ret;
if (argc < 2) {
printf("arg must be config file\n");
return -EINVAL;
}
ret = runtime_init(argv[1], main_handler, NULL);
if (ret) {
printf("failed to start runtime\n");
return ret;
}
return 0;
}