CMD_INM_ICMP_PING_INIT,
CMD_INM_ICMP_PING_DEINIT,
+ CMD_INM_ICMP_PING_START,
+ CMD_INM_ICMP_PING_STOP,
CMD_MAX,
};
{CMD_INM_STOP_CHECK_GATEWAY, "CMD_INM_STOP_CHECK_GATEWAY"},
{CMD_INM_ICMP_PING_INIT, "CMD_INM_ICMP_PING_INIT"},
{CMD_INM_ICMP_PING_DEINIT, "CMD_INM_ICMP_PING_DEINIT"},
+ {CMD_INM_ICMP_PING_START, "CMD_INM_ICMP_PING_START"},
+ {CMD_INM_ICMP_PING_STOP, "CMD_INM_ICMP_PING_STOP"},
{ -1, NULL }, };
}
static void __icmp_ping_cb (gboolean found,
+ gchar *reason,
gchar *ip,
gpointer user_data)
{
if (!ip)
return;
- printf("%s %s\n", ip, found ? "Found" : "Not found");
+ printf("%s %s %s\n", ip, found ? "Found" : "Not found", reason ? reason : "");
return;
}
return;
}
+
+void test_inm_icmp_ping_start()
+{
+ char *target_ip;
+ int ret = 0;
+
+ target_ip = NULL;
+
+ printf("Input target IP address :\n");
+ if (scanf(" %18ms", &target_ip) < 1)
+ return;
+ if (strlen(target_ip) <= 0)
+ printf("invalid IP !!\n");
+ else
+ printf("IP: [%s]\n", target_ip);
+
+ ret = inm_icmp_ping_start(target_ip, 0, 0, 0);
+ if (ret == INM_ICMP_PING_ERROR_NONE) {
+ printf(MAKE_GREEN"inm_icmp_ping_start"RESET_COLOR"\n");
+ } else {
+ printf(MAKE_RED"inm_icmp_ping_start: %s ",
+ print_icmp_ping_err(ret));
+ printf(RESET_COLOR"\n");
+ }
+ free(target_ip);
+}
+
+void test_inm_icmp_ping_stop()
+{
+ char *target_ip;
+ int ret = 0;
+
+ target_ip = NULL;
+
+ printf("Input target IP address :\n");
+ if (scanf(" %18ms", &target_ip) < 1)
+ return;
+ if (strlen(target_ip) <= 0)
+ printf("invalid IP !!\n");
+ else
+ printf("IP: [%s]\n", target_ip);
+
+ ret = inm_icmp_ping_stop(target_ip);
+ if (ret == INM_ICMP_PING_ERROR_NONE) {
+ printf(MAKE_GREEN"inm_icmp_ping_stop"RESET_COLOR"\n");
+ } else {
+ printf(MAKE_RED"inm_icmp_ping_stop: %s ",
+ print_icmp_ping_err(ret));
+ printf(RESET_COLOR"\n");
+ }
+
+ free(target_ip);
+}
+
typedef void (*test_func)(void);
typedef struct {
{CMD_INM_ICMP_PING_INIT, test_inm_icmp_ping_init},
{CMD_INM_ICMP_PING_DEINIT, test_inm_icmp_ping_deinit},
+ {CMD_INM_ICMP_PING_START, test_inm_icmp_ping_start},
+ {CMD_INM_ICMP_PING_STOP, test_inm_icmp_ping_stop},
{ -1, NULL }, };