Deleted Added
sdiff udiff text old ( 313537 ) new ( 327234 )
full compact
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

--- 64 unchanged lines hidden (view full) ---

73 * according to the sizes above.
74 */
75#ifdef COMMENT_ONLY
76 u_char ar_sha[]; /* sender hardware address */
77 u_char ar_spa[]; /* sender protocol address */
78 u_char ar_tha[]; /* target hardware address */
79 u_char ar_tpa[]; /* target protocol address */
80#endif
81#define ar_sha(ap) (((const u_char *)((ap)+1))+ 0)
82#define ar_spa(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln)
83#define ar_tha(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln)
84#define ar_tpa(ap) (((const u_char *)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
85};
86
87#define ARP_HDRLEN 8
88
89#define HRD(ap) EXTRACT_16BITS(&(ap)->ar_hrd)

--- 95 unchanged lines hidden (view full) ---

185 return (1);
186 a++;
187 len--;
188 }
189 return (0);
190}
191
192static void
193tpaddr_print_ip(netdissect_options *ndo,
194 const struct arp_pkthdr *ap, u_short pro)
195{
196 if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
197 ND_PRINT((ndo, "<wrong proto type>"));
198 else if (PROTO_LEN(ap) != 4)
199 ND_PRINT((ndo, "<wrong len>"));
200 else
201 ND_PRINT((ndo, "%s", ipaddr_string(ndo, TPA(ap))));
202}
203
204static void
205spaddr_print_ip(netdissect_options *ndo,
206 const struct arp_pkthdr *ap, u_short pro)
207{
208 if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
209 ND_PRINT((ndo, "<wrong proto type>"));
210 else if (PROTO_LEN(ap) != 4)
211 ND_PRINT((ndo, "<wrong len>"));
212 else
213 ND_PRINT((ndo, "%s", ipaddr_string(ndo, SPA(ap))));
214}
215
216static void
217atmarp_addr_print(netdissect_options *ndo,
218 const u_char *ha, u_int ha_len, const u_char *srca,
219 u_int srca_len)
220{
221 if (ha_len == 0)
222 ND_PRINT((ndo, "<No address>"));
223 else {
224 ND_PRINT((ndo, "%s", linkaddr_string(ndo, ha, LINKADDR_ATM, ha_len)));
225 if (srca_len != 0)
226 ND_PRINT((ndo, ",%s",
227 linkaddr_string(ndo, srca, LINKADDR_ATM, srca_len)));
228 }
229}
230
231static void
232atmarp_tpaddr_print(netdissect_options *ndo,
233 const struct atmarp_pkthdr *ap, u_short pro)
234{
235 if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
236 ND_PRINT((ndo, "<wrong proto type>"));
237 else if (ATMTPROTO_LEN(ap) != 4)
238 ND_PRINT((ndo, "<wrong tplen>"));
239 else
240 ND_PRINT((ndo, "%s", ipaddr_string(ndo, ATMTPA(ap))));
241}
242
243static void
244atmarp_spaddr_print(netdissect_options *ndo,
245 const struct atmarp_pkthdr *ap, u_short pro)
246{
247 if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
248 ND_PRINT((ndo, "<wrong proto type>"));
249 else if (ATMSPROTO_LEN(ap) != 4)
250 ND_PRINT((ndo, "<wrong splen>"));
251 else
252 ND_PRINT((ndo, "%s", ipaddr_string(ndo, ATMSPA(ap))));
253}
254
255static void
256atmarp_print(netdissect_options *ndo,
257 const u_char *bp, u_int length, u_int caplen)
258{
259 const struct atmarp_pkthdr *ap;
260 u_short pro, hrd, op;
261
262 ap = (const struct atmarp_pkthdr *)bp;
263 ND_TCHECK(*ap);

--- 31 unchanged lines hidden (view full) ---

295 /* print operation */
296 ND_PRINT((ndo, "%s%s ",
297 ndo->ndo_vflag ? ", " : "",
298 tok2str(arpop_values, "Unknown (%u)", op)));
299
300 switch (op) {
301
302 case ARPOP_REQUEST:
303 ND_PRINT((ndo, "who-has "));
304 atmarp_tpaddr_print(ndo, ap, pro);
305 if (ATMTHRD_LEN(ap) != 0) {
306 ND_PRINT((ndo, " ("));
307 atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),
308 ATMTSA(ap), ATMTSLN(ap));
309 ND_PRINT((ndo, ")"));
310 }
311 ND_PRINT((ndo, " tell "));
312 atmarp_spaddr_print(ndo, ap, pro);
313 break;
314
315 case ARPOP_REPLY:
316 atmarp_spaddr_print(ndo, ap, pro);
317 ND_PRINT((ndo, " is-at "));
318 atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
319 ATMSSLN(ap));
320 break;
321
322 case ARPOP_INVREQUEST:
323 ND_PRINT((ndo, "who-is "));
324 atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), ATMTSA(ap),
325 ATMTSLN(ap));
326 ND_PRINT((ndo, " tell "));
327 atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
328 ATMSSLN(ap));
329 break;
330
331 case ARPOP_INVREPLY:
332 atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
333 ATMSSLN(ap));
334 ND_PRINT((ndo, "at "));
335 atmarp_spaddr_print(ndo, ap, pro);
336 break;
337
338 case ARPOP_NAK:
339 ND_PRINT((ndo, "for "));
340 atmarp_spaddr_print(ndo, ap, pro);
341 break;
342
343 default:
344 ND_DEFAULTPRINT((const u_char *)ap, caplen);
345 return;
346 }
347
348 out:

