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. :)
1995-03-02 06:41:40 +00:00
|
|
|
/*
|
1996-11-18 22:07:41 +00:00
|
|
|
* Copyright (c) 1990, 1991, 1992, 1993, 1996
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code distributions
|
|
|
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
* distributions including binary code include the above copyright notice and
|
|
|
|
* this paragraph in its entirety in the documentation or other materials
|
2004-08-07 04:28:56 +00:00
|
|
|
* provided with the distribution
|
|
|
|
*
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
1997-10-13 11:03:36 +00:00
|
|
|
|
2003-05-03 21:06:42 +00:00
|
|
|
#if 0
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
#ifndef lint
|
1997-10-13 11:03:36 +00:00
|
|
|
static const char copyright[] =
|
1996-11-18 22:07:41 +00:00
|
|
|
"@(#) Copyright (c) 1990, 1991, 1992, 1993, 1996\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
#endif /* not lint */
|
2003-05-03 21:06:42 +00:00
|
|
|
#endif
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
1995-05-30 03:57:47 +00:00
|
|
|
/*
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* rarpd - Reverse ARP Daemon
|
|
|
|
*
|
2003-08-16 22:23:16 +00:00
|
|
|
* Usage: rarpd -a [-dfsv] [-t directory] [hostname]
|
|
|
|
* rarpd [-dfsv] [-t directory] interface [hostname]
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* 'hostname' is optional solely for backwards compatibility with Sun's rarpd.
|
|
|
|
* Currently, the argument is ignored.
|
|
|
|
*/
|
1996-11-18 22:07:41 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/socket.h>
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
#include <sys/time.h>
|
1996-11-18 22:07:41 +00:00
|
|
|
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
#include <net/bpf.h>
|
2001-06-11 09:29:34 +00:00
|
|
|
#include <net/ethernet.h>
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
#include <net/if.h>
|
1996-11-18 22:07:41 +00:00
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/if_ether.h>
|
1996-11-18 22:07:41 +00:00
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
#include <dirent.h>
|
1996-11-18 22:07:41 +00:00
|
|
|
#include <errno.h>
|
2003-07-11 14:13:21 +00:00
|
|
|
#include <ifaddrs.h>
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
#include <netdb.h>
|
2001-06-18 06:48:33 +00:00
|
|
|
#include <stdarg.h>
|
1996-11-18 22:07:41 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
1996-09-24 08:08:11 +00:00
|
|
|
|
2004-04-20 13:26:52 +00:00
|
|
|
/* Cast a struct sockaddr to a struct sockaddr_in */
|
1996-11-18 22:07:41 +00:00
|
|
|
#define SATOSIN(sa) ((struct sockaddr_in *)(sa))
|
|
|
|
|
|
|
|
#ifndef TFTP_DIR
|
|
|
|
#define TFTP_DIR "/tftpboot"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ARPSECS (20 * 60) /* as per code in netinet/if_ether.c */
|
|
|
|
#define REVARP_REQUEST ARPOP_REVREQUEST
|
|
|
|
#define REVARP_REPLY ARPOP_REVREPLY
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
|
|
|
/*
|
1995-05-30 03:57:47 +00:00
|
|
|
* The structure for each interface.
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*/
|
|
|
|
struct if_info {
|
2003-07-11 14:13:21 +00:00
|
|
|
struct if_info *ii_next;
|
|
|
|
int ii_fd; /* BPF file descriptor */
|
|
|
|
in_addr_t ii_ipaddr; /* IP address */
|
|
|
|
in_addr_t ii_netmask; /* subnet or net mask */
|
|
|
|
u_char ii_eaddr[ETHER_ADDR_LEN]; /* ethernet address */
|
|
|
|
char ii_ifname[IF_NAMESIZE];
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The list of all interfaces that are being listened to. rarp_loop()
|
|
|
|
* "selects" on the descriptors in this list.
|
|
|
|
*/
|
|
|
|
struct if_info *iflist;
|
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
int verbose; /* verbose messages */
|
2001-06-11 09:29:34 +00:00
|
|
|
const char *tftp_dir = TFTP_DIR; /* tftp directory */
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
2001-06-18 06:48:33 +00:00
|
|
|
int dflag; /* messages to stdout/stderr, not syslog(3) */
|
2001-06-11 09:29:34 +00:00
|
|
|
int sflag; /* ignore /tftpboot */
|
1996-11-18 22:07:41 +00:00
|
|
|
|
|
|
|
static u_char zero[6];
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
2001-06-11 09:29:34 +00:00
|
|
|
static int bpf_open(void);
|
2003-06-15 03:00:22 +00:00
|
|
|
static in_addr_t choose_ipaddr(in_addr_t **, in_addr_t, in_addr_t);
|
2001-06-11 09:29:34 +00:00
|
|
|
static char *eatoa(u_char *);
|
2001-06-18 06:48:33 +00:00
|
|
|
static int expand_syslog_m(const char *fmt, char **newfmt);
|
2001-06-11 09:29:34 +00:00
|
|
|
static void init(char *);
|
2004-04-20 13:58:14 +00:00
|
|
|
static void init_one(struct ifaddrs *, char *, int);
|
2003-06-15 03:00:22 +00:00
|
|
|
static char *intoa(in_addr_t);
|
|
|
|
static in_addr_t ipaddrtonetmask(in_addr_t);
|
2001-06-18 06:48:33 +00:00
|
|
|
static void logmsg(int, const char *, ...) __printflike(2, 3);
|
2003-06-15 03:00:22 +00:00
|
|
|
static int rarp_bootable(in_addr_t);
|
2001-06-11 09:29:34 +00:00
|
|
|
static int rarp_check(u_char *, u_int);
|
|
|
|
static void rarp_loop(void);
|
|
|
|
static int rarp_open(char *);
|
|
|
|
static void rarp_process(struct if_info *, u_char *, u_int);
|
2001-06-18 06:48:33 +00:00
|
|
|
static void rarp_reply(struct if_info *, struct ether_header *,
|
2003-06-15 03:00:22 +00:00
|
|
|
in_addr_t, u_int);
|
|
|
|
static void update_arptab(u_char *, in_addr_t);
|
2001-06-11 09:29:34 +00:00
|
|
|
static void usage(void);
|
1996-11-27 20:45:10 +00:00
|
|
|
|
1999-09-15 01:58:44 +00:00
|
|
|
int
|
2001-06-11 09:29:34 +00:00
|
|
|
main(int argc, char *argv[])
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
1996-11-18 22:07:41 +00:00
|
|
|
int op;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
char *ifname, *hostname, *name;
|
|
|
|
|
|
|
|
int aflag = 0; /* listen on "all" interfaces */
|
|
|
|
int fflag = 0; /* don't fork */
|
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
if ((name = strrchr(argv[0], '/')) != NULL)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
++name;
|
|
|
|
else
|
|
|
|
name = argv[0];
|
|
|
|
if (*name == '-')
|
|
|
|
++name;
|
|
|
|
|
1995-05-30 03:57:47 +00:00
|
|
|
/*
|
2001-06-18 06:48:33 +00:00
|
|
|
* All error reporting is done through syslog, unless -d is specified
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*/
|
1996-11-18 22:07:41 +00:00
|
|
|
openlog(name, LOG_PID | LOG_CONS, LOG_DAEMON);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
|
|
|
opterr = 0;
|
2003-08-16 22:23:16 +00:00
|
|
|
while ((op = getopt(argc, argv, "adfst:v")) != -1)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
switch (op) {
|
|
|
|
case 'a':
|
|
|
|
++aflag;
|
|
|
|
break;
|
|
|
|
|
2001-06-18 06:48:33 +00:00
|
|
|
case 'd':
|
|
|
|
++dflag;
|
|
|
|
break;
|
|
|
|
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
case 'f':
|
|
|
|
++fflag;
|
|
|
|
break;
|
|
|
|
|
1996-11-27 20:45:10 +00:00
|
|
|
case 's':
|
|
|
|
++sflag;
|
|
|
|
break;
|
|
|
|
|
2001-11-16 16:49:21 +00:00
|
|
|
case 't':
|
|
|
|
tftp_dir = optarg;
|
|
|
|
break;
|
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
case 'v':
|
|
|
|
++verbose;
|
|
|
|
break;
|
|
|
|
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
2003-08-16 22:23:16 +00:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
ifname = (aflag == 0) ? argv[0] : NULL;
|
|
|
|
hostname = ifname ? argv[1] : argv[0];
|
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
if ((aflag && ifname) || (!aflag && ifname == NULL))
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
usage();
|
|
|
|
|
2003-08-16 22:23:16 +00:00
|
|
|
init(ifname);
|
1995-05-30 03:57:47 +00:00
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
if (!fflag) {
|
1995-07-18 21:35:32 +00:00
|
|
|
if (daemon(0,0)) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "cannot fork");
|
1996-11-18 22:07:41 +00:00
|
|
|
exit(1);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
}
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
rarp_loop();
|
1999-11-27 17:06:40 +00:00
|
|
|
return(0);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-11-18 22:07:41 +00:00
|
|
|
* Add to the interface list.
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2004-04-20 13:58:14 +00:00
|
|
|
init_one(struct ifaddrs *ifa, char *target, int pass1)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
2004-04-20 13:58:14 +00:00
|
|
|
struct if_info *ii, *ii2;
|
2001-06-11 09:29:34 +00:00
|
|
|
struct sockaddr_dl *ll;
|
1996-11-18 22:07:41 +00:00
|
|
|
int family;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
family = ifa->ifa_addr->sa_family;
|
1996-11-18 22:07:41 +00:00
|
|
|
switch (family) {
|
|
|
|
case AF_INET:
|
2004-04-20 13:58:14 +00:00
|
|
|
if (pass1)
|
|
|
|
/* Consider only AF_LINK during pass1. */
|
|
|
|
return;
|
|
|
|
/* FALLTHROUGH */
|
1996-11-18 22:07:41 +00:00
|
|
|
case AF_LINK:
|
2003-07-11 14:13:21 +00:00
|
|
|
if (!(ifa->ifa_flags & IFF_UP) ||
|
|
|
|
(ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)))
|
1996-11-18 22:07:41 +00:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't bother going any further if not the target interface */
|
2003-07-11 14:13:21 +00:00
|
|
|
if (target != NULL && strcmp(ifa->ifa_name, target) != 0)
|
1996-11-18 22:07:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Look for interface in list */
|
|
|
|
for (ii = iflist; ii != NULL; ii = ii->ii_next)
|
2003-07-11 14:13:21 +00:00
|
|
|
if (strcmp(ifa->ifa_name, ii->ii_ifname) == 0)
|
1996-11-18 22:07:41 +00:00
|
|
|
break;
|
|
|
|
|
2004-04-20 13:58:14 +00:00
|
|
|
if (pass1 && ii != NULL)
|
|
|
|
/* We've already seen that interface once. */
|
|
|
|
return;
|
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
/* Allocate a new one if not found */
|
|
|
|
if (ii == NULL) {
|
|
|
|
ii = (struct if_info *)malloc(sizeof(*ii));
|
|
|
|
if (ii == NULL) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "malloc: %m");
|
1996-11-18 22:07:41 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
bzero(ii, sizeof(*ii));
|
|
|
|
ii->ii_fd = -1;
|
2003-07-11 14:13:21 +00:00
|
|
|
strlcpy(ii->ii_ifname, ifa->ifa_name, sizeof(ii->ii_ifname));
|
1996-11-18 22:07:41 +00:00
|
|
|
ii->ii_next = iflist;
|
|
|
|
iflist = ii;
|
2004-04-20 13:58:14 +00:00
|
|
|
} else if (!pass1 && ii->ii_ipaddr != 0) {
|
|
|
|
/*
|
|
|
|
* Second AF_INET definition for that interface: clone
|
|
|
|
* the existing one, and work on that cloned one.
|
|
|
|
* This must be another IP address for this interface,
|
|
|
|
* so avoid killing the previous configuration.
|
|
|
|
*/
|
|
|
|
ii2 = (struct if_info *)malloc(sizeof(*ii2));
|
|
|
|
if (ii2 == NULL) {
|
|
|
|
logmsg(LOG_ERR, "malloc: %m");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
memcpy(ii2, ii, sizeof(*ii2));
|
|
|
|
ii2->ii_fd = -1;
|
|
|
|
ii2->ii_next = iflist;
|
|
|
|
iflist = ii2;
|
|
|
|
|
|
|
|
ii = ii2;
|
1996-11-18 22:07:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (family) {
|
|
|
|
case AF_INET:
|
2003-07-11 14:13:21 +00:00
|
|
|
ii->ii_ipaddr = SATOSIN(ifa->ifa_addr)->sin_addr.s_addr;
|
|
|
|
ii->ii_netmask = SATOSIN(ifa->ifa_netmask)->sin_addr.s_addr;
|
1996-11-18 22:07:41 +00:00
|
|
|
if (ii->ii_netmask == 0)
|
|
|
|
ii->ii_netmask = ipaddrtonetmask(ii->ii_ipaddr);
|
2003-07-11 14:13:21 +00:00
|
|
|
if (ii->ii_fd < 0)
|
1996-11-18 22:07:41 +00:00
|
|
|
ii->ii_fd = rarp_open(ii->ii_ifname);
|
|
|
|
break;
|
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
case AF_LINK:
|
|
|
|
ll = (struct sockaddr_dl *)ifa->ifa_addr;
|
|
|
|
if (ll->sdl_type == IFT_ETHER)
|
|
|
|
bcopy(LLADDR(ll), ii->ii_eaddr, 6);
|
|
|
|
break;
|
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
}
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
/*
|
|
|
|
* Initialize all "candidate" interfaces that are in the system
|
|
|
|
* configuration list. A "candidate" is up, not loopback and not
|
|
|
|
* point to point.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2001-06-11 09:29:34 +00:00
|
|
|
init(char *target)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
2001-06-11 09:29:34 +00:00
|
|
|
struct if_info *ii, *nii, *lii;
|
2003-07-11 14:13:21 +00:00
|
|
|
struct ifaddrs *ifhead, *ifa;
|
|
|
|
int error;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
error = getifaddrs(&ifhead);
|
|
|
|
if (error) {
|
|
|
|
logmsg(LOG_ERR, "getifaddrs: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2004-04-20 13:58:14 +00:00
|
|
|
/*
|
|
|
|
* We make two passes over the list we have got. In the first
|
|
|
|
* one, we only collect AF_LINK interfaces, and initialize our
|
|
|
|
* list of interfaces from them. In the second pass, we
|
|
|
|
* collect the actual IP addresses from the AF_INET
|
|
|
|
* interfaces, and allow for the same interface name to appear
|
|
|
|
* multiple times (in case of more than one IP address).
|
|
|
|
*/
|
|
|
|
for (ifa = ifhead; ifa != NULL; ifa = ifa->ifa_next)
|
|
|
|
init_one(ifa, target, 1);
|
2003-07-11 14:13:21 +00:00
|
|
|
for (ifa = ifhead; ifa != NULL; ifa = ifa->ifa_next)
|
2004-04-20 13:58:14 +00:00
|
|
|
init_one(ifa, target, 0);
|
2003-07-11 14:13:21 +00:00
|
|
|
freeifaddrs(ifhead);
|
1996-11-18 22:07:41 +00:00
|
|
|
|
|
|
|
/* Throw away incomplete interfaces */
|
|
|
|
lii = NULL;
|
|
|
|
for (ii = iflist; ii != NULL; ii = nii) {
|
|
|
|
nii = ii->ii_next;
|
|
|
|
if (ii->ii_ipaddr == 0 ||
|
|
|
|
bcmp(ii->ii_eaddr, zero, 6) == 0) {
|
|
|
|
if (lii == NULL)
|
|
|
|
iflist = nii;
|
|
|
|
else
|
|
|
|
lii->ii_next = nii;
|
|
|
|
if (ii->ii_fd >= 0)
|
|
|
|
close(ii->ii_fd);
|
|
|
|
free(ii);
|
|
|
|
continue;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
lii = ii;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
|
|
|
|
/* Verbose stuff */
|
|
|
|
if (verbose)
|
|
|
|
for (ii = iflist; ii != NULL; ii = ii->ii_next)
|
2003-06-15 03:00:22 +00:00
|
|
|
logmsg(LOG_DEBUG, "%s %s 0x%08x %s",
|
1996-11-19 23:57:06 +00:00
|
|
|
ii->ii_ifname, intoa(ntohl(ii->ii_ipaddr)),
|
2003-06-15 03:00:22 +00:00
|
|
|
(in_addr_t)ntohl(ii->ii_netmask), eatoa(ii->ii_eaddr));
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2001-06-11 09:29:34 +00:00
|
|
|
usage(void)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
2003-08-16 22:23:16 +00:00
|
|
|
(void)fprintf(stderr, "%s\n%s\n",
|
|
|
|
"usage: rarpd -a [-dfsv] [-t directory]",
|
|
|
|
" rarpd [-dfsv] [-t directory] interface");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
static int
|
2001-06-11 09:29:34 +00:00
|
|
|
bpf_open(void)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int n = 0;
|
|
|
|
char device[sizeof "/dev/bpf000"];
|
|
|
|
|
|
|
|
/*
|
1995-05-30 03:57:47 +00:00
|
|
|
* Go through all the minors and find one that isn't in use.
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*/
|
|
|
|
do {
|
|
|
|
(void)sprintf(device, "/dev/bpf%d", n++);
|
|
|
|
fd = open(device, O_RDWR);
|
2001-06-11 09:29:34 +00:00
|
|
|
} while ((fd == -1) && (errno == EBUSY));
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
2001-06-11 09:29:34 +00:00
|
|
|
if (fd == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "%s: %m", device);
|
1996-11-18 22:07:41 +00:00
|
|
|
exit(1);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open a BPF file and attach it to the interface named 'device'.
|
|
|
|
* Set immediate mode, and set a filter that accepts only RARP requests.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static int
|
2001-06-11 09:29:34 +00:00
|
|
|
rarp_open(char *device)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
struct ifreq ifr;
|
1996-11-18 22:07:41 +00:00
|
|
|
u_int dlt;
|
|
|
|
int immediate;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
|
|
|
static struct bpf_insn insns[] = {
|
1996-11-18 22:07:41 +00:00
|
|
|
BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 12),
|
|
|
|
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, ETHERTYPE_REVARP, 0, 3),
|
|
|
|
BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 20),
|
|
|
|
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, REVARP_REQUEST, 0, 1),
|
|
|
|
BPF_STMT(BPF_RET|BPF_K, sizeof(struct ether_arp) +
|
|
|
|
sizeof(struct ether_header)),
|
|
|
|
BPF_STMT(BPF_RET|BPF_K, 0),
|
|
|
|
};
|
|
|
|
static struct bpf_program filter = {
|
|
|
|
sizeof insns / sizeof(insns[0]),
|
|
|
|
insns
|
|
|
|
};
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
|
|
|
fd = bpf_open();
|
1995-05-30 03:57:47 +00:00
|
|
|
/*
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* Set immediate mode so packets are processed as they arrive.
|
|
|
|
*/
|
|
|
|
immediate = 1;
|
2001-06-11 09:29:34 +00:00
|
|
|
if (ioctl(fd, BIOCIMMEDIATE, &immediate) == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "BIOCIMMEDIATE: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2003-07-11 14:13:21 +00:00
|
|
|
strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
2001-06-11 09:29:34 +00:00
|
|
|
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "BIOCSETIF: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Check that the data link layer is an Ethernet; this code won't
|
|
|
|
* work with anything else.
|
|
|
|
*/
|
2001-06-11 09:29:34 +00:00
|
|
|
if (ioctl(fd, BIOCGDLT, (caddr_t)&dlt) == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "BIOCGDLT: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
if (dlt != DLT_EN10MB) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "%s is not an ethernet", device);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Set filter program.
|
|
|
|
*/
|
2001-06-11 09:29:34 +00:00
|
|
|
if (ioctl(fd, BIOCSETF, (caddr_t)&filter) == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "BIOCSETF: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform various sanity checks on the RARP request packet. Return
|
|
|
|
* false on failure and log the reason.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static int
|
2001-06-11 09:29:34 +00:00
|
|
|
rarp_check(u_char *p, u_int len)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
|
|
|
struct ether_header *ep = (struct ether_header *)p;
|
|
|
|
struct ether_arp *ap = (struct ether_arp *)(p + sizeof(*ep));
|
|
|
|
|
|
|
|
if (len < sizeof(*ep) + sizeof(*ap)) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "truncated request, got %u, expected %lu",
|
2001-06-16 18:55:13 +00:00
|
|
|
len, (u_long)(sizeof(*ep) + sizeof(*ap)));
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* XXX This test might be better off broken out...
|
|
|
|
*/
|
1996-11-18 22:07:41 +00:00
|
|
|
if (ntohs(ep->ether_type) != ETHERTYPE_REVARP ||
|
|
|
|
ntohs(ap->arp_hrd) != ARPHRD_ETHER ||
|
|
|
|
ntohs(ap->arp_op) != REVARP_REQUEST ||
|
|
|
|
ntohs(ap->arp_pro) != ETHERTYPE_IP ||
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
ap->arp_hln != 6 || ap->arp_pln != 4) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_DEBUG, "request fails sanity check");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (bcmp((char *)&ep->ether_shost, (char *)&ap->arp_sha, 6) != 0) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_DEBUG, "ether/arp sender address mismatch");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (bcmp((char *)&ap->arp_sha, (char *)&ap->arp_tha, 6) != 0) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_DEBUG, "ether/arp target address mismatch");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1995-05-30 03:57:47 +00:00
|
|
|
* Loop indefinitely listening for RARP requests on the
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* interfaces in 'iflist'.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2001-06-11 09:29:34 +00:00
|
|
|
rarp_loop(void)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
1996-11-18 22:07:41 +00:00
|
|
|
u_char *buf, *bp, *ep;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
int cc, fd;
|
|
|
|
fd_set fds, listeners;
|
|
|
|
int bufsize, maxfd = 0;
|
|
|
|
struct if_info *ii;
|
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
if (iflist == NULL) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "no interfaces");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2001-06-11 09:29:34 +00:00
|
|
|
if (ioctl(iflist->ii_fd, BIOCGBLEN, (caddr_t)&bufsize) == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "BIOCGBLEN: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2001-06-13 11:56:00 +00:00
|
|
|
buf = malloc(bufsize);
|
1996-11-18 22:07:41 +00:00
|
|
|
if (buf == NULL) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "malloc: %m");
|
1996-11-18 22:07:41 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
while (1) {
|
1996-11-19 23:57:06 +00:00
|
|
|
/*
|
|
|
|
* Find the highest numbered file descriptor for select().
|
|
|
|
* Initialize the set of descriptors to listen to.
|
|
|
|
*/
|
1996-11-18 22:07:41 +00:00
|
|
|
FD_ZERO(&fds);
|
|
|
|
for (ii = iflist; ii != NULL; ii = ii->ii_next) {
|
|
|
|
FD_SET(ii->ii_fd, &fds);
|
|
|
|
if (ii->ii_fd > maxfd)
|
|
|
|
maxfd = ii->ii_fd;
|
|
|
|
}
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
listeners = fds;
|
2001-06-11 09:29:34 +00:00
|
|
|
if (select(maxfd + 1, &listeners, NULL, NULL, NULL) == -1) {
|
1996-11-18 22:07:41 +00:00
|
|
|
/* Don't choke when we get ptraced */
|
|
|
|
if (errno == EINTR)
|
|
|
|
continue;
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "select: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
for (ii = iflist; ii != NULL; ii = ii->ii_next) {
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
fd = ii->ii_fd;
|
1996-11-18 22:07:41 +00:00
|
|
|
if (!FD_ISSET(fd, &listeners))
|
|
|
|
continue;
|
|
|
|
again:
|
|
|
|
cc = read(fd, (char *)buf, bufsize);
|
|
|
|
/* Don't choke when we get ptraced */
|
2001-06-11 09:29:34 +00:00
|
|
|
if ((cc == -1) && (errno == EINTR))
|
1996-11-18 22:07:41 +00:00
|
|
|
goto again;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
/* Loop through the packet(s) */
|
|
|
|
#define bhp ((struct bpf_hdr *)bp)
|
|
|
|
bp = buf;
|
|
|
|
ep = bp + cc;
|
|
|
|
while (bp < ep) {
|
2001-06-11 09:29:34 +00:00
|
|
|
u_int caplen, hdrlen;
|
1996-11-18 22:07:41 +00:00
|
|
|
|
|
|
|
caplen = bhp->bh_caplen;
|
|
|
|
hdrlen = bhp->bh_hdrlen;
|
|
|
|
if (rarp_check(bp + hdrlen, caplen))
|
1996-11-27 20:42:09 +00:00
|
|
|
rarp_process(ii, bp + hdrlen, caplen);
|
1996-11-18 22:07:41 +00:00
|
|
|
bp += BPF_WORDALIGN(hdrlen + caplen);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
#undef bhp
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* True if this server can boot the host whose IP address is 'addr'.
|
|
|
|
* This check is made by looking in the tftp directory for the
|
|
|
|
* configuration file.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static int
|
2003-06-15 03:00:22 +00:00
|
|
|
rarp_bootable(in_addr_t addr)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
2001-06-11 09:29:34 +00:00
|
|
|
struct dirent *dent;
|
|
|
|
DIR *d;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
char ipname[9];
|
1996-11-18 22:07:41 +00:00
|
|
|
static DIR *dd = NULL;
|
|
|
|
|
2003-06-15 03:00:22 +00:00
|
|
|
(void)sprintf(ipname, "%08X", (in_addr_t)ntohl(addr));
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If directory is already open, rewind it. Otherwise, open it.
|
|
|
|
*/
|
1996-11-18 22:07:41 +00:00
|
|
|
if ((d = dd) != NULL)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
rewinddir(d);
|
|
|
|
else {
|
1996-11-18 22:07:41 +00:00
|
|
|
if (chdir(tftp_dir) == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "chdir: %s: %m", tftp_dir);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
d = opendir(".");
|
1996-11-18 22:07:41 +00:00
|
|
|
if (d == NULL) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "opendir: %m");
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
dd = d;
|
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
while ((dent = readdir(d)) != NULL)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
if (strncmp(dent->d_name, ipname, 8) == 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a list of IP addresses, 'alist', return the first address that
|
|
|
|
* is on network 'net'; 'netmask' is a mask indicating the network portion
|
|
|
|
* of the address.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static in_addr_t
|
2003-06-15 03:00:22 +00:00
|
|
|
choose_ipaddr(in_addr_t **alist, in_addr_t net, in_addr_t netmask)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
1996-11-18 22:07:41 +00:00
|
|
|
for (; *alist; ++alist)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
if ((**alist & netmask) == net)
|
|
|
|
return **alist;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Answer the RARP request in 'pkt', on the interface 'ii'. 'pkt' has
|
|
|
|
* already been checked for validity. The reply is overlaid on the request.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2001-06-11 09:29:34 +00:00
|
|
|
rarp_process(struct if_info *ii, u_char *pkt, u_int len)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
|
|
|
struct ether_header *ep;
|
|
|
|
struct hostent *hp;
|
2003-06-15 03:00:22 +00:00
|
|
|
in_addr_t target_ipaddr;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
char ename[256];
|
|
|
|
|
|
|
|
ep = (struct ether_header *)pkt;
|
1996-11-19 23:57:06 +00:00
|
|
|
/* should this be arp_tha? */
|
2001-06-11 09:29:34 +00:00
|
|
|
if (ether_ntohost(ename, (struct ether_addr *)&ep->ether_shost) != 0) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "cannot map %s to name",
|
1996-11-27 20:42:09 +00:00
|
|
|
eatoa(ep->ether_shost));
|
1996-11-18 22:07:41 +00:00
|
|
|
return;
|
1996-11-27 20:42:09 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
|
1996-11-27 20:42:09 +00:00
|
|
|
if ((hp = gethostbyname(ename)) == NULL) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "cannot map %s to IP address", ename);
|
1996-11-18 22:07:41 +00:00
|
|
|
return;
|
1996-11-27 20:42:09 +00:00
|
|
|
}
|
|
|
|
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
/*
|
1996-11-18 22:07:41 +00:00
|
|
|
* Choose correct address from list.
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*/
|
1996-11-18 22:07:41 +00:00
|
|
|
if (hp->h_addrtype != AF_INET) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "cannot handle non IP addresses for %s",
|
1996-11-19 23:57:06 +00:00
|
|
|
ename);
|
|
|
|
return;
|
1996-11-18 22:07:41 +00:00
|
|
|
}
|
2003-06-15 03:00:22 +00:00
|
|
|
target_ipaddr = choose_ipaddr((in_addr_t **)hp->h_addr_list,
|
1996-11-18 22:07:41 +00:00
|
|
|
ii->ii_ipaddr & ii->ii_netmask,
|
1996-11-19 23:57:06 +00:00
|
|
|
ii->ii_netmask);
|
1996-11-18 22:07:41 +00:00
|
|
|
if (target_ipaddr == 0) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "cannot find %s on net %s",
|
1996-11-19 23:57:06 +00:00
|
|
|
ename, intoa(ntohl(ii->ii_ipaddr & ii->ii_netmask)));
|
1996-11-18 22:07:41 +00:00
|
|
|
return;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-27 20:45:10 +00:00
|
|
|
if (sflag || rarp_bootable(target_ipaddr))
|
1996-11-18 22:07:41 +00:00
|
|
|
rarp_reply(ii, ep, target_ipaddr, len);
|
|
|
|
else if (verbose > 1)
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_INFO, "%s %s at %s DENIED (not bootable)",
|
1996-11-18 22:07:41 +00:00
|
|
|
ii->ii_ifname,
|
1996-11-19 23:57:06 +00:00
|
|
|
eatoa(ep->ether_shost),
|
|
|
|
intoa(ntohl(target_ipaddr)));
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-11-18 22:07:41 +00:00
|
|
|
* Poke the kernel arp tables with the ethernet/ip address combinataion
|
|
|
|
* given. When processing a reply, we must do this so that the booting
|
|
|
|
* host (i.e. the guy running rarpd), won't try to ARP for the hardware
|
|
|
|
* address of the guy being booted (he cannot answer the ARP).
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*/
|
2001-06-11 09:29:34 +00:00
|
|
|
struct sockaddr_inarp sin_inarp = {
|
|
|
|
sizeof(struct sockaddr_inarp), AF_INET, 0,
|
|
|
|
{0},
|
|
|
|
{0},
|
|
|
|
0, 0
|
1996-11-18 22:07:41 +00:00
|
|
|
};
|
2001-06-11 09:29:34 +00:00
|
|
|
struct sockaddr_dl sin_dl = {
|
|
|
|
sizeof(struct sockaddr_dl), AF_LINK, 0, IFT_ETHER, 0, 6,
|
2002-05-09 14:15:57 +00:00
|
|
|
0, ""
|
1996-11-18 22:07:41 +00:00
|
|
|
};
|
2001-06-11 09:29:34 +00:00
|
|
|
struct {
|
1996-11-18 22:07:41 +00:00
|
|
|
struct rt_msghdr rthdr;
|
|
|
|
char rtspace[512];
|
|
|
|
} rtmsg;
|
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2003-06-15 03:00:22 +00:00
|
|
|
update_arptab(u_char *ep, in_addr_t ipaddr)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
2001-06-11 09:29:34 +00:00
|
|
|
int cc;
|
|
|
|
struct sockaddr_inarp *ar, *ar2;
|
|
|
|
struct sockaddr_dl *ll, *ll2;
|
|
|
|
struct rt_msghdr *rt;
|
|
|
|
int xtype, xindex;
|
1996-11-18 22:07:41 +00:00
|
|
|
static pid_t pid;
|
1998-04-02 13:20:15 +00:00
|
|
|
int r;
|
2001-06-11 09:29:34 +00:00
|
|
|
static int seq;
|
1996-11-18 22:07:41 +00:00
|
|
|
|
1998-04-02 13:20:15 +00:00
|
|
|
r = socket(PF_ROUTE, SOCK_RAW, 0);
|
2001-06-11 09:29:34 +00:00
|
|
|
if (r == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "raw route socket: %m");
|
1998-04-02 13:20:15 +00:00
|
|
|
exit(1);
|
1996-11-18 22:07:41 +00:00
|
|
|
}
|
1998-04-02 13:20:15 +00:00
|
|
|
pid = getpid();
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
ar = &sin_inarp;
|
1996-11-19 23:57:06 +00:00
|
|
|
ar->sin_addr.s_addr = ipaddr;
|
1996-11-18 22:07:41 +00:00
|
|
|
ll = &sin_dl;
|
|
|
|
bcopy(ep, LLADDR(ll), 6);
|
|
|
|
|
|
|
|
/* Get the type and interface index */
|
|
|
|
rt = &rtmsg.rthdr;
|
|
|
|
bzero(rt, sizeof(rtmsg));
|
|
|
|
rt->rtm_version = RTM_VERSION;
|
|
|
|
rt->rtm_addrs = RTA_DST;
|
|
|
|
rt->rtm_type = RTM_GET;
|
|
|
|
rt->rtm_seq = ++seq;
|
|
|
|
ar2 = (struct sockaddr_inarp *)rtmsg.rtspace;
|
|
|
|
bcopy(ar, ar2, sizeof(*ar));
|
|
|
|
rt->rtm_msglen = sizeof(*rt) + sizeof(*ar);
|
|
|
|
errno = 0;
|
2001-06-11 09:29:34 +00:00
|
|
|
if ((write(r, rt, rt->rtm_msglen) == -1) && (errno != ESRCH)) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "rtmsg get write: %m");
|
1998-04-02 13:20:15 +00:00
|
|
|
close(r);
|
1996-11-19 23:57:06 +00:00
|
|
|
return;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
do {
|
|
|
|
cc = read(r, rt, sizeof(rtmsg));
|
|
|
|
} while (cc > 0 && (rt->rtm_seq != seq || rt->rtm_pid != pid));
|
2001-06-11 09:29:34 +00:00
|
|
|
if (cc == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "rtmsg get read: %m");
|
1998-04-02 13:20:15 +00:00
|
|
|
close(r);
|
1996-11-19 23:57:06 +00:00
|
|
|
return;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
ll2 = (struct sockaddr_dl *)((u_char *)ar2 + ar2->sin_len);
|
|
|
|
if (ll2->sdl_family != AF_LINK) {
|
|
|
|
/*
|
|
|
|
* XXX I think this means the ip address is not on a
|
|
|
|
* directly connected network (the family is AF_INET in
|
|
|
|
* this case).
|
|
|
|
*/
|
2003-06-15 03:00:22 +00:00
|
|
|
logmsg(LOG_ERR, "bogus link family (%d) wrong net for %08X?\n",
|
1996-11-19 23:57:06 +00:00
|
|
|
ll2->sdl_family, ipaddr);
|
1998-04-02 13:20:15 +00:00
|
|
|
close(r);
|
1996-11-18 22:07:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
xtype = ll2->sdl_type;
|
|
|
|
xindex = ll2->sdl_index;
|
|
|
|
|
|
|
|
/* Set the new arp entry */
|
|
|
|
bzero(rt, sizeof(rtmsg));
|
|
|
|
rt->rtm_version = RTM_VERSION;
|
|
|
|
rt->rtm_addrs = RTA_DST | RTA_GATEWAY;
|
|
|
|
rt->rtm_inits = RTV_EXPIRE;
|
|
|
|
rt->rtm_rmx.rmx_expire = time(0) + ARPSECS;
|
|
|
|
rt->rtm_flags = RTF_HOST | RTF_STATIC;
|
|
|
|
rt->rtm_type = RTM_ADD;
|
|
|
|
rt->rtm_seq = ++seq;
|
|
|
|
|
|
|
|
bcopy(ar, ar2, sizeof(*ar));
|
|
|
|
|
|
|
|
ll2 = (struct sockaddr_dl *)((u_char *)ar2 + sizeof(*ar2));
|
|
|
|
bcopy(ll, ll2, sizeof(*ll));
|
|
|
|
ll2->sdl_type = xtype;
|
|
|
|
ll2->sdl_index = xindex;
|
|
|
|
|
|
|
|
rt->rtm_msglen = sizeof(*rt) + sizeof(*ar2) + sizeof(*ll2);
|
|
|
|
errno = 0;
|
2001-06-11 09:29:34 +00:00
|
|
|
if ((write(r, rt, rt->rtm_msglen) == -1) && (errno != EEXIST)) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "rtmsg add write: %m");
|
1998-04-02 13:20:15 +00:00
|
|
|
close(r);
|
1996-11-19 23:57:06 +00:00
|
|
|
return;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
do {
|
|
|
|
cc = read(r, rt, sizeof(rtmsg));
|
|
|
|
} while (cc > 0 && (rt->rtm_seq != seq || rt->rtm_pid != pid));
|
1998-04-02 13:20:15 +00:00
|
|
|
close(r);
|
2001-06-11 09:29:34 +00:00
|
|
|
if (cc == -1) {
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "rtmsg add read: %m");
|
1996-11-19 23:57:06 +00:00
|
|
|
return;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build a reverse ARP packet and sent it out on the interface.
|
1996-11-18 22:07:41 +00:00
|
|
|
* 'ep' points to a valid REVARP_REQUEST. The REVARP_REPLY is built
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* on top of the request, then written to the network.
|
|
|
|
*
|
|
|
|
* RFC 903 defines the ether_arp fields as follows. The following comments
|
|
|
|
* are taken (more or less) straight from this document.
|
|
|
|
*
|
1996-11-18 22:07:41 +00:00
|
|
|
* REVARP_REQUEST
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*
|
|
|
|
* arp_sha is the hardware address of the sender of the packet.
|
|
|
|
* arp_spa is undefined.
|
|
|
|
* arp_tha is the 'target' hardware address.
|
|
|
|
* In the case where the sender wishes to determine his own
|
|
|
|
* protocol address, this, like arp_sha, will be the hardware
|
|
|
|
* address of the sender.
|
|
|
|
* arp_tpa is undefined.
|
|
|
|
*
|
1996-11-18 22:07:41 +00:00
|
|
|
* REVARP_REPLY
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
*
|
|
|
|
* arp_sha is the hardware address of the responder (the sender of the
|
|
|
|
* reply packet).
|
|
|
|
* arp_spa is the protocol address of the responder (see the note below).
|
|
|
|
* arp_tha is the hardware address of the target, and should be the same as
|
|
|
|
* that which was given in the request.
|
|
|
|
* arp_tpa is the protocol address of the target, that is, the desired address.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* Note that the requirement that arp_spa be filled in with the responder's
|
1995-05-30 03:57:47 +00:00
|
|
|
* protocol is purely for convenience. For instance, if a system were to use
|
|
|
|
* both ARP and RARP, then the inclusion of the valid protocol-hardware
|
|
|
|
* address pair (arp_spa, arp_sha) may eliminate the need for a subsequent
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
* ARP request.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2003-06-15 03:00:22 +00:00
|
|
|
rarp_reply(struct if_info *ii, struct ether_header *ep, in_addr_t ipaddr,
|
2001-06-11 09:29:34 +00:00
|
|
|
u_int len)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
2001-06-11 09:29:34 +00:00
|
|
|
u_int n;
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
struct ether_arp *ap = (struct ether_arp *)(ep + 1);
|
|
|
|
|
|
|
|
update_arptab((u_char *)&ap->arp_sha, ipaddr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build the rarp reply by modifying the rarp request in place.
|
|
|
|
*/
|
1996-11-18 22:07:41 +00:00
|
|
|
ap->arp_op = htons(REVARP_REPLY);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
#ifdef BROKEN_BPF
|
|
|
|
ep->ether_type = ETHERTYPE_REVARP;
|
|
|
|
#endif
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
bcopy((char *)&ap->arp_sha, (char *)&ep->ether_dhost, 6);
|
|
|
|
bcopy((char *)ii->ii_eaddr, (char *)&ep->ether_shost, 6);
|
|
|
|
bcopy((char *)ii->ii_eaddr, (char *)&ap->arp_sha, 6);
|
|
|
|
|
|
|
|
bcopy((char *)&ipaddr, (char *)ap->arp_tpa, 4);
|
|
|
|
/* Target hardware is unchanged. */
|
|
|
|
bcopy((char *)&ii->ii_ipaddr, (char *)ap->arp_spa, 4);
|
|
|
|
|
1996-11-18 22:07:41 +00:00
|
|
|
/* Zero possible garbage after packet. */
|
|
|
|
bzero((char *)ep + (sizeof(*ep) + sizeof(*ap)),
|
|
|
|
len - (sizeof(*ep) + sizeof(*ap)));
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
n = write(ii->ii_fd, (char *)ep, len);
|
1996-11-18 22:07:41 +00:00
|
|
|
if (n != len)
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_ERR, "write: only %d of %d bytes written", n, len);
|
1996-11-18 22:07:41 +00:00
|
|
|
if (verbose)
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(LOG_INFO, "%s %s at %s REPLIED", ii->ii_ifname,
|
1996-11-27 20:42:09 +00:00
|
|
|
eatoa(ap->arp_tha),
|
1996-11-19 23:57:06 +00:00
|
|
|
intoa(ntohl(ipaddr)));
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the netmask of an IP address. This routine is used if
|
|
|
|
* SIOCGIFNETMASK doesn't work.
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static in_addr_t
|
2003-06-15 03:00:22 +00:00
|
|
|
ipaddrtonetmask(in_addr_t addr)
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
{
|
1996-11-19 23:57:06 +00:00
|
|
|
addr = ntohl(addr);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
if (IN_CLASSA(addr))
|
1996-11-19 23:57:06 +00:00
|
|
|
return htonl(IN_CLASSA_NET);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
if (IN_CLASSB(addr))
|
1996-11-19 23:57:06 +00:00
|
|
|
return htonl(IN_CLASSB_NET);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
if (IN_CLASSC(addr))
|
1996-11-19 23:57:06 +00:00
|
|
|
return htonl(IN_CLASSC_NET);
|
2003-06-15 03:00:22 +00:00
|
|
|
logmsg(LOG_DEBUG, "unknown IP address class: %08X", addr);
|
1996-11-19 23:57:06 +00:00
|
|
|
return htonl(0xffffffff);
|
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. :)
1995-03-02 06:41:40 +00:00
|
|
|
}
|
1996-11-18 22:07:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A faster replacement for inet_ntoa().
|
|
|
|
*/
|
2003-07-11 14:13:21 +00:00
|
|
|
static char *
|
2003-06-15 03:00:22 +00:00
|
|
|
intoa(in_addr_t addr)
|
1996-11-18 22:07:41 +00:00
|
|
|
{
|
2001-06-11 09:29:34 +00:00
|
|
|
char *cp;
|
|
|
|
u_int byte;
|
|
|
|
int n;
|
1996-11-18 22:07:41 +00:00
|
|
|
static char buf[sizeof(".xxx.xxx.xxx.xxx")];
|
|
|
|
|
|
|
|
cp = &buf[sizeof buf];
|
|
|
|
*--cp = '\0';
|
|
|
|
|
|
|
|
n = 4;
|
|
|
|
do {
|
|
|
|
byte = addr & 0xff;
|
|
|
|
*--cp = byte % 10 + '0';
|
|
|
|
byte /= 10;
|
|
|
|
if (byte > 0) {
|
|
|
|
*--cp = byte % 10 + '0';
|
|
|
|
byte /= 10;
|
|
|
|
if (byte > 0)
|
|
|
|
*--cp = byte + '0';
|
|
|
|
}
|
|
|
|
*--cp = '.';
|
|
|
|
addr >>= 8;
|
|
|
|
} while (--n > 0);
|
|
|
|
|
|
|
|
return cp + 1;
|
|
|
|
}
|
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
static char *
|
2001-06-11 09:29:34 +00:00
|
|
|
eatoa(u_char *ea)
|
1996-11-18 22:07:41 +00:00
|
|
|
{
|
|
|
|
static char buf[sizeof("xx:xx:xx:xx:xx:xx")];
|
|
|
|
|
|
|
|
(void)sprintf(buf, "%x:%x:%x:%x:%x:%x",
|
|
|
|
ea[0], ea[1], ea[2], ea[3], ea[4], ea[5]);
|
|
|
|
return (buf);
|
|
|
|
}
|
2001-06-18 06:48:33 +00:00
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
static void
|
2001-06-18 06:48:33 +00:00
|
|
|
logmsg(int pri, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list v;
|
|
|
|
FILE *fp;
|
|
|
|
char *newfmt;
|
|
|
|
|
|
|
|
va_start(v, fmt);
|
|
|
|
if (dflag) {
|
|
|
|
if (pri == LOG_ERR)
|
|
|
|
fp = stderr;
|
|
|
|
else
|
|
|
|
fp = stdout;
|
|
|
|
if (expand_syslog_m(fmt, &newfmt) == -1) {
|
|
|
|
vfprintf(fp, fmt, v);
|
|
|
|
} else {
|
|
|
|
vfprintf(fp, newfmt, v);
|
|
|
|
free(newfmt);
|
|
|
|
}
|
|
|
|
fputs("\n", fp);
|
|
|
|
fflush(fp);
|
|
|
|
} else {
|
|
|
|
vsyslog(pri, fmt, v);
|
|
|
|
}
|
|
|
|
va_end(v);
|
|
|
|
}
|
|
|
|
|
2003-07-11 14:13:21 +00:00
|
|
|
static int
|
2001-06-18 06:48:33 +00:00
|
|
|
expand_syslog_m(const char *fmt, char **newfmt) {
|
|
|
|
const char *str, *m;
|
|
|
|
char *p, *np;
|
|
|
|
|
|
|
|
p = strdup("");
|
|
|
|
str = fmt;
|
|
|
|
while ((m = strstr(str, "%m")) != NULL) {
|
2001-07-05 16:53:49 +00:00
|
|
|
asprintf(&np, "%s%.*s%s", p, (int)(m - str),
|
|
|
|
str, strerror(errno));
|
2001-06-18 06:48:33 +00:00
|
|
|
free(p);
|
|
|
|
if (np == NULL) {
|
|
|
|
errno = ENOMEM;
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
p = np;
|
|
|
|
str = m + 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*str != '\0') {
|
|
|
|
asprintf(&np, "%s%s", p, str);
|
|
|
|
free(p);
|
|
|
|
if (np == NULL) {
|
|
|
|
errno = ENOMEM;
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
p = np;
|
|
|
|
}
|
|
|
|
|
|
|
|
*newfmt = p;
|
|
|
|
return (0);
|
|
|
|
}
|