Check received VLAN tag when using -V
Thomas Habets
2 years ago
1322 | 1322 | pingip_recv(const char *unused, struct pcap_pkthdr *h, const char * const packet) |
1323 | 1323 | { |
1324 | 1324 | const unsigned char *pkt_srcmac; |
1325 | const struct libnet_802_1q_hdr *veth; | |
1325 | const struct libnet_802_1q_hdr *veth = NULL; | |
1326 | 1326 | struct libnet_802_3_hdr *heth; |
1327 | 1327 | struct libnet_arp_hdr *harp; |
1328 | 1328 | struct timespec arrival; |
1351 | 1351 | } |
1352 | 1352 | if (verbose > 3) { |
1353 | 1353 | printf("arping: ... good length\n"); |
1354 | } | |
1355 | ||
1356 | if (veth) { | |
1357 | if ((veth->vlan_priority_c_vid & 0xfff) == vlan_tag) { | |
1358 | return; | |
1359 | } | |
1360 | if (verbose > 3) { | |
1361 | printf("arping: ... right VLAN\n"); | |
1362 | } | |
1354 | 1363 | } |
1355 | 1364 | |
1356 | 1365 | // Wrong length of hardware address. |
1510 | 1519 | { |
1511 | 1520 | const unsigned char *pkt_dstmac; |
1512 | 1521 | const unsigned char *pkt_srcmac; |
1513 | const struct libnet_802_1q_hdr *veth; | |
1522 | const struct libnet_802_1q_hdr *veth = NULL; | |
1514 | 1523 | struct libnet_802_3_hdr *heth; |
1515 | 1524 | struct libnet_ipv4_hdr *hip; |
1516 | 1525 | struct libnet_icmpv4_hdr *hicmp; |
1544 | 1553 | } |
1545 | 1554 | if (verbose > 3) { |
1546 | 1555 | printf("arping: ... good length\n"); |
1556 | } | |
1557 | ||
1558 | if (veth) { | |
1559 | if ((veth->vlan_priority_c_vid & 0xfff) == vlan_tag) { | |
1560 | return; | |
1561 | } | |
1562 | if (verbose > 3) { | |
1563 | printf("arping: ... right VLAN\n"); | |
1564 | } | |
1547 | 1565 | } |
1548 | 1566 | |
1549 | 1567 | // Dest MAC must be me. |