From 609cc86717e7ef7c931a732f9612d92c860c6b4a Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 6 Aug 2014 06:44:15 +0200 Subject: [PATCH] monitor: Do not abort when receiving unknown ARPHRD --- monitor/main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/monitor/main.c b/monitor/main.c index a630a53c..6d3d442c 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -148,23 +148,31 @@ static int process_pcap(struct pcap *pcap) uint16_t proto_type; if (len < 16) { - fprintf(stderr, "Too short package\n"); - return EXIT_FAILURE; + printf("Too short packet\n"); + continue; } arphrd_type = L_GET_UNALIGNED((const uint16_t *) (buf + 2)); if (L_BE16_TO_CPU(arphrd_type) != ARPHRD_NETLINK) { - fprintf(stderr, "Wrong header type\n"); - return EXIT_FAILURE; + printf("Unsupported ARPHRD %u\n", + L_BE16_TO_CPU(arphrd_type)); + continue; } proto_type = L_GET_UNALIGNED((const uint16_t *) (buf + 14)); switch (L_BE16_TO_CPU(proto_type)) { + case NETLINK_ROUTE: + printf("RTNL packet\n"); + break; case NETLINK_GENERIC: nlmon_print(nlmon, buf + 16, len - 16); break; + default: + printf("Other protocol %u\n", + L_BE16_TO_CPU(proto_type)); + break; } }