3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-20 04:19:25 +01:00

monitor: Extract PAE port traffic out of PCAP files and decode it

This commit is contained in:
Marcel Holtmann 2014-08-10 18:30:08 -07:00
parent b66765635f
commit a2a59e78fa
3 changed files with 31 additions and 14 deletions

View File

@ -163,6 +163,7 @@ static int process_pcap(struct pcap *pcap)
while (pcap_read(pcap, &tv, buf, snaplen, &len, &real_len)) { while (pcap_read(pcap, &tv, buf, snaplen, &len, &real_len)) {
uint16_t arphrd_type; uint16_t arphrd_type;
uint16_t proto_type; uint16_t proto_type;
uint16_t pkt_type;
if (len < 16) { if (len < 16) {
printf("Too short packet\n"); printf("Too short packet\n");
@ -172,22 +173,37 @@ static int process_pcap(struct pcap *pcap)
if (len < real_len) if (len < real_len)
printf("Packet truncated from %u\n", real_len); printf("Packet truncated from %u\n", real_len);
arphrd_type = L_GET_UNALIGNED((const uint16_t *) (buf + 2)); pkt_type = L_GET_UNALIGNED((const uint16_t *) buf);
pkt_type = L_BE16_TO_CPU(pkt_type);
if (L_BE16_TO_CPU(arphrd_type) != ARPHRD_NETLINK) { arphrd_type = L_GET_UNALIGNED((const uint16_t *) (buf + 2));
printf("Unsupported ARPHRD %u\n", arphrd_type = L_BE16_TO_CPU(arphrd_type);
L_BE16_TO_CPU(arphrd_type));
continue;
}
proto_type = L_GET_UNALIGNED((const uint16_t *) (buf + 14)); proto_type = L_GET_UNALIGNED((const uint16_t *) (buf + 14));
proto_type = L_BE16_TO_CPU(proto_type);
switch (L_BE16_TO_CPU(proto_type)) { switch (arphrd_type) {
case NETLINK_ROUTE: case ARPHRD_ETHER:
nlmon_print_rtnl(nlmon, &tv, buf, len); switch (proto_type) {
case ETH_P_PAE:
nlmon_print_pae(nlmon, &tv, pkt_type, -1,
buf, len);
break;
}
break; break;
case NETLINK_GENERIC: case ARPHRD_NETLINK:
nlmon_print_genl(nlmon, &tv, buf + 16, len - 16); switch (proto_type) {
case NETLINK_ROUTE:
nlmon_print_rtnl(nlmon, &tv, buf, len);
break;
case NETLINK_GENERIC:
nlmon_print_genl(nlmon, &tv,
buf + 16, len - 16);
break;
}
break;
default:
printf("Unsupported ARPHRD %u\n", arphrd_type);
break; break;
} }
} }

View File

@ -1640,7 +1640,7 @@ static struct l_io *open_packet(const char *name)
} }
void nlmon_print_pae(struct nlmon *nlmon, const struct timeval *tv, void nlmon_print_pae(struct nlmon *nlmon, const struct timeval *tv,
uint8_t type, uint32_t index, uint8_t type, int index,
const void *data, uint32_t size) const void *data, uint32_t size)
{ {
char str[16]; char str[16];
@ -1649,7 +1649,8 @@ void nlmon_print_pae(struct nlmon *nlmon, const struct timeval *tv,
print_packet(tv, (type == PACKET_HOST) ? '>' : '<', print_packet(tv, (type == PACKET_HOST) ? '>' : '<',
COLOR_YELLOW, "PAE Packet", str, ""); COLOR_YELLOW, "PAE Packet", str, "");
print_attr(0, "Interface Index: %u", index); if (index >= 0)
print_attr(0, "Interface Index: %u", index);
print_hexdump(0, data, size); print_hexdump(0, data, size);
} }

View File

@ -35,5 +35,5 @@ void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv,
void nlmon_print_genl(struct nlmon *nlmon, const struct timeval *tv, void nlmon_print_genl(struct nlmon *nlmon, const struct timeval *tv,
const void *data, uint32_t size); const void *data, uint32_t size);
void nlmon_print_pae(struct nlmon *nlmon, const struct timeval *tv, void nlmon_print_pae(struct nlmon *nlmon, const struct timeval *tv,
uint8_t type, uint32_t index, uint8_t type, int index,
const void *data, uint32_t size); const void *data, uint32_t size);