tcpdump mailing list archives

Fwd: [patch] Get tcpdump v3.9.6 to build on Solaris 8


From: Ken Bantoft <ken () xelerance com>
Date: Mon, 23 Jul 2007 19:27:11 -0400

FYI... this was emailed to me directly. I'm not committing it, as Petter notes it then fails to build on Linux.

Ken

Begin forwarded message:

From: Petter Reinholdtsen <pere () hungry com>
Date: July 23, 2007 1:34:43 PM EDT (CA)
To: ken () xelerance com
Subject: [patch] Get tcpdump v3.9.6 to build on Solaris 8


Hi.  I email you directly because you were listed in the CHANGES file,
and the address patches () tcpdump org mentioned in the README file
bounces, and the mailing list tcpdump-workers () lists tcpdump org do not
allow me as a non-subscriber to post to them.

Here is a draft patch to get tcpdump 3.9.6 building on Solaris 8.  The
build fail with addrtoname.c because the ether_header struct is
redefined in ether.h.  It is also defined in <netinet/if_ether.h> on
Solaris 8, and that definition is sligthly different from the Linux
definition, as the members ether_dhost and ether_shost are struct
ether_addr and not arrays.

This patch got the source building on Solaris, but will fail on Linux.

I'm not quite sure how to best structure the code to get it building
on both Solaris and Linux, but thought I should pass this patch along
anyway.

I did not quite understand why there are two sets of the ESRC and EDST
macros, either.  If they are moved to the ether.h file, the change
needed would be limited to that file only.

diff -ur /local/store/storeslem/tcpdump/src-3.9.6-local/ether.h ./ ether.h --- /local/store/storeslem/tcpdump/src-3.9.6-local/ether.h 2002-12-11 08:13:51.000000000 +0100
+++ ./ether.h   2007-07-23 18:40:45.026356000 +0200
@@ -41,14 +41,38 @@
  */
 #define        ETHER_ADDR_LEN          6

+/* Copied from addrtoname.c to have ether_addr and ether_header decleared */
+#ifdef USE_ETHER_NTOHOST
+#ifdef HAVE_NETINET_IF_ETHER_H
+struct mbuf; /* Squelch compiler warnings on some platforms for */
+struct rtentry;                /* declarations in <net/if.h> */
+#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
+#include <netinet/if_ether.h>
+#endif /* HAVE_NETINET_IF_ETHER_H */
+#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
+#include <netinet/ether.h>
+#endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
+
+#if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
+#ifndef HAVE_STRUCT_ETHER_ADDR
+struct ether_addr {
+       u_int8_t ether_addr_octet[ETHER_ADDR_LEN];
+};
+#endif
+extern int ether_ntohost(char *, const struct ether_addr *);
+#endif
+#endif /* USE_ETHER_NTOHOST */
+
+#ifndef HAVE_NETINET_IF_ETHER_H
 /*
  * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
  */
 struct ether_header {
-       u_int8_t        ether_dhost[ETHER_ADDR_LEN];
-       u_int8_t        ether_shost[ETHER_ADDR_LEN];
+       struct ether_addr       ether_dhost;
+       struct ether_addr       ether_shost;
        u_int16_t       ether_type;
 };
+#endif /* not HAVE_NETINET_IF_ETHER_H */

 /*
* Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some diff -ur /local/store/storeslem/tcpdump/src-3.9.6-local/ interface.h ./interface.h --- /local/store/storeslem/tcpdump/src-3.9.6-local/interface.h 2006-02-08 02:40:09.000000000 +0100
+++ ./interface.h       2007-07-23 18:53:55.229286000 +0200
@@ -97,8 +97,8 @@
 #define LITTLE_ENDIAN 1234
 #endif

-#define ESRC(ep) ((ep)->ether_shost)
-#define EDST(ep) ((ep)->ether_dhost)
+#define ESRC(ep) ((ep)->ether_shost.ether_addr_octet)
+#define EDST(ep) ((ep)->ether_dhost.ether_addr_octet)

 #ifndef NTOHL
 #define NTOHL(x)       (x) = ntohl(x)
diff -ur /local/store/storeslem/tcpdump/src-3.9.6-local/ netdissect.h ./netdissect.h --- /local/store/storeslem/tcpdump/src-3.9.6-local/netdissect.h 2006-02-08 02:40:09.000000000 +0100
+++ ./netdissect.h      2007-07-23 17:45:36.462710000 +0200
@@ -180,8 +180,8 @@
 #define LITTLE_ENDIAN 1234
 #endif

-#define ESRC(ep) ((ep)->ether_shost)
-#define EDST(ep) ((ep)->ether_dhost)
+#define ESRC(ep) ((ep)->ether_shost.ether_addr_octet)
+#define EDST(ep) ((ep)->ether_dhost.ether_addr_octet)

 #ifndef NTOHL
 #define NTOHL(x)       (x) = ntohl(x)

-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: