Update version number to 2.0pre1.
Packet internals: Refactor initialization steps.

Now WritablePacket::WritablePacket() is the only constructor; a separate
initialize() function does initialization work.  Semantics should be
unchanged.

Together with the next commit, this improves performance by a couple
percent on Linux, but makes performance a couple percent worse on my iMac.
Configuration:

   InfiniteSource(LIMIT 100000000, STOP true, TIMESTAMP false)
     -> Queue -> Discard

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Packet internals: Arrange annotations so a single memset can clear them.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Packet: Introduce a packet pool to speed allocations.

Freed packets accumulate and are directly reused.  Packet data is also
reused if it's the right size.  On multicore, packet data is reused per
thread, but then eventually pushed into a global list.  Inspired by Luigi
Rizzo.

The following configuration:

i :: InfiniteSource(LIMIT 10000000, STOP true, TIMESTAMP false, ACTIVE false)
  -> d :: Discard;
DriverManager(set a $(now), write i.active true, wait,
  set b $(now), print $(div $(i.limit) $(sub $b $a)))

on my iMac, pushes more than 2x as many packets with this patch as without
(25.3Mpps vs. 11.2Mpps).

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Tests: Add valgrind %ignores as necessary.
Tests: Improve Valgrind lines so errors cause test failures.
IP6Address: Correct hashcode.

!
CheckIP6Header: Documentation nit.
FromDevice.u: Support BURST keyword argument.

Based on a version from Luigi Rizzo.  Also keep _count up to date.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
ToDevice.u: Nits.
Variable expansion is recursive.

So something like "define(DEV eth0, GW $DEV:gw)" will now work as expected.
Depth is limited to 10 to prevent infinite recursion.  Perhaps expansion
should be done at definition time, but it is not currently done that way,
partially because manual text says "all definitions happen simultaneously".
Tests pass.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
AddressInfo: Support ":gw", and read network prefixes for Ethernet devices.

Given an IP prefix "X", the address "X:gw" is the default gateway address
for X -- namely, the network address for X, with the lowest-order bit
turned on.

Given an Ethernet device "X", on Linux and in the Linux kernel module,
"X:net" is now the default IPv4 network address.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
test-ping-userlevel: Make it work out-of-the-box on most networks

by using new $DEV:gw support.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
AddressInfo internals: Look up addresses using getifaddrs().

This library function is more standardized than the hodgepodge used
previously: it works on FreeBSD, Mac, and Linux.  However, I'm not sure
libraries like uclibc provide it, so keep the old Linux version; but use it
only if getifaddrs is not available.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
User ToDevice: Support sending packets via pcap.

Luigi Rizzo reports this can be significantly faster on FreeBSD.
Specify the send method via a METHOD keyword.

Simultaneously, update FromDevice to support METHOD.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
test-ping-userlevel: Ping 8.8.8.8, not read.

Read isn't pingable at the moment.
ICMPPingSource: Correct a printout ('from' should report the ping source).
User ToDevice: Add BURST argument.

Luigi Rizzo request (he also provided a preliminary patch).

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
On Mac OS X, define _DARWIN_UNLIMITED_SELECT.

Thanks, Marc Lehmann/libev.
User FromDevice: #include enough that BIOCIMMEDIATE will be defined.

This took hours for me to debug: on Mac OS X packets were arriving in
bursts, because (it turned out) BIOCIMMEDIATE hadn't been defined, and so
hadn't been used.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>