37 lines
984 B
C
37 lines
984 B
C
#include <stdio.h>
|
|
#include "cli.h"
|
|
#include "compiler.h"
|
|
#include "internal/cli/options.h"
|
|
#include "internal/ping/cli_handlers.h"
|
|
#include "ping/cli.h"
|
|
|
|
/* Forward declarations */
|
|
static inline const char * option_arg_type_to_str(int type);
|
|
/* -------------------- */
|
|
|
|
int
|
|
cli_handle_help(__unused const char *arg, __unused void *config_void)
|
|
{
|
|
printf("ft_ping - Send ICMP ECHO_REQUEST to network hosts\n");
|
|
printf("Usage: ft_ping [options] <destination>\n\n");
|
|
cli_print_options(g_options, PING_OPT_LEN, option_arg_type_to_str);
|
|
|
|
return CLI_EXIT_SUCCESS;
|
|
}
|
|
|
|
static inline const char *
|
|
option_arg_type_to_str(int type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case OPT_ARG_NONE: return "";
|
|
case OPT_ARG_INT: return "<NUM>";
|
|
case OPT_ARG_UINT: return "<NUM>";
|
|
case OPT_ARG_SECONDS: return "<SEC>";
|
|
case OPT_ARG_BYTES: return "<SIZE>";
|
|
case OPT_ARG_TTL: return "<TTL>";
|
|
case OPT_ARG_PATTERN: return "<HEX>";
|
|
case OPT_ARG_STRING: return "<STR>";
|
|
default: return "<ARG>";
|
|
}
|
|
}
|