Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
bin_PROGRAMS = choparp
choparp_SOURCES = src/choparp.c
man_MANS = src/choparp.8

AM_TESTS_ENVIRONMENT = \
AM_BUILDDIR='$(abs_top_builddir)'; \
AM_SRCDIR='$(abs_top_srcdir)'; \
AM_SHELL='$(SHELL)'; \
export AM_BUILDDIR AM_SRCDIR AM_SHELL ;

LOG_DRIVER = \
env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh --comments

TEST_EXTENSIONS = .sh

SH_LOG_DRIVER = $(LOG_DRIVER)
SH_LOG_COMPILER = $(SHELL)

TESTS = test/linux-ns-unshare.sh
EXTRA_DIST = $(TESTS) m4/NOTES
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ list.
Build instructions
------------------

Requires libpcap.
Requires libpcap, autoconf, and automake.

```
autoreconf -is
./configure
make
make check
sudo make install
```

If autotools displease you, it is still possible to build directly.

`gcc -o choparp choparp.c -lpcap`

Expand Down
46 changes: 46 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is based on David A. Wheeler's template for configure.ac

# Process this file with autoconf to produce a configure script.

# Initialize autoconf.
AC_INIT([choparp], [20150613])
# Force autoconf to be at least this version number:
AC_PREREQ([2.68])
# Safety check - list a source file that wouldn't be in other directories:
AC_CONFIG_SRCDIR([src/choparp.c])
# Put configuration results here, so we can easily #include them:
AC_CONFIG_HEADERS([config.h])
# Put autotools auxiliary files in subdirectories to reduce clutter:
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])

# Enable "automake" to simplify creating makefiles:
AM_INIT_AUTOMAKE([subdir-objects foreign -Wall -Werror])
AC_CONFIG_FILES([Makefile])

# TAP test driver support
AC_PROG_AWK
AC_REQUIRE_AUX_FILE([tap-driver.sh])

# Checks for programs, e.g., AC_PROG_CC
AC_PROG_CC
# only needef for automake < 1.14
AM_PROG_CC_C_O

# Checks for libraries.
AC_CHECK_LIB([pcap], [pcap_lookupdev], [], [AC_MSG_ERROR([missing required library libpcap])])

# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h],
[], [AC_MSG_ERROR([missing required platform headers])])
AC_CHECK_HEADER([pcap.h], [], [AC_MSG_ERROR([missing required header pcap.h])])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([ftruncate inet_ntop memset socket strchr strtol])

# Do final output.
AC_OUTPUT
6 changes: 6 additions & 0 deletions m4/NOTES
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This directory was added to conform with modern autotools conventions,
superseding acinclude.m4. Additional local Autoconf macros would
reside here.

This NOTES file exists to add the directory to git and effectively
suppresses a spurious warning message.
100 changes: 63 additions & 37 deletions src/choparp.8
Original file line number Diff line number Diff line change
Expand Up @@ -35,75 +35,101 @@
.Nd cheap and omitted proxy ARP
.Sh SYNOPSIS
.Nm chpoarp
.Op Fl p Ar file
.Op Fl v
.Ar if_name mac_addr
.Oo Fl Oc Ns Ar net_addr Ns
.Op / Ns Ar net_mask
.Ar ...
.Sh DESCRIPTION
.Pp
.Nm choparp
.Nm choparp
is a easy-to-use proxy ARP daemon.
It watches ARP request packets visible on the interface specified by argument
.Ar if_name ,
and sends proxy ARP reply to the sender if the ARP request queries the
MAC address
.Pq ethernet hardware address
for the network specified by
.Ar net_addr Ns / Ar net_mask .
.Ar net_addr Ns / Ns Ar net_mask .
.Pp
.Bl -tag -width indent
.It Fl p Ar file
Save process id to the given file.
.It Fl v
Send diagnostic messages to stdout. Repeat to increase verbosity.
.It Ar if_name
Network interface on which to listen and respond to ARP requests.
.It Ar mac_addr
The MAC address to be published for the specified hosts, in one of three formats.
.Bl -tag -width indent
.It Ar xx:xx:xx:xx:xx:xx
Static value specified as 6 colon-separated byte values in hexadecimal.
.It Ar vhid: Ns Oo <nnn>|0x<xx> Oc
Virtual router (VRRP/CARP) address with the final octet (VRID)
given by decimal value <nnn> or hexadecimal value <xx> .
.It Ar auto
Usually,
.Ar mac_addr
is th MAC address to be published for the specified hosts.
It is normally the address of
is the address of
.Ar if_name .
The format of
.Ar mac_addr
must be 6 colon-separated bytes of hexadecimal value, such as
.Ad 00:00:01:01:14:46 .
The keyword
.Ad auto
can also be used to use the address of
Specify the keyword
.Sy auto
to use the address of
.Ar if_name
from the system configuration.
.Pp
A
.Xr carp 4
virtual router address can be specified as
.Ad vhid:<hex>
detected from the system configuration.
.El
.
.Pp
.Ar net_addr
must be in dotted quad notation
.Pq for example Ad 133.138.1.134
or be a 32 bit hexadecimal value starting with
.It Ar net_addr
IPv4 address in either dotted quad notation
.Pq for example Ar 192.0.2.2
or, BSD-style, as a 32 bit hexadecimal value starting with
.Dq 0x
.Pq for example Ad 0x858a0186 .
.Pq for example Ar 0x858a0186 .
.It Ar net_mask
Alone,
.Ar net_addr
specifies a single host; to specify an IP range, include a
.Ar net_mask
can likewise be speficied as a dotted quad or hexadecimal value,
or alternatively as a mask length. The following address specifications
are therefore equivalent:
in the same way one would specify a subnet.
Full 32-bit values may be in either dotted-decimal and BSD-style hexadecimal format.
Prefix lengths may be specified in CIDR notation.
The following address specifications are equivalent:
.Bl -item -offset indent
.It
.Ad 192.168.98.0/255.255.254.0
.Ar 192.0.2.0/255.255.254.0
.It
.Ad 192.168.98.0/0xfffffe00
.Ar 0xc0000200/0xfffffe00
.It
.Ad 192.168.98.0/23
.Ar 192.0.2.0/0xfffffe00
.It
.Ar 192.0.2.0/23
.El
.Pp
Multiple addresses can be specified.
Addresses can be
.Em excluded
by preceding them with
.Fl
Address matches may be either affirmative or negative, with affirmative as the default.
To exclude an address or range, specify a negative match with a prefix
.Dq -
(dash) prefix.
Multiple matches may be specified, with at least one being affirmative.
.El
.Sh EXAMPLES
If you have network interface
.Dq ne0
with MAC address
.Dq 00:00:01:01:14:16 ,
and would like to send proxy ARP reply for 192.168.0.64/26,
.Dq 00:00:5e:00:53:01
, and would like to send proxy ARP reply for 192.168.0.64/26,
the argument would be as follows:
.Bd -literal -offset indent
choparp ne0 00:00:01:01:14:46 192.168.0.64/255.255.255.192
choparp ne0 00:00:5e:00:53:01 192.168.0.64/26
.Ed
.Pp
Were
.Dq ne0
assigned the IPv4 address 192.168.0.65/26,
you could additionally exclude the the host address and all-ones and all-zeroes
broadcast addresses as follows:
.Bd -literal -offset indent
choparp ne0 00:00:5e:00:53:01 192.168.0.64/26 -192.168.0.64/31 -192.168.0.127
.Ed
.Sh BUGS
Supports Ethernet interfaces only.
Expand Down
Loading