aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSUZUKI, Shinsuke <suz@kame.net>2006-04-11 04:33:52 +0000
committerSUZUKI, Shinsuke <suz@kame.net>2006-04-11 04:33:52 +0000
commit58227a7064c3fb83495e9275711aa94fbd13157a (patch)
tree74af27116013ec588824b2e22da49051dcf423af
parentabb5df61450dc03f615e97c3ea75ee5c5f4db23f (diff)
* removed 'ifdef USE_POOL' macros, since it is always ON
* rename some pool-related variables to prepare for the support of prefix-pool
-rw-r--r--CHANGES4
-rw-r--r--cfparse.y22
-rw-r--r--cftoken.l12
-rw-r--r--config.c27
-rw-r--r--config.h13
-rw-r--r--dhcp6s.c44
6 files changed, 22 insertions, 100 deletions
diff --git a/CHANGES b/CHANGES
index 825cb3c..9bf0a28 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+2006-04-11 SUZUKI, Shinsuke <suz@kame.net>
+ * removed 'ifdef USE_POOL' macros, since it is always ON
+ * rename some pool-related variables to prepare for the support of prefix-pool
+
--- 20060322 tar ball released ---
2006-03-20 SUZUKI, Shinsuke <suz@kame.net>
* fixed a bug that dhcp6c cannot receive a DHCPv6 packet on linux.
diff --git a/cfparse.y b/cfparse.y
index 2a862d4..9d8857f 100644
--- a/cfparse.y
+++ b/cfparse.y
@@ -83,7 +83,7 @@ extern void yyerror __P((char *, ...))
} while (0)
static struct cf_namelist *iflist_head, *hostlist_head, *iapdlist_head;
-static struct cf_namelist *poollist_head;
+static struct cf_namelist *addrpoollist_head;
static struct cf_namelist *authinfolist_head, *keylist_head;
static struct cf_namelist *ianalist_head;
struct cf_list *cf_dns_list, *cf_dns_name_list, *cf_ntp_list;
@@ -110,7 +110,7 @@ static void cleanup_cflist __P((struct cf_list *));
%token AUTHENTICATION PROTOCOL ALGORITHM DELAYED RECONFIG HMACMD5 MONOCOUNTER
%token AUTHNAME RDM KEY
%token KEYINFO REALM KEYID SECRET KEYNAME EXPIRE
-%token POOL POOLNAME RANGE TO ADDRESS_POOL
+%token ADDRPOOL POOLNAME RANGE TO ADDRESS_POOL
%token NUMBER SLASH EOS BCL ECL STRING QSTRING PREFIX INFINITY
%token COMMA
@@ -150,7 +150,7 @@ statement:
| ia_statement
| authentication_statement
| key_statement
- | pool_statement
+ | addrpool_statement
;
interface_statement:
@@ -336,14 +336,14 @@ key_statement:
}
;
-pool_statement:
- POOL POOLNAME BCL declarations ECL EOS
+addrpool_statement:
+ ADDRPOOL POOLNAME BCL declarations ECL EOS
{
struct cf_namelist *pool;
MAKE_NAMELIST(pool, $2, $4);
- if (add_namelist(pool, &poollist_head))
+ if (add_namelist(pool, &addrpoollist_head))
return (-1);
}
;
@@ -1090,8 +1090,8 @@ cleanup()
authinfolist_head = NULL;
cleanup_namelist(keylist_head);
keylist_head = NULL;
- cleanup_namelist(poollist_head);
- poollist_head = NULL;
+ cleanup_namelist(addrpoollist_head);
+ addrpoollist_head = NULL;
cleanup_cflist(cf_sip_list);
cf_sip_list = NULL;
@@ -1129,11 +1129,9 @@ cleanup_cflist(p)
return;
n = p->next;
-#ifdef USE_POOL
if (p->type == DECL_ADDRESSPOOL) {
free(((struct dhcp6_poolspec *)p->ptr)->name);
}
-#endif
if (p->ptr)
free(p->ptr);
if (p->list)
@@ -1161,10 +1159,8 @@ cf_post_config()
if (configure_ia(ianalist_head, IATYPE_NA))
config_fail();
-#ifdef USE_POOL
- if (configure_pool(poollist_head))
+ if (configure_pool(addrpoollist_head))
config_fail();
-#endif /* USE_POOL */
if (configure_interface(iflist_head))
config_fail();
diff --git a/cftoken.l b/cftoken.l
index a329cb0..337a6cc 100644
--- a/cftoken.l
+++ b/cftoken.l
@@ -110,7 +110,7 @@ ecl \}
%s S_AUTH
%s S_KEY
%s S_SECRET
-%s S_POOL
+%s S_ADDRPOOL
%%
%{
@@ -137,9 +137,13 @@ ecl \}
return (HOSTNAME);
}
- /* pool configuration */
-<S_CNF>pool { DECHO; BEGIN S_POOL; return (POOL); }
-<S_POOL>{string} {
+ /* address pool configuration */
+<S_CNF>address-pool { DECHO; BEGIN S_ADDRPOOL; return (ADDRPOOL); }
+
+ /* kept for a backward compatiblity */
+<S_CNF>pool { DECHO; BEGIN S_ADDRPOOL; return (ADDRPOOL); }
+
+<S_ADDRPOOL>{string} {
DECHO;
yylval.str = strdup(yytext);
BEGIN S_CNF;
diff --git a/config.c b/config.c
index 1db285f..bdb17f2 100644
--- a/config.c
+++ b/config.c
@@ -58,9 +58,7 @@
#include <common.h>
#include <auth.h>
#include <base64.h>
-#ifdef USE_POOL
#include <lease.h>
-#endif /* USE_POOL */
extern int errno;
@@ -75,7 +73,6 @@ static struct keyinfo *key_list, *key_list0;
static struct authinfo *auth_list, *auth_list0;
static struct dhcp6_list siplist0, sipnamelist0, dnslist0, dnsnamelist0, ntplist0;
static long long optrefreshtime0;
-#ifdef USE_POOL
#ifndef DHCP6_DYNAMIC_HOSTCONF_MAX
#define DHCP6_DYNAMIC_HOSTCONF_MAX 1024
#endif
@@ -87,7 +84,6 @@ static TAILQ_HEAD(dynamic_hostconf_listhead, dynamic_hostconf)
dynamic_hostconf_head;
static unsigned int dynamic_hostconf_count;
static struct pool_conf *pool_conflist, *pool_conflist0;
-#endif /* USE_POOL */
enum { DHCPOPTCODE_SEND, DHCPOPTCODE_REQUEST, DHCPOPTCODE_ALLOW };
@@ -110,9 +106,7 @@ struct dhcp6_ifconf {
struct authinfo *authinfo; /* authentication information
* (no need to clear) */
-#ifdef USE_POOL
struct dhcp6_poolspec pool;
-#endif
};
extern struct cf_list *cf_dns_list, *cf_dns_name_list, *cf_ntp_list;
@@ -134,13 +128,11 @@ static void clear_authinfo __P((struct authinfo *));
static int configure_duid __P((char *, struct duid *));
static int get_default_ifid __P((struct prefix_ifconf *));
static char *qstrdup __P((char *));
-#ifdef USE_POOL
static void clear_poolconf __P((struct pool_conf *));
static struct pool_conf *create_pool __P((char *, struct dhcp6_range *));
struct host_conf *find_dynamic_hostconf __P((struct duid *));
static int in6_addr_cmp __P((struct in6_addr *, struct in6_addr *));
static void in6_addr_inc __P((struct in6_addr *));
-#endif /* USE_POOL */
int
configure_interface(iflist)
@@ -259,7 +251,6 @@ configure_interface(iflist)
cp += strlen(ifc->scriptpath) - 1;
*cp = '\0'; /* clear the terminating quote */
break;
-#ifdef USE_POOL
case DECL_ADDRESSPOOL:
{
struct dhcp6_poolspec* spec;
@@ -297,7 +288,6 @@ configure_interface(iflist)
ifc->pool.name, ifc->ifname);
}
break;
-#endif /* USE_POOL */
default:
dprintf(LOG_ERR, FNAME, "%s:%d "
"invalid interface configuration",
@@ -599,7 +589,6 @@ configure_host(hostlist)
"delayed auth with %s (keyid=%08x)",
host->name, hconf->delayedkey->keyid);
break;
-#ifdef USE_POOL
case DECL_ADDRESSPOOL:
{
struct dhcp6_poolspec* spec;
@@ -637,7 +626,6 @@ configure_host(hostlist)
hconf->pool.name, hconf->name);
}
break;
-#endif /* USE_POOL */
default:
dprintf(LOG_ERR, FNAME, "%s:%d "
"invalid host configuration for %s",
@@ -1314,9 +1302,7 @@ configure_cleanup()
dhcp6_clear_list(&ntplist0);
TAILQ_INIT(&ntplist0);
optrefreshtime0 = -1;
-#ifdef USE_POOL
clear_poolconf(pool_conflist0);
-#endif /* USE_POOL */
}
void
@@ -1365,10 +1351,8 @@ configure_commit()
ifp->authalgorithm = ifc->authinfo->algorithm;
ifp->authrdm = ifc->authinfo->rdm;
}
-#ifdef USE_POOL
ifp->pool = ifc->pool;
ifc->pool.name = NULL;
-#endif
}
clear_ifconf(dhcp6_ifconflist);
@@ -1418,12 +1402,10 @@ configure_commit()
/* commit information refresh time */
optrefreshtime = optrefreshtime0;
-#ifdef USE_POOL
/* commit pool configuration */
clear_poolconf(pool_conflist);
pool_conflist = pool_conflist0;
pool_conflist0 = NULL;
-#endif /* USE_POOL */
}
static void
@@ -1443,10 +1425,8 @@ clear_ifconf(iflist)
if (ifc->scriptpath)
free(ifc->scriptpath);
-#ifdef USE_POOL
if (ifc->pool.name)
free(ifc->pool.name);
-#endif
free(ifc);
}
}
@@ -1505,10 +1485,8 @@ clear_hostconf(hlist)
dhcp6_clear_list(&host->addr_list);
if (host->duid.duid_id)
free(host->duid.duid_id);
-#ifdef USE_POOL
if (host->pool.name)
free(host->pool.name);
-#endif
free(host);
}
}
@@ -1824,11 +1802,9 @@ find_hostconf(duid)
{
struct host_conf *host;
-#ifdef USE_POOL
if ((host = find_dynamic_hostconf(duid)) != NULL) {
return (host);
}
-#endif /* USE_POOL */
for (host = host_conflist; host; host = host->next) {
if (host->duid.duid_len == duid->duid_len &&
@@ -1911,7 +1887,6 @@ qstrdup(qstr)
return (dup);
}
-#ifdef USE_POOL
int
configure_pool(poollist)
struct cf_namelist *poollist;
@@ -2249,5 +2224,3 @@ in6_addr_inc(addr)
break;
}
}
-#endif /* USE_POOL */
-
diff --git a/config.h b/config.h
index e3c237b..fe56b3b 100644
--- a/config.h
+++ b/config.h
@@ -33,9 +33,6 @@
TAILQ_HEAD(ia_conflist, ia_conf);
TAILQ_HEAD(pifc_list, prefix_ifconf);
-#define USE_POOL
-
-#ifdef USE_POOL
struct dhcp6_poolspec {
char* name;
u_int32_t pltime;
@@ -56,7 +53,6 @@ struct pool_conf {
struct in6_addr max;
struct in6_addr cur;
};
-#endif /* USE_POOL */
/* per-interface information */
struct dhcp6_if {
@@ -80,9 +76,7 @@ struct dhcp6_if {
#define DHCIFF_RAPID_COMMIT 0x2
int server_pref; /* server preference (server only) */
-#ifdef USE_POOL
struct dhcp6_poolspec pool; /* address pool (server only) */
-#endif
char *scriptpath; /* path to config script (client only) */
struct dhcp6_list reqopt_list;
@@ -224,10 +218,8 @@ struct host_conf {
struct dhcp6_list prefix_list;
/* address to be assigned for the host */
struct dhcp6_list addr_list;
-#ifdef USE_POOL
/* address pool from which addresses are assigned for the host */
struct dhcp6_poolspec pool;
-#endif
/* secret key shared with the client for delayed authentication */
struct keyinfo *delayedkey;
@@ -272,7 +264,7 @@ struct cf_list {
enum { DECL_SEND, DECL_ALLOW, DECL_INFO_ONLY, DECL_REQUEST, DECL_DUID,
DECL_PREFIX, DECL_PREFERENCE, DECL_SCRIPT, DECL_DELAYEDKEY,
DECL_ADDRESS,
- DECL_RANGE, DECL_ADDRESSPOOL, /* USE_POOL */
+ DECL_RANGE, DECL_ADDRESSPOOL,
IFPARAM_SLA_ID, IFPARAM_SLA_LEN,
DHCPOPT_RAPID_COMMIT, DHCPOPT_AUTHINFO,
DHCPOPT_DNS, DHCPOPT_DNSNAME,
@@ -319,7 +311,6 @@ extern struct dhcp6_prefix *find_prefix6 __P((struct dhcp6_list *,
struct dhcp6_prefix *));
extern struct ia_conf *find_iaconf __P((struct ia_conflist *, int, u_int32_t));
extern struct keyinfo *find_key __P((char *, size_t, u_int32_t));
-#ifdef USE_POOL
extern int configure_pool __P((struct cf_namelist *));
extern struct pool_conf *find_pool __P((const char *));
extern int is_available_in_pool __P((struct pool_conf *, struct in6_addr *));
@@ -327,5 +318,3 @@ extern int get_free_address_from_pool __P((struct pool_conf *,
struct in6_addr *));
struct host_conf *create_dynamic_hostconf __P((struct duid *,
struct dhcp6_poolspec *));
-#endif /* USE_POOL */
-
diff --git a/dhcp6s.c b/dhcp6s.c
index 7d626dd..78904b8 100644
--- a/dhcp6s.c
+++ b/dhcp6s.c
@@ -74,10 +74,8 @@
#include <base64.h>
#include <control.h>
#include <dhcp6_ctl.h>
-#ifdef USE_POOL
#include <signal.h>
#include <lease.h>
-#endif
#define DUID_FILE LOCALDBDIR "/dhcp6s_duid"
#define DHCP6S_CONF SYSCONFDIR "/dhcp6s.conf"
@@ -189,10 +187,8 @@ static int make_ia __P((struct dhcp6_listval *, struct dhcp6_list *,
struct dhcp6_list *, struct host_conf *, int));
static int make_match_ia __P((struct dhcp6_listval *, struct dhcp6_list *,
struct dhcp6_list *));
-#ifdef USE_POOL
static int make_iana_from_pool __P((struct dhcp6_poolspec *,
struct dhcp6_listval *, struct dhcp6_list *));
-#endif
static void calc_ia_timo __P((struct dhcp6_ia *, struct dhcp6_list *,
struct host_conf *));
static void update_binding_duration __P((struct dhcp6_binding *));
@@ -340,12 +336,10 @@ server6_init()
static struct sockaddr_in6 sa6_any_relay_storage;
TAILQ_INIT(&dhcp6_binding_head);
-#ifdef USE_POOL
if (lease_init() != 0) {
dprintf(LOG_ERR, FNAME, "failed to initialize the lease table");
exit(1);
}
-#endif
ifidx = if_nametoindex(device);
if (ifidx == 0) {
@@ -1253,14 +1247,12 @@ react_solicit(ifp, dh6, len, optinfo, from, fromlen, relayinfohead)
struct dhcp6_list conflist;
struct dhcp6_listval *iana;
-#ifdef USE_POOL
if (client_conf == NULL && ifp->pool.name) {
if ((client_conf = create_dynamic_hostconf(&optinfo->clientID,
&ifp->pool)) == NULL)
dprintf(LOG_NOTICE, FNAME,
"failed to make host configuration");
}
-#endif
TAILQ_INIT(&conflist);
/* make a local copy of the configured addresses */
@@ -1470,14 +1462,12 @@ react_request(ifp, pi, dh6, len, optinfo, from, fromlen, relayinfohead)
struct dhcp6_list conflist;
struct dhcp6_listval *iana;
-#ifdef USE_POOL
if (client_conf == NULL && ifp->pool.name) {
if ((client_conf = create_dynamic_hostconf(&optinfo->clientID,
&ifp->pool)) == NULL)
dprintf(LOG_NOTICE, FNAME,
"failed to make host configuration");
}
-#endif
TAILQ_INIT(&conflist);
/* make a local copy of the configured prefixes */
@@ -2193,9 +2183,7 @@ release_binding_ia(iap, retlist, optinfo)
lvia->val_prefix6.plen);
break;
case DHCP6_LISTVAL_IANA:
-#ifdef USE_POOL
release_address(&lvia->val_prefix6.addr);
-#endif
dprintf(LOG_DEBUG, FNAME,
"bound address %s "
"has been released",
@@ -2430,17 +2418,12 @@ make_ia(spec, conflist, retlist, client_conf, do_binding)
* trivial case:
* if the configuration is empty, we cannot make any IA.
*/
-#ifdef USE_POOL
if (TAILQ_EMPTY(conflist)) {
if (spec->type != DHCP6_LISTVAL_IANA ||
client_conf->pool.name == NULL) {
return (0);
}
}
-#else
- if (TAILQ_EMPTY(conflist))
- return (0);
-#endif /* USE_POOL */
TAILQ_INIT(&ialist);
@@ -2448,7 +2431,6 @@ make_ia(spec, conflist, retlist, client_conf, do_binding)
for (specia = TAILQ_FIRST(&spec->sublist); specia;
specia = TAILQ_NEXT(specia, link)) {
/* try to find an IA that matches the spec best. */
-#ifdef USE_POOL
if (!TAILQ_EMPTY(conflist)) {
if (make_match_ia(specia, conflist, &ialist))
found++;
@@ -2457,13 +2439,8 @@ make_ia(spec, conflist, retlist, client_conf, do_binding)
if (make_iana_from_pool(&client_conf->pool, specia, &ialist))
found++;
}
-#else
- if (make_match_ia(specia, conflist, &ialist))
- found++;
-#endif /* USE_POOL */
}
if (found == 0) {
-#ifdef USE_POOL
if (!TAILQ_EMPTY(conflist)) {
struct dhcp6_listval *v;
@@ -2484,17 +2461,6 @@ make_ia(spec, conflist, retlist, client_conf, do_binding)
if (make_iana_from_pool(&client_conf->pool, NULL, &ialist))
found = 1;
}
-#else
- struct dhcp6_listval *v;
-
- /* use the first IA in the configuration list */
- v = TAILQ_FIRST(conflist);
- if (dhcp6_add_listval(&ialist, v->type, &v->uv, NULL)) {
- found = 1;
- TAILQ_REMOVE(conflist, v, link);
- dhcp6_clear_listval(v);
- }
-#endif /* USE_POOL */
}
if (found) {
memset(&ia, 0, sizeof(ia));
@@ -2543,10 +2509,8 @@ make_match_ia(spec, conflist, retlist)
break;
case DHCP6_LISTVAL_STATEFULADDR6:
/* No "partial match" for addresses */
-#ifdef USE_POOL
if (is_leased(&spec->val_statefuladdr6.addr))
match = 0;
-#endif
break;
default:
dprintf(LOG_ERR, FNAME, "unsupported IA type");
@@ -2570,7 +2534,6 @@ make_match_ia(spec, conflist, retlist)
return (matched);
}
-#ifdef USE_POOL
/* making sublist of iana */
static int
make_iana_from_pool(poolspec, spec, retlist)
@@ -2614,7 +2577,6 @@ make_iana_from_pool(poolspec, spec, retlist)
return (found);
}
-#endif /* USE_POOL */
static void
calc_ia_timo(ia, ialist, client_conf)
@@ -2755,7 +2717,6 @@ add_binding(clientid, btype, iatype, iaid, val0)
"failed to copy binding data");
goto fail;
}
-#ifdef USE_POOL
/* lease address */
if (iatype == DHCP6_LISTVAL_IANA) {
struct dhcp6_list *ia_list = &binding->val_list;
@@ -2783,7 +2744,6 @@ add_binding(clientid, btype, iatype, iaid, val0)
goto fail;
}
}
-#endif /* USE_POOL */
break;
default:
dprintf(LOG_ERR, FNAME, "unexpected binding type(%d)", btype);
@@ -2889,7 +2849,6 @@ free_binding(binding)
/* free configuration info in a type dependent manner. */
switch (binding->type) {
case DHCP6_BINDING_IA:
-#ifdef USE_POOL
/* releaes address */
if (binding->iatype == DHCP6_LISTVAL_IANA) {
struct dhcp6_list *ia_list = &binding->val_list;
@@ -2904,7 +2863,6 @@ free_binding(binding)
release_address(&lv->val_statefuladdr6.addr);
}
}
-#endif /* USE_POOL */
dhcp6_clear_list(&binding->val_list);
break;
default:
@@ -2954,10 +2912,8 @@ binding_timo(arg)
in6addr2str(&iav->val_prefix6.addr, 0),
iav->val_prefix6.plen,
bindingstr(binding));
-#ifdef USE_POOL
if (binding->iatype == DHCP6_LISTVAL_IANA)
release_address(&iav->val_prefix6.addr);
-#endif
TAILQ_REMOVE(ia_list, iav, link);
dhcp6_clear_listval(iav);
}