]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-gre.c
Default to first interface from pcap_findalldevs()
[tcpdump] / print-gre.c
index 89cbe076c44c35f997b6187b725150dbb0027730..187a5b9f48297a9b260ea4d1e4a3328d01ccc871 100644 (file)
@@ -45,6 +45,7 @@
 #include <string.h>
 
 #include "netdissect.h"
+#include "addrtostr.h"
 #include "extract.h"
 #include "ethertype.h"
 
@@ -330,8 +331,8 @@ static void
 gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
                  const u_char *bp, u_int len)
 {
-       struct in_addr a;
        const u_char *up = bp;
+       char buf[INET_ADDRSTRLEN];
 
        if (sreoff & 3) {
                ND_PRINT((ndo, ", badoffset=%u", sreoff));
@@ -350,10 +351,9 @@ gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
                if (len < 4 || srelen == 0)
                        return;
 
-               memcpy(&a, bp, sizeof(a));
+               addrtostr(bp, buf, sizeof(buf));
                ND_PRINT((ndo, " %s%s",
-                   ((bp - up) == sreoff) ? "*" : "",
-                   inet_ntoa(a)));
+                   ((bp - up) == sreoff) ? "*" : "", buf));
 
                bp += 4;
                len -= 4;