1 /* $NetBSD: dns_str_resflags.c,v 1.3 2023/12/23 20:30:43 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 /* Viktor Dukhovni 28 /*--*/ 29 30 /* 31 * System library. 32 */ 33 #include <sys_defs.h> 34 #include <netinet/in.h> 35 #include <arpa/nameser.h> 36 #include <resolv.h> 37 38 /* 39 * Utility library. 40 */ 41 #include <name_mask.h> 42 43 /* 44 * DNS library. 45 */ 46 #include <dns.h> 47 48 /* 49 * Application-specific. 50 */ 51 52 /* 53 * This list overlaps with dns_res_opt_masks[] in smtp.c, but there we 54 * permit only a small subset of all possible flags. 55 */ 56 static const LONG_NAME_MASK resflag_table[] = { 57 "RES_INIT", RES_INIT, 58 "RES_DEBUG", RES_DEBUG, 59 #if defined(RES_AAONLY) && !HAVE_GLIBC_API_VERSION_SUPPORT(2, 24) 60 "RES_AAONLY", RES_AAONLY, 61 #endif 62 "RES_USEVC", RES_USEVC, 63 #if defined(RES_PRIMARY) && !HAVE_GLIBC_API_VERSION_SUPPORT(2, 24) 64 "RES_PRIMARY", RES_PRIMARY, 65 #endif 66 "RES_IGNTC", RES_IGNTC, 67 "RES_RECURSE", RES_RECURSE, 68 "RES_DEFNAMES", RES_DEFNAMES, 69 "RES_STAYOPEN", RES_STAYOPEN, 70 "RES_DNSRCH", RES_DNSRCH, 71 #ifdef RES_INSECURE1 72 "RES_INSECURE1", RES_INSECURE1, 73 #endif 74 #ifdef RES_INSECURE2 75 "RES_INSECURE2", RES_INSECURE2, 76 #endif 77 "RES_NOALIASES", RES_NOALIASES, 78 #ifdef RES_USE_INET6 79 "RES_USE_INET6", RES_USE_INET6, 80 #endif 81 #ifdef RES_ROTATE 82 "RES_ROTATE", RES_ROTATE, 83 #endif 84 #if defined(RES_NOCHECKNAME) && !HAVE_GLIBC_API_VERSION_SUPPORT(2, 24) 85 "RES_NOCHECKNAME", RES_NOCHECKNAME, 86 #endif 87 "RES_USE_EDNS0", RES_USE_EDNS0, 88 "RES_USE_DNSSEC", RES_USE_DNSSEC, 89 #if defined(RES_KEEPTSIG) && !HAVE_GLIBC_API_VERSION_SUPPORT(2, 24) 90 "RES_KEEPTSIG", RES_KEEPTSIG, 91 #endif 92 #if defined(RES_BLAST) && !HAVE_GLIBC_API_VERSION_SUPPORT(2, 24) 93 "RES_BLAST", RES_BLAST, 94 #endif 95 #ifdef RES_USEBSTRING 96 "RES_USEBSTRING", RES_USEBSTRING, 97 #endif 98 #ifdef RES_NSID 99 "RES_NSID", RES_NSID, 100 #endif 101 #ifdef RES_NOIP6DOTINT 102 "RES_NOIP6DOTINT", RES_NOIP6DOTINT, 103 #endif 104 #ifdef RES_USE_DNAME 105 "RES_USE_DNAME", RES_USE_DNAME, 106 #endif 107 #ifdef RES_NO_NIBBLE2 108 "RES_NO_NIBBLE2", RES_NO_NIBBLE2, 109 #endif 110 #ifdef RES_SNGLKUP 111 "RES_SNGLKUP", RES_SNGLKUP, 112 #endif 113 #ifdef RES_SNGLKUPREOP 114 "RES_SNGLKUPREOP", RES_SNGLKUPREOP, 115 #endif 116 #ifdef RES_NOTLDQUERY 117 "RES_NOTLDQUERY", RES_NOTLDQUERY, 118 #endif 119 0, 120 }; 121 122 /* dns_str_resflags - convert RES_* resolver flags to printable form */ 123 124 const char *dns_str_resflags(unsigned long mask) 125 { 126 static VSTRING *buf; 127 128 if (buf == 0) 129 buf = vstring_alloc(20); 130 return (str_long_name_mask_opt(buf, "dsns_str_resflags", resflag_table, 131 mask, NAME_MASK_NUMBER | NAME_MASK_PIPE)); 132 } 133