feat: --tos param
This commit is contained in:
parent
7a76ff8d2a
commit
381f3bd159
7 changed files with 32 additions and 1 deletions
|
|
@ -61,6 +61,14 @@ enum {
|
||||||
OPT_ARG_SECONDS, \
|
OPT_ARG_SECONDS, \
|
||||||
"Wait N seconds between packets" \
|
"Wait N seconds between packets" \
|
||||||
) \
|
) \
|
||||||
|
X( \
|
||||||
|
'T', \
|
||||||
|
"tos", \
|
||||||
|
required_argument, \
|
||||||
|
cli_handle_tos, \
|
||||||
|
OPT_ARG_UINT, \
|
||||||
|
"Set Type of Service (TOS)" \
|
||||||
|
) \
|
||||||
X( \
|
X( \
|
||||||
't', \
|
't', \
|
||||||
"ttl", \
|
"ttl", \
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ int cli_handle_quiet(const char *arg, void *config);
|
||||||
int cli_handle_size(const char *arg, void *config);
|
int cli_handle_size(const char *arg, void *config);
|
||||||
int cli_handle_linger(const char *arg, void *config);
|
int cli_handle_linger(const char *arg, void *config);
|
||||||
int cli_handle_timeout(const char *arg, void *config);
|
int cli_handle_timeout(const char *arg, void *config);
|
||||||
|
int cli_handle_tos(const char *arg, void *config);
|
||||||
int cli_handle_ttl(const char *arg, void *config);
|
int cli_handle_ttl(const char *arg, void *config);
|
||||||
int cli_handle_verbose(const char *arg, void *config);
|
int cli_handle_verbose(const char *arg, void *config);
|
||||||
int cli_handle_version(const char *arg, void *config);
|
int cli_handle_version(const char *arg, void *config);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ struct ping_config
|
||||||
uint64_t preload;
|
uint64_t preload;
|
||||||
double interval;
|
double interval;
|
||||||
uint8_t ttl;
|
uint8_t ttl;
|
||||||
|
uint8_t tos;
|
||||||
size_t packet_size;
|
size_t packet_size;
|
||||||
double linger;
|
double linger;
|
||||||
double timeout;
|
double timeout;
|
||||||
|
|
|
||||||
2
libicmp
2
libicmp
|
|
@ -1 +1 @@
|
||||||
Subproject commit e6693c97cc22b82adc3be85c72a5d5f655c69eb1
|
Subproject commit 71ca9abc2e05de9cf61b135a4699ed3bb97a8969
|
||||||
|
|
@ -55,6 +55,7 @@ libping_core_la_SOURCES = \
|
||||||
cli/handlers/option_map.c \
|
cli/handlers/option_map.c \
|
||||||
cli/handlers/handle_size.c \
|
cli/handlers/handle_size.c \
|
||||||
cli/handlers/handle_timeout.c \
|
cli/handlers/handle_timeout.c \
|
||||||
|
cli/handlers/handle_tos.c \
|
||||||
cli/handlers/handle_ttl.c \
|
cli/handlers/handle_ttl.c \
|
||||||
cli/handlers/handle_version.c \
|
cli/handlers/handle_version.c \
|
||||||
cli/handlers/handle_verbose.c \
|
cli/handlers/handle_verbose.c \
|
||||||
|
|
|
||||||
14
src/ping/cli/handlers/handle_tos.c
Normal file
14
src/ping/cli/handlers/handle_tos.c
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include "ping/cli.h"
|
||||||
|
#include "internal/cli/parse_utils.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
cli_handle_tos(const char *arg, void *config_void)
|
||||||
|
{
|
||||||
|
struct ping_config *config = (struct ping_config *)config_void;
|
||||||
|
uint64_t tos;
|
||||||
|
|
||||||
|
if (0 != cli_parse_uint64(arg, &tos) || tos > 255)
|
||||||
|
return CLI_ERROR;
|
||||||
|
config->tos = (uint8_t)tos;
|
||||||
|
return CLI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -60,6 +60,12 @@ ping_create_handle(const struct ping_config *config)
|
||||||
icmp_destroy(handle);
|
icmp_destroy(handle);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (0 != config->tos && 0 != icmp_set_tos(handle, config->tos))
|
||||||
|
{
|
||||||
|
dprintf(STDERR_FILENO, "%s: %s\n", g_prog_name, icmp_strerror(handle));
|
||||||
|
icmp_destroy(handle);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue