Deleted Added
full compact
print-arp.c (313537) print-arp.c (327234)
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
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)
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
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
193atmarp_addr_print(netdissect_options *ndo,
194 const u_char *ha, u_int ha_len, const u_char *srca,
195 u_int srca_len)
196{
197 if (ha_len == 0)
198 ND_PRINT((ndo, "<No address>"));
199 else {
200 ND_PRINT((ndo, "%s", linkaddr_string(ndo, ha, LINKADDR_ATM, ha_len)));
201 if (srca_len != 0)
202 ND_PRINT((ndo, ",%s",
203 linkaddr_string(ndo, srca, LINKADDR_ATM, srca_len)));
204 }
205}
206
207static 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
208atmarp_print(netdissect_options *ndo,
209 const u_char *bp, u_int length, u_int caplen)
210{
211 const struct atmarp_pkthdr *ap;
212 u_short pro, hrd, op;
213
214 ap = (const struct atmarp_pkthdr *)bp;
215 ND_TCHECK(*ap);

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

247 /* print operation */
248 ND_PRINT((ndo, "%s%s ",
249 ndo->ndo_vflag ? ", " : "",
250 tok2str(arpop_values, "Unknown (%u)", op)));
251
252 switch (op) {
253
254 case ARPOP_REQUEST:
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:
255 ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, ATMTPA(ap))));
303 ND_PRINT((ndo, "who-has "));
304 atmarp_tpaddr_print(ndo, ap, pro);
256 if (ATMTHRD_LEN(ap) != 0) {
257 ND_PRINT((ndo, " ("));
258 atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),
259 ATMTSA(ap), ATMTSLN(ap));
260 ND_PRINT((ndo, ")"));
261 }
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 }
262 ND_PRINT((ndo, "tell %s", ipaddr_string(ndo, ATMSPA(ap))));
311 ND_PRINT((ndo, " tell "));
312 atmarp_spaddr_print(ndo, ap, pro);
263 break;
264
265 case ARPOP_REPLY:
313 break;
314
315 case ARPOP_REPLY:
266 ND_PRINT((ndo, "%s is-at ", ipaddr_string(ndo, ATMSPA(ap))));
316 atmarp_spaddr_print(ndo, ap, pro);
317 ND_PRINT((ndo, " is-at "));
267 atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
268 ATMSSLN(ap));
269 break;
270
271 case ARPOP_INVREQUEST:
272 ND_PRINT((ndo, "who-is "));
273 atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), ATMTSA(ap),
274 ATMTSLN(ap));
275 ND_PRINT((ndo, " tell "));
276 atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
277 ATMSSLN(ap));
278 break;
279
280 case ARPOP_INVREPLY:
281 atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
282 ATMSSLN(ap));
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));
283 ND_PRINT((ndo, "at %s", ipaddr_string(ndo, ATMSPA(ap))));
334 ND_PRINT((ndo, "at "));
335 atmarp_spaddr_print(ndo, ap, pro);
284 break;
285
286 case ARPOP_NAK:
336 break;
337
338 case ARPOP_NAK:
287 ND_PRINT((ndo, "for %s", ipaddr_string(ndo, ATMSPA(ap))));
339 ND_PRINT((ndo, "for "));
340 atmarp_spaddr_print(ndo, ap, pro);
288 break;
289
290 default:
291 ND_DEFAULTPRINT((const u_char *)ap, caplen);
292 return;
293 }
294
295 out:

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

327 case ARPHRD_FRELAY:
328 linkaddr = LINKADDR_FRELAY;
329 break;
330 default:
331 linkaddr = LINKADDR_ETHER;
332 break;
333 }
334
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
335 if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) {
388 if (!ND_TTEST2(*TPA(ap), PROTO_LEN(ap))) {
336 ND_PRINT((ndo, "%s", tstr));
337 ND_DEFAULTPRINT((const u_char *)ap, length);
338 return;
339 }
340
341 if (!ndo->ndo_eflag) {
342 ND_PRINT((ndo, "ARP, "));
343 }

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

362 /* print operation */
363 ND_PRINT((ndo, "%s%s ",
364 ndo->ndo_vflag ? ", " : "",
365 tok2str(arpop_values, "Unknown (%u)", op)));
366
367 switch (op) {
368
369 case ARPOP_REQUEST:
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:
370 ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap))));
423 ND_PRINT((ndo, "who-has "));
424 tpaddr_print_ip(ndo, ap, pro);
371 if (isnonzero((const u_char *)THA(ap), HRD_LEN(ap)))
372 ND_PRINT((ndo, " (%s)",
373 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
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))));
374 ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap))));
428 ND_PRINT((ndo, " tell "));
429 spaddr_print_ip(ndo, ap, pro);
375 break;
376
377 case ARPOP_REPLY:
430 break;
431
432 case ARPOP_REPLY:
378 ND_PRINT((ndo, "%s is-at %s",
379 ipaddr_string(ndo, SPA(ap)),
433 spaddr_print_ip(ndo, ap, pro);
434 ND_PRINT((ndo, " is-at %s",
380 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
381 break;
382
383 case ARPOP_REVREQUEST:
384 ND_PRINT((ndo, "who-is %s tell %s",
385 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
386 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
387 break;
388
389 case ARPOP_REVREPLY:
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:
390 ND_PRINT((ndo, "%s at %s",
391 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
392 ipaddr_string(ndo, TPA(ap))));
445 ND_PRINT((ndo, "%s at ",
446 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
447 tpaddr_print_ip(ndo, ap, pro);
393 break;
394
395 case ARPOP_INVREQUEST:
396 ND_PRINT((ndo, "who-is %s tell %s",
397 linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
398 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
399 break;
400
401 case ARPOP_INVREPLY:
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:
402 ND_PRINT((ndo,"%s at %s",
403 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap)),
404 ipaddr_string(ndo, SPA(ap))));
457 ND_PRINT((ndo,"%s at ",
458 linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
459 spaddr_print_ip(ndo, ap, pro);
405 break;
406
407 default:
408 ND_DEFAULTPRINT((const u_char *)ap, caplen);
409 return;
410 }
411
412 out:

--- 13 unchanged lines hidden ---
460 break;
461
462 default:
463 ND_DEFAULTPRINT((const u_char *)ap, caplen);
464 return;
465 }
466
467 out:

--- 13 unchanged lines hidden ---