Commit 58ec50d2 authored by Stephane Glondu's avatar Stephane Glondu

Imported Upstream version 0.52

parent c7f6a20b
28 July 2011: ahcpd 0.52
* Port to OpenBSD, by Vincent Gross.
* Tweaks for compatibility Mac OS X, thanks to Matthieu Boutier.
* Fixed incorrect testing of the prefix length of received IPv6
prefixes, thanks to Gabriel Kerneis.
29 January 2010: ahcpd 0.51
* Servers are now configured with a plain-text configuration file.
......
......@@ -19,7 +19,7 @@ ahcpd: $(OBJS)
.man.html:
rman -f html $< | \
sed -e "s|<a href='babel.8'|<a href=\"../babel/babel.html\"|" \
sed -e "s|<a href='babeld.8'|<a href=\"../babel/babeld.html\"|" \
-e "s|<a href='\\(ahcp[-a-z]*\\).8'|<a href=\"\1.html\"|" \
-e "s|<a href='[^']*8'>\\(.*(8)\\)</a>|\1|" \
> $@
......
Ahcpd
=====
Ahcpd is a daemon for configuring an IPv6 network using the Ad-Hoc
Configuration Protocol (AHCP). AHCP is designed for wireless mesh
networks, where DHCP and IPv6 autoconfiguration do not work, but could in
......@@ -5,39 +8,39 @@ principle also be used on wired networks.
Installation
************
============
$ make
# make install
$ make
# make install
If compiling for OpenWRT, you will probably want to say something like
$ make CC=mipsel-linux-gcc PLATFORM_DEFINES='-march=mips32'
$ make CC=mipsel-linux-gcc PLATFORM_DEFINES='-march=mips32'
You can reduce the size of the ahcpd binary by omitting server
functionality; to do so, specify
$ make EXTRA_DEFINES=-DNO_SERVER
$ make EXTRA_DEFINES=-DNO_SERVER
Setting up a server
*******************
===================
You need to set up one or more authoritative servers in your network. The
server should be run as
$ ahcpd -c /etc/ahcpd.conf wlan0
$ ahcpd -c /etc/ahcpd.conf wlan0
where the configuration file /etc/ahcpd.conf should say something like
mode server
mode server
prefix fde6:20f5:c9ac:358::/64
prefix 192.168.4.128/25
lease-dir /var/lib/leases
name-server fde6:20f5:c9ac:358::1
name-server 192.168.4.1
ntp-server 192.168.4.2
prefix fde6:20f5:c9ac:358::/64
prefix 192.168.4.128/25
lease-dir /var/lib/leases
name-server fde6:20f5:c9ac:358::1
name-server 192.168.4.1
ntp-server 192.168.4.2
If you want ahcpd to fork into the background, pass it the ``-D'' flag.
The server does not need to run ahcpd as root, as long as it can write the
......@@ -55,15 +58,14 @@ as they serve disjoint IPv4 address ranges.
Setting up a client
*******************
===================
Unlike the server, the client needs to run ahcpd as root. No configuration
file is needed, just run
# ahcpd wlan0
# ahcpd wlan0
and you should get IPv4 and IPv6 addresses in a few seconds.
Juliusz Chroboczek
<jch@pps.jussieu.fr>
--Juliusz Chroboczek
......@@ -35,46 +35,46 @@ ipv6_address="$AHCP_IPv6_ADDRESS"
platform=`uname`
if [ "$platform" = "Darwin" ]; then
if [ "$platform" = "Linux" ]; then
findcmd ip iproute
(ip -6 addr show dev lo | grep -q 'inet6') || \
die "No IPv6 address on lo, please modprobe ipv6"
add_ipv6_address() {
ifconfig "$1" inet6 "$2/$3"
ip -6 addr add "$2/$3" dev "$1"
}
del_ipv6_address() {
ifconfig "$1" inet6 "$2/$3" delete
ip -6 addr del "$2/$3" dev "$1"
}
add_ipv4_address() {
ifconfig "$1" inet "$2/$3"
ip addr add "$2/$3" dev "$1"
}
del_ipv4_address() {
ifconfig "$1" inet "$2/$3" delete
ip addr del "$2/$3" dev "$1"
}
else
findcmd ip iproute
(ip -6 addr show dev lo | grep -q 'inet6') || \
die "No IPv6 address on lo, please modprobe ipv6"
add_ipv6_address() {
ip -6 addr add "$2/$3" dev "$1"
ifconfig "$1" inet6 "$2/$3"
}
del_ipv6_address() {
ip -6 addr del "$2/$3" dev "$1"
ifconfig "$1" inet6 "$2/$3" delete
}
add_ipv4_address() {
ip addr add "$2/$3" dev "$1"
ifconfig "$1" inet "$2/$3"
}
del_ipv4_address() {
ip addr del "$2/$3" dev "$1"
ifconfig "$1" inet "$2/$3" delete
}
fi
add_addresses() {
......
......@@ -33,8 +33,9 @@ THE SOFTWARE.
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/uio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include "ahcpd.h"
......@@ -315,7 +316,7 @@ main(int argc, char **argv)
rc = random_eui64(myid);
if(rc < 0) {
fprintf(stderr, "Couldn't generate unique id.\n");
exit(1);
goto fail;
}
write_unique_id:
......@@ -831,7 +832,7 @@ main(int argc, char **argv)
" "
"[-i file] [-s script] [-D] [-I pidfile] [-L logfile]\n"
" "
"[-c statement] [-C filename]"
"[-C statement] [-c filename]"
"interface...\n");
exit(1);
......@@ -973,10 +974,6 @@ ahcp_socket(int port)
if(s < 0)
return -1;
rc = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &zero, sizeof(one));
if(rc < 0)
goto fail;
rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
if(rc < 0)
perror("setsockopt(SO_REUSEADDR)");
......@@ -1113,7 +1110,7 @@ void
timeval_minus(struct timeval *d,
const struct timeval *s1, const struct timeval *s2)
{
if(s1->tv_usec > s2->tv_usec) {
if(s1->tv_usec >= s2->tv_usec) {
d->tv_usec = s1->tv_usec - s2->tv_usec;
d->tv_sec = s1->tv_sec - s2->tv_sec;
} else {
......
......@@ -14,10 +14,11 @@ transitive connectivity, such as mesh networks.
.SH OPTIONS
.TP
.BI \-m " multicast-address"
Speficy the link-local multicast address to be used by AHCP.
Specify the link-local multicast address to be used by AHCP. The
default is ff02::cca6:c0f9:e182:5359.
.TP
.BI \-p " port"
Specify the UDP port number to be used by AHCP.
Specify the UDP port number to be used by AHCP. The default is 5359.
.TP
.B \-n
Operate as a forwarder: participate in the flooding protocol, but don't
......@@ -34,7 +35,7 @@ Do not configure DNS.
.TP
.BI \-t " time"
Specify the time, in seconds, for which leases are requested. The default
is slightly over one hour.
is slightly over one hour. Must be between five minutes and a year.
.TP
.BI \-s " script"
Specify the configuration script to run. The default is
......@@ -52,8 +53,7 @@ If it doesn't exist, it will be created by
.BR ahcpd .
.TP
.BI \-c " filename"
Specify the name of the configuration file. The default is
.BR /etc/babeld.conf .
Specify the name of the configuration file.
.TP
.BI \-C " statement"
Specify a configuration statement directly on the command line.
......@@ -68,7 +68,8 @@ defaults to standard error if not daemonising, and to
otherwise.
.TP
.BI \-I " pidfile"
Specify a file to write our process id to.
Specify a file to write our process id to. The default is
.B /var/run/ahcpd.pid.
.SH CONFIGURATION FILE FORMAT
The configuration is a sequence of lines, each of which starts with
one of the keywords below. Blank lines are ignored. Comments are
......@@ -87,10 +88,14 @@ flag is present on the command line. If present, this must be the first
line in the configuration file.
.TP
.BI prefix " prefix"
Specifies either a prefix to use for configuring clients. This keyword is
only valid in server configurations, and may be specified twice, once for
Specifies a prefix to use for configuring clients. This keyword is only
valid in server configurations, and may be specified twice, once for
IPv4 and once for IPv6.
.TP
.BI lease-dir " directory"
Specifies a directory to store lease files. This keyword is only valid
in server configurations.
.TP
.BI name-server " address"
Specifies the address of a DNS server to configure clients with. This
keyword is only valid in server configurations, and may be repeated
......@@ -149,7 +154,7 @@ necessary.
.SH SEE ALSO
.BR dhcpcd (8),
.BR dhclient (8),
.BR babel (8),
.BR babeld (8),
.BR olsrd (8),
.BR ntpd (8),
.IR "The Ad-Hoc Configuration Protocol" .
......
......@@ -31,12 +31,13 @@ THE SOFTWARE.
#include <sys/uio.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <time.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#ifdef __linux__
#include <netinet/ether.h>
......@@ -505,7 +506,7 @@ parse_message(int configure, const unsigned char *data, int len,
if(config->ipv6_address) {
config->our_ipv6_address = copy_prefix_list(config->ipv6_address);
} else if(config->ipv6_prefix && config->ipv6_prefix->n > 0 &&
config->ipv6_prefix->l[0].plen >= 64) {
config->ipv6_prefix->l[0].plen <= 64) {
unsigned char address[16];
int have_address = 0;
......@@ -863,12 +864,15 @@ int
random_eui64(unsigned char *eui)
{
int fd, rc;
fd = open("/dev/random", O_RDONLY);
/* If there's no /dev/urandom, this will fail with ENOENT,
which the caller will deal with gracefully. */
fd = open("/dev/urandom", O_RDONLY);
if(fd < 0)
return -1;
rc = read(fd, eui, 8);
if(rc < 0)
if(rc < 8)
return -1;
close(fd);
......
......@@ -29,8 +29,10 @@ THE SOFTWARE.
#include <time.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <dirent.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "ahcpd.h"
......
......@@ -23,7 +23,9 @@ THE SOFTWARE.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include "prefix.h"
......
......@@ -26,8 +26,10 @@ THE SOFTWARE.
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "ahcpd.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment