Discussion:
PATCH: shared library support
James Ralston
2005-01-09 07:11:43 UTC
Permalink
qAttached is a patch for libnet 1.1.2.1 that adds support (via libtool)
for building libnet as a shared library.

Before applying it, rename configure.in to configure.ac, and remove
acconfig.h. Then apply the patch and run autoreconf.

I used autoconf 2.59, automake 1.9.2, and libtool 1.5.6. Using
automake 1.8.3 did *not* work (perl bombed out with an error).

I tested the resulting shared library on Linux (i386) by linking
tcptraceroute against it; I've had no problems.

Someone with better knowledge of the libnet code should correct my
AC_DEFINE descriptions; most of them are just dummy text.
--
James Ralston, Information Technology
Software Engineering Institute
Carnegie Mellon University, Pittsburgh, PA, USA
Frédéric Raynal
2005-01-10 08:08:41 UTC
Permalink
Hello

wouldn't be possible to pas an argument to the ./configure to select
between static or dynamic building (or even both) ?
Post by James Ralston
qAttached is a patch for libnet 1.1.2.1 that adds support (via libtool)
for building libnet as a shared library.
- AC_DEFINE(HAVE_DLPI)
+ AC_DEFINE(HAVE_DLPI, 1, [I don't know what this does.])
DLPI = Data Link Provider Interface
It is a device used ton inject packets at link layer under HPUX for
instance.
Post by James Ralston
+ AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [I don't know what this does.])
On some systems struct sockaddr does not have a sa_len field.
BTW, if someone has a pointer to an explanation on why it is prensent
on some system, and not on others, I'd like to have it.
Post by James Ralston
*solaris*)
- AC_DEFINE(HAVE_SOLARIS)
+ AC_DEFINE(HAVE_SOLARIS, 1, [I don't know what this does.])
It is defined for some particular Solaris stuff:
- getipnodebynap() instead of gethostbyname2()
- getipnodebyaddr() instead of gethostbyaddr()
- some device specific binding (in DLPI)
Post by James Ralston
- AC_DEFINE_UNQUOTED(DLPI_DEV_PREFIX, "$dir")
+ AC_DEFINE_UNQUOTED(DLPI_DEV_PREFIX, "$dir", [I don't know what this does.])
AFAIK DLPI is reachable through a device, usually placed in /dev, but
it can be placed somewhere else. This is to define to path to the dlpi
device.
Post by James Ralston
case "`uname -r`" in
5.4)
- AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
+ AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG, 1, [I don't know what this does.])
;;
5.5*)
- AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
+ AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG, 1, [I don't know what this does.])
;;
5.8)
- AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
- AC_DEFINE(HAVE_SOLARIS_IPV6)
+ AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG, 1, [I don't know what this does.])
+ AC_DEFINE(HAVE_SOLARIS_IPV6, 1, [I don't know what this does.])
;;
5.9)
- AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
- AC_DEFINE(HAVE_SOLARIS_IPV6)
+ AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG, 1, [I don't know what this does.])
+ AC_DEFINE(HAVE_SOLARIS_IPV6, 1, [I don't know what this does.])
;;
esac
STUPID_SOLARIS_CHECKSUM_BUG: on some old Solaris, TCP checksum are
poorly computed (see libnet_checksum.c):
#if (STUPID_SOLARIS_CHECKSUM_BUG)
tcph_p->th_sum = tcph_p->th_off << 2;
return (1);
#endif /* STUPID_SOLARIS_CHECKSUM_BUG */
There is something similar for HPUX11 too just below.

HAVE_SOLARIS_IPV6: IPv6 is not available on older Solaris, like 5.5 or
previous. This ensures that the solaris we are on do have IPv6.
Post by James Ralston
*hpux11*)
- AC_DEFINE(HAVE_HPUX11)
+ AC_DEFINE(HAVE_HPUX11, 1, [I don't know what this does.])
Also a "stupid bug" (quoting Mike ;), see in libnet_checksum.c

#if (HAVE_HPUX11)
if (l->injection_type != LIBNET_LINK)
{
/*
* Similiar to the Solaris Checksum bug - but need to
* add
* the size of the TCP payload (only for raw
* sockets).
*/
tcph_p->th_sum = (tcph_p->th_off << 2) +
(len - (tcph_p->th_off << 2));
return (1);
}
#endif

Reading the code from libne_link_dlpi, it also seems HPUX made many
changes in its network link layer handling when reaching the version
11. Thus, these changes are used. For instance, writing use a specific
structure called dl_hp_rawdata_req_t.
Post by James Ralston
+ AC_DEFINE(NO_SNPRINTF, 1, [I don't know what this does.])
Not all system do define snprintf(). For those who dont, snprintf is
porrly replaced with sprintf() and the length field is ignored.



I hope this helps,

Fred Raynal

Loading...