resolve-host: add option to list protocols
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 5 Feb 2015 02:06:36 +0000 (21:06 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Jan 2016 17:13:08 +0000 (12:13 -0500)
man/systemd-resolve.xml
src/resolve/resolve-tool.c

index fc06b9e..546054a 100644 (file)
     done, and a hostname is retrieved for the specified addresses.</para>
 
     <para>The <option>--type=</option> switch may be used to specify a DNS resource record type (A, AAAA, SOA, MX, ...) in
-    order to request a specific DNS resource record, instead of the address or reverse address lookups.</para>
+    order to request a specific DNS resource record, instead of the address or reverse address lookups.
+    The special value <literal>help</literal> may be used to list known values.</para>
 
     <para>The <option>--service</option> switch may be used to resolve <ulink
     url="https://tools.ietf.org/html/rfc2782">SRV</ulink> and <ulink
         same time. The setting <literal>llmnr</literal> is identical to specifying this switch once with
         <literal>llmnr-ipv4</literal> and once via <literal>llmnr-ipv6</literal>. Note that this option does not force
         the service to resolve the operation with the specified protocol, as that might require a suitable network
-        interface and configuration.</para></listitem>
+        interface and configuration.
+        The special value <literal>help</literal> may be used to list known values.
+        </para></listitem>
       </varlistentry>
 
       <varlistentry>
 
         <listitem><para>Specifies the DNS resource record type (e.g. A, AAAA, MX, …) and class (e.g. IN, ANY, …) to
         look up. If these options are used a DNS resource record set matching the specified class and type is
-        requested. The class defaults to IN if only a type is specified.</para></listitem>
+        requested. The class defaults to IN if only a type is specified.
+        The special value <literal>help</literal> may be used to list known values.
+        </para></listitem>
       </varlistentry>
 
       <varlistentry>
index fdaeb8d..9bee953 100644 (file)
@@ -900,6 +900,12 @@ static int reset_statistics(sd_bus *bus) {
         return 0;
 }
 
+static void help_protocol_types(void) {
+        if (arg_legend)
+                puts("Known protocol types:");
+        puts("dns\nllmnr\nllmnr-ipv4\nllmnr-ipv6");
+}
+
 static void help_dns_types(void) {
         int i;
         const char *t;
@@ -930,22 +936,22 @@ static void help(void) {
         printf("%s [OPTIONS...] NAME...\n"
                "%s [OPTIONS...] --service [[NAME] TYPE] DOMAIN\n\n"
                "Resolve domain names, IPv4 and IPv6 addresses, DNS resource records, and services.\n\n"
-               "  -h --help                 Show this help\n"
-               "     --version              Show package version\n"
-               "  -4                        Resolve IPv4 addresses\n"
-               "  -6                        Resolve IPv6 addresses\n"
-               "  -i --interface=INTERFACE  Look on interface\n"
-               "  -p --protocol=PROTOCOL    Look via protocol\n"
-               "  -t --type=TYPE            Query RR with DNS type\n"
-               "  -c --class=CLASS          Query RR with DNS class\n"
-               "     --service              Resolve service (SRV)\n"
-               "     --service-address=BOOL Do [not] resolve address for services\n"
-               "     --service-txt=BOOL     Do [not] resolve TXT records for services\n"
-               "     --cname=BOOL           Do [not] follow CNAME redirects\n"
-               "     --search=BOOL          Do [not] use search domains\n"
-               "     --legend=BOOL          Do [not] print column headers and meta information\n"
-               "     --statistics           Show resolver statistics\n"
-               "     --reset-statistics     Reset resolver statistics\n"
+               "  -h --help                   Show this help\n"
+               "     --version                Show package version\n"
+               "  -4                          Resolve IPv4 addresses\n"
+               "  -6                          Resolve IPv6 addresses\n"
+               "  -i --interface=INTERFACE    Look on interface\n"
+               "  -p --protocol=PROTOCOL|help Look via protocol\n"
+               "  -t --type=TYPE|help         Query RR with DNS type\n"
+               "  -c --class=CLASS|help       Query RR with DNS class\n"
+               "     --service                Resolve service (SRV)\n"
+               "     --service-address=BOOL   Do [not] resolve address for services\n"
+               "     --service-txt=BOOL       Do [not] resolve TXT records for services\n"
+               "     --cname=BOOL             Do [not] follow CNAME redirects\n"
+               "     --search=BOOL            Do [not] use search domains\n"
+               "     --legend=BOOL            Do [not] print column headers and meta information\n"
+               "     --statistics             Show resolver statistics\n"
+               "     --reset-statistics       Reset resolver statistics\n"
                , program_invocation_short_name, program_invocation_short_name);
 }
 
@@ -1061,7 +1067,10 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case 'p':
-                        if (streq(optarg, "dns"))
+                        if (streq(optarg, "help")) {
+                                help_protocol_types();
+                                return 0;
+                        } else if (streq(optarg, "dns"))
                                 arg_flags |= SD_RESOLVED_DNS;
                         else if (streq(optarg, "llmnr"))
                                 arg_flags |= SD_RESOLVED_LLMNR;