xref: /netbsd-src/external/ibm-public/postfix/dist/src/dns/dns_str_resflags.c (revision f0fde9902fd4d72ded2807793acc7bfaa1ebf243)
1 /*	$NetBSD: dns_str_resflags.c,v 1.2 2020/03/18 19:05:15 christos Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	dns_str_resflags 3
6 /* SUMMARY
7 /*	convert resolver flags to printable form
8 /* SYNOPSIS
9 /*	#include <dns.h>
10 /*
11 /*	const char *dns_str_resflags(mask)
12 /*	unsigned long mask;
13 /* DESCRIPTION
14 /*	dns_str_resflags() converts RES_* resolver(5) flags from internal
15 /*	form to printable string. Individual flag names are separated
16 /*	with '|'.  The result is overwritten with each call.
17 /* LICENSE
18 /* .ad
19 /* .fi
20 /*	The Secure Mailer license must be distributed with this software.
21 /* AUTHOR(S)
22 /*	Wietse Venema
23 /*	Google, Inc.
24 /*	111 8th Avenue
25 /*	New York, NY 10011, USA
26 /*--*/
27 
28  /*
29   * System library.
30   */
31 #include <sys_defs.h>
32 #include <netinet/in.h>
33 #include <arpa/nameser.h>
34 #include <resolv.h>
35 
36  /*
37   * Utility library.
38   */
39 #include <name_mask.h>
40 
41  /*
42   * DNS library.
43   */
44 #include <dns.h>
45 
46  /*
47   * Application-specific.
48   */
49 
50  /*
51   * This list overlaps with dns_res_opt_masks[] in smtp.c, but there we
52   * permit only a small subset of all possible flags.
53   */
54 static const LONG_NAME_MASK resflag_table[] = {
55     "RES_INIT", RES_INIT,
56     "RES_DEBUG", RES_DEBUG,
57 #ifdef RES_AAONLY
58     "RES_AAONLY", RES_AAONLY,
59 #endif
60     "RES_USEVC", RES_USEVC,
61 #ifdef RES_PRIMARY
62     "RES_PRIMARY", RES_PRIMARY,
63 #endif
64     "RES_IGNTC", RES_IGNTC,
65     "RES_RECURSE", RES_RECURSE,
66     "RES_DEFNAMES", RES_DEFNAMES,
67     "RES_STAYOPEN", RES_STAYOPEN,
68     "RES_DNSRCH", RES_DNSRCH,
69 #ifdef RES_INSECURE1
70     "RES_INSECURE1", RES_INSECURE1,
71 #endif
72 #ifdef RES_INSECURE2
73     "RES_INSECURE2", RES_INSECURE2,
74 #endif
75     "RES_NOALIASES", RES_NOALIASES,
76 #ifdef RES_USE_INET6
77     "RES_USE_INET6", RES_USE_INET6,
78 #endif
79 #ifdef RES_ROTATE
80     "RES_ROTATE", RES_ROTATE,
81 #endif
82 #ifdef RES_NOCHECKNAME
83     "RES_NOCHECKNAME", RES_NOCHECKNAME,
84 #endif
85     "RES_USE_EDNS0", RES_USE_EDNS0,
86     "RES_USE_DNSSEC", RES_USE_DNSSEC,
87 #ifdef RES_KEEPTSIG
88     "RES_KEEPTSIG", RES_KEEPTSIG,
89 #endif
90 #ifdef RES_BLAST
91     "RES_BLAST", RES_BLAST,
92 #endif
93 #ifdef RES_USEBSTRING
94     "RES_USEBSTRING", RES_USEBSTRING,
95 #endif
96 #ifdef RES_NSID
97     "RES_NSID", RES_NSID,
98 #endif
99 #ifdef RES_NOIP6DOTINT
100     "RES_NOIP6DOTINT", RES_NOIP6DOTINT,
101 #endif
102 #ifdef RES_USE_DNAME
103     "RES_USE_DNAME", RES_USE_DNAME,
104 #endif
105 #ifdef RES_NO_NIBBLE2
106     "RES_NO_NIBBLE2", RES_NO_NIBBLE2,
107 #endif
108 #ifdef RES_SNGLKUP
109     "RES_SNGLKUP", RES_SNGLKUP,
110 #endif
111 #ifdef RES_SNGLKUPREOP
112     "RES_SNGLKUPREOP", RES_SNGLKUPREOP,
113 #endif
114 #ifdef RES_NOTLDQUERY
115     "RES_NOTLDQUERY", RES_NOTLDQUERY,
116 #endif
117     0,
118 };
119 
120 /* dns_str_resflags - convert RES_* resolver flags to printable form */
121 
122 const char *dns_str_resflags(unsigned long mask)
123 {
124     static VSTRING *buf;
125 
126     if (buf == 0)
127 	buf = vstring_alloc(20);
128     return (str_long_name_mask_opt(buf, "dsns_str_resflags", resflag_table,
129 				   mask, NAME_MASK_NUMBER | NAME_MASK_PIPE));
130 }
131