Commit c7f6a20b authored by Stephane Glondu's avatar Stephane Glondu

Imported Upstream version 0.51

parent ab5d88f4
29 January 2010: ahcpd 0.51
* Servers are now configured with a plain-text configuration file.
* Implemented client-side support for prefix delegation (-P).
* Made requesting state more persistent, to deal with packet loss.
* Fixed a typo that prevented the -I option from working.
* Fixed compilation on BSD systems.
* Fixed a bug that could cause an expired lease to be discarded when
older ones are available.
11 August 2009: ahcpd 0.50
* Complete redesign of AHCP as a client-server protocol layered over
a built-in multicast routing layer. This protocol (version 1) is
completely incompatible with the old (version 0) protocol.
25 May 2008: ahcpd 0.5
* Made ahcpd gracefully survive interfaces going up/down or being
renumbered, as usually happens when tunnels or VPNs are started or
stopped.
* Implemented the ability to run as a daemon.
* Implemented the ability to try multiple stateful servers.
* Implemented the flag -r, which prevents the routing protocol from
being started.
17 February 2008: ahcpd 0.4
* Implemented stateful configuration for IPv4.
* Tweaked timing to avoid hopping between competing configurations.
* Fixed conversion of Babel hello intervals to seconds.
28 October 2007: ahcpd 0.3
* Moved user-serviceable parts to /etc/ahcp/
* Added support for configuring an NTP server.
* Made ahcp print warnings when a clock inconsistency is detected.
* Fixed error handling when the configuration script dies unexpectedly.
27 September 2007: ahcpd 0.2
* Fixed a bug in computation of validity time that would cause ahcpd
to be much more chatty than necessary.
22 August 2007: ahcpd 0.1
* Initial public release.
......@@ -6,9 +6,9 @@ DEFINES = $(PLATFORM_DEFINES)
CFLAGS = $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES)
SRCS = ahcpd.c monotonic.c transport.c config.c lease.c
SRCS = ahcpd.c monotonic.c transport.c prefix.c configure.c config.c lease.c
OBJS = ahcpd.o monotonic.o transport.o config.o lease.o
OBJS = ahcpd.o monotonic.o transport.o prefix.o configure.o config.o lease.o
LDLIBS = -lrt
......@@ -34,7 +34,7 @@ install.minimal: all
mkdir -p $(TARGET)$(PREFIX)/bin/
-rm -f $(TARGET)$(PREFIX)/bin/ahcpd
cp ahcpd $(TARGET)$(PREFIX)/bin/
mkdir -p /etc/ahcp/
mkdir -p $(TARGET)/etc/ahcp/
-rm -f $(TARGET)/etc/ahcp/ahcp-config.sh
cp ahcp-config.sh $(TARGET)/etc/ahcp/
chmod +x $(TARGET)/etc/ahcp/ahcp-config.sh
......
......@@ -23,16 +23,21 @@ functionality; to do so, specify
Setting up a server
*******************
You need to set up one or more authoritative servers in your network. Your
server should run something like
You need to set up one or more authoritative servers in your network. The
server should be run as
$ ahcpd -S fde6:20f5:c9ac:358::,192.168.4.128,192.168.4.254,/var/lib/leases \
wlan0
$ ahcpd -c /etc/ahcpd.conf wlan0
where fde6:20f5:c9ac:358:: is your IPv6 prefix, 192.168.4.128 through
192.168.4.254 is the range of IPv4 addresses you want to give out to
clients, and /var/lib/leases is the location of the persistent lease
database.
where the configuration file /etc/ahcpd.conf should say something like
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
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
......@@ -52,8 +57,8 @@ as they serve disjoint IPv4 address ranges.
Setting up a client
*******************
Unlike the server, the client needs to run ahcpd as root. Simply run
something like
Unlike the server, the client needs to run ahcpd as root. No configuration
file is needed, just run
# ahcpd wlan0
......
This diff is collapsed.
/*
Copyright (c) 2007-2009 by Juliusz Chroboczek
Copyright (c) 2007-2010 by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -20,15 +20,56 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* nothing */
#elif defined(__GNUC__)
#define inline __inline
#if (__GNUC__ >= 3)
#define restrict __restrict
#else
#define restrict /**/
#endif
#else
#define inline /**/
#define restrict /**/
#endif
#if defined(__GNUC__) && (__GNUC__ >= 3)
#define ATTRIBUTE(x) __attribute__ (x)
#define LIKELY(_x) __builtin_expect(!!(_x), 1)
#define UNLIKELY(_x) __builtin_expect(!!(_x), 0)
#else
#define ATTRIBUTE(x) /**/
#define LIKELY(_x) !!(_x)
#define UNLIKELY(_x) !!(_x)
#endif
#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
#define COLD __attribute__ ((cold))
#else
#define COLD /**/
#endif
#undef MAX
#undef MIN
#ifdef HAVE_VALGRIND
#include <valgrind/memcheck.h>
#else
#ifndef VALGRIND_MAKE_MEM_UNDEFINED
#define VALGRIND_MAKE_MEM_UNDEFINED(a, b) do {} while(0)
#endif
#ifndef VALGRIND_CHECK_MEM_IS_DEFINED
#define VALGRIND_CHECK_MEM_IS_DEFINED(a, b) do {} while(0)
#endif
#endif
#define MAX(x,y) ((x)<=(y)?(y):(x))
#define MIN(x,y) ((x)<=(y)?(x):(y))
extern int nodns, af;
extern int nodns, af, request_prefix_delegation;
extern char *config_script;
extern int debug_level;
extern int debug;
extern unsigned char myid[8];
extern int numnetworks;
struct network {
......@@ -54,3 +95,33 @@ void timeval_plus_msec(struct timeval *d,
const struct timeval *s, int msecs);
int timeval_compare(const struct timeval *s1, const struct timeval *s2);
int clock_stepped();
void do_debugf(int level, const char *format, ...)
ATTRIBUTE ((format (printf, 2, 3))) COLD;
#if defined NO_DEBUG
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
#define debugf(_level, ...) do {} while(0)
#elif defined __GNUC__
#define debugf(_level, _args...) do {} while(0)
#else
static inline void debugf(_level, const char *format, ...) { return; }
#endif
#else
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
#define debugf(_level, ...) \
do { \
if(UNLIKELY(debug >= _level)) do_debugf(_level, __VA_ARGS__); \
} while(0)
#elif defined __GNUC__
#define debugf(_level, _args...) \
do { \
if(UNLIKELY(debug >= _level)) do_debugf(_level, _args); \
} while(0)
#else
static inline void debugf(int _level, const char *format, ...) { return; }
#endif
#endif
......@@ -20,13 +20,13 @@ Speficy the link-local multicast address to be used by AHCP.
Specify the UDP port number to be used by AHCP.
.TP
.B \-n
Participate in the flooding protocol, but don't actually perform any
configuration.
Operate as a forwarder: participate in the flooding protocol, but don't
actually perform any configuration.
.TP
.B \-4
Only attempt to configure IPv4 addresses.
.TP
.B \-4
.B \-6
Only attempt to configure IPv6 addresses.
.TP
.B \-N
......@@ -51,22 +51,12 @@ Specify the filename containing this host's unique id. The default is
If it doesn't exist, it will be created by
.BR ahcpd .
.TP
.BI \-S " ipv6,first,last,dir,name-server,ntp-server"
Run as an AHCP server rather than a client.
.I Ipv6
specifies the IPv6 prefix.
.I First
and
.I last
represent the bounds of the range of IPv4 addresses available; active
leases will be stored in the directory
.IR dir ,
which should be in persistent storage (not a RAM disk).
.B Name-server
and
.B ntp-server
can be IPv4 or IPv6 addresses, and specify respectively the address of the
DNS server and of the NTP server to configure clients with.
.BI \-c " filename"
Specify the name of the configuration file. The default is
.BR /etc/babeld.conf .
.TP
.BI \-C " statement"
Specify a configuration statement directly on the command line.
.TP
.B \-D
Daemonise at startup.
......@@ -79,6 +69,37 @@ otherwise.
.TP
.BI \-I " pidfile"
Specify a file to write our process id to.
.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
introduced with an octothorp
.RB `` # ''
and terminate at the end of the line.
The following keywords are recognised:
.TP
.BR mode " " server | client | forwarder
Specifies whether the daemon operates as a server, a client, or
a forwarder. If omitted, the default is to operate as a client, unless
the
.B \-n
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
IPv4 and once for IPv6.
.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
multiple times.
.TP
.BI ntp-server " address"
Specifies the address of an NTP server to configure clients with. This
keyword is only valid in server configurations, and may be repeated
multiple times.
.SH FILES
.TP
.B /var/lib/ahcp\-unique\-id
......
This diff is collapsed.
/*
Copyright (c) 2007-2009 by Juliusz Chroboczek
Copyright (c) 2007-2010 by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -20,62 +20,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
extern const unsigned char v4prefix[16];
/* This holds both IPv6 and IPv4, and both prefixes and addresses. For
IPv4, we use v4prefix above. For addresses, plen is 0xFF. */
struct prefix {
unsigned char p[16];
unsigned char plen;
};
#define MAX_PREFIX 8
struct prefix_list {
int n;
struct prefix l[MAX_PREFIX];
};
/* This is used both to hold the contents of a message and to hold our
current configuration. */
struct config_data {
/* The following fields come from a message */
unsigned origin, origin_m, expires, expires_m;
struct prefix_list *server_ipv6, *server_ipv4;
struct prefix_list *ipv6_prefix, *ipv4_prefix,
*ipv6_address, *ipv4_address;
struct prefix_list *name_server, *ntp_server;
/* This field is only in our configuration. */
struct prefix_list *our_ipv6_address;
struct server_config {
const char *lease_dir;
struct prefix_list *name_server, *ntp_server, *ipv6_prefix;
unsigned char lease_first[4], lease_last[4];
};
extern struct config_data *config_data;
void prefix_list_extract4(unsigned char *dest, struct prefix_list *p);
void prefix_list_extract6(unsigned char *dest, struct prefix_list *p);
unsigned int config_renew_time(void);
void free_config_data(struct config_data *config);
int config_data_compatible(struct config_data *config1,
struct config_data *config2);
struct config_data *copy_config_data(struct config_data *config);
struct config_data *make_config_data(int expires,
unsigned char *ipv4,
unsigned char *ipv6_prefix,
unsigned char *name_server,
int name_server_len,
unsigned char *ntp_server,
int ntp_server_len,
char **interfaces);
extern int client_config;
extern struct server_config *server_config;
struct config_data *parse_message(int configure,
const unsigned char *data, int len,
char **interfaces);
int unconfigure(char **interfaces);
int query_body(unsigned char opcode, int time, const unsigned char *ipv4,
unsigned char *buf, int buflen);
int server_body(unsigned char opcode, struct config_data *config,
unsigned char *buf, int buflen);
int address_conflict(struct prefix_list *a, struct prefix_list *b);
int if_eui64(char *ifname, unsigned char *eui);
int random_eui64(unsigned char *eui);
int parse_config_from_string(char *string);
int parse_config_from_file(char *filename);
This diff is collapsed.
/*
Copyright (c) 2007-2010 by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* This is used both to hold the contents of a message and to hold our
current configuration. */
struct config_data {
/* The following fields come from a message */
unsigned origin, origin_m, expires, expires_m;
struct prefix_list *server_ipv6, *server_ipv4;
struct prefix_list *ipv6_prefix, *ipv4_prefix,
*ipv6_address, *ipv4_address,
*ipv6_prefix_delegation, *ipv4_prefix_delegation;
int ipv4_mandatory, ipv6_mandatory,
ipv4_delegation_mandatory, ipv6_delegation_mandatory;
struct prefix_list *name_server, *ntp_server;
/* This field is only in our configuration. */
struct prefix_list *our_ipv6_address;
};
extern struct config_data *config_data;
unsigned int config_renew_time(void);
void free_config_data(struct config_data *config);
int config_data_compatible(struct config_data *config1,
struct config_data *config2);
struct config_data *copy_config_data(struct config_data *config);
struct config_data *make_config_data(int expires,
unsigned char *ipv4,
struct server_config *server_config,
char **interfaces);
struct config_data *parse_message(int configure,
const unsigned char *data, int len,
char **interfaces);
int unconfigure(char **interfaces);
int query_body(unsigned char opcode, int time, const unsigned char *ipv4,
unsigned char *buf, int buflen);
int server_body(unsigned char opcode, struct config_data *config,
unsigned char *buf, int buflen);
int address_conflict(struct prefix_list *a, struct prefix_list *b);
int if_eui64(char *ifname, unsigned char *eui);
int random_eui64(unsigned char *eui);
......@@ -168,7 +168,7 @@ find_oldest_entry()
continue;
a = now.tv_sec - entries[i].lease_end_m;
if(a > age) {
a = age;
age = a;
j = i;
}
}
......@@ -793,9 +793,8 @@ lease_init(const char *dir,
continue;
}
if(debug)
printf("Lease file %s: %u %u.\n",
e->d_name, lease_orig, lease_time);
debugf(1, "Lease file %s: %u %u.\n",
e->d_name, lease_orig, lease_time);
if(clock_status == CLOCK_TRUSTED) {
if(lease_expired(NULL, lease_orig, lease_time)) {
......@@ -857,6 +856,7 @@ take_lease(const unsigned char *client_id, int client_len,
time = MAX_RELATIVE_LEASE_TIME;
a0 = 0;
/* Client suggested an IP. If it is in range, try that. */
if(suggested_ipv4) {
a0 = ipv4_address(suggested_ipv4);
entry = find_entry(a0);
......@@ -867,25 +867,30 @@ take_lease(const unsigned char *client_id, int client_len,
a0 = 0;
}
}
/* See if we have an old lease for this client. */
if(a0 < first_address || a0 > last_address) {
entry = find_entry_by_id(client_id, client_len);
if(entry)
a0 = entry->address;
}
/* Choose a free slot. */
if(a0 < first_address || a0 > last_address)
a0 = find_entryless(first_address, last_address);
/* Choose the oldest slot. */
if(a0 < first_address || a0 > last_address) {
entry = find_oldest_entry();
if(entry)
a0 = entry->address;
}
/* Give up, take the first one. */
if(a0 < first_address || a0 > last_address)
a0 = first_address;
/* Now scan all addresses in range sequentially, starting at a0. */
a = a0;
do {
int rc;
......
/*
Copyright (c) 2007-2010 by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <arpa/inet.h>
#include "prefix.h"
void
free_prefix_list(struct prefix_list *l)
{
free(l);
}
struct prefix_list *
copy_prefix_list(struct prefix_list *l)
{
struct prefix_list *c = malloc(sizeof(struct prefix_list));
if(c == NULL)
return NULL;
memcpy(c, l, sizeof(struct prefix_list));
return c;
}
int
prefix_list_eq(struct prefix_list *l1, struct prefix_list *l2)
{
return l1->n == l2->n &&
memcmp(l1->l, l2->l, l1->n * sizeof(struct prefix)) == 0;
}
int
prefix_list_v4(struct prefix_list *l)
{
int i;
for(i = 0; i < l->n; i++) {
if(l->l[i].plen < 96 ||
memcmp(l->l[i].p, v4prefix, 12) != 0)
return 0;
}
return 1;
}
void
prefix_list_extract6(unsigned char *dest, struct prefix_list *p)
{
if(!p || p->n == 0)
memset(dest, 0, 16);
memcpy(dest, p->l[0].p, 16);
}
void
prefix_list_extract4(unsigned char *dest, struct prefix_list *p)
{
if(!p || p->n == 0)
memset(dest, 0, 4);
memcpy(dest, p->l[0].p + 12, 4);
}
static void
parse_a6(struct prefix *p, const unsigned char *data)
{
memcpy(p->p, data, 16);
p->plen = 0xFF;
}
static void
parse_a4(struct prefix *p, const unsigned char *data)
{
memcpy(p->p, v4prefix, 12);
memcpy(p->p + 12, data, 4);
p->plen = 0xFF;
}
static void
parse_p6(struct prefix *p, const unsigned char *data)
{
memcpy(p->p, data, 16);
p->plen = data[16];
}
static void
parse_p4(struct prefix *p, const unsigned char *data)
{
memcpy(p->p, v4prefix, 12);
memcpy(p->p + 12, data, 4);
p->plen = data[4] + 96;
}
/* Note that this returns an empty prefix list, rather than NULL, when len
is 0. We rely on this in order to keep track of requested options. */
struct prefix_list *
raw_prefix_list(const unsigned char *data, int len, int kind)
{
struct prefix_list *l = calloc(1, sizeof(struct prefix_list));
int i, size;
void (*parser)(struct prefix *, const unsigned char*) = NULL;
if(l == NULL)
return NULL;
switch(kind) {
case IPv6_ADDRESS: size = 16; parser = parse_a6; break;
case IPv4_ADDRESS: size = 4; parser = parse_a4; break;
case IPv6_PREFIX: size = 17; parser = parse_p6; break;
case IPv4_PREFIX: size = 5; parser = parse_p4; break;
default: abort();
}
if(len % size != 0)
return NULL;
i = 0;
while(i < len) {
if(l->n >= MAX_PREFIX)
break;
parser(&l->l[l->n], data + i);
l->n++;
i += size;
}
return l;
}
/* Uses a static buffer. */
char *
format_prefix_list(struct prefix_list *p, int kind)
{
static char buf[120];
int i, j, k;
const char *r;
j = 0;
for(i = 0; i < p->n; i++) {
switch(kind) {
case IPv6_ADDRESS:
r = inet_ntop(AF_INET6, p->l[i].p, buf + j, 120 - j);
if(r == NULL) return NULL;
j += strlen(r);
break;
case IPv4_ADDRESS:
r = inet_ntop(AF_INET, p->l[i].p + 12, buf + j, 120 - j);
if(r == NULL) return NULL;
j += strlen(r);
break;
case ADDRESS:
if(memcmp(p->l[i].p, v4prefix, 12) == 0)
r = inet_ntop(AF_INET, p->l[i].p + 12, buf + j, 120 - j);
else
r = inet_ntop(AF_INET6, p->l[i].p, buf + j, 120 - j);
if(r == NULL) return NULL;
j += strlen(r);
break;
case IPv6_PREFIX:
r = inet_ntop(AF_INET6, p->l[i].p, buf + j, 120 - j);
if(r == NULL) return NULL;
j += strlen(r);
k = snprintf(buf + j, 120 - j, "/%u", p->l[i].plen);
if(k < 0 || k >= 120 - j) return NULL;
j += k;
break;
case IPv4_PREFIX:
r = inet_ntop(AF_INET, p->l[i].p + 12, buf + j, 120 - j);
if(r == NULL) return NULL;
j += strlen(r);
k = snprintf(buf + j, 120 - j, "/%u", p->l[i].plen - 96);
if(k < 0 || k >= 120 - j) return NULL;
j += k;
break;
default: abort();
}
if(j >= 119) return NULL;
if(i + 1 < p->n)
buf[j++] = ' ';
}
if(j >= 120)
return NULL;
buf[j++] = '\0';
return buf;
}
struct prefix_list *
parse_prefix(char *address, int kind)
{
struct prefix_list *list;
unsigned char ipv6[16], ipv4[4];
int plen, rc;
plen = 0xFF;
switch(kind) {
case IPv6_ADDRESS:
rc = inet_pton(AF_INET6, address, ipv6);
if(rc > 0)
goto return_ipv6;
return NULL;
case IPv4_ADDRESS:
rc = inet_pton(AF_INET, address, ipv4);
if(rc > 0)
goto return_ipv4;
case ADDRESS:
rc = inet_pton(AF_INET, address, ipv4);
if(rc > 0)
goto return_ipv4;
rc = inet_pton(AF_INET6, address, ipv6);
if(rc > 0)
goto return_ipv6;
return NULL;
case PREFIX: {
char buf[30];
char *p;
p = strchr(address, '/');
if(p == NULL || p - address >= 30)
return NULL;
plen = atoi(p + 1);
if(plen <= 0 || plen > 128)
return NULL;
memcpy(buf, address, p - address);
buf[p - address] = '\0';
rc = inet_pton(AF_INET, buf, ipv4);
if(rc > 0) {
if(plen > 32)
return NULL;
goto return_ipv4;
}
rc = inet_pton(AF_INET6, buf, ipv6);
if(rc > 0)
goto return_ipv6;
return NULL;
}
default:
abort();
}
return_ipv6:
list = calloc(1, sizeof(struct prefix_list));
if(list == NULL)
return NULL;
list->n = 1;
memcpy(list->l[0].p, ipv6, 16);
list->l[0].plen = plen;
return list;
return_ipv4:
list = calloc(1, sizeof(struct prefix_list));
if(list == NULL)
return NULL;