History log of /freebsd-current/usr.sbin/rarpd/rarpd.c
Revision Date Author Comments
# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 107597fb 27-Mar-2023 Gordon Bergling <gbe@FreeBSD.org>

rarpd(8): Fix a typo in a source code comment

- s/combinataion/combination/

Obtained from: NetBSD
MFC after: 3 days


# 9b10f59a 13-Dec-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

SPDX: mostly fixes to previous changes.

Introduce the recently approved BSD-1-Clause and replace 0BSD which
never did fit well our use cases.


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 2f8c6c0a 16-Apr-2017 Patrick Kelsey <pkelsey@FreeBSD.org>

Fix userland tools that don't check the format of routing socket
messages before accessing message fields that may not be present,
removing dead/duplicate/misleading code along the way.

Document the message format for each routing socket message in
route.h.

Fix a bug in usr.bin/netstat introduced in r287351 that resulted in
pointer computation with essentially random 16-bit offsets and
dereferencing of the results.

Reviewed by: ae
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D10330


# 78db15cc 16-May-2016 Don Lewis <truckman@FreeBSD.org>

When clearing rtmsg, pass &rtmsg to bzero() instead of the address of
just the header

Reported by: Coverity
CID: 1007568, 1194256
MFC after: 1 week


# 220fa950 07-Apr-2013 Marius Strobl <marius@FreeBSD.org>

Add some missing newlines and static declarations.

MFC after: 3 days


# 9711a168 31-Jan-2013 Gleb Smirnoff <glebius@FreeBSD.org>

Retire struct sockaddr_inarp.

Since ARP and routing are separated, "proxy only" entries
don't have any meaning, thus we don't need additional field
in sockaddr to pass SIN_PROXY flag.

New kernel is binary compatible with old tools, since sizes
of sockaddr_inarp and sockaddr_in match, and sa_family are
filled with same value.

The structure declaration is left for compatibility with
third party software, but in tree code no longer use it.

Reviewed by: ru, andre, net@


# ef231949 09-Jul-2012 Hiroki Sato <hrs@FreeBSD.org>

- Add IFT_L2VLAN (vlan(4)) support.
- Add -P option to support PID file. When -a is specified /var/run/rarpd.pid
is used, and when an interface is specified /var/run/rarpd.<ifname>.pid is
used by default.


# 9840ec17 19-Jan-2012 Eitan Adler <eadler@FreeBSD.org>

Fix warning when compiling with gcc46:
error: variable 'hostname' set but not used

Approved by: dim, cperciva (mentor, blanket for pre-mentorship already-approved commits)
MFC after: 3 days


# 441238cf 06-Dec-2010 Gleb Smirnoff <glebius@FreeBSD.org>

Catch up with kernel using time_uptime to drive ARP timeouts.

Noticed by: jilles


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 486c8cc4 06-Aug-2004 Warner Losh <imp@FreeBSD.org>

Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived software
(with permission of addtional copyright holders where appropriate)


# d7706da3 20-Apr-2004 Joerg Wunsch <joerg@FreeBSD.org>

While walking over the list of interfaces obtained from getifaddrs(3),
rarpd clobbered any AF_INET information already configured for a given
interface name, so interfaces with more than one IP address made rarpd
listen only for the last address out of all IP aliases.

I changed this, so that AF_LINK information is always collected first
(to ensure the interface name gets its link-layer address associated),
but while looking for AF_INET addresses, the configuration is cloned
if there has already been one IP address seen for that interface name.

Thus, rarpd now effectively listens on all subnets.

MFC after: 1 week


# 27b1d631 20-Apr-2004 Joerg Wunsch <joerg@FreeBSD.org>

Fix a typo.


# b0fed5c6 16-Aug-2003 Philippe Charnier <charnier@FreeBSD.org>

Make it clear that -a flag and interface parameter are mutually exclusive


# cd025b3c 11-Jul-2003 Maxime Henrion <mux@FreeBSD.org>

Huge cleanup of the rarpd(8) code :
- Use getifaddrs() instead of rolling our own buggy one. Previously,
rarpd(8) would fail to see some interfaces because of a hardcoded limit.
It now successfully sees any interface in the system, and this also makes
the code _much_ simpler.
- Replace strncpy() calls with strlcpy() calls. Some uses of strncpy()
were bogus ; the code wasn't ensuring that the string was NUL terminated.
- Don't try to guard about select() FD_* macros being undefined.
- Use IF_NAMESIZE and ETHER_ADDR_LEN macros where appropriate.
- Add static keywords to function definitions for consistency, since
the prototypes have it (I wonder why GCC didn't complain about this).
- Remove compat code for very old BSD versions and SunOS.
- Remove code for systems not having the dirent.h header.
- The code is now WARNS=5 clean so mark it as such.
- Don't add -DTFTP_DIR="/tftpboot" to the build command line since it's
the default.

MFC after: 2 weeks


# 9c6bbd7d 14-Jun-2003 John-Mark Gurney <jmg@FreeBSD.org>

make rarpd use in_addr_t instead of u_long since this is neccessary
on 64bit platforms

ok'd by: silence


# b728350e 03-May-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID over rcsid[]. Protect copyright[] where needed.


# 8662984e 15-Sep-2002 David Malone <dwmalone@FreeBSD.org>

Add "-t" to useage message and comment. (The -t option was added
independently by Robert, but also proposed in the PR below).

PR: 38126
Submitted by: Josh Elsasser <jre@vineyard.net>
MFC after: 1 month


# 80077d2c 09-May-2002 Ollivier Robert <roberto@FreeBSD.org>

Fix buildworld breakage.

Submitted by: Maxim Konovalov <maxim@macomnet.ru>


# c3ce2b2b 16-Nov-2001 Robert Watson <rwatson@FreeBSD.org>

o Allow rarpd to accept an additional '-t directory' argument, specifying
an alternative to /tftpboot. This is useful it you're using tftpd
with an alternative root (using -s), and would like rarpd to respond
selectively to RARP requests using the same criteria as tftp.

Obtained from: TrustedBSD Project
Sponsored by: DARPA, NAI Labs


# 01a0ec6c 05-Jul-2001 Matt Jacob <mjacob@FreeBSD.org>

make it compile on alpha again


# e376b9ff 18-Jun-2001 Peter Pentchev <roam@FreeBSD.org>

Add a -d command-line option; when used in conjunction with -f, rarpd
sends error messages to stderr, normal output to stdout, instead of
logging everything via syslog.

Turn off the FORMAT_AUDIT in the Makefile, until I can figure out how
to disable the check for one single line in the source :(

Reviewed by: dd, silence on -audit
MFC after: 1 month


# 2b4aa634 16-Jun-2001 Jonathan Lemon <jlemon@FreeBSD.org>

Comply with POSIX rules:
o Use %u for printing u_int.
o Cast sizeof() to u_long, and print with %lu

Reviewed by: wollman


# 818b5b76 16-Jun-2001 Jonathan Lemon <jlemon@FreeBSD.org>

Undo last braino and fix properly.


# f4d3963e 16-Jun-2001 Jonathan Lemon <jlemon@FreeBSD.org>

Fix warning:
489: warning: int format, different type arg (arg 4)


# 87c5c2d4 13-Jun-2001 Bruce Evans <bde@FreeBSD.org>

Fixed world breakage on systems where ntohl() doesn't return u_long
(e.g., on alphas, or even on i386's with a POSIX-200x-conformant
ntohl() (ntohl() returns uint32_t which is u_int on i386's)).

Fixed related bugs and bogons while I'm here:
- ntohl() was "fixed" for printing in 1 place by casting to
"(unsigned int )". This breaks the value on systems where u_int
is smaller than uint32_t, and has 2 style bugs.
- spell u_int consistently (never use "unsigned").
- break K&R support some more (don't cast malloc()'s arg to a wrong
type...).


# f351b05a 11-Jun-2001 Peter Pentchev <roam@FreeBSD.org>

WARNS=2 cleanup, ANSIfication, manpage mdoc(7) cleanup.

Once again, as explained in my messages to -audit, the ANSIfication comes
as part of the preparation to add a new -d command-line flag to send
output to stdout/stderr. That commit will come in a week, pending any
further comments/objections. For those who have missed the -audit mails,
it's at http://people.FreeBSD.org/~roam/bsd/rarpd/usr.sbin-rarpd-d.patch

Asbestos suit: on ;)
Reviewed by: dd, silence on -audit
MFC after: 1 month


# b7e469ad 27-Nov-1999 Philippe Charnier <charnier@FreeBSD.org>

Remove incorrect section name. Incomplete -Wall cleaning.


# e46b89dc 14-Sep-1999 Peter Wemm <peter@FreeBSD.org>

Fix warning: return type of `main' is not `int'


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 904b32a9 06-Dec-1998 Alexander Langer <alex@FreeBSD.org>

Sync usage string with reality: removed -n, added -s.


# 88edbb05 02-Apr-1998 Ollivier Robert <roberto@FreeBSD.org>

Fix bug in rarpd:

Explanation of the bug: when processing its first request, rarpd
opens a routing socket to send requests to the arp table. It keeps
that socket open afterwards, while waiting for new RARP requests.

Meanwhile, the data received on the routing socket fill up until
they are about 8Kbytes in size. Any additional data is lost.

When rarpd receives its next RARP request, it tries to access the
ARP table via a routing socket call, then waits for the answer to
its own request. This answer is lost because the received data is
already filled: when looking for the reply, rarpd receives only
8kbytes worth of data, then loops waiting forever.

Someone please test it on -STABLE and commit it. We can close the PR
when testing on STABLE is done.

PR: bin/5669
Submitted by: Pierre Beyssac <pb@fasterix.freenix.org>


# cc03533c 16-Jan-1998 Bruce Evans <bde@FreeBSD.org>

Removed most unused includes of <net/if_var.h> outside the kernel.


# aa40a0da 13-Oct-1997 Philippe Charnier <charnier@FreeBSD.org>

Mdoc'ify man page.


# 6c3f552a 30-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 476602a9 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 702a1d01 03-Jan-1997 Garrett Wollman <wollman@FreeBSD.org>

Update to match changes in <net/if.h>.


# a9695b96 27-Nov-1996 Bill Fenner <fenner@FreeBSD.org>

Add -s flag to always supply mapping if known, ignoring the
presence or absence of files in /tftpboot.


# b60287db 27-Nov-1996 Bill Fenner <fenner@FreeBSD.org>

Make the man page reflect reality. Add BUGS section about DNS.

Logging cleanups (including logging the requestor's MAC address instead
of the server's).


# 7632575b 19-Nov-1996 Bill Paul <wpaul@FreeBSD.org>

Although I got rarpd to work, it was largely through kludgery. Bill
Fenner was kind enough to point out the error of my ways. This incorporates
diffs from him which:

- Keep everything in network order.
- Log the booted ether & ip address, instead of my address on that net
- change several exit()'s to return()'s, so that rarpd continues running
even if it thinks it's in a weird state.

One small tweak by me: in rarp_bootable(), we have to make sure to
construct 'ipname' in host byte order (if we don't, we have to
specify /tftpboot/<remote IP in hex> with <remote IP in hex> in
network byte order, which is confusing).

Also restored use of <dirent.h> rather than <sys/dir.h> as pointed
out by bde.

Also updated the man page so that the -v flag is documented.

With any luck, I won't have to touch this thing again.


# 5a0da0a5 18-Nov-1996 Bill Paul <wpaul@FreeBSD.org>

Dohw! Left out one important htonl() in update_arptab().

Pointed out by: Bill Fenner


# 867de433 18-Nov-1996 Bill Paul <wpaul@FreeBSD.org>

Fix up new rarpd.

This includes the following changes:

- Support for poking ARP entries into the local table is now built
in, so the arptab.c module I hacked together is no longer needed.

- rarp_process() and rarp_reply() now accept a len argument which is
passed down from rarp_loop() which tells rarp_reply() exactly how
long the original RARP frame was. (Usually, it's 60 bytes, which is
the minimum.) Previously, the length was calculated using the sum
of sizeof(struct ether_header) + sizeof(struct ether_arp) (plus the
ethernet frame header, I think). The result was a total packet
length of 42 bytes. Now, rarp_reply() sends out packets that are
the same size as those it recieves (60 bytes). This agrees with the
behavior of rarpd on SunOS (as observed with tcpdump). The unused
extra bytes are zeroed.


# 4bef56e8 18-Nov-1996 Bill Paul <wpaul@FreeBSD.org>

Import new version of rarpd from the BPF 1.1 distribution from LBL.

Obtained from: LBL, BPF 1.1 distribution


# 0c8ea4d4 24-Sep-1996 Bruce Evans <bde@FreeBSD.org>

Eliminated includes of the "temporary" backwards compatibility header
<sys/dir.h> in applications. Maintained existing (inadequate) ifdefs
for dir.h vs dirent.h in libdialog, amd and rarpd, but didn't add any
new ones.


# 81ff470f 24-Aug-1996 Bill Paul <wpaul@FreeBSD.org>

It appears that with FreeBSD-current, we need to set the ethernet
frame type in network byte order. The htons() that wasn't needed in
2.1 is now required in 2.2.

Ultimately, this rarpd should be replaced with the more recent one
supplied with the new BPF distribution.


# cef6b9bc 18-Jul-1995 Bill Paul <wpaul@FreeBSD.org>

Use daemon() to deamonify ourselves.


# 709e8f9a 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 84e41ecf 01-Apr-1995 Bill Paul <wpaul@FreeBSD.org>

Get rid of ether_addr.c: it's been moved to libc. Also add proper
declaration for ether_ntohost(). (Does anyone know what header file
is supposed to contain the declarations for the ether_addr functions?
I can't them in the SunOS includes anywhere.)


# 11207259 03-Mar-1995 Bill Paul <wpaul@FreeBSD.org>

Gave rarpd back the ability to poke temporary entries into the arp
table; arptab.c is really a hacked up version of arp.c that only
supports adding temporary entries. (This stuff is nasty -- I wish I
knew what was so wrong with SIOCSARP/SIOCGARP/etc... that made the
BSD developers decide to take it out.) The idea here is that the
client issuing the rarp is expected to be in the middle of booting
and would therefore be unable to answer arp queries from other machines
on the wire. Having rarpd stuff a temporary entry for the booting
host into the local arp table helps keep arp requests from going unanswered.

Also added ether_print() and ether_ntoa() to the ether_addr.c module.
Eventually I'll get ether_aton() and ether_hostton() written and
then this file can be dropped straight into libc. (Assuming no one
objects, of course. :)


# 9636a39a 01-Mar-1995 Bill Paul <wpaul@FreeBSD.org>

Obtained from: An old BPF release packaged with the tcpdump-2.0 source code.


"Yes Virginia, there is a rarpd."

(Before anyone asks, this *not* the rarpd from NetBSD. It did come from
the same place as theirs, however.)

This is a port of the rarpd program included with the tcpdump-2.0
source code (which I finally unearthed after scrounging around
some of the darker corners of the Internet). It's as close to the
original as I could keep it except for the following changes:

- The original program was based on an older version of the Berkeley
Packet Filter which used different filter programming instructions.
Fortunately, an updated RARP packet filter is available right in the
BPF man page so this was easy to fix.

- The old code didn't know how to deal with variable length addresses
in ifreq buffers. This has been fixed.

- Some byte order weirdness had to be fixed. The sanity checks in
rarp_check() needed some htons()es, and the rarp_reply() function
needed to properly set the ether_type field in the ethernet header
to ETHERTYPE_REVARP before transmitting the packet, otherwise
the bytes in ether_type would wind up reversed. It is important to note
that using htons(ETHERTYPE_REVARP) will not work. This is odd, because
the NetBSD rarpd uses htons(ETHERTYPE_REVARP). (Praise be to tcpdump:
I would never have been able to track this silliness down without it.)

- The update_arptab() function has been castrated. It depends on
SIOCSARP which has been deprecated in 4.4BSD. The NetBSD people
don't seem to be using this function either. It wouldn't be too
hard to replace this with equivalent code from arp.c, but it
might not be necessary.

- I put together an ether_ntohost() support function that allows
both local (/etc/ethers) and NIS lookups. This stuff should go
in libc at some point, but nothing else seems to need it for now,
so it can wait a while.

As you may have guessed, you need to have the Berkeley Packet Filter in
your kernel in order to use this program. The good news is that together
with the recently added bootparamd, you can use finally use a FreeBSD
box to boot Sun boxes over the network. (This was my whole motivation
for getting this stuff to work: I have this one subnet that has a whole
bunch of Sun3 X-terminals on it with only two Sun4 workstations, both
of which are locked in peoples' offices. If those two machines crash
(and they do every so often) then none of the X-terms will boot. Now I
can use a spare PC that I have as a boot server. :)