summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/res_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/res_debug.c')
-rw-r--r--src/lib/libc/net/res_debug.c132
1 files changed, 40 insertions, 92 deletions
diff --git a/src/lib/libc/net/res_debug.c b/src/lib/libc/net/res_debug.c
index e0f2a89418..02f9e4a1ea 100644
--- a/src/lib/libc/net/res_debug.c
+++ b/src/lib/libc/net/res_debug.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: res_debug.c,v 1.18 2005/03/06 16:17:23 moritz Exp $ */ 1/* $OpenBSD: res_debug.c,v 1.19 2005/03/25 13:24:12 otto Exp $ */
2 2
3/* 3/*
4 * ++Copyright++ 1985, 1990, 1993 4 * ++Copyright++ 1985, 1990, 1993
@@ -78,7 +78,7 @@
78static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; 78static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
79static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $"; 79static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $";
80#else 80#else
81static char rcsid[] = "$OpenBSD: res_debug.c,v 1.18 2005/03/06 16:17:23 moritz Exp $"; 81static char rcsid[] = "$OpenBSD: res_debug.c,v 1.19 2005/03/25 13:24:12 otto Exp $";
82#endif 82#endif
83#endif /* LIBC_SCCS and not lint */ 83#endif /* LIBC_SCCS and not lint */
84 84
@@ -107,8 +107,7 @@ static const char *loc_ntoal(const u_char *binary, char *ascii, int ascii_len);
107 107
108/* XXX: we should use getservbyport() instead. */ 108/* XXX: we should use getservbyport() instead. */
109static const char * 109static const char *
110dewks(wks) 110dewks(int wks)
111 int wks;
112{ 111{
113 static char nbuf[20]; 112 static char nbuf[20];
114 113
@@ -167,8 +166,7 @@ dewks(wks)
167 166
168/* XXX: we should use getprotobynumber() instead. */ 167/* XXX: we should use getprotobynumber() instead. */
169static const char * 168static const char *
170deproto(protonum) 169deproto(int protonum)
171 int protonum;
172{ 170{
173 static char nbuf[20]; 171 static char nbuf[20];
174 172
@@ -192,11 +190,8 @@ deproto(protonum)
192} 190}
193 191
194static const u_char * 192static const u_char *
195do_rrset(msg, len, cp, cnt, pflag, file, hs) 193do_rrset(const u_char *msg, int len, const u_char *cp, int cnt, int pflag,
196 int cnt, pflag, len; 194 FILE *file, const char *hs)
197 const u_char *cp, *msg;
198 const char *hs;
199 FILE *file;
200{ 195{
201 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); 196 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res);
202 int n; 197 int n;
@@ -234,8 +229,7 @@ do_rrset(msg, len, cp, cnt, pflag, file, hs)
234} 229}
235 230
236void 231void
237__p_query(msg) 232__p_query(const u_char *msg)
238 const u_char *msg;
239{ 233{
240 __fp_query(msg, stdout); 234 __fp_query(msg, stdout);
241} 235}
@@ -245,11 +239,9 @@ __p_query(msg)
245 * This is intended to be primarily a debugging routine. 239 * This is intended to be primarily a debugging routine.
246 */ 240 */
247void 241void
248__fp_resstat(statp, file) 242__fp_resstat(struct __res_state *statp, FILE *file)
249 struct __res_state *statp;
250 FILE *file;
251{ 243{
252 register u_long mask; 244 u_long mask;
253 245
254 fprintf(file, ";; res options:"); 246 fprintf(file, ";; res options:");
255 if (!statp) 247 if (!statp)
@@ -265,15 +257,12 @@ __fp_resstat(statp, file)
265 * This is intended to be primarily a debugging routine. 257 * This is intended to be primarily a debugging routine.
266 */ 258 */
267void 259void
268__fp_nquery(msg, len, file) 260__fp_nquery(const u_char *msg, int len, FILE *file)
269 const u_char *msg;
270 int len;
271 FILE *file;
272{ 261{
273 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); 262 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res);
274 register const u_char *cp, *endMark; 263 const u_char *cp, *endMark;
275 register const HEADER *hp; 264 const HEADER *hp;
276 register int n; 265 int n;
277 266
278 if ((_resp->options & RES_INIT) == 0 && res_init() == -1) 267 if ((_resp->options & RES_INIT) == 0 && res_init() == -1)
279 return; 268 return;
@@ -394,18 +383,13 @@ __fp_nquery(msg, len, file)
394} 383}
395 384
396void 385void
397__fp_query(msg, file) 386__fp_query(const u_char *msg, FILE *file)
398 const u_char *msg;
399 FILE *file;
400{ 387{
401 fp_nquery(msg, PACKETSZ, file); 388 fp_nquery(msg, PACKETSZ, file);
402} 389}
403 390
404const u_char * 391const u_char *
405__p_cdnname(cp, msg, len, file) 392__p_cdnname(const u_char *cp, const u_char *msg, int len, FILE *file)
406 const u_char *cp, *msg;
407 int len;
408 FILE *file;
409{ 393{
410 char name[MAXDNAME]; 394 char name[MAXDNAME];
411 int n; 395 int n;
@@ -420,9 +404,7 @@ __p_cdnname(cp, msg, len, file)
420} 404}
421 405
422const u_char * 406const u_char *
423__p_cdname(cp, msg, file) 407__p_cdname(const u_char *cp, const u_char *msg, FILE *file)
424 const u_char *cp, *msg;
425 FILE *file;
426{ 408{
427 return (p_cdnname(cp, msg, PACKETSZ, file)); 409 return (p_cdnname(cp, msg, PACKETSZ, file));
428} 410}
@@ -432,11 +414,7 @@ __p_cdname(cp, msg, file)
432 length supplied). */ 414 length supplied). */
433 415
434const u_char * 416const u_char *
435__p_fqnname(cp, msg, msglen, name, namelen) 417__p_fqnname(const u_char *cp, const u_char *msg, int msglen, char *name, int namelen)
436 const u_char *cp, *msg;
437 int msglen;
438 char *name;
439 int namelen;
440{ 418{
441 int n, newlen; 419 int n, newlen;
442 420
@@ -456,9 +434,7 @@ __p_fqnname(cp, msg, msglen, name, namelen)
456 */ 434 */
457 435
458const u_char * 436const u_char *
459__p_fqname(cp, msg, file) 437__p_fqname(const u_char *cp, const u_char *msg, FILE *file)
460 const u_char *cp, *msg;
461 FILE *file;
462{ 438{
463 char name[MAXDNAME]; 439 char name[MAXDNAME];
464 const u_char *n; 440 const u_char *n;
@@ -474,9 +450,7 @@ __p_fqname(cp, msg, file)
474 * Print resource record fields in human readable form. 450 * Print resource record fields in human readable form.
475 */ 451 */
476const u_char * 452const u_char *
477__p_rr(cp, msg, file) 453__p_rr(const u_char *cp, const u_char *msg, FILE *file)
478 const u_char *cp, *msg;
479 FILE *file;
480{ 454{
481 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); 455 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res);
482 int type, class, dlen, n, c; 456 int type, class, dlen, n, c;
@@ -932,10 +906,7 @@ const struct res_sym __p_type_syms[] = {
932}; 906};
933 907
934int 908int
935__sym_ston(syms, name, success) 909__sym_ston(const struct res_sym *syms, char *name, int *success)
936 const struct res_sym *syms;
937 char *name;
938 int *success;
939{ 910{
940 for (; syms->name != 0; syms++) { 911 for (; syms->name != 0; syms++) {
941 if (strcasecmp (name, syms->name) == 0) { 912 if (strcasecmp (name, syms->name) == 0) {
@@ -950,10 +921,7 @@ __sym_ston(syms, name, success)
950} 921}
951 922
952const char * 923const char *
953__sym_ntos(syms, number, success) 924__sym_ntos(const struct res_sym *syms, int number, int *success)
954 const struct res_sym *syms;
955 int number;
956 int *success;
957{ 925{
958 static char unname[20]; 926 static char unname[20];
959 927
@@ -973,10 +941,7 @@ __sym_ntos(syms, number, success)
973 941
974 942
975const char * 943const char *
976__sym_ntop(syms, number, success) 944__sym_ntop(const struct res_sym *syms, int number, int *success)
977 const struct res_sym *syms;
978 int number;
979 int *success;
980{ 945{
981 static char unname[20]; 946 static char unname[20];
982 947
@@ -997,8 +962,7 @@ __sym_ntop(syms, number, success)
997 * Return a string for the type 962 * Return a string for the type
998 */ 963 */
999const char * 964const char *
1000__p_type(type) 965__p_type(int type)
1001 int type;
1002{ 966{
1003 return (__sym_ntos (__p_type_syms, type, (int *)0)); 967 return (__sym_ntos (__p_type_syms, type, (int *)0));
1004} 968}
@@ -1007,8 +971,7 @@ __p_type(type)
1007 * Return a mnemonic for class 971 * Return a mnemonic for class
1008 */ 972 */
1009const char * 973const char *
1010__p_class(class) 974__p_class(int class)
1011 int class;
1012{ 975{
1013 return (__sym_ntos (__p_class_syms, class, (int *)0)); 976 return (__sym_ntos (__p_class_syms, class, (int *)0));
1014} 977}
@@ -1017,8 +980,7 @@ __p_class(class)
1017 * Return a mnemonic for an option 980 * Return a mnemonic for an option
1018 */ 981 */
1019const char * 982const char *
1020__p_option(option) 983__p_option(u_long option)
1021 u_long option;
1022{ 984{
1023 static char nbuf[40]; 985 static char nbuf[40];
1024 986
@@ -1047,13 +1009,12 @@ __p_option(option)
1047 * Return a mnemonic for a time to live 1009 * Return a mnemonic for a time to live
1048 */ 1010 */
1049const char * 1011const char *
1050p_time(value) 1012p_time(u_int32_t value)
1051 u_int32_t value;
1052{ 1013{
1053 static char nbuf[40]; 1014 static char nbuf[40];
1054 char *ebuf; 1015 char *ebuf;
1055 int secs, mins, hours, days; 1016 int secs, mins, hours, days;
1056 register char *p; 1017 char *p;
1057 int tmp; 1018 int tmp;
1058 1019
1059 if (value == 0) { 1020 if (value == 0) {
@@ -1129,8 +1090,7 @@ static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,
1129 1090
1130/* takes an XeY precision/size value, returns a string representation. */ 1091/* takes an XeY precision/size value, returns a string representation. */
1131static const char * 1092static const char *
1132precsize_ntoa(prec) 1093precsize_ntoa(u_int8_t prec)
1133 u_int8_t prec;
1134{ 1094{
1135 static char retbuf[sizeof "90000000.00"]; 1095 static char retbuf[sizeof "90000000.00"];
1136 unsigned long val; 1096 unsigned long val;
@@ -1147,14 +1107,13 @@ precsize_ntoa(prec)
1147 1107
1148/* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */ 1108/* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */
1149static u_int8_t 1109static u_int8_t
1150precsize_aton(strptr) 1110precsize_aton(char **strptr)
1151 char **strptr;
1152{ 1111{
1153 unsigned int mval = 0, cmval = 0; 1112 unsigned int mval = 0, cmval = 0;
1154 u_int8_t retval = 0; 1113 u_int8_t retval = 0;
1155 register char *cp; 1114 char *cp;
1156 register int exponent; 1115 int exponent;
1157 register int mantissa; 1116 int mantissa;
1158 1117
1159 cp = *strptr; 1118 cp = *strptr;
1160 1119
@@ -1189,11 +1148,9 @@ precsize_aton(strptr)
1189 1148
1190/* converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */ 1149/* converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */
1191static u_int32_t 1150static u_int32_t
1192latlon2ul(latlonstrptr,which) 1151latlon2ul(char **latlonstrptr, int *which)
1193 char **latlonstrptr;
1194 int *which;
1195{ 1152{
1196 register char *cp; 1153 char *cp;
1197 u_int32_t retval; 1154 u_int32_t retval;
1198 int deg = 0, min = 0, secs = 0, secsfrac = 0; 1155 int deg = 0, min = 0, secs = 0, secsfrac = 0;
1199 1156
@@ -1288,9 +1245,7 @@ latlon2ul(latlonstrptr,which)
1288/* converts a zone file representation in a string to an RDATA on-the-wire 1245/* converts a zone file representation in a string to an RDATA on-the-wire
1289 * representation. */ 1246 * representation. */
1290int 1247int
1291loc_aton(ascii, binary) 1248loc_aton(const char *ascii, u_char *binary)
1292 const char *ascii;
1293 u_char *binary;
1294{ 1249{
1295 const char *maxcp; 1250 const char *maxcp;
1296 u_char *bcp; 1251 u_char *bcp;
@@ -1399,22 +1354,17 @@ loc_aton(ascii, binary)
1399} 1354}
1400 1355
1401const char * 1356const char *
1402loc_ntoa(binary, ascii) 1357loc_ntoa(const u_char *binary, char *ascii)
1403 const u_char *binary;
1404 char *ascii;
1405{ 1358{
1406 return loc_ntoal(binary, ascii, 255); 1359 return loc_ntoal(binary, ascii, 255);
1407} 1360}
1408 1361
1409/* takes an on-the-wire LOC RR and formats it in a human readable format. */ 1362/* takes an on-the-wire LOC RR and formats it in a human readable format. */
1410static const char * 1363static const char *
1411loc_ntoal(binary, ascii, ascii_len) 1364loc_ntoal(const u_char *binary, char *ascii, int ascii_len)
1412 const u_char *binary;
1413 char *ascii;
1414 int ascii_len;
1415{ 1365{
1416 static char *error = "?"; 1366 static char *error = "?";
1417 register const u_char *cp = binary; 1367 const u_char *cp = binary;
1418 1368
1419 int latdeg, latmin, latsec, latsecfrac; 1369 int latdeg, latmin, latsec, latsecfrac;
1420 int longdeg, longmin, longsec, longsecfrac; 1370 int longdeg, longmin, longsec, longsecfrac;
@@ -1513,8 +1463,7 @@ loc_ntoal(binary, ascii, ascii_len)
1513 1463
1514/* Return the number of DNS hierarchy levels in the name. */ 1464/* Return the number of DNS hierarchy levels in the name. */
1515int 1465int
1516__dn_count_labels(name) 1466__dn_count_labels(char *name)
1517 char *name;
1518{ 1467{
1519 int i, len, count; 1468 int i, len, count;
1520 1469
@@ -1544,8 +1493,7 @@ __dn_count_labels(name)
1544 * SIG records are required to be printed like this, by the Secure DNS RFC. 1493 * SIG records are required to be printed like this, by the Secure DNS RFC.
1545 */ 1494 */
1546char * 1495char *
1547__p_secstodate (secs) 1496__p_secstodate (long unsigned int secs)
1548 unsigned long secs;
1549{ 1497{
1550 static char output[15]; /* YYYYMMDDHHMMSS and null */ 1498 static char output[15]; /* YYYYMMDDHHMMSS and null */
1551 time_t clock = secs; 1499 time_t clock = secs;