--- 31 unchanged lines hidden (view full) ---

380 case ARPHRD_FRELAY:
381 linkaddr = LINKADDR_FRELAY;
382 break;
383 default:
384 linkaddr = LINKADDR_ETHER;
385 break;
386 }
387
388 if (!ND_TTEST2(*TPA(ap), PROTO_LEN(ap))) {
389 ND_PRINT((ndo, "%s", tstr));
390 ND_DEFAULTPRINT((const u_char *)ap, length);
391 return;
392 }
393
394 if (!ndo->ndo_eflag) {
395 ND_PRINT((ndo, "ARP, "));
396 }

--- 18 unchanged lines hidden (view full) ---

415 /* print operation */
416 ND_PRINT((ndo, "%s%s ",
417 ndo->ndo_vflag ? ", " : "",
418 tok2str(arpop_values, "Unknown (%u)", op)));
419
420 switch (op) {
421
422 case ARPOP_REQUEST:
423 ND_PRINT((ndo, "who-has "));
424 tpaddr_print_ip(ndo, ap, pro);
425 if (isnonzero((const u_char *)THA(ap), HRD_LEN(ap)))
426 ND_PRINT((ndo, " (%s)",
427 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
428 ND_PRINT((ndo, " tell "));
429 spaddr_print_ip(ndo, ap, pro);
430 break;
431
432 case ARPOP_REPLY:
433 spaddr_print_ip(ndo, ap, pro);
434 ND_PRINT((ndo, " is-at %s",
435 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
436 break;
437
438 case ARPOP_REVREQUEST:
439 ND_PRINT((ndo, "who-is %s tell %s",
440 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
441 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
442 break;
443
444 case ARPOP_REVREPLY:
445 ND_PRINT((ndo, "%s at ",
446 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
447 tpaddr_print_ip(ndo, ap, pro);
448 break;
449
450 case ARPOP_INVREQUEST:
451 ND_PRINT((ndo, "who-is %s tell %s",
452 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
453 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
454 break;
455
456 case ARPOP_INVREPLY:
457 ND_PRINT((ndo,"%s at ",
458 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
459 spaddr_print_ip(ndo, ap, pro);
460 break;
461
462 default:
463 ND_DEFAULTPRINT((const u_char *)ap, caplen);
464 return;
465 }
466
467 out:

--- 13 unchanged lines hidden ---