]> The Tcpdump Group git mirrors - tcpdump/blob - print-atalk.c
Rename the fn_printX() functions to nd_printX()
[tcpdump] / print-atalk.c
1 /*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 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
22 /* \summary: AppleTalk printer */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include "netdissect-stdinc.h"
29
30 #include <stdio.h>
31 #include <string.h>
32
33 #include "netdissect.h"
34 #include "addrtoname.h"
35 #include "ethertype.h"
36 #include "extract.h"
37 #include "appletalk.h"
38
39 static const char tstr[] = "[|atalk]";
40
41 static const struct tok type2str[] = {
42 { ddpRTMP, "rtmp" },
43 { ddpRTMPrequest, "rtmpReq" },
44 { ddpECHO, "echo" },
45 { ddpIP, "IP" },
46 { ddpARP, "ARP" },
47 { ddpKLAP, "KLAP" },
48 { 0, NULL }
49 };
50
51 struct aarp {
52 nd_uint16_t htype, ptype;
53 nd_uint8_t halen, palen;
54 nd_uint16_t op;
55 uint8_t hsaddr[6];
56 uint8_t psaddr[4];
57 uint8_t hdaddr[6];
58 uint8_t pdaddr[4];
59 };
60
61 static void atp_print(netdissect_options *, const struct atATP *, u_int);
62 static void atp_bitmap_print(netdissect_options *, u_char);
63 static void nbp_print(netdissect_options *, const struct atNBP *, u_int, u_short, u_char, u_char);
64 static const struct atNBPtuple *nbp_tuple_print(netdissect_options *ndo, const struct atNBPtuple *,
65 const u_char *,
66 u_short, u_char, u_char);
67 static const struct atNBPtuple *nbp_name_print(netdissect_options *, const struct atNBPtuple *,
68 const u_char *);
69 static const char *ataddr_string(netdissect_options *, u_short, u_char);
70 static void ddp_print(netdissect_options *, const u_char *, u_int, u_int, u_short, u_char, u_char);
71 static const char *ddpskt_string(netdissect_options *, u_int);
72
73 /*
74 * Print LLAP packets received on a physical LocalTalk interface.
75 */
76 u_int
77 ltalk_if_print(netdissect_options *ndo,
78 const struct pcap_pkthdr *h, const u_char *p)
79 {
80 u_int hdrlen;
81
82 ndo->ndo_protocol = "ltalk_if";
83 hdrlen = llap_print(ndo, p, h->len);
84 if (hdrlen == 0) {
85 /* Cut short by the snapshot length. */
86 return (h->caplen);
87 }
88 return (hdrlen);
89 }
90
91 /*
92 * Print AppleTalk LLAP packets.
93 */
94 u_int
95 llap_print(netdissect_options *ndo,
96 const u_char *bp, u_int length)
97 {
98 const struct LAP *lp;
99 const struct atDDP *dp;
100 const struct atShortDDP *sdp;
101 u_short snet;
102 u_int hdrlen;
103
104 ndo->ndo_protocol = "llap";
105 if (length < sizeof(*lp)) {
106 ND_PRINT(" [|llap %u]", length);
107 return (length);
108 }
109 if (!ND_TTEST_LEN(bp, sizeof(*lp))) {
110 ND_PRINT(" [|llap]");
111 return (0); /* cut short by the snapshot length */
112 }
113 lp = (const struct LAP *)bp;
114 bp += sizeof(*lp);
115 length -= sizeof(*lp);
116 hdrlen = sizeof(*lp);
117 switch (EXTRACT_U_1(lp->type)) {
118
119 case lapShortDDP:
120 if (length < ddpSSize) {
121 ND_PRINT(" [|sddp %u]", length);
122 return (length);
123 }
124 if (!ND_TTEST_LEN(bp, ddpSSize)) {
125 ND_PRINT(" [|sddp]");
126 return (0); /* cut short by the snapshot length */
127 }
128 sdp = (const struct atShortDDP *)bp;
129 ND_PRINT("%s.%s",
130 ataddr_string(ndo, 0, EXTRACT_U_1(lp->src)), ddpskt_string(ndo, EXTRACT_U_1(sdp->srcSkt)));
131 ND_PRINT(" > %s.%s:",
132 ataddr_string(ndo, 0, EXTRACT_U_1(lp->dst)), ddpskt_string(ndo, EXTRACT_U_1(sdp->dstSkt)));
133 bp += ddpSSize;
134 length -= ddpSSize;
135 hdrlen += ddpSSize;
136 ddp_print(ndo, bp, length, EXTRACT_U_1(sdp->type), 0, EXTRACT_U_1(lp->src), EXTRACT_U_1(sdp->srcSkt));
137 break;
138
139 case lapDDP:
140 if (length < ddpSize) {
141 ND_PRINT(" [|ddp %u]", length);
142 return (length);
143 }
144 if (!ND_TTEST_LEN(bp, ddpSize)) {
145 ND_PRINT(" [|ddp]");
146 return (0); /* cut short by the snapshot length */
147 }
148 dp = (const struct atDDP *)bp;
149 snet = EXTRACT_BE_U_2(dp->srcNet);
150 ND_PRINT("%s.%s", ataddr_string(ndo, snet, EXTRACT_U_1(dp->srcNode)),
151 ddpskt_string(ndo, EXTRACT_U_1(dp->srcSkt)));
152 ND_PRINT(" > %s.%s:",
153 ataddr_string(ndo, EXTRACT_BE_U_2(dp->dstNet), EXTRACT_U_1(dp->dstNode)),
154 ddpskt_string(ndo, EXTRACT_U_1(dp->dstSkt)));
155 bp += ddpSize;
156 length -= ddpSize;
157 hdrlen += ddpSize;
158 ddp_print(ndo, bp, length, EXTRACT_U_1(dp->type), snet, EXTRACT_U_1(dp->srcNode), EXTRACT_U_1(dp->srcSkt));
159 break;
160
161 #ifdef notdef
162 case lapKLAP:
163 klap_print(bp, length);
164 break;
165 #endif
166
167 default:
168 ND_PRINT("%u > %u at-lap#%u %u",
169 EXTRACT_U_1(lp->src), EXTRACT_U_1(lp->dst), EXTRACT_U_1(lp->type), length);
170 break;
171 }
172 return (hdrlen);
173 }
174
175 /*
176 * Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called
177 * when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk
178 * packets in them).
179 */
180 void
181 atalk_print(netdissect_options *ndo,
182 const u_char *bp, u_int length)
183 {
184 const struct atDDP *dp;
185 u_short snet;
186
187 ndo->ndo_protocol = "atalk";
188 if(!ndo->ndo_eflag)
189 ND_PRINT("AT ");
190
191 if (length < ddpSize) {
192 ND_PRINT(" [|ddp %u]", length);
193 return;
194 }
195 if (!ND_TTEST_LEN(bp, ddpSize)) {
196 ND_PRINT(" [|ddp]");
197 return;
198 }
199 dp = (const struct atDDP *)bp;
200 snet = EXTRACT_BE_U_2(dp->srcNet);
201 ND_PRINT("%s.%s", ataddr_string(ndo, snet, EXTRACT_U_1(dp->srcNode)),
202 ddpskt_string(ndo, EXTRACT_U_1(dp->srcSkt)));
203 ND_PRINT(" > %s.%s: ",
204 ataddr_string(ndo, EXTRACT_BE_U_2(dp->dstNet), EXTRACT_U_1(dp->dstNode)),
205 ddpskt_string(ndo, EXTRACT_U_1(dp->dstSkt)));
206 bp += ddpSize;
207 length -= ddpSize;
208 ddp_print(ndo, bp, length, EXTRACT_U_1(dp->type), snet, EXTRACT_U_1(dp->srcNode), EXTRACT_U_1(dp->srcSkt));
209 }
210
211 /* XXX should probably pass in the snap header and do checks like arp_print() */
212 void
213 aarp_print(netdissect_options *ndo,
214 const u_char *bp, u_int length)
215 {
216 const struct aarp *ap;
217
218 #define AT(member) ataddr_string(ndo, (ap->member[1]<<8)|ap->member[2],ap->member[3])
219
220 ndo->ndo_protocol = "aarp";
221 ND_PRINT("aarp ");
222 ap = (const struct aarp *)bp;
223 if (!ND_TTEST_SIZE(ap)) {
224 /* Just bail if we don't have the whole chunk. */
225 ND_PRINT(" [|aarp]");
226 return;
227 }
228 if (length < sizeof(*ap)) {
229 ND_PRINT(" [|aarp %u]", length);
230 return;
231 }
232 if (EXTRACT_BE_U_2(ap->htype) == 1 &&
233 EXTRACT_BE_U_2(ap->ptype) == ETHERTYPE_ATALK &&
234 EXTRACT_U_1(ap->halen) == 6 && EXTRACT_U_1(ap->palen) == 4 )
235 switch (EXTRACT_BE_U_2(ap->op)) {
236
237 case 1: /* request */
238 ND_PRINT("who-has %s tell %s", AT(pdaddr), AT(psaddr));
239 return;
240
241 case 2: /* response */
242 ND_PRINT("reply %s is-at %s", AT(psaddr), etheraddr_string(ndo, ap->hsaddr));
243 return;
244
245 case 3: /* probe (oy!) */
246 ND_PRINT("probe %s tell %s", AT(pdaddr), AT(psaddr));
247 return;
248 }
249 ND_PRINT("len %u op %u htype %u ptype %#x halen %u palen %u",
250 length, EXTRACT_BE_U_2(ap->op), EXTRACT_BE_U_2(ap->htype),
251 EXTRACT_BE_U_2(ap->ptype), EXTRACT_U_1(ap->halen), EXTRACT_U_1(ap->palen));
252 }
253
254 /*
255 * Print AppleTalk Datagram Delivery Protocol packets.
256 */
257 static void
258 ddp_print(netdissect_options *ndo,
259 const u_char *bp, u_int length, u_int t,
260 u_short snet, u_char snode, u_char skt)
261 {
262
263 switch (t) {
264
265 case ddpNBP:
266 nbp_print(ndo, (const struct atNBP *)bp, length, snet, snode, skt);
267 break;
268
269 case ddpATP:
270 atp_print(ndo, (const struct atATP *)bp, length);
271 break;
272
273 case ddpEIGRP:
274 eigrp_print(ndo, bp, length);
275 break;
276
277 default:
278 ND_PRINT(" at-%s %u", tok2str(type2str, NULL, t), length);
279 break;
280 }
281 }
282
283 static void
284 atp_print(netdissect_options *ndo,
285 const struct atATP *ap, u_int length)
286 {
287 uint8_t control;
288 uint32_t data;
289
290 if ((const u_char *)(ap + 1) > ndo->ndo_snapend) {
291 /* Just bail if we don't have the whole chunk. */
292 ND_PRINT("%s", tstr);
293 return;
294 }
295 if (length < sizeof(*ap)) {
296 ND_PRINT(" [|atp %u]", length);
297 return;
298 }
299 length -= sizeof(*ap);
300 control = EXTRACT_U_1(ap->control);
301 switch (control & 0xc0) {
302
303 case atpReqCode:
304 ND_PRINT(" atp-req%s %u",
305 control & atpXO? " " : "*",
306 EXTRACT_BE_U_2(ap->transID));
307
308 atp_bitmap_print(ndo, EXTRACT_U_1(ap->bitmap));
309
310 if (length != 0)
311 ND_PRINT(" [len=%u]", length);
312
313 switch (control & (atpEOM|atpSTS)) {
314 case atpEOM:
315 ND_PRINT(" [EOM]");
316 break;
317 case atpSTS:
318 ND_PRINT(" [STS]");
319 break;
320 case atpEOM|atpSTS:
321 ND_PRINT(" [EOM,STS]");
322 break;
323 }
324 break;
325
326 case atpRspCode:
327 ND_PRINT(" atp-resp%s%u:%u (%u)",
328 control & atpEOM? "*" : " ",
329 EXTRACT_BE_U_2(ap->transID), EXTRACT_U_1(ap->bitmap), length);
330 switch (control & (atpXO|atpSTS)) {
331 case atpXO:
332 ND_PRINT(" [XO]");
333 break;
334 case atpSTS:
335 ND_PRINT(" [STS]");
336 break;
337 case atpXO|atpSTS:
338 ND_PRINT(" [XO,STS]");
339 break;
340 }
341 break;
342
343 case atpRelCode:
344 ND_PRINT(" atp-rel %u", EXTRACT_BE_U_2(ap->transID));
345
346 atp_bitmap_print(ndo, EXTRACT_U_1(ap->bitmap));
347
348 /* length should be zero */
349 if (length)
350 ND_PRINT(" [len=%u]", length);
351
352 /* there shouldn't be any control flags */
353 if (control & (atpXO|atpEOM|atpSTS)) {
354 char c = '[';
355 if (control & atpXO) {
356 ND_PRINT("%cXO", c);
357 c = ',';
358 }
359 if (control & atpEOM) {
360 ND_PRINT("%cEOM", c);
361 c = ',';
362 }
363 if (control & atpSTS) {
364 ND_PRINT("%cSTS", c);
365 }
366 ND_PRINT("]");
367 }
368 break;
369
370 default:
371 ND_PRINT(" atp-0x%x %u (%u)", control,
372 EXTRACT_BE_U_2(ap->transID), length);
373 break;
374 }
375 data = EXTRACT_BE_U_4(ap->userData);
376 if (data != 0)
377 ND_PRINT(" 0x%x", data);
378 }
379
380 static void
381 atp_bitmap_print(netdissect_options *ndo,
382 u_char bm)
383 {
384 u_int i;
385
386 /*
387 * The '& 0xff' below is needed for compilers that want to sign
388 * extend a u_char, which is the case with the Ultrix compiler.
389 * (gcc is smart enough to eliminate it, at least on the Sparc).
390 */
391 if ((bm + 1) & (bm & 0xff)) {
392 char c = '<';
393 for (i = 0; bm; ++i) {
394 if (bm & 1) {
395 ND_PRINT("%c%u", c, i);
396 c = ',';
397 }
398 bm >>= 1;
399 }
400 ND_PRINT(">");
401 } else {
402 for (i = 0; bm; ++i)
403 bm >>= 1;
404 if (i > 1)
405 ND_PRINT("<0-%u>", i - 1);
406 else
407 ND_PRINT("<0>");
408 }
409 }
410
411 static void
412 nbp_print(netdissect_options *ndo,
413 const struct atNBP *np, u_int length, u_short snet,
414 u_char snode, u_char skt)
415 {
416 const struct atNBPtuple *tp =
417 (const struct atNBPtuple *)((const u_char *)np + nbpHeaderSize);
418 uint8_t control;
419 u_int i;
420 const u_char *ep;
421
422 if (length < nbpHeaderSize) {
423 ND_PRINT(" truncated-nbp %u", length);
424 return;
425 }
426
427 length -= nbpHeaderSize;
428 if (length < 8) {
429 /* must be room for at least one tuple */
430 ND_PRINT(" truncated-nbp %u", length + nbpHeaderSize);
431 return;
432 }
433 /* ep points to end of available data */
434 ep = ndo->ndo_snapend;
435 if ((const u_char *)tp > ep) {
436 ND_PRINT("%s", tstr);
437 return;
438 }
439 control = EXTRACT_U_1(np->control);
440 switch (i = (control & 0xf0)) {
441
442 case nbpBrRq:
443 case nbpLkUp:
444 ND_PRINT(i == nbpLkUp? " nbp-lkup %u:":" nbp-brRq %u:", EXTRACT_U_1(np->id));
445 if ((const u_char *)(tp + 1) > ep) {
446 ND_PRINT("%s", tstr);
447 return;
448 }
449 (void)nbp_name_print(ndo, tp, ep);
450 /*
451 * look for anomalies: the spec says there can only
452 * be one tuple, the address must match the source
453 * address and the enumerator should be zero.
454 */
455 if ((control & 0xf) != 1)
456 ND_PRINT(" [ntup=%u]", control & 0xf);
457 if (EXTRACT_U_1(tp->enumerator))
458 ND_PRINT(" [enum=%u]", EXTRACT_U_1(tp->enumerator));
459 if (EXTRACT_BE_U_2(tp->net) != snet ||
460 EXTRACT_U_1(tp->node) != snode ||
461 EXTRACT_U_1(tp->skt) != skt)
462 ND_PRINT(" [addr=%s.%u]",
463 ataddr_string(ndo, EXTRACT_BE_U_2(tp->net),
464 EXTRACT_U_1(tp->node)),
465 EXTRACT_U_1(tp->skt));
466 break;
467
468 case nbpLkUpReply:
469 ND_PRINT(" nbp-reply %u:", EXTRACT_U_1(np->id));
470
471 /* print each of the tuples in the reply */
472 for (i = control & 0xf; i != 0 && tp; i--)
473 tp = nbp_tuple_print(ndo, tp, ep, snet, snode, skt);
474 break;
475
476 default:
477 ND_PRINT(" nbp-0x%x %u (%u)", control, EXTRACT_U_1(np->id), length);
478 break;
479 }
480 }
481
482 /* print a counted string */
483 static const char *
484 print_cstring(netdissect_options *ndo,
485 const char *cp, const u_char *ep)
486 {
487 u_int length;
488
489 if (cp >= (const char *)ep) {
490 ND_PRINT("%s", tstr);
491 return (0);
492 }
493 length = EXTRACT_U_1(cp);
494 cp++;
495
496 /* Spec says string can be at most 32 bytes long */
497 if (length > 32) {
498 ND_PRINT("[len=%u]", length);
499 return (0);
500 }
501 while (length != 0) {
502 if (cp >= (const char *)ep) {
503 ND_PRINT("%s", tstr);
504 return (0);
505 }
506 fn_print_char(ndo, EXTRACT_U_1(cp));
507 cp++;
508 length--;
509 }
510 return (cp);
511 }
512
513 static const struct atNBPtuple *
514 nbp_tuple_print(netdissect_options *ndo,
515 const struct atNBPtuple *tp, const u_char *ep,
516 u_short snet, u_char snode, u_char skt)
517 {
518 const struct atNBPtuple *tpn;
519
520 if ((const u_char *)(tp + 1) > ep) {
521 ND_PRINT("%s", tstr);
522 return 0;
523 }
524 tpn = nbp_name_print(ndo, tp, ep);
525
526 /* if the enumerator isn't 1, print it */
527 if (EXTRACT_U_1(tp->enumerator) != 1)
528 ND_PRINT("(%u)", EXTRACT_U_1(tp->enumerator));
529
530 /* if the socket doesn't match the src socket, print it */
531 if (EXTRACT_U_1(tp->skt) != skt)
532 ND_PRINT(" %u", EXTRACT_U_1(tp->skt));
533
534 /* if the address doesn't match the src address, it's an anomaly */
535 if (EXTRACT_BE_U_2(tp->net) != snet ||
536 EXTRACT_U_1(tp->node) != snode)
537 ND_PRINT(" [addr=%s]",
538 ataddr_string(ndo, EXTRACT_BE_U_2(tp->net), EXTRACT_U_1(tp->node)));
539
540 return (tpn);
541 }
542
543 static const struct atNBPtuple *
544 nbp_name_print(netdissect_options *ndo,
545 const struct atNBPtuple *tp, const u_char *ep)
546 {
547 const char *cp = (const char *)tp + nbpTupleSize;
548
549 ND_PRINT(" ");
550
551 /* Object */
552 ND_PRINT("\"");
553 if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
554 /* Type */
555 ND_PRINT(":");
556 if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
557 /* Zone */
558 ND_PRINT("@");
559 if ((cp = print_cstring(ndo, cp, ep)) != NULL)
560 ND_PRINT("\"");
561 }
562 }
563 return ((const struct atNBPtuple *)cp);
564 }
565
566
567 #define HASHNAMESIZE 4096
568
569 struct hnamemem {
570 u_int addr;
571 char *name;
572 struct hnamemem *nxt;
573 };
574
575 static struct hnamemem hnametable[HASHNAMESIZE];
576
577 static const char *
578 ataddr_string(netdissect_options *ndo,
579 u_short atnet, u_char athost)
580 {
581 struct hnamemem *tp, *tp2;
582 u_int i = (atnet << 8) | athost;
583 char nambuf[256+1];
584 static int first = 1;
585 FILE *fp;
586
587 /*
588 * if this is the first call, see if there's an AppleTalk
589 * number to name map file.
590 */
591 if (first && (first = 0, !ndo->ndo_nflag)
592 && (fp = fopen("/etc/atalk.names", "r"))) {
593 char line[256];
594 u_int i1, i2;
595
596 while (fgets(line, sizeof(line), fp)) {
597 if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
598 continue;
599 if (sscanf(line, "%u.%u %256s", &i1, &i2, nambuf) == 3)
600 /* got a hostname. */
601 i2 |= (i1 << 8);
602 else if (sscanf(line, "%u %256s", &i1, nambuf) == 2)
603 /* got a net name */
604 i2 = (i1 << 8) | 255;
605 else
606 continue;
607
608 for (tp = &hnametable[i2 & (HASHNAMESIZE-1)];
609 tp->nxt; tp = tp->nxt)
610 ;
611 tp->addr = i2;
612 tp->nxt = newhnamemem(ndo);
613 tp->name = strdup(nambuf);
614 if (tp->name == NULL)
615 (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
616 "ataddr_string: strdup(nambuf)");
617 }
618 fclose(fp);
619 }
620
621 for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
622 if (tp->addr == i)
623 return (tp->name);
624
625 /* didn't have the node name -- see if we've got the net name */
626 i |= 255;
627 for (tp2 = &hnametable[i & (HASHNAMESIZE-1)]; tp2->nxt; tp2 = tp2->nxt)
628 if (tp2->addr == i) {
629 tp->addr = (atnet << 8) | athost;
630 tp->nxt = newhnamemem(ndo);
631 (void)nd_snprintf(nambuf, sizeof(nambuf), "%s.%u",
632 tp2->name, athost);
633 tp->name = strdup(nambuf);
634 if (tp->name == NULL)
635 (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
636 "ataddr_string: strdup(nambuf)");
637 return (tp->name);
638 }
639
640 tp->addr = (atnet << 8) | athost;
641 tp->nxt = newhnamemem(ndo);
642 if (athost != 255)
643 (void)nd_snprintf(nambuf, sizeof(nambuf), "%u.%u", atnet, athost);
644 else
645 (void)nd_snprintf(nambuf, sizeof(nambuf), "%u", atnet);
646 tp->name = strdup(nambuf);
647 if (tp->name == NULL)
648 (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
649 "ataddr_string: strdup(nambuf)");
650
651 return (tp->name);
652 }
653
654 static const struct tok skt2str[] = {
655 { rtmpSkt, "rtmp" }, /* routing table maintenance */
656 { nbpSkt, "nis" }, /* name info socket */
657 { echoSkt, "echo" }, /* AppleTalk echo protocol */
658 { zipSkt, "zip" }, /* zone info protocol */
659 { 0, NULL }
660 };
661
662 static const char *
663 ddpskt_string(netdissect_options *ndo,
664 u_int skt)
665 {
666 static char buf[8];
667
668 if (ndo->ndo_nflag) {
669 (void)nd_snprintf(buf, sizeof(buf), "%u", skt);
670 return (buf);
671 }
672 return (tok2str(skt2str, "%u", skt));
673 }