diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/resolve-host/resolve-host.c | 46 | ||||
-rw-r--r-- | src/resolve/resolved-dns-rr.h | 4 | ||||
-rw-r--r-- | src/systemctl/systemctl.c | 7 |
3 files changed, 53 insertions, 4 deletions
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c index 1b1edaf6ec..1063790640 100644 --- a/src/resolve-host/resolve-host.c +++ b/src/resolve-host/resolve-host.c @@ -39,6 +39,7 @@ static int arg_family = AF_UNSPEC; static int arg_ifindex = 0; static uint16_t arg_type = 0; static uint16_t arg_class = 0; +static bool arg_legend = true; static int resolve_host(sd_bus *bus, const char *name) { @@ -387,6 +388,32 @@ static int resolve_record(sd_bus *bus, const char *name) { return 0; } +static void help_dns_types(void) { + int i; + const char *t; + + if (arg_legend) + puts("Known dns types:"); + for (i = 0; i < _DNS_TYPE_MAX; i++) { + t = dns_type_to_string(i); + if (t) + puts(t); + } +} + +static void help_dns_classes(void) { + int i; + const char *t; + + if (arg_legend) + puts("Known dns classes:"); + for (i = 0; i < _DNS_CLASS_MAX; i++) { + t = dns_class_to_string(i); + if (t) + puts(t); + } +} + static void help(void) { printf("%s [OPTIONS...]\n\n" "Resolve IPv4 or IPv6 addresses.\n\n" @@ -397,12 +424,14 @@ static void help(void) { " -i INTERFACE Filter by interface\n" " -t --type=TYPE Query RR with DNS type\n" " -c --class=CLASS Query RR with DNS class\n" + " --no-legend Do not print column headers\n" , program_invocation_short_name); } static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, + ARG_NO_LEGEND, }; static const struct option options[] = { @@ -410,6 +439,7 @@ static int parse_argv(int argc, char *argv[]) { { "version", no_argument, NULL, ARG_VERSION }, { "type", no_argument, NULL, 't' }, { "class", no_argument, NULL, 'c' }, + { "no-legend", no_argument, NULL, ARG_NO_LEGEND }, {} }; @@ -447,19 +477,35 @@ static int parse_argv(int argc, char *argv[]) { break; case 't': + if (streq(optarg, "help")) { + help_dns_types(); + return 0; + } + r = dns_type_from_string(optarg, &arg_type); if (r < 0) { log_error("Failed to parse RR record type %s", optarg); return r; } + break; case 'c': + if (streq(optarg, "help")) { + help_dns_classes(); + return 0; + } + r = dns_class_from_string(optarg, &arg_class); if (r < 0) { log_error("Failed to parse RR record class %s", optarg); return r; } + + break; + + case ARG_NO_LEGEND: + arg_legend = false; break; case '?': diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h index 524630071d..7b73cdc6ca 100644 --- a/src/resolve/resolved-dns-rr.h +++ b/src/resolve/resolved-dns-rr.h @@ -35,6 +35,8 @@ typedef struct DnsResourceRecord DnsResourceRecord; enum { DNS_CLASS_IN = 0x01, DNS_CLASS_ANY = 0xFF, + _DNS_CLASS_MAX, + _DNS_CLASS_INVALID = -1 }; /* DNS record types, see RFC 1035 */ @@ -60,6 +62,8 @@ enum { DNS_TYPE_TSIG = 0xFA, DNS_TYPE_IXFR = 0xFB, DNS_TYPE_AXFR = 0xFC, + _DNS_TYPE_MAX, + _DNS_TYPE_INVALID = -1 }; struct DnsResourceKey { diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 21e33d5bfc..8ec0db2b2d 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -5627,18 +5627,17 @@ static int runlevel_help(void) { return 0; } -static int help_types(void) { +static void help_types(void) { int i; const char *t; - puts("Available unit types:"); + if (!arg_no_legend) + puts("Available unit types:"); for (i = 0; i < _UNIT_TYPE_MAX; i++) { t = unit_type_to_string(i); if (t) puts(t); } - - return 0; } static int systemctl_parse_argv(int argc, char *argv[]) { |