|
31 | 31 | #include "netdissect.h"
|
32 | 32 | #include "extract.h"
|
33 | 33 | #include "af.h"
|
| 34 | +#include "addrtostr.h" |
34 | 35 |
|
35 | 36 | /*
|
36 | 37 | * pflog headers, at least as they exist now.
|
@@ -337,6 +338,34 @@ static const struct tok pf_directions_other[] = {
|
337 | 338 | { 0, NULL }
|
338 | 339 | };
|
339 | 340 |
|
| 341 | +static void |
| 342 | +print_pf_addr(netdissect_options *ndo, const char *tag, u_int naf, |
| 343 | + const struct pf_addr *addr, const nd_uint16_t port) |
| 344 | +{ |
| 345 | + char buf[INET6_ADDRSTRLEN]; |
| 346 | + uint16_t portnum; |
| 347 | + |
| 348 | + ND_PRINT("%s ", tag); |
| 349 | + ND_TCHECK_SIZE(addr); |
| 350 | + switch (naf) { |
| 351 | + |
| 352 | + case BSD_AF_INET: |
| 353 | + addrtostr(addr->v4, buf, sizeof(buf)); |
| 354 | + break; |
| 355 | + |
| 356 | + case BSD_AF_INET6_BSD: |
| 357 | + addrtostr6(addr->v6, buf, sizeof(buf)); |
| 358 | + break; |
| 359 | + |
| 360 | + default: |
| 361 | + strlcpy(buf, "?", sizeof(buf)); |
| 362 | + break; |
| 363 | + } |
| 364 | + ND_PRINT("%s:", buf); |
| 365 | + portnum = GET_BE_U_2(port); |
| 366 | + ND_PRINT("%u", portnum); |
| 367 | +} |
| 368 | + |
340 | 369 | static void
|
341 | 370 | pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
|
342 | 371 | {
|
@@ -427,6 +456,20 @@ pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
|
427 | 456 | }
|
428 | 457 | nd_printjnp(ndo, (const u_char*)hdr->ifname, PFLOG_IFNAMSIZ);
|
429 | 458 | ND_PRINT(": ");
|
| 459 | + if (length == PFLOG_HEADER_LEN_OPENBSD) { |
| 460 | + if (ndo->ndo_vflag && GET_U_1(hdr->u.openbsd.rewritten)) { |
| 461 | + uint8_t naf; |
| 462 | + |
| 463 | + ND_PRINT("[rewritten: "); |
| 464 | + naf = GET_U_1(hdr->u.openbsd.naf); |
| 465 | + print_pf_addr(ndo, "src", naf, &hdr->u.openbsd.saddr, |
| 466 | + hdr->u.openbsd.sport); |
| 467 | + ND_PRINT(", "); |
| 468 | + print_pf_addr(ndo, "src", naf, &hdr->u.openbsd.daddr, |
| 469 | + hdr->u.openbsd.dport); |
| 470 | + ND_PRINT("; "); |
| 471 | + } |
| 472 | + } |
430 | 473 | }
|
431 | 474 |
|
432 | 475 | void
|
|
0 commit comments