Explicitly request literal mode after .Xr.
[netbsd-mini2440.git] / dist / tcpdump / print-bootp.c
blob3a840f0aae3ee3683c3d18f6d9f7614ebae5368f
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 * Format and print bootp packets.
25 #include <sys/cdefs.h>
26 #ifndef lint
27 #if 0
28 static const char rcsid[] _U_ =
29 "@(#) Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.7 2007/01/29 20:56:00 guy Exp (LBL)";
30 #else
31 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
32 #endif
33 #endif
35 #ifdef HAVE_CONFIG_H
36 #include "config.h"
37 #endif
39 #include <tcpdump-stdinc.h>
41 #include <stdio.h>
42 #include <string.h>
44 #include "interface.h"
45 #include "addrtoname.h"
46 #include "extract.h"
47 #include "ether.h"
48 #include "bootp.h"
50 static void rfc1048_print(const u_char *);
51 static void cmu_print(const u_char *);
52 static char *client_fqdn_flags(u_int flags);
54 static char tstr[] = " [|bootp]";
56 static const struct tok bootp_flag_values[] = {
57 { 0x8000, "Broadcast" },
58 { 0, NULL}
61 static const struct tok bootp_op_values[] = {
62 { BOOTPREQUEST, "Request" },
63 { BOOTPREPLY, "Reply" },
64 { 0, NULL}
68 * Print bootp requests
70 void
71 bootp_print(register const u_char *cp, u_int length)
73 register const struct bootp *bp;
74 static const u_char vm_cmu[4] = VM_CMU;
75 static const u_char vm_rfc1048[4] = VM_RFC1048;
77 bp = (const struct bootp *)cp;
78 TCHECK(bp->bp_op);
80 printf("BOOTP/DHCP, %s",
81 tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op));
83 if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
84 TCHECK2(bp->bp_chaddr[0], 6);
85 printf(" from %s", etheraddr_string(bp->bp_chaddr));
88 printf(", length %u", length);
90 if (!vflag)
91 return;
93 TCHECK(bp->bp_secs);
95 /* The usual hardware address type is 1 (10Mb Ethernet) */
96 if (bp->bp_htype != 1)
97 printf(", htype %d", bp->bp_htype);
99 /* The usual length for 10Mb Ethernet address is 6 bytes */
100 if (bp->bp_htype != 1 || bp->bp_hlen != 6)
101 printf(", hlen %d", bp->bp_hlen);
103 /* Only print interesting fields */
104 if (bp->bp_hops)
105 printf(", hops %d", bp->bp_hops);
106 if (bp->bp_xid)
107 printf(", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid));
108 if (bp->bp_secs)
109 printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs));
111 printf(", Flags [%s]",
112 bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags)));
113 if (vflag > 1)
114 printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags));
116 /* Client's ip address */
117 TCHECK(bp->bp_ciaddr);
118 if (bp->bp_ciaddr.s_addr)
119 printf("\n\t Client-IP %s", ipaddr_string(&bp->bp_ciaddr));
121 /* 'your' ip address (bootp client) */
122 TCHECK(bp->bp_yiaddr);
123 if (bp->bp_yiaddr.s_addr)
124 printf("\n\t Your-IP %s", ipaddr_string(&bp->bp_yiaddr));
126 /* Server's ip address */
127 TCHECK(bp->bp_siaddr);
128 if (bp->bp_siaddr.s_addr)
129 printf("\n\t Server-IP %s", ipaddr_string(&bp->bp_siaddr));
131 /* Gateway's ip address */
132 TCHECK(bp->bp_giaddr);
133 if (bp->bp_giaddr.s_addr)
134 printf("\n\t Gateway-IP %s", ipaddr_string(&bp->bp_giaddr));
136 /* Client's Ethernet address */
137 if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
138 TCHECK2(bp->bp_chaddr[0], 6);
139 printf("\n\t Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr));
142 TCHECK2(bp->bp_sname[0], 1); /* check first char only */
143 if (*bp->bp_sname) {
144 printf("\n\t sname \"");
145 if (fn_print(bp->bp_sname, snapend)) {
146 putchar('"');
147 fputs(tstr + 1, stdout);
148 return;
150 putchar('"');
152 TCHECK2(bp->bp_file[0], 1); /* check first char only */
153 if (*bp->bp_file) {
154 printf("\n\t file \"");
155 if (fn_print(bp->bp_file, snapend)) {
156 putchar('"');
157 fputs(tstr + 1, stdout);
158 return;
160 putchar('"');
163 /* Decode the vendor buffer */
164 TCHECK(bp->bp_vend[0]);
165 if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
166 sizeof(u_int32_t)) == 0)
167 rfc1048_print(bp->bp_vend);
168 else if (memcmp((const char *)bp->bp_vend, vm_cmu,
169 sizeof(u_int32_t)) == 0)
170 cmu_print(bp->bp_vend);
171 else {
172 u_int32_t ul;
174 ul = EXTRACT_32BITS(&bp->bp_vend);
175 if (ul != 0)
176 printf("\n\t Vendor-#0x%x", ul);
179 return;
180 trunc:
181 fputs(tstr, stdout);
185 * The first character specifies the format to print:
186 * i - ip address (32 bits)
187 * p - ip address pairs (32 bits + 32 bits)
188 * l - long (32 bits)
189 * L - unsigned long (32 bits)
190 * s - short (16 bits)
191 * b - period-seperated decimal bytes (variable length)
192 * x - colon-seperated hex bytes (variable length)
193 * a - ascii string (variable length)
194 * B - on/off (8 bits)
195 * $ - special (explicit code to handle)
197 static struct tok tag2str[] = {
198 /* RFC1048 tags */
199 { TAG_PAD, " PAD" },
200 { TAG_SUBNET_MASK, "iSubnet-Mask" }, /* subnet mask (RFC950) */
201 { TAG_TIME_OFFSET, "LTime-Zone" }, /* seconds from UTC */
202 { TAG_GATEWAY, "iDefault-Gateway" }, /* default gateway */
203 { TAG_TIME_SERVER, "iTime-Server" }, /* time servers (RFC868) */
204 { TAG_NAME_SERVER, "iIEN-Name-Server" }, /* IEN name servers (IEN116) */
205 { TAG_DOMAIN_SERVER, "iDomain-Name-Server" }, /* domain name (RFC1035) */
206 { TAG_LOG_SERVER, "iLOG" }, /* MIT log servers */
207 { TAG_COOKIE_SERVER, "iCS" }, /* cookie servers (RFC865) */
208 { TAG_LPR_SERVER, "iLPR-Server" }, /* lpr server (RFC1179) */
209 { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */
210 { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */
211 { TAG_HOSTNAME, "aHostname" }, /* ascii hostname */
212 { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */
213 { TAG_END, " END" },
214 /* RFC1497 tags */
215 { TAG_DUMPPATH, "aDP" },
216 { TAG_DOMAINNAME, "aDomain-Name" },
217 { TAG_SWAP_SERVER, "iSS" },
218 { TAG_ROOTPATH, "aRP" },
219 { TAG_EXTPATH, "aEP" },
220 /* RFC2132 tags */
221 { TAG_IP_FORWARD, "BIPF" },
222 { TAG_NL_SRCRT, "BSRT" },
223 { TAG_PFILTERS, "pPF" },
224 { TAG_REASS_SIZE, "sRSZ" },
225 { TAG_DEF_TTL, "bTTL" },
226 { TAG_MTU_TIMEOUT, "lMTU-Timeout" },
227 { TAG_MTU_TABLE, "sMTU-Table" },
228 { TAG_INT_MTU, "sMTU" },
229 { TAG_LOCAL_SUBNETS, "BLSN" },
230 { TAG_BROAD_ADDR, "iBR" },
231 { TAG_DO_MASK_DISC, "BMD" },
232 { TAG_SUPPLY_MASK, "BMS" },
233 { TAG_DO_RDISC, "BRouter-Discovery" },
234 { TAG_RTR_SOL_ADDR, "iRSA" },
235 { TAG_STATIC_ROUTE, "pStatic-Route" },
236 { TAG_USE_TRAILERS, "BUT" },
237 { TAG_ARP_TIMEOUT, "lAT" },
238 { TAG_ETH_ENCAP, "BIE" },
239 { TAG_TCP_TTL, "bTT" },
240 { TAG_TCP_KEEPALIVE, "lKI" },
241 { TAG_KEEPALIVE_GO, "BKG" },
242 { TAG_NIS_DOMAIN, "aYD" },
243 { TAG_NIS_SERVERS, "iYS" },
244 { TAG_NTP_SERVERS, "iNTP" },
245 { TAG_VENDOR_OPTS, "bVendor-Option" },
246 { TAG_NETBIOS_NS, "iNetbios-Name-Server" },
247 { TAG_NETBIOS_DDS, "iWDD" },
248 { TAG_NETBIOS_NODE, "$Netbios-Node" },
249 { TAG_NETBIOS_SCOPE, "aNetbios-Scope" },
250 { TAG_XWIN_FS, "iXFS" },
251 { TAG_XWIN_DM, "iXDM" },
252 { TAG_NIS_P_DOMAIN, "sN+D" },
253 { TAG_NIS_P_SERVERS, "iN+S" },
254 { TAG_MOBILE_HOME, "iMH" },
255 { TAG_SMPT_SERVER, "iSMTP" },
256 { TAG_POP3_SERVER, "iPOP3" },
257 { TAG_NNTP_SERVER, "iNNTP" },
258 { TAG_WWW_SERVER, "iWWW" },
259 { TAG_FINGER_SERVER, "iFG" },
260 { TAG_IRC_SERVER, "iIRC" },
261 { TAG_STREETTALK_SRVR, "iSTS" },
262 { TAG_STREETTALK_STDA, "iSTDA" },
263 { TAG_REQUESTED_IP, "iRequested-IP" },
264 { TAG_IP_LEASE, "lLease-Time" },
265 { TAG_OPT_OVERLOAD, "$OO" },
266 { TAG_TFTP_SERVER, "aTFTP" },
267 { TAG_BOOTFILENAME, "aBF" },
268 { TAG_DHCP_MESSAGE, " DHCP-Message" },
269 { TAG_SERVER_ID, "iServer-ID" },
270 { TAG_PARM_REQUEST, "bParameter-Request" },
271 { TAG_MESSAGE, "aMSG" },
272 { TAG_MAX_MSG_SIZE, "sMSZ" },
273 { TAG_RENEWAL_TIME, "lRN" },
274 { TAG_REBIND_TIME, "lRB" },
275 { TAG_VENDOR_CLASS, "aVendor-Class" },
276 { TAG_CLIENT_ID, "$Client-ID" },
277 /* RFC 2485 */
278 { TAG_OPEN_GROUP_UAP, "aUAP" },
279 /* RFC 2563 */
280 { TAG_DISABLE_AUTOCONF, "BNOAUTO" },
281 /* RFC 2610 */
282 { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */
283 { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */
284 /* RFC 2937 */
285 { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */
286 /* RFC 3011 */
287 { TAG_IP4_SUBNET_SELECT, "iSUBNET" },
288 /* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */
289 { TAG_USER_CLASS, "aCLASS" },
290 { TAG_SLP_NAMING_AUTH, "aSLP-NA" },
291 { TAG_CLIENT_FQDN, "$FQDN" },
292 { TAG_AGENT_CIRCUIT, "$Agent-Information" },
293 { TAG_AGENT_REMOTE, "bARMT" },
294 { TAG_AGENT_MASK, "bAMSK" },
295 { TAG_TZ_STRING, "aTZSTR" },
296 { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */
297 { TAG_AUTH, "bAUTH" }, /* XXX 'b' */
298 { TAG_VINES_SERVERS, "iVINES" },
299 { TAG_SERVER_RANK, "sRANK" },
300 { TAG_CLIENT_ARCH, "sARCH" },
301 { TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */
302 { TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */
303 { TAG_LDAP_URL, "aLDAP" },
304 { TAG_6OVER4, "i6o4" },
305 { TAG_PRINTER_NAME, "aPRTR" },
306 { TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */
307 { TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */
308 { TAG_NETINFO_PARENT, "iNI" },
309 { TAG_NETINFO_PARENT_TAG, "aNITAG" },
310 { TAG_URL, "aURL" },
311 { TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */
312 { 0, NULL }
314 /* 2-byte extended tags */
315 static struct tok xtag2str[] = {
316 { 0, NULL }
319 /* DHCP "options overload" types */
320 static struct tok oo2str[] = {
321 { 1, "file" },
322 { 2, "sname" },
323 { 3, "file+sname" },
324 { 0, NULL }
327 /* NETBIOS over TCP/IP node type options */
328 static struct tok nbo2str[] = {
329 { 0x1, "b-node" },
330 { 0x2, "p-node" },
331 { 0x4, "m-node" },
332 { 0x8, "h-node" },
333 { 0, NULL }
336 /* ARP Hardware types, for Client-ID option */
337 static struct tok arp2str[] = {
338 { 0x1, "ether" },
339 { 0x6, "ieee802" },
340 { 0x7, "arcnet" },
341 { 0xf, "frelay" },
342 { 0x17, "strip" },
343 { 0x18, "ieee1394" },
344 { 0, NULL }
347 static struct tok dhcp_msg_values[] = {
348 { DHCPDISCOVER, "Discover" },
349 { DHCPOFFER, "Offer" },
350 { DHCPREQUEST, "Request" },
351 { DHCPDECLINE, "Decline" },
352 { DHCPACK, "ACK" },
353 { DHCPNAK, "NACK" },
354 { DHCPRELEASE, "Release" },
355 { DHCPINFORM, "Inform" },
356 { 0, NULL }
359 #define AGENT_SUBOPTION_CIRCUIT_ID 1
360 static struct tok agent_suboption_values[] = {
361 { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" },
362 { 0, NULL }
366 static void
367 rfc1048_print(register const u_char *bp)
369 register u_int16_t tag;
370 register u_int len, size;
371 register const char *cp;
372 register char c;
373 int first, idx;
374 u_int32_t ul;
375 u_int16_t us;
376 u_int8_t uc, subopt, suboptlen;
378 printf("\n\t Vendor-rfc1048 Extensions");
380 /* Step over magic cookie */
381 printf("\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp));
382 bp += sizeof(int32_t);
384 /* Loop while we there is a tag left in the buffer */
385 while (TTEST2(*bp, 1)) {
386 tag = *bp++;
387 if (tag == TAG_PAD && vflag < 3)
388 continue;
389 if (tag == TAG_END && vflag < 3)
390 return;
391 if (tag == TAG_EXTENDED_OPTION) {
392 TCHECK2(*(bp + 1), 2);
393 tag = EXTRACT_16BITS(bp + 1);
394 /* XXX we don't know yet if the IANA will
395 * preclude overlap of 1-byte and 2-byte spaces.
396 * If not, we need to offset tag after this step.
398 cp = tok2str(xtag2str, "?xT%u", tag);
399 } else
400 cp = tok2str(tag2str, "?T%u", tag);
401 c = *cp++;
403 if (tag == TAG_PAD || tag == TAG_END)
404 len = 0;
405 else {
406 /* Get the length; check for truncation */
407 TCHECK2(*bp, 1);
408 len = *bp++;
411 printf("\n\t %s Option %u, length %u%s", cp, tag, len,
412 len > 0 ? ": " : "");
414 if (tag == TAG_PAD && vflag > 2) {
415 u_int ntag = 1;
416 while (TTEST2(*bp, 1) && *bp == TAG_PAD) {
417 bp++;
418 ntag++;
420 if (ntag > 1)
421 printf(", occurs %u", ntag);
424 if (!TTEST2(*bp, len)) {
425 printf("[|rfc1048 %u]", len);
426 return;
429 if (tag == TAG_DHCP_MESSAGE && len == 1) {
430 uc = *bp++;
431 printf("%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc));
432 continue;
435 if (tag == TAG_PARM_REQUEST) {
436 idx = 0;
437 while (len-- > 0) {
438 uc = *bp++;
439 cp = tok2str(tag2str, "?Option %u", uc);
440 if (idx % 4 == 0)
441 printf("\n\t ");
442 else
443 printf(", ");
444 printf("%s", cp + 1);
445 idx++;
447 continue;
450 if (tag == TAG_EXTENDED_REQUEST) {
451 first = 1;
452 while (len > 1) {
453 len -= 2;
454 us = EXTRACT_16BITS(bp);
455 bp += 2;
456 cp = tok2str(xtag2str, "?xT%u", us);
457 if (!first)
458 putchar('+');
459 printf("%s", cp + 1);
460 first = 0;
462 continue;
465 /* Print data */
466 size = len;
467 if (c == '?') {
468 /* Base default formats for unknown tags on data size */
469 if (size & 1)
470 c = 'b';
471 else if (size & 2)
472 c = 's';
473 else
474 c = 'l';
476 first = 1;
477 switch (c) {
479 case 'a':
480 /* ascii strings */
481 putchar('"');
482 if (fn_printn(bp, size, snapend)) {
483 putchar('"');
484 goto trunc;
486 putchar('"');
487 bp += size;
488 size = 0;
489 break;
491 case 'i':
492 case 'l':
493 case 'L':
494 /* ip addresses/32-bit words */
495 while (size >= sizeof(ul)) {
496 if (!first)
497 putchar(',');
498 ul = EXTRACT_32BITS(bp);
499 if (c == 'i') {
500 ul = htonl(ul);
501 printf("%s", ipaddr_string(&ul));
502 } else if (c == 'L')
503 printf("%d", ul);
504 else
505 printf("%u", ul);
506 bp += sizeof(ul);
507 size -= sizeof(ul);
508 first = 0;
510 break;
512 case 'p':
513 /* IP address pairs */
514 while (size >= 2*sizeof(ul)) {
515 if (!first)
516 putchar(',');
517 memcpy((char *)&ul, (const char *)bp, sizeof(ul));
518 printf("(%s:", ipaddr_string(&ul));
519 bp += sizeof(ul);
520 memcpy((char *)&ul, (const char *)bp, sizeof(ul));
521 printf("%s)", ipaddr_string(&ul));
522 bp += sizeof(ul);
523 size -= 2*sizeof(ul);
524 first = 0;
526 break;
528 case 's':
529 /* shorts */
530 while (size >= sizeof(us)) {
531 if (!first)
532 putchar(',');
533 us = EXTRACT_16BITS(bp);
534 printf("%u", us);
535 bp += sizeof(us);
536 size -= sizeof(us);
537 first = 0;
539 break;
541 case 'B':
542 /* boolean */
543 while (size > 0) {
544 if (!first)
545 putchar(',');
546 switch (*bp) {
547 case 0:
548 putchar('N');
549 break;
550 case 1:
551 putchar('Y');
552 break;
553 default:
554 printf("%u?", *bp);
555 break;
557 ++bp;
558 --size;
559 first = 0;
561 break;
563 case 'b':
564 case 'x':
565 default:
566 /* Bytes */
567 while (size > 0) {
568 if (!first)
569 putchar(c == 'x' ? ':' : '.');
570 if (c == 'x')
571 printf("%02x", *bp);
572 else
573 printf("%u", *bp);
574 ++bp;
575 --size;
576 first = 0;
578 break;
580 case '$':
581 /* Guys we can't handle with one of the usual cases */
582 switch (tag) {
584 case TAG_NETBIOS_NODE:
585 tag = *bp++;
586 --size;
587 fputs(tok2str(nbo2str, NULL, tag), stdout);
588 break;
590 case TAG_OPT_OVERLOAD:
591 tag = *bp++;
592 --size;
593 fputs(tok2str(oo2str, NULL, tag), stdout);
594 break;
596 case TAG_CLIENT_FQDN:
597 /* option 81 should be at least 3 bytes long */
598 if (len < 3) {
599 printf("ERROR: option 81 len %u < 3 bytes", len);
600 break;
602 if (*bp)
603 printf("[%s] ", client_fqdn_flags(*bp));
604 bp++;
605 if (*bp || *(bp+1))
606 printf("%u/%u ", *bp, *(bp+1));
607 bp += 2;
608 putchar('"');
609 if (fn_printn(bp, size - 3, snapend)) {
610 putchar('"');
611 goto trunc;
613 putchar('"');
614 bp += size - 3;
615 size = 0;
616 break;
618 case TAG_CLIENT_ID:
619 { int type = *bp++;
620 size--;
621 if (type == 0) {
622 putchar('"');
623 if (fn_printn(bp, size, snapend)) {
624 putchar('"');
625 goto trunc;
627 putchar('"');
628 bp += size;
629 size = 0;
630 break;
631 } else {
632 printf("%s ", tok2str(arp2str, "hardware-type %u,", type));
634 while (size > 0) {
635 if (!first)
636 putchar(':');
637 printf("%02x", *bp);
638 ++bp;
639 --size;
640 first = 0;
642 break;
645 case TAG_AGENT_CIRCUIT:
647 while (size > 0 ) {
648 subopt = *bp++;
649 suboptlen = *bp++;
650 size -= 2;
651 printf("\n\t %s SubOption %u, length %u: ",
652 tok2str(agent_suboption_values, "Unknown", subopt),
653 subopt,
654 suboptlen);
656 if (subopt == 0 || suboptlen == 0) {
657 break;
660 switch(subopt) {
661 case AGENT_SUBOPTION_CIRCUIT_ID:
662 for (idx = 0; idx < suboptlen; idx++) {
663 safeputchar(*(bp+idx));
665 break;
666 default:
667 print_unknown_data(bp, "\n\t\t", suboptlen);
670 size -= suboptlen;
671 bp += suboptlen;
674 break;
676 default:
677 printf("[unknown special tag %u, size %u]",
678 tag, size);
679 bp += size;
680 size = 0;
681 break;
683 break;
685 /* Data left over? */
686 if (size) {
687 printf("\n\t trailing data length %u", len);
688 bp += size;
691 return;
692 trunc:
693 printf("|[rfc1048]");
696 static void
697 cmu_print(register const u_char *bp)
699 register const struct cmu_vend *cmu;
701 #define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \
702 if (cmu->m.s_addr != 0) \
703 printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); }
705 printf(" vend-cmu");
706 cmu = (const struct cmu_vend *)bp;
708 /* Only print if there are unknown bits */
709 TCHECK(cmu->v_flags);
710 if ((cmu->v_flags & ~(VF_SMASK)) != 0)
711 printf(" F:0x%x", cmu->v_flags);
712 PRINTCMUADDR(v_dgate, "DG");
713 PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*");
714 PRINTCMUADDR(v_dns1, "NS1");
715 PRINTCMUADDR(v_dns2, "NS2");
716 PRINTCMUADDR(v_ins1, "IEN1");
717 PRINTCMUADDR(v_ins2, "IEN2");
718 PRINTCMUADDR(v_ts1, "TS1");
719 PRINTCMUADDR(v_ts2, "TS2");
720 return;
722 trunc:
723 fputs(tstr, stdout);
724 #undef PRINTCMUADDR
727 static char *
728 client_fqdn_flags(u_int flags)
730 static char buf[8+1];
731 int i = 0;
733 if (flags & CLIENT_FQDN_FLAGS_S)
734 buf[i++] = 'S';
735 if (flags & CLIENT_FQDN_FLAGS_O)
736 buf[i++] = 'O';
737 if (flags & CLIENT_FQDN_FLAGS_E)
738 buf[i++] = 'E';
739 if (flags & CLIENT_FQDN_FLAGS_N)
740 buf[i++] = 'N';
741 buf[i] = '\0';
743 return buf;