GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libc/net/res_debug_syms.c Lines: 0 11 0.0 %
Date: 2017-11-13 Branches: 0 8 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: res_debug_syms.c,v 1.2 2015/10/05 02:57:16 guenther Exp $	*/
2
3
/*
4
 * ++Copyright++ 1985, 1990, 1993
5
 * -
6
 * Copyright (c) 1985, 1990, 1993
7
 *    The Regents of the University of California.  All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 * 3. Neither the name of the University nor the names of its contributors
18
 *    may be used to endorse or promote products derived from this software
19
 *    without specific prior written permission.
20
 *
21
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31
 * SUCH DAMAGE.
32
 * -
33
 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
34
 *
35
 * Permission to use, copy, modify, and distribute this software for any
36
 * purpose with or without fee is hereby granted, provided that the above
37
 * copyright notice and this permission notice appear in all copies, and that
38
 * the name of Digital Equipment Corporation not be used in advertising or
39
 * publicity pertaining to distribution of the document or software without
40
 * specific, written prior permission.
41
 *
42
 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
43
 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
44
 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
45
 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
46
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
47
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
48
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49
 * SOFTWARE.
50
 * -
51
 * Portions Copyright (c) 1995 by International Business Machines, Inc.
52
 *
53
 * International Business Machines, Inc. (hereinafter called IBM) grants
54
 * permission under its copyrights to use, copy, modify, and distribute this
55
 * Software with or without fee, provided that the above copyright notice and
56
 * all paragraphs of this notice appear in all copies, and that the name of IBM
57
 * not be used in connection with the marketing of any product incorporating
58
 * the Software or modifications thereof, without specific, written prior
59
 * permission.
60
 *
61
 * To the extent it has a right to do so, IBM grants an immunity from suit
62
 * under its patents, if any, for the use, sale or manufacture of products to
63
 * the extent that such products are used for performing Domain Name System
64
 * dynamic updates in TCP/IP networks by means of the Software.  No immunity is
65
 * granted for any product per se or for any other function of any product.
66
 *
67
 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
68
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
69
 * PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
70
 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
71
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
72
 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
73
 * --Copyright--
74
 */
75
76
77
#include <sys/types.h>
78
#include <netinet/in.h>
79
#include <arpa/nameser.h>
80
81
#include <resolv.h>
82
#include <stdio.h>
83
84
/*
85
 * Names of RR classes and qclasses.  Classes and qclasses are the same, except
86
 * that C_ANY is a qclass but not a class.  (You can ask for records of class
87
 * C_ANY, but you can't have any records of that class in the database.)
88
 */
89
const struct res_sym __p_class_syms[] = {
90
	{C_IN,		"IN"},
91
	{C_CHAOS,	"CHAOS"},
92
	{C_HS,		"HS"},
93
	{C_HS,		"HESIOD"},
94
	{C_ANY,		"ANY"},
95
	{C_IN, 		(char *)0}
96
};
97
98
/*
99
 * Names of RR types and qtypes.  Types and qtypes are the same, except
100
 * that T_ANY is a qtype but not a type.  (You can ask for records of type
101
 * T_ANY, but you can't have any records of that type in the database.)
102
 */
103
const struct res_sym __p_type_syms[] = {
104
	{T_A,		"A",		"address"},
105
	{T_NS,		"NS",		"name server"},
106
	{T_MD,		"MD",		"mail destination (deprecated)"},
107
	{T_MF,		"MF",		"mail forwarder (deprecated)"},
108
	{T_CNAME,	"CNAME",	"canonical name"},
109
	{T_SOA,		"SOA",		"start of authority"},
110
	{T_MB,		"MB",		"mailbox"},
111
	{T_MG,		"MG",		"mail group member"},
112
	{T_MR,		"MR",		"mail rename"},
113
	{T_NULL,	"NULL",		"null"},
114
	{T_WKS,		"WKS",		"well-known service (deprecated)"},
115
	{T_PTR,		"PTR",		"domain name pointer"},
116
	{T_HINFO,	"HINFO",	"host information"},
117
	{T_MINFO,	"MINFO",	"mailbox information"},
118
	{T_MX,		"MX",		"mail exchanger"},
119
	{T_TXT,		"TXT",		"text"},
120
	{T_RP,		"RP",		"responsible person"},
121
	{T_AFSDB,	"AFSDB",	"DCE or AFS server"},
122
	{T_X25,		"X25",		"X25 address"},
123
	{T_ISDN,	"ISDN",		"ISDN address"},
124
	{T_RT,		"RT",		"router"},
125
	{T_NSAP,	"NSAP",		"nsap address"},
126
	{T_NSAP_PTR,	"NSAP_PTR",	"domain name pointer"},
127
	{T_SIG,		"SIG",		"signature"},
128
	{T_KEY,		"KEY",		"key"},
129
	{T_PX,		"PX",		"mapping information"},
130
	{T_GPOS,	"GPOS",		"geographical position (withdrawn)"},
131
	{T_AAAA,	"AAAA",		"IPv6 address"},
132
	{T_LOC,		"LOC",		"location"},
133
	{T_NXT,		"NXT",		"next valid name (unimplemented)"},
134
	{T_EID,		"EID",		"endpoint identifier (unimplemented)"},
135
	{T_NIMLOC,	"NIMLOC",	"NIMROD locator (unimplemented)"},
136
	{T_SRV,		"SRV",		"server selection"},
137
	{T_ATMA,	"ATMA",		"ATM address (unimplemented)"},
138
	{T_IXFR,	"IXFR",		"incremental zone transfer"},
139
	{T_AXFR,	"AXFR",		"zone transfer"},
140
	{T_MAILB,	"MAILB",	"mailbox-related data (deprecated)"},
141
	{T_MAILA,	"MAILA",	"mail agent (deprecated)"},
142
	{T_UINFO,	"UINFO",	"user information (nonstandard)"},
143
	{T_UID,		"UID",		"user ID (nonstandard)"},
144
	{T_GID,		"GID",		"group ID (nonstandard)"},
145
	{T_NAPTR,	"NAPTR",	"URN Naming Authority"},
146
#ifdef ALLOW_T_UNSPEC
147
	{T_UNSPEC,	"UNSPEC",	"unspecified data (nonstandard)"},
148
#endif /* ALLOW_T_UNSPEC */
149
	{T_ANY,		"ANY",		"\"any\""},
150
	{0, 		NULL,		NULL}
151
};
152
153
const char *
154
__sym_ntos(const struct res_sym *syms, int number, int *success)
155
{
156
	static char unname[20];
157
158
	for (; syms->name != 0; syms++) {
159
		if (number == syms->number) {
160
			if (success)
161
				*success = 1;
162
			return (syms->name);
163
		}
164
	}
165
166
	snprintf(unname, sizeof unname, "%d", number);
167
	if (success)
168
		*success = 0;
169
	return (unname);
170
}
171
DEF_STRONG(__sym_ntos);
172
173
/*
174
 * Return a string for the type
175
 */
176
const char *
177
__p_type(int type)
178
{
179
	return (__sym_ntos (__p_type_syms, type, (int *)0));
180
}
181
DEF_STRONG(__p_type);
182
183
/*
184
 * Return a mnemonic for class
185
 */
186
const char *
187
__p_class(int class)
188
{
189
	return (__sym_ntos (__p_class_syms, class, (int *)0));
190
}
191
DEF_STRONG(__p_class);
192