#ifndef PING_CLI_OPT_H #define PING_CLI_OPT_H #include #include "cli.h" /* Ping-specific arg types, extending libcli's base enum */ enum { OPT_ARG_SECONDS = OPT_ARG_STRING + 1, OPT_ARG_BYTES, OPT_ARG_TTL, OPT_ARG_PATTERN, }; #define PING_OPTIONS_LIST \ X( \ 'h', \ "help", \ no_argument, \ cli_handle_help, \ OPT_ARG_NONE, \ "Display this help and exit" \ ) \ X( \ 'V', \ "version", \ no_argument, \ cli_handle_version, \ OPT_ARG_NONE, \ "Display version information and exit" \ ) \ X( \ 'v', \ "verbose", \ no_argument, \ cli_handle_verbose, \ OPT_ARG_NONE, \ "Verbose output" \ ) \ X( \ 'q', \ "quiet", \ no_argument, \ cli_handle_quiet, \ OPT_ARG_NONE, \ "Quiet mode (only show summary)" \ ) \ X( \ 'c', \ "count", \ required_argument, \ cli_handle_count, \ OPT_ARG_UINT, \ "Stop after sending N packets" \ ) \ X( \ 'i', \ "interval", \ required_argument, \ cli_handle_interval, \ OPT_ARG_SECONDS, \ "Wait N seconds between packets" \ ) \ X( \ 't', \ "ttl", \ required_argument, \ cli_handle_ttl, \ OPT_ARG_TTL, \ "Set Time To Live" \ ) \ X( \ 's', \ "size", \ required_argument, \ cli_handle_size, \ OPT_ARG_BYTES, \ "Packet size in bytes" \ ) \ X( \ 'W', \ "timeout", \ required_argument, \ cli_handle_timeout, \ OPT_ARG_SECONDS, \ "Timeout for replies in seconds" \ ) \ X( \ 'w', \ "deadline", \ required_argument, \ cli_handle_deadline, \ OPT_ARG_SECONDS, \ "Exit after N seconds regardless of packets sent/received" \ ) \ X( \ 'f', \ "flood", \ no_argument, \ cli_handle_flood, \ OPT_ARG_NONE, \ "Flood mode" \ ) \ X( \ 'M', \ "dont-fragment", \ no_argument, \ cli_handle_dont_fragment, \ OPT_ARG_NONE, \ "Set the Don't Fragment bit" \ ) \ X( \ 'l', \ "preload", \ required_argument, \ cli_handle_preload, \ OPT_ARG_UINT, \ "Send N packets in burst before normal loop" \ ) \ X( \ 'p', \ "pattern", \ required_argument, \ cli_handle_pattern, \ OPT_ARG_PATTERN, \ "Fill packet payload with hex pattern" \ ) #undef X #define X(short_opt, long_opt, has_arg, handler, arg_type, desc) + 1 enum { PING_OPT_LEN = (0 PING_OPTIONS_LIST) }; #undef X #define X(short_opt, long_opt, has_arg, handler, arg_type, desc) \ + (1 * (has_arg == no_argument) \ + (2 * (has_arg == required_argument) \ + (3 * (has_arg == optional_argument)))) enum { PING_OPTSTR_LEN = (2 PING_OPTIONS_LIST) }; /* +2 for ':' to disable getopt error messages and \0 */ #endif