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