Remove *really* old PIM_OLD_KERNEL #ifdef

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Minor cleanup and refactor 'int datalen' --> 'size_t len'

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Fix issue #23: Handle ip_len correct (host byte order) on older BSD's

See issue #23 and https://wiki.freebsd.org/SOCK_RAW for details.  Thanks
to Olivier Cochard-Labbé for all the sparring help on this and his work
on FreeBSD!

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Remove *really* old Linux ip_csum anachronism (pre Linux 2.0)

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Add fragmentation support for PIM register messages

The encapsulation added by register messages to multicast frames will
sometimes cause the size of the resulting frame to exceed the MTU of the
outbound interface.  Since the socket has option IP_HDRINCL set, the
kernel will not fragment the IP packet, so it is up to pimd to do it.

When receiving a fragmented PIM register message the UNIX kernel will
reassemble the whole frame before sending it to userspace, so there is
no need for this functionality in pimd.

Signed-off-by: Michael Fine <mfine@cumulusnetworks.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
send_pim(): Seed fragmentation with outbound interface's MTU size

Refactor new PIM fragmentation support to use outbound interface MTU as
seed value instead of packet len / 2.  When encapsulating MAX (1500)
frame packets over an interface with MIN MTU (576) this commit will only
need to send three fragments, rather than four.  We still need proper
PMTU support, or the recently proposed PIM MTU discovery support.

Show length of full PIM register frame in debug.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Modify format of debug output for improved readability.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
pim.c: Whitespace cleanup.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
pim.c: Refactor send_raw_ip() and send_fragment() --> send_frame()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
debug.c: Cleanup display of virtual interface table.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Adjust display of first NBR in VIF table.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
pim.c: Refactor in preparation for merge of pim_send() & pim_send_unicast().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
send_fragment(): Try including PIM header as well in fragments ...

RFC4601 seems to suggest that each fragment should consist of not only
the IP header, but also a PIM header, before the inner/encapsulated IP
packet:

    "If a multicast packet is fragmented on the way into the Register
     Tunnel, each fragment is encapsulated individually so it contains
     IP, PIM, and inner IP headers." -- RFC4601 section 4.4.1

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Minor cleanup.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
debug_frame(): Cleanup to more easily be able to debug whole frames.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Final adaptions to IP fragmentation support for PIM register messages.

This commit standardizes on the simplistic approach for fragmenting PIM
register messages (multicast tunneling) made by Michael Fine.

A more generic, PMTU prepared, but non-working (!) version of the same
made by me is also added, but ifdef:ed out.  Feel free to debug it and
submit a patch :)

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
pimd.conf: Fix default prefix length in static RP example 224/8 --> 224/4

The example `rp_address 192.168.10.1 224.0.0.0/4` is intended to cover
the whole IPv4 multicast range.

For details, see http://en.wikipedia.org/wiki/Multicast_address

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Fix issue #33: pimd does not work in background under FreeBSD

skif-kiev commented on 14 Apr:
> Being started without --debug and --foreground options pimd cant
> determine bootstrap router so doesn't send RP advertises. The reason
> is that we call `pid = getpid()` in routesock.c and use that value
> later to determine the valid message from routing socket.
>
> But between those operations we do `fork()` in main.c to daemonize
> pimd, so it gets new process ID that is different from pid. After that
> `rtm.rtm_pid != pid` becomes always true and `k_req_incoming()` always
> returns FALSE.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>