summaryrefslogtreecommitdiff
path: root/keama
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2017-04-26 11:15:52 +0200
committerFrancis Dupont <fdupont@isc.org>2019-11-12 09:57:36 +0100
commit804cb3240a9951c751d4e4cdae908acaa182b1b1 (patch)
treed1e26a64eca2418d191a48f00a54ac406de680c2 /keama
parentf0e9f064b6ad581511e887f9f048288b1b7e2a72 (diff)
downloadisc-dhcp-804cb3240a9951c751d4e4cdae908acaa182b1b1.tar.gz
Checkpoint (did server-id, second pass at 75%)
Diffstat (limited to 'keama')
-rw-r--r--keama/confparse.c220
-rw-r--r--keama/data.c27
-rw-r--r--keama/data.h6
-rw-r--r--keama/dhcp3/kea.json24
-rw-r--r--keama/fordhcp/kea.json9
-rw-r--r--keama/keama.h4
-rw-r--r--keama/parse.c22
-rw-r--r--keama/samples/example.json10
-rw-r--r--keama/samples/simple.json12
-rw-r--r--keama/samples/vmnet8.json18
-rw-r--r--keama/tests/badduid.err7
-rw-r--r--keama/tests/badduid.msg1
-rw-r--r--keama/tests/duid2.err10
-rw-r--r--keama/tests/duid2.msg1
-rw-r--r--keama/tests/duiden6.in67
-rw-r--r--keama/tests/duiden6.out12
-rw-r--r--keama/tests/duidennoid.err8
-rw-r--r--keama/tests/duidennoid.msg1
-rw-r--r--keama/tests/duidennonum.err7
-rw-r--r--keama/tests/duidennonum.msg1
-rw-r--r--keama/tests/duidll6.in68
-rw-r--r--keama/tests/duidll6.out10
-rw-r--r--keama/tests/duidllbadtype.err7
-rw-r--r--keama/tests/duidllbadtype.msg1
-rw-r--r--keama/tests/duidllhw6.in69
-rw-r--r--keama/tests/duidllhw6.out12
-rw-r--r--keama/tests/duidllnohw.err7
-rw-r--r--keama/tests/duidllnohw.msg1
-rw-r--r--keama/tests/duidllt6.in68
-rw-r--r--keama/tests/duidllt6.out10
-rw-r--r--keama/tests/duidlltbadtype.err7
-rw-r--r--keama/tests/duidlltbadtype.msg1
-rw-r--r--keama/tests/duidlltnohw.err7
-rw-r--r--keama/tests/duidlltnohw.msg1
-rw-r--r--keama/tests/duidlltnotime.err7
-rw-r--r--keama/tests/duidlltnotime.msg1
-rw-r--r--keama/tests/duidlltthw4.err47
-rw-r--r--keama/tests/duidlltthw4.msg1
-rw-r--r--keama/tests/duidlltthw6.in67
-rw-r--r--keama/tests/duidlltthw6.out13
-rw-r--r--keama/tests/duidnoid.err7
-rw-r--r--keama/tests/duidnoid.msg1
-rw-r--r--keama/tests/execstatement4.out2
-rw-r--r--keama/tests/execstatement6.out2
-rw-r--r--keama/tests/host6.notyet20
-rw-r--r--keama/tests/hostuid4.out6
-rw-r--r--keama/tests/minimal4.out2
-rw-r--r--keama/tests/minimal6.out2
-rw-r--r--keama/tests/optdatagrouppool4.out2
-rw-r--r--keama/tests/optiondatapool4.out4
-rw-r--r--keama/tests/optiondatapool6.out4
-rw-r--r--keama/tests/orphan4.out2
-rw-r--r--keama/tests/orphan6.out2
-rw-r--r--keama/tests/permitauth4.out2
-rw-r--r--keama/tests/permitauth6.out2
-rw-r--r--keama/tests/pool4.out4
-rw-r--r--keama/tests/pool6.out4
-rw-r--r--keama/tests/prefix.in612
-rw-r--r--keama/tests/prefix.out29
-rw-r--r--keama/tests/prefix0.err69
-rw-r--r--keama/tests/prefix0.msg1
-rw-r--r--keama/tests/prefix128.err69
-rw-r--r--keama/tests/prefix128.msg1
-rw-r--r--keama/tests/prefix2.in612
-rw-r--r--keama/tests/prefix2.out29
-rw-r--r--keama/tests/range4.out4
-rw-r--r--keama/tests/range6.in61
-rw-r--r--keama/tests/range6.out7
-rw-r--r--keama/tests/shareone4.out2
-rw-r--r--keama/tests/shareone6.out2
-rw-r--r--keama/tests/subclass4.out4
-rw-r--r--keama/tests/subclass6.out4
-rw-r--r--keama/tests/subclassbinsel4.out4
-rw-r--r--keama/tests/subclassbinsel6.out4
-rw-r--r--keama/tests/subnet4.in419
-rw-r--r--keama/tests/subnet4.out29
-rw-r--r--keama/tests/subnet42if.err48
-rw-r--r--keama/tests/subnet42if.msg1
-rw-r--r--keama/tests/subnet4badmask.err47
-rw-r--r--keama/tests/subnet4badmask.msg1
-rw-r--r--keama/tests/subnet4nomask.err47
-rw-r--r--keama/tests/subnet4nomask.msg1
-rw-r--r--keama/tests/subnet6.in622
-rw-r--r--keama/tests/subnet6.out37
-rw-r--r--keama/tests/subnet62if.err68
-rw-r--r--keama/tests/subnet62if.msg1
-rw-r--r--keama/tests/subnet6nolen.err67
-rw-r--r--keama/tests/subnet6nolen.msg1
-rw-r--r--keama/tests/subnet6noslash.err67
-rw-r--r--keama/tests/subnet6noslash.msg1
-rw-r--r--keama/tests/temporary.in613
-rw-r--r--keama/tests/temporary.out30
92 files changed, 810 insertions, 124 deletions
diff --git a/keama/confparse.c b/keama/confparse.c
index 1c980dbc..0e748109 100644
--- a/keama/confparse.c
+++ b/keama/confparse.c
@@ -78,6 +78,7 @@ conf_file_parse(struct parse *cfile)
top->kind = TOPLEVEL;
dhcp = createMap();
dhcp->kind = ROOT_GROUP;
+ (void) peek_token(NULL, NULL, cfile);
TAILQ_CONCAT(&dhcp->comments, &cfile->comments);
stackPush(cfile, dhcp);
assert(cfile->stack_top == 1);
@@ -1055,6 +1056,7 @@ parse_host_declaration(struct parse *cfile)
listPush(hosts, host);
}
+/* Simple tool to declare used (and only used) reservation identifiers */
static void
add_host_reservation_identifiers(struct parse *cfile, const char *id)
{
@@ -1095,9 +1097,9 @@ parse_class_declaration(struct parse *cfile, int type)
struct element *pc = NULL; /* p(arent)c(lass) */
struct element *tmp;
struct element *expr;
- int declaration = 0;
- struct string *data;
+ struct element *data;
isc_boolean_t binary = ISC_FALSE;
+ int declaration = 0;
struct string *name;
isc_boolean_t lose = ISC_FALSE;
@@ -1167,13 +1169,12 @@ parse_class_declaration(struct parse *cfile, int type)
if (type == CLASS_TYPE_SUBCLASS) {
token = peek_token(&val, NULL, cfile);
if (token == STRING) {
- unsigned data_len;
+ unsigned len;
- skip_token(&val, &data_len, cfile);
- data = makeString(data_len, val);
+ skip_token(&val, &len, cfile);
+ data = createString(makeString(len, val));
} else if (token == NUMBER_OR_NAME || token == NUMBER) {
- data = makeString(-1, "0x");
- concatString(data, parse_hexa(cfile));
+ data = createHexa(parse_hexa(cfile));
binary = ISC_TRUE;
} else {
skip_token(&val, NULL, cfile);
@@ -1200,7 +1201,8 @@ parse_class_declaration(struct parse *cfile, int type)
selector = mapGet(tmp, "string");
if (selector == NULL)
continue;
- if (eqString(stringValue(selector), data)) {
+ if (eqString(stringValue(selector),
+ stringValue(data))) {
class = tmp;
break;
}
@@ -1219,12 +1221,11 @@ parse_class_declaration(struct parse *cfile, int type)
else {
tmp->skip = ISC_TRUE;
mapSet(gc, tmp, "super");
- tmp = createString(data);
- tmp->skip = ISC_TRUE;
+ data->skip = ISC_TRUE;
if (binary)
- mapSet(gc, tmp, "binary");
+ mapSet(gc, data, "binary");
else
- mapSet(gc, tmp, "string");
+ mapSet(gc, data, "string");
}
listPush(group_classes, gc);
}
@@ -1243,12 +1244,11 @@ parse_class_declaration(struct parse *cfile, int type)
tmp = createString(name);
tmp->skip = ISC_TRUE;
mapSet(class, tmp, "super");
- tmp = createString(data);
- tmp->skip = ISC_TRUE;
+ data->skip = ISC_TRUE;
if (binary)
- mapSet(class, tmp, "binary");
+ mapSet(class, data, "binary");
else
- mapSet(class, tmp, "string");
+ mapSet(class, data, "string");
subname = makeString(-1, "sub#");
concatString(subname, name);
snprintf(buf, sizeof(buf),
@@ -1377,6 +1377,12 @@ parse_class_declaration(struct parse *cfile, int type)
subclass_inherit(cfile, class, copy(pc));
}
+/*
+ * Inherit entries:
+ * - first copy entries from the current superclass to the subclass
+ * - second try to reduce the subclass matching condition
+ */
+
static void
subclass_inherit(struct parse *cfile,
struct element *class,
@@ -1496,6 +1502,10 @@ subclass_inherit(struct parse *cfile,
mapSet(class, reduced, "test");
}
+/*
+ * Try to reduce a match-if condition into a Kea evaluate bool "test"
+ */
+
static void
add_match_class(struct parse *cfile,
struct element *class,
@@ -1795,9 +1805,15 @@ parse_subnet_declaration(struct parse *cfile)
chain->mask = netmask;
prefix = addrmask(address, netmask);
- if (prefix == NULL)
+ if (prefix == NULL) {
+ char bufa[INET_ADDRSTRLEN];
+ char bufm[INET_ADDRSTRLEN];
+
+ inet_ntop(AF_INET, address->content, bufa, INET_ADDRSTRLEN);
+ inet_ntop(AF_INET, netmask->content, bufm, INET_ADDRSTRLEN);
parse_error(cfile, "can't get a prefix from %s mask %s",
- address->content, netmask->content);
+ bufa, bufm);
+ }
mapSet(subnet, createString(prefix), "subnet");
common_subnet_parsing(cfile, subnets, subnet);
@@ -1961,6 +1977,12 @@ parse_group_declaration(struct parse *cfile)
dissolve_group(cfile, group);
}
+/*
+ * Dissolve a group. Called when a group is closed.
+ * - spread parameters to children
+ * - attach declarations at an upper level
+ */
+
void
dissolve_group(struct parse *cfile, struct element *group)
{
@@ -2300,6 +2322,11 @@ dissolve_group(struct parse *cfile, struct element *group)
}
}
+/*
+ * Specialized derivation routine for option-data
+ * (options are identified by space + name and/or code
+ */
+
static void
option_data_derive(struct parse *cfile, struct handle *src,
struct handle *dst, isc_boolean_t is_pools)
@@ -2539,6 +2566,7 @@ parse_address_range6(struct parse *cfile, int type, size_t where)
is_temporary = ISC_TRUE;
appendString(lo, " ");
appendString(lo, val);
+ skip_token(NULL, NULL, cfile);
}
} else if (token == TEMPORARY) {
/*
@@ -2696,7 +2724,7 @@ parse_fixed_prefix6(struct parse *cfile, size_t host_decl)
ia = parse_ip6_addr_txt(cfile);
if (ia == NULL)
parse_error(cfile, "can't parse fixed-prefix6 address");
- token = next_token(NULL, NULL, cfile);
+ token = next_token(&val, NULL, cfile);
if (token != SLASH)
parse_error(cfile, "expecting '/'");
appendString(ia, val);
@@ -2921,41 +2949,45 @@ parse_server_duid_conf(struct parse *cfile) {
const char *val;
unsigned int len;
struct string *ll_addr;
- struct string *duid;
- struct element *sv_duid;
+ struct element *duid;
+ struct element *item;
+ int ll_type;
+
+ duid = createMap();
+ TAILQ_CONCAT(&duid->comments, &cfile->comments);
/*
* Consume the SERVER_DUID token.
*/
next_token(&val, NULL, cfile);
- duid = makeString(-1, val);
/*
* Obtain the DUID type.
*/
token = next_token(&val, NULL, cfile);
- appendString(duid, " ");
- appendString(duid, val);
/*
* Enterprise is the easiest - enterprise number and raw data
* are required.
*/
if (token == EN) {
+ item = createString(makeString(-1, "EN"));
+ mapSet(duid, item, "type");
+
/*
* Get enterprise number and identifier.
*/
token = next_token(&val, NULL, cfile);
if (token != NUMBER)
parse_error(cfile, "enterprise number expected");
- appendString(duid, " ");
- appendString(duid, val);
+ item = createInt(atoi(val));
+ mapSet(duid, item, "enterprise-id");
token = next_token(&val, &len, cfile);
if (token != STRING)
parse_error(cfile, "identifier expected");
- appendString(duid, " ");
- appendString(duid, val);
+ item = createString(makeString(len, val));
+ mapSet(duid, item, "identifier");
}
/*
@@ -2966,20 +2998,36 @@ parse_server_duid_conf(struct parse *cfile) {
* value, then we set the actual DUID.
*/
else if (token == LL) {
+ item = createString(makeString(-1, "LL"));
+ mapSet(duid, item, "type");
+
if (peek_token(NULL, NULL, cfile) != SEMI) {
/*
* Get our hardware type and address.
*/
token = next_token(NULL, NULL, cfile);
- appendString(duid, " ");
- appendString(duid, val);
+ switch (token) {
+ case ETHERNET:
+ ll_type = HTYPE_ETHER;
+ break;
+ case TOKEN_RING:
+ ll_type = HTYPE_IEEE802;
+ break;
+ case TOKEN_FDDI:
+ ll_type = HTYPE_FDDI;
+ break;
+ default:
+ parse_error(cfile, "hardware type expected");
+ }
+ item = createInt(ll_type);
+ mapSet(duid, item, "htype");
- ll_addr = parse_cshl(cfile);
+ ll_addr = parse_hexa(cfile);
if (ll_addr == NULL)
parse_error(cfile,
"can't get hardware address");
- appendString(duid, " ");
- appendString(duid, ll_addr->content);
+ item = createString(ll_addr);
+ mapSet(duid, item, "identifier");
}
}
@@ -2991,27 +3039,42 @@ parse_server_duid_conf(struct parse *cfile) {
* value, then we set the actual DUID.
*/
else if (token == LLT) {
+ item = createString(makeString(-1, "LLT"));
+ mapSet(duid, item, "type");
+
if (peek_token(NULL, NULL, cfile) != SEMI) {
/*
* Get our hardware type, timestamp, and address.
*/
token = next_token(NULL, NULL, cfile);
- appendString(duid, " ");
- appendString(duid, val);
+ switch (token) {
+ case ETHERNET:
+ ll_type = HTYPE_ETHER;
+ break;
+ case TOKEN_RING:
+ ll_type = HTYPE_IEEE802;
+ break;
+ case TOKEN_FDDI:
+ ll_type = HTYPE_FDDI;
+ break;
+ default:
+ parse_error(cfile, "hardware type expected");
+ }
+ item = createInt(ll_type);
+ mapSet(duid, item, "htype");
token = next_token(&val, NULL, cfile);
if (token != NUMBER)
parse_error(cfile, "timestamp expected");
- appendString(duid, " ");
- appendString(duid, val);
+ item = createInt(atoi(val));
+ mapSet(duid, item, "time");
- ll_addr = parse_cshl(cfile);
+ ll_addr = parse_hexa(cfile);
if (ll_addr == NULL)
parse_error(cfile,
"can't get hardware address");
- appendString(duid, " ");
- appendString(duid, ll_addr->content);
- memset(&ll_addr, 0, sizeof(ll_addr));
+ item = createString(ll_addr);
+ mapSet(duid, item, "identifier");
}
}
@@ -3025,11 +3088,18 @@ parse_server_duid_conf(struct parse *cfile) {
* This also works for existing DUID types of course.
*/
else if (token == NUMBER) {
+ item = createString(makeString(-1, val));
+ item->skip = ISC_TRUE;
+ /* Kea wants EN, LL or LLT so skip the whole thing */
+ duid->skip = ISC_TRUE;
+ cfile->issue_counter++;
+ mapSet(duid, item, "type");
+
token = next_token(&val, &len, cfile);
if (token != STRING)
parse_error(cfile, "identifier expected");
- appendString(duid, " ");
- appendString(duid, val);
+ item = createString(makeString(len, val));
+ mapSet(duid, item, "identifier");
}
/*
@@ -3045,16 +3115,21 @@ parse_server_duid_conf(struct parse *cfile) {
if (token != SEMI)
parse_error(cfile, "semicolon expected");
- sv_duid = createString(duid);
- sv_duid->skip = ISC_TRUE;
- TAILQ_CONCAT(&sv_duid->comments, &cfile->comments);
- cfile->issue_counter++;
- mapSet(cfile->stack[cfile->stack_top], sv_duid, "server-duid");
+ /* server-id is a global parameter */
+ if (mapContains(cfile->stack[1], "server-id"))
+ parse_error(cfile, "there is already a server-id");
+ /* DHCPv6 only but not fatal */
+ if ((local_family != AF_INET6) && !duid->skip) {
+ duid->skip = ISC_TRUE;
+ cfile->issue_counter++;
+ }
+ mapSet(cfile->stack[1], duid, "server-id");
}
/*
* Push new interface on the interface list when it is not already.
*/
+
static void
new_network_interface(struct parse *cfile, struct element *iface)
{
@@ -3127,6 +3202,13 @@ addrmask(const struct string *address, const struct string *netmask)
return makeString(-1, buf);
}
+/*
+ * find a place where to put a reservation
+ * (reservations aka hosts must be in a subnet in Kea)
+ * (defaulting to the last defined subnet (e.g. for reservations
+ * without any address).
+ */
+
static struct element *
find_match(struct parse *cfile, struct element *host)
{
@@ -3176,19 +3258,41 @@ find_match(struct parse *cfile, struct element *host)
return cfile->stack[1];
}
+/*
+ * Compute a prefix length from lower - higher IPv6 addresses.
+ */
+
+static const uint8_t bytemasks[8] = {
+ 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff
+};
+
static int
get_prefix_length(const char *low, const char *high)
{
- uint32_t low_int;
- uint32_t high_int;
- uint32_t xor_int;
- int plen;
+ uint8_t lo[16];
+ uint8_t hi[16];
+ uint8_t xor[16];
+ int i, plen;
+
+ if ((inet_pton(AF_INET6, low, lo) != 1) ||
+ (inet_pton(AF_INET6, high, hi) != 1))
+ return -100;
+
+ for (i = 0; i < 16; i++)
+ xor[i] = lo[i] ^ hi[i];
+ for (plen = 0; plen < 128; plen += 8)
+ if (xor[plen / 8] != 0)
+ break;
+ if (plen == 128)
+ return plen;
+ for (i = (plen / 8) + 1; i < 16; ++i)
+ if (xor[i] != 0)
+ return -2;
+ for (i = 0; i < 8; i++) {
+ uint8_t msk = ~xor[plen / 8];
- memcpy(&low_int, low, 4);
- memcpy(&high_int, high, 4);
- xor_int = low_int ^ high_int;
- for (plen = 0; plen <= 32; ++plen)
- if (xor_int == bitmasks[plen])
- return plen;
+ if (msk == bytemasks[i])
+ return plen + i + 1;
+ }
return -1;
}
diff --git a/keama/data.c b/keama/data.c
index 6e37d3cc..15a8aed7 100644
--- a/keama/data.c
+++ b/keama/data.c
@@ -963,3 +963,30 @@ derive(struct handle *src, struct handle *dst)
mapSet(item, copy(src->value), src->key);
}
}
+
+struct string *
+hexaValue(struct element *s)
+{
+ struct string *h;
+
+ assert(s != NULL);
+ assert(s->type == ELEMENT_STRING);
+
+ h = stringValue(s);
+ assert(h->length >= 2);
+
+ /* string leading 0x */
+ return makeString(h->length - 2, h->content + 2);
+}
+
+struct element *
+createHexa(struct string *h)
+{
+ struct string *s;
+
+ assert(h != NULL);
+
+ s = makeString(-1, "0x");
+ concatString(s, h);
+ return createString(s);
+}
diff --git a/keama/data.h b/keama/data.h
index a7f1225e..d00fd865 100644
--- a/keama/data.h
+++ b/keama/data.h
@@ -275,7 +275,7 @@ struct element *copy(struct element *e);
struct element *copyList(struct element *l);
struct element *copyMap(struct element *m);
-/* Handle */
+/* Handles */
TAILQ_HEAD(handles, handle);
struct handle {
@@ -289,4 +289,8 @@ struct handle {
struct handle* mapPop(struct element *);
void derive(struct handle *, struct handle *);
+/* Hexadecimal literals */
+struct string *hexaValue(struct element *);
+struct element *createHexa(struct string *);
+
#endif /* DATA_H */
diff --git a/keama/dhcp3/kea.json b/keama/dhcp3/kea.json
index 04247649..fa9aa5f1 100644
--- a/keama/dhcp3/kea.json
+++ b/keama/dhcp3/kea.json
@@ -1,18 +1,18 @@
{
+ # NATIONAL DHCPD Secondary Failover Peer Unique Configuration
+ # 2010-12-14 ~bpeterson
+ # ! !
+ # ! DO NOT EDIT !
+ # ! !
+ # All dhcp configuration files are handled by cfengine at
+ # meles.srv.pavlovmedia.corp
+ # Non-unique configuration is contained in dhcp3/common.dhcpd
+ # Individual dhcp scopes are defined by sitecode as shared networks in
+ # dhcp3/folder.dhcpd/$SITECODE.dhcpd
+ # Files are included into the dhcpd.conf with include statements in
+ # dhcp3/folder.dhcpd/includes.dhcpd
"Dhcp4": {
"option-data": [
- # NATIONAL DHCPD Secondary Failover Peer Unique Configuration
- # 2010-12-14 ~bpeterson
- # ! !
- # ! DO NOT EDIT !
- # ! !
- # All dhcp configuration files are handled by cfengine at
- # meles.srv.pavlovmedia.corp
- # Non-unique configuration is contained in dhcp3/common.dhcpd
- # Individual dhcp scopes are defined by sitecode as shared networks in
- # dhcp3/folder.dhcpd/$SITECODE.dhcpd
- # Files are included into the dhcpd.conf with include statements in
- # dhcp3/folder.dhcpd/includes.dhcpd
{
"space": "dhcp4",
"name": "dhcp-server-identifier",
diff --git a/keama/fordhcp/kea.json b/keama/fordhcp/kea.json
index f83f749a..02b6df49 100644
--- a/keama/fordhcp/kea.json
+++ b/keama/fordhcp/kea.json
@@ -1,4 +1,13 @@
{
+ # dhcpd.conf file for jaguar in 950 charter failover pair jaguar and
+ # gozer.
+ #
+ # NOTE: DHCP Service for the 950 Wireless Network is now being
+ # handled by sauber.isc.org.
+ #
+ #######################################################################
+ # Global Configuration
+ #
"Dhcp4": {
// "config": [
// /// lease-file-name is an internal ISC DHCP feature
diff --git a/keama/keama.h b/keama/keama.h
index fb737efe..3f04bfac 100644
--- a/keama/keama.h
+++ b/keama/keama.h
@@ -39,6 +39,10 @@ enum resolve {
/* From includes/dhcp.h */
+#define HTYPE_ETHER 1
+#define HTYPE_IEEE802 6
+#define HTYPE_FDDI 8
+
#define DHO_DHCP_SERVER_IDENTIFIER 54
#define DHO_VENDOR_CLASS_IDENTIFIER 60
#define DHO_USER_CLASS 77
diff --git a/keama/parse.c b/keama/parse.c
index 8e4a8cf6..2db9cdd8 100644
--- a/keama/parse.c
+++ b/keama/parse.c
@@ -3157,10 +3157,8 @@ parse_non_binary(struct element *expr,
case NUMBER_OR_NAME:
/* Return a const-data to make a difference with
- a string literal. */
- data = makeString(-1, "0x");
- concatString(data, parse_hexa(cfile));
- mapSet(expr, createString(data), "const-data");
+ a string literal. createHexa() adds 0x */
+ mapSet(expr, createHexa(parse_hexa(cfile)), "const-data");
break;
case NS_FORMERR:
@@ -4066,24 +4064,26 @@ parse_option_statement(struct element *result,
mapSet(opt_data, data, "data");
}
}
+ /* string */
+ else if (((*fmt == 't') || (*fmt == 'X')) &&
+ (expr->type == ELEMENT_STRING))
+ mapSet(opt_data, expr, "data");
/* binary */
else if ((*fmt == 'E') || (*fmt == 'X')) {
- struct string *hexa;
-
if (expr->type != ELEMENT_MAP)
goto giveup;
data = mapGet(expr, "const-data");
if (data == NULL)
goto giveup;
/* remove leading 0x */
- hexa = stringValue(data);
- data = createString(makeString(hexa->length - 2,
- hexa->content + 2));
+ data = createString(hexaValue(data));
mapSet(opt_data, data, "data");
mapSet(opt_data, createBool(ISC_FALSE), "csv-format");
}
- if (!mapContains(opt_data, "data")) {
+ if (mapContains(opt_data, "data")) {
+ /* insert warning comment */
+ } else {
giveup:
opt_data->skip = ISC_TRUE;
cfile->issue_counter++;
@@ -4741,6 +4741,8 @@ config_match_client_id(struct element *config, struct parse *cfile)
parse_error(cfile, "ignore-client-uids is DHCPv4 only");
value = mapGet(config, "value");
+ /* match-client-id is !ignore-client-uids */
+ value = createBool(!boolValue(value));
for (scope = cfile->stack_top; scope > 0; --scope) {
int kind = cfile->stack[scope]->kind;
diff --git a/keama/samples/example.json b/keama/samples/example.json
index 85efb184..6f43e2b8 100644
--- a/keama/samples/example.json
+++ b/keama/samples/example.json
@@ -1,11 +1,11 @@
{
+ # dhcpd.conf
+ #
+ # Sample configuration file for ISC dhcpd
+ #
+ # Required
"Dhcp4": {
"option-data": [
- # dhcpd.conf
- #
- # Sample configuration file for ISC dhcpd
- #
- # Required
# option definitions common to all supported networks...
{
"space": "dhcp4",
diff --git a/keama/samples/simple.json b/keama/samples/simple.json
index 5b6625b3..119b2377 100644
--- a/keama/samples/simple.json
+++ b/keama/samples/simple.json
@@ -1,12 +1,12 @@
{
+ # -------------------------
+ # dhcpd.conf
+ #
+ # Sample configuration file for ISC dhcpd
+ #
+ # option definitions common to all supported networks...
"Dhcp4": {
"option-data": [
- # -------------------------
- # dhcpd.conf
- #
- # Sample configuration file for ISC dhcpd
- #
- # option definitions common to all supported networks...
{
"space": "dhcp4",
"name": "domain-name",
diff --git a/keama/samples/vmnet8.json b/keama/samples/vmnet8.json
index 75bc6870..c71c54fc 100644
--- a/keama/samples/vmnet8.json
+++ b/keama/samples/vmnet8.json
@@ -1,14 +1,14 @@
{
+ # Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
+ #
+ # This file was automatically generated by the VMware configuration program.
+ # See Instructions below if you want to modify it.
+ #
+ # We set domain-name-servers to make some DHCP clients happy
+ # (dhclient as configured in SuSE, TurboLinux, etc.).
+ # We also supply a domain name to make pump (Red Hat 6.x) happy.
+ #
"Dhcp4": {
-// # Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
-// #
-// # This file was automatically generated by the VMware configuration program.
-// # See Instructions below if you want to modify it.
-// #
-// # We set domain-name-servers to make some DHCP clients happy
-// # (dhclient as configured in SuSE, TurboLinux, etc.).
-// # We also supply a domain name to make pump (Red Hat 6.x) happy.
-// #
// ###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####
// # Modification Instructions: This section of the configuration file contains
// # information generated by the configuration program. Do not modify this
diff --git a/keama/tests/badduid.err b/keama/tests/badduid.err
new file mode 100644
index 00000000..36545d59
--- /dev/null
+++ b/keama/tests/badduid.err
@@ -0,0 +1,7 @@
+# bad (no type) server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# server duid declaration
+server-duid "enterprise-specific-identifier-1234";
diff --git a/keama/tests/badduid.msg b/keama/tests/badduid.msg
new file mode 100644
index 00000000..3d0b373e
--- /dev/null
+++ b/keama/tests/badduid.msg
@@ -0,0 +1 @@
+badduid.err line 7: DUID type of LLT, EN, or LL expected
diff --git a/keama/tests/duid2.err b/keama/tests/duid2.err
new file mode 100644
index 00000000..d09404e9
--- /dev/null
+++ b/keama/tests/duid2.err
@@ -0,0 +1,10 @@
+# two server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# EN server duid declaration
+server-duid en 2495 "enterprise-specific-identifier-1234";
+
+# LL server duid declaration
+server-duid ll ethernet 00:16:6F:49:7D:9B;
diff --git a/keama/tests/duid2.msg b/keama/tests/duid2.msg
new file mode 100644
index 00000000..19e12f97
--- /dev/null
+++ b/keama/tests/duid2.msg
@@ -0,0 +1 @@
+duid2.err line 10: there is already a server-id
diff --git a/keama/tests/duiden6.in6 b/keama/tests/duiden6.in6
new file mode 100644
index 00000000..462c6fde
--- /dev/null
+++ b/keama/tests/duiden6.in6
@@ -0,0 +1,7 @@
+# EN server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# EN server duid declaration
+server-duid en 2495 "enterprise-specific-identifier-1234";
diff --git a/keama/tests/duiden6.out b/keama/tests/duiden6.out
new file mode 100644
index 00000000..433c8877
--- /dev/null
+++ b/keama/tests/duiden6.out
@@ -0,0 +1,12 @@
+{
+ # EN server duid config
+ # authoritative is mandatory
+ "Dhcp6": {
+ # EN server duid declaration
+ "server-id": {
+ "type": "EN",
+ "enterprise-id": 2495,
+ "identifier": "enterprise-specific-identifier-1234"
+ }
+ }
+}
diff --git a/keama/tests/duidennoid.err b/keama/tests/duidennoid.err
new file mode 100644
index 00000000..aecf93a9
--- /dev/null
+++ b/keama/tests/duidennoid.err
@@ -0,0 +1,8 @@
+# bad (no identifier) EN server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# EN server duid declaration
+server-duid en 2495;
+
diff --git a/keama/tests/duidennoid.msg b/keama/tests/duidennoid.msg
new file mode 100644
index 00000000..36d3f3b1
--- /dev/null
+++ b/keama/tests/duidennoid.msg
@@ -0,0 +1 @@
+duidennoid.err line 7: identifier expected
diff --git a/keama/tests/duidennonum.err b/keama/tests/duidennonum.err
new file mode 100644
index 00000000..6cad99d4
--- /dev/null
+++ b/keama/tests/duidennonum.err
@@ -0,0 +1,7 @@
+# bad (no number) EN server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# EN server duid declaration
+server-duid en "enterprise-specific-identifier-1234";
diff --git a/keama/tests/duidennonum.msg b/keama/tests/duidennonum.msg
new file mode 100644
index 00000000..9500ed90
--- /dev/null
+++ b/keama/tests/duidennonum.msg
@@ -0,0 +1 @@
+duidennonum.err line 7: enterprise number expected
diff --git a/keama/tests/duidll6.in6 b/keama/tests/duidll6.in6
new file mode 100644
index 00000000..b5f0e02e
--- /dev/null
+++ b/keama/tests/duidll6.in6
@@ -0,0 +1,8 @@
+# LL server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LL server duid declaration
+server-duid ll;
+
diff --git a/keama/tests/duidll6.out b/keama/tests/duidll6.out
new file mode 100644
index 00000000..c298ad71
--- /dev/null
+++ b/keama/tests/duidll6.out
@@ -0,0 +1,10 @@
+{
+ # LL server duid config
+ # authoritative is mandatory
+ "Dhcp6": {
+ # LL server duid declaration
+ "server-id": {
+ "type": "LL"
+ }
+ }
+}
diff --git a/keama/tests/duidllbadtype.err b/keama/tests/duidllbadtype.err
new file mode 100644
index 00000000..a3bd9360
--- /dev/null
+++ b/keama/tests/duidllbadtype.err
@@ -0,0 +1,7 @@
+# bad (unknown hardware type) LL server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LL server duid declaration
+server-duid ll foobar 00:16:6F:49:7D:9B;
diff --git a/keama/tests/duidllbadtype.msg b/keama/tests/duidllbadtype.msg
new file mode 100644
index 00000000..f867abca
--- /dev/null
+++ b/keama/tests/duidllbadtype.msg
@@ -0,0 +1 @@
+duidllbadtype.err line 7: hardware type expected
diff --git a/keama/tests/duidllhw6.in6 b/keama/tests/duidllhw6.in6
new file mode 100644
index 00000000..0de7ffff
--- /dev/null
+++ b/keama/tests/duidllhw6.in6
@@ -0,0 +1,9 @@
+# LL server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LL server duid declaration
+server-duid ll ethernet 00:16:6F:49:7D:9B;
+
+
diff --git a/keama/tests/duidllhw6.out b/keama/tests/duidllhw6.out
new file mode 100644
index 00000000..e2f9c813
--- /dev/null
+++ b/keama/tests/duidllhw6.out
@@ -0,0 +1,12 @@
+{
+ # LL server duid config
+ # authoritative is mandatory
+ "Dhcp6": {
+ # LL server duid declaration
+ "server-id": {
+ "type": "LL",
+ "htype": 1,
+ "identifier": "00166f497d9b"
+ }
+ }
+}
diff --git a/keama/tests/duidllnohw.err b/keama/tests/duidllnohw.err
new file mode 100644
index 00000000..ee2caa7a
--- /dev/null
+++ b/keama/tests/duidllnohw.err
@@ -0,0 +1,7 @@
+# bad (no hardware address) LL server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LL server duid declaration
+server-duid ll fddi;
diff --git a/keama/tests/duidllnohw.msg b/keama/tests/duidllnohw.msg
new file mode 100644
index 00000000..6c66c7c8
--- /dev/null
+++ b/keama/tests/duidllnohw.msg
@@ -0,0 +1 @@
+duidllnohw.err line 7: expecting hexadecimal number.
diff --git a/keama/tests/duidllt6.in6 b/keama/tests/duidllt6.in6
new file mode 100644
index 00000000..13003af8
--- /dev/null
+++ b/keama/tests/duidllt6.in6
@@ -0,0 +1,8 @@
+# LLT server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LLT server duid declaration
+server-duid llt;
+
diff --git a/keama/tests/duidllt6.out b/keama/tests/duidllt6.out
new file mode 100644
index 00000000..39a017bd
--- /dev/null
+++ b/keama/tests/duidllt6.out
@@ -0,0 +1,10 @@
+{
+ # LLT server duid config
+ # authoritative is mandatory
+ "Dhcp6": {
+ # LLT server duid declaration
+ "server-id": {
+ "type": "LLT"
+ }
+ }
+}
diff --git a/keama/tests/duidlltbadtype.err b/keama/tests/duidlltbadtype.err
new file mode 100644
index 00000000..4650daac
--- /dev/null
+++ b/keama/tests/duidlltbadtype.err
@@ -0,0 +1,7 @@
+# bad (unknown hardware type) LLT server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LLT server duid declaration
+server-duid llt foobar 213982198 00:16:6F:49:7D:9B;
diff --git a/keama/tests/duidlltbadtype.msg b/keama/tests/duidlltbadtype.msg
new file mode 100644
index 00000000..14fc5e44
--- /dev/null
+++ b/keama/tests/duidlltbadtype.msg
@@ -0,0 +1 @@
+duidlltbadtype.err line 7: hardware type expected
diff --git a/keama/tests/duidlltnohw.err b/keama/tests/duidlltnohw.err
new file mode 100644
index 00000000..10f8bf02
--- /dev/null
+++ b/keama/tests/duidlltnohw.err
@@ -0,0 +1,7 @@
+# bad (no hardware address) LLT server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LLT server duid declaration
+server-duid llt token-ring 213982198;
diff --git a/keama/tests/duidlltnohw.msg b/keama/tests/duidlltnohw.msg
new file mode 100644
index 00000000..b1aee1f9
--- /dev/null
+++ b/keama/tests/duidlltnohw.msg
@@ -0,0 +1 @@
+duidlltnohw.err line 7: expecting hexadecimal number.
diff --git a/keama/tests/duidlltnotime.err b/keama/tests/duidlltnotime.err
new file mode 100644
index 00000000..92a387f1
--- /dev/null
+++ b/keama/tests/duidlltnotime.err
@@ -0,0 +1,7 @@
+# bad (no timestamp) LLT server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LLT server duid declaration
+server-duid llt token-ring A8:16:6F:49:7D:9B;
diff --git a/keama/tests/duidlltnotime.msg b/keama/tests/duidlltnotime.msg
new file mode 100644
index 00000000..c176c4d8
--- /dev/null
+++ b/keama/tests/duidlltnotime.msg
@@ -0,0 +1 @@
+duidlltnotime.err line 7: timestamp expected
diff --git a/keama/tests/duidlltthw4.err4 b/keama/tests/duidlltthw4.err4
new file mode 100644
index 00000000..4c2d2b63
--- /dev/null
+++ b/keama/tests/duidlltthw4.err4
@@ -0,0 +1,7 @@
+# LLT server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LLT server duid declaration
+server-duid llt token-ring 213982198 00:16:6F:49:7D:9B;
diff --git a/keama/tests/duidlltthw4.msg b/keama/tests/duidlltthw4.msg
new file mode 100644
index 00000000..7e842d2d
--- /dev/null
+++ b/keama/tests/duidlltthw4.msg
@@ -0,0 +1 @@
+duidlltthw4.err4 line 7: expecting a parameter or declaration
diff --git a/keama/tests/duidlltthw6.in6 b/keama/tests/duidlltthw6.in6
new file mode 100644
index 00000000..4c2d2b63
--- /dev/null
+++ b/keama/tests/duidlltthw6.in6
@@ -0,0 +1,7 @@
+# LLT server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# LLT server duid declaration
+server-duid llt token-ring 213982198 00:16:6F:49:7D:9B;
diff --git a/keama/tests/duidlltthw6.out b/keama/tests/duidlltthw6.out
new file mode 100644
index 00000000..e7f3cea8
--- /dev/null
+++ b/keama/tests/duidlltthw6.out
@@ -0,0 +1,13 @@
+{
+ # LLT server duid config
+ # authoritative is mandatory
+ "Dhcp6": {
+ # LLT server duid declaration
+ "server-id": {
+ "type": "LLT",
+ "htype": 6,
+ "time": 213982198,
+ "identifier": "00166f497d9b"
+ }
+ }
+}
diff --git a/keama/tests/duidnoid.err b/keama/tests/duidnoid.err
new file mode 100644
index 00000000..e018478c
--- /dev/null
+++ b/keama/tests/duidnoid.err
@@ -0,0 +1,7 @@
+# bad (no identifier) numeric server duid config
+
+# authoritative is mandatory
+authoritative;
+
+# server duid declaration
+server-duid 9;
diff --git a/keama/tests/duidnoid.msg b/keama/tests/duidnoid.msg
new file mode 100644
index 00000000..8ab2b0ba
--- /dev/null
+++ b/keama/tests/duidnoid.msg
@@ -0,0 +1 @@
+duidnoid.err line 7: identifier expected
diff --git a/keama/tests/execstatement4.out b/keama/tests/execstatement4.out
index e185f41f..0086dd00 100644
--- a/keama/tests/execstatement4.out
+++ b/keama/tests/execstatement4.out
@@ -1,4 +1,6 @@
{
+ # DHCPv4 executable statement config
+ # authoritative is mandatory
"Dhcp4": {
"valid-lifetime": 1800
// # impossible to convert statement statement
diff --git a/keama/tests/execstatement6.out b/keama/tests/execstatement6.out
index 3ccc775e..a12e8b10 100644
--- a/keama/tests/execstatement6.out
+++ b/keama/tests/execstatement6.out
@@ -1,4 +1,6 @@
{
+ # DHCPv6 executable statement config
+ # authoritative is mandatory
"Dhcp6": {
"valid-lifetime": 1800
// # impossible to convert statement statement
diff --git a/keama/tests/host6.notyet b/keama/tests/host6.notyet
new file mode 100644
index 00000000..daff911e
--- /dev/null
+++ b/keama/tests/host6.notyet
@@ -0,0 +1,20 @@
+# DHCPv6 host declaration config
+
+# authoritative is mandatory
+authoritative;
+
+# subnet declaration
+subnet6 2001::/64 {
+ range6 2001::100 2001::200;
+}
+
+# host declarations
+host test1 {
+ hardware ethernet 00:07:0E:36:48:19;
+ fixed-address6 2001::1, 2001::10;
+}
+
+host test2 {
+ hardware fddi 00:07:0E:36:48:19;
+ fixed-prefix6 2001:0:0:1::/64;
+}
diff --git a/keama/tests/hostuid4.out b/keama/tests/hostuid4.out
index 09432180..71825583 100644
--- a/keama/tests/hostuid4.out
+++ b/keama/tests/hostuid4.out
@@ -1,8 +1,8 @@
{
+ # host declaration with client-identfiers config
+ # authoritative is mandatory
"Dhcp4": {
"subnet4": [
- # host declaration with client-identfiers config
- # authoritative is mandatory
# subnet4 declaration
{
"subnet": "10.5.5.0/27",
@@ -49,7 +49,7 @@
]
}
],
- "match-client-id": false,
+ "match-client-id": true,
"host-reservation-identifiers": [
"client-id",
"hw-address"
diff --git a/keama/tests/minimal4.out b/keama/tests/minimal4.out
index cbc68ddc..52dca9a7 100644
--- a/keama/tests/minimal4.out
+++ b/keama/tests/minimal4.out
@@ -1,4 +1,6 @@
{
+ # DHCPv4 minimal config
+ # authoritative is mandatory
"Dhcp4": {
"valid-lifetime": 1800
}
diff --git a/keama/tests/minimal6.out b/keama/tests/minimal6.out
index b8082ca4..dfafcf75 100644
--- a/keama/tests/minimal6.out
+++ b/keama/tests/minimal6.out
@@ -1,4 +1,6 @@
{
+ # DHCPv6 minimal config
+ # authoritative is mandatory
"Dhcp6": {
"valid-lifetime": 1800
}
diff --git a/keama/tests/optdatagrouppool4.out b/keama/tests/optdatagrouppool4.out
index 1926ee71..f154aca4 100644
--- a/keama/tests/optdatagrouppool4.out
+++ b/keama/tests/optdatagrouppool4.out
@@ -1,4 +1,6 @@
{
+ # embedded option-data in DHCPv4 pool config
+ # authoritative is mandatory
"Dhcp4": {
"valid-lifetime": 1800,
"subnet4": [
diff --git a/keama/tests/optiondatapool4.out b/keama/tests/optiondatapool4.out
index 3a6e3ac5..60097801 100644
--- a/keama/tests/optiondatapool4.out
+++ b/keama/tests/optiondatapool4.out
@@ -1,8 +1,8 @@
{
+ # option-data in DHCPv4 pool config
+ # authoritative is mandatory
"Dhcp4": {
"subnet4": [
- # option-data in DHCPv4 pool config
- # authoritative is mandatory
# subnet declaration
{
"subnet": "10.5.5.0/27",
diff --git a/keama/tests/optiondatapool6.out b/keama/tests/optiondatapool6.out
index 83dc3ced..880cb59d 100644
--- a/keama/tests/optiondatapool6.out
+++ b/keama/tests/optiondatapool6.out
@@ -1,8 +1,8 @@
{
+ # option-data in DHCPv6 pool config
+ # authoritative is mandatory
"Dhcp6": {
"subnet6": [
- # option-data in DHCPv6 pool config
- # authoritative is mandatory
# subnet declaration
{
"subnet": "2001::/64",
diff --git a/keama/tests/orphan4.out b/keama/tests/orphan4.out
index b1d2d181..5411f5c5 100644
--- a/keama/tests/orphan4.out
+++ b/keama/tests/orphan4.out
@@ -1,4 +1,6 @@
{
+ # DHCPv4 orphan reservation config
+ # authoritative is mandatory
"Dhcp4": {
"valid-lifetime": 1800,
"host-reservation-identifiers": [
diff --git a/keama/tests/orphan6.out b/keama/tests/orphan6.out
index 8be6cd2d..7b9d05f4 100644
--- a/keama/tests/orphan6.out
+++ b/keama/tests/orphan6.out
@@ -1,4 +1,6 @@
{
+ # DHCPv6 orphan reservation config
+ # authoritative is mandatory
"Dhcp6": {
"valid-lifetime": 1800,
"host-reservation-identifiers": [
diff --git a/keama/tests/permitauth4.out b/keama/tests/permitauth4.out
index 521a56bd..4cb4334b 100644
--- a/keama/tests/permitauth4.out
+++ b/keama/tests/permitauth4.out
@@ -1,4 +1,6 @@
{
+ # DHCPv4 permit authenticated client config
+ # authoritative is mandatory
"Dhcp4": {
"valid-lifetime": 1800,
"subnet4": [
diff --git a/keama/tests/permitauth6.out b/keama/tests/permitauth6.out
index 6acefb7b..6ca7af56 100644
--- a/keama/tests/permitauth6.out
+++ b/keama/tests/permitauth6.out
@@ -1,4 +1,6 @@
{
+ # DHCPv4 permit authenticated client config
+ # authoritative is mandatory
"Dhcp6": {
"valid-lifetime": 1800,
"subnet6": [
diff --git a/keama/tests/pool4.out b/keama/tests/pool4.out
index 11dfb90f..76dc7372 100644
--- a/keama/tests/pool4.out
+++ b/keama/tests/pool4.out
@@ -1,8 +1,8 @@
{
+ # DHCPv4 pool config
+ # authoritative is mandatory
"Dhcp4": {
"subnet4": [
- # DHCPv4 pool config
- # authoritative is mandatory
# subnet declaration
{
"subnet": "10.5.5.0/27",
diff --git a/keama/tests/pool6.out b/keama/tests/pool6.out
index eb949010..a2b4c550 100644
--- a/keama/tests/pool6.out
+++ b/keama/tests/pool6.out
@@ -1,8 +1,8 @@
{
+ # DHCPv6 pool config
+ # authoritative is mandatory
"Dhcp6": {
"subnet6": [
- # DHCPv6 pool config
- # authoritative is mandatory
# subnet declaration
{
"subnet": "2001::/64",
diff --git a/keama/tests/prefix.in6 b/keama/tests/prefix.in6
new file mode 100644
index 00000000..78e1f399
--- /dev/null
+++ b/keama/tests/prefix.in6
@@ -0,0 +1,12 @@
+# DHCPv6 prefix config
+
+# authoritative is mandatory
+authoritative;
+
+# subnet declaration
+subnet6 2001::/64 {
+ # range declaration
+ option dhcp6.domain-search "example.com", "example.org";
+ default-lease-time 1800;
+ prefix6 2001:0:0:10:: 2001:0:0:1f:: / 64;
+}
diff --git a/keama/tests/prefix.out b/keama/tests/prefix.out
new file mode 100644
index 00000000..cccd3dd4
--- /dev/null
+++ b/keama/tests/prefix.out
@@ -0,0 +1,29 @@
+{
+ # DHCPv6 prefix config
+ # authoritative is mandatory
+ "Dhcp6": {
+ "subnet6": [
+ # subnet declaration
+ {
+ "subnet": "2001::/64",
+ "option-data": [
+ # range declaration
+ {
+ "space": "dhcp6",
+ "name": "domain-search",
+ "code": 24,
+ "data": "example.com, example.org"
+ }
+ ],
+ "valid-lifetime": 1800,
+ "pd-pools": [
+ {
+ "prefix": "2001:0:0:10::",
+ "delegated-len": 64,
+ "prefix-len": 60
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/keama/tests/prefix0.err6 b/keama/tests/prefix0.err6
new file mode 100644
index 00000000..c10b6d15
--- /dev/null
+++ b/keama/tests/prefix0.err6
@@ -0,0 +1,9 @@
+# DHCPv6 (bad 128 bit length) prefix config
+
+# subnet declaration
+subnet6 2001::/64 {
+ # range declaration
+ option dhcp6.domain-search "example.com", "example.org";
+ default-lease-time 1800;
+ prefix6 2001:0:0:10:: 2001:0:0:1f:: / 128;
+}
diff --git a/keama/tests/prefix0.msg b/keama/tests/prefix0.msg
new file mode 100644
index 00000000..73952817
--- /dev/null
+++ b/keama/tests/prefix0.msg
@@ -0,0 +1 @@
+prefix0.err6 line 8: networks have 0 to 128 bits (exclusive)
diff --git a/keama/tests/prefix128.err6 b/keama/tests/prefix128.err6
new file mode 100644
index 00000000..c10b6d15
--- /dev/null
+++ b/keama/tests/prefix128.err6
@@ -0,0 +1,9 @@
+# DHCPv6 (bad 128 bit length) prefix config
+
+# subnet declaration
+subnet6 2001::/64 {
+ # range declaration
+ option dhcp6.domain-search "example.com", "example.org";
+ default-lease-time 1800;
+ prefix6 2001:0:0:10:: 2001:0:0:1f:: / 128;
+}
diff --git a/keama/tests/prefix128.msg b/keama/tests/prefix128.msg
new file mode 100644
index 00000000..ee874c74
--- /dev/null
+++ b/keama/tests/prefix128.msg
@@ -0,0 +1 @@
+prefix128.err6 line 8: networks have 0 to 128 bits (exclusive)
diff --git a/keama/tests/prefix2.in6 b/keama/tests/prefix2.in6
new file mode 100644
index 00000000..f1f6b2ac
--- /dev/null
+++ b/keama/tests/prefix2.in6
@@ -0,0 +1,12 @@
+# DHCPv6 prefix config
+
+# authoritative is mandatory
+authoritative;
+
+# subnet declaration
+subnet6 2001::/64 {
+ # range declaration
+ option dhcp6.domain-search "example.com", "example.org";
+ default-lease-time 1800;
+ prefix6 2001:0:0:1:: 2001:0:0:3:: / 64;
+}
diff --git a/keama/tests/prefix2.out b/keama/tests/prefix2.out
new file mode 100644
index 00000000..d29c573f
--- /dev/null
+++ b/keama/tests/prefix2.out
@@ -0,0 +1,29 @@
+{
+ # DHCPv6 prefix config
+ # authoritative is mandatory
+ "Dhcp6": {
+ "subnet6": [
+ # subnet declaration
+ {
+ "subnet": "2001::/64",
+ "option-data": [
+ # range declaration
+ {
+ "space": "dhcp6",
+ "name": "domain-search",
+ "code": 24,
+ "data": "example.com, example.org"
+ }
+ ],
+ "valid-lifetime": 1800,
+ "pd-pools": [
+// {
+// "prefix": "2001:0:0:1::",
+// "delegated-len": 64,
+// "prefix-highest": "2001:0:0:3::"
+// }
+ ]
+ }
+ ]
+ }
+}
diff --git a/keama/tests/range4.out b/keama/tests/range4.out
index 6799cbec..fcaf5162 100644
--- a/keama/tests/range4.out
+++ b/keama/tests/range4.out
@@ -1,8 +1,8 @@
{
+ # DHCPv4 range config
+ # authoritative is mandatory
"Dhcp4": {
"subnet4": [
- # DHCPv4 range config
- # authoritative is mandatory
# subnet declaration
{
"subnet": "10.5.5.0/27",
diff --git a/keama/tests/range6.in6 b/keama/tests/range6.in6
index 813b20b5..05f30b45 100644
--- a/keama/tests/range6.in6
+++ b/keama/tests/range6.in6
@@ -9,4 +9,5 @@ subnet6 2001::/64 {
option dhcp6.domain-search "example.com", "example.org";
default-lease-time 1800;
range6 2001::100 2001::200;
+ range6 2001::1000/116;
}
diff --git a/keama/tests/range6.out b/keama/tests/range6.out
index 173c45fb..706a2ade 100644
--- a/keama/tests/range6.out
+++ b/keama/tests/range6.out
@@ -1,8 +1,8 @@
{
+ # DHCPv6 range config
+ # authoritative is mandatory
"Dhcp6": {
"subnet6": [
- # DHCPv6 range config
- # authoritative is mandatory
# subnet declaration
{
"subnet": "2001::/64",
@@ -19,6 +19,9 @@
"pools": [
{
"pool": "2001::100 - 2001::200"
+ },
+ {
+ "pool": "2001::1000/116"
}
]
}
diff --git a/keama/tests/shareone4.out b/keama/tests/shareone4.out
index bb5a0165..a9f04dc4 100644
--- a/keama/tests/shareone4.out
+++ b/keama/tests/shareone4.out
@@ -1,4 +1,6 @@
{
+ # DHCPv4 one-subnet shared-network declaration config
+ # authoritative is mandatory
"Dhcp4": {
"interfaces-config": {
"interfaces": [
diff --git a/keama/tests/shareone6.out b/keama/tests/shareone6.out
index a3649c18..6d4f733c 100644
--- a/keama/tests/shareone6.out
+++ b/keama/tests/shareone6.out
@@ -1,4 +1,6 @@
{
+ # DHCPv6 one-subnet shared-network declaration config
+ # authoritative is mandatory
"Dhcp6": {
"interfaces-config": {
"interfaces": [
diff --git a/keama/tests/subclass4.out b/keama/tests/subclass4.out
index 84fbe534..716a7a6e 100644
--- a/keama/tests/subclass4.out
+++ b/keama/tests/subclass4.out
@@ -1,8 +1,8 @@
{
+ # subclass declaration config
+ # authoritative is mandatory
"Dhcp4": {
"option-def": [
- # subclass declaration config
- # authoritative is mandatory
# options
{
"space": "dhcp4",
diff --git a/keama/tests/subclass6.out b/keama/tests/subclass6.out
index 22122de4..237c20cd 100644
--- a/keama/tests/subclass6.out
+++ b/keama/tests/subclass6.out
@@ -1,8 +1,8 @@
{
+ # subclass declaration config
+ # authoritative is mandatory
"Dhcp6": {
"option-def": [
- # subclass declaration config
- # authoritative is mandatory
# options
{
"space": "dhcp6",
diff --git a/keama/tests/subclassbinsel4.out b/keama/tests/subclassbinsel4.out
index da2d74b2..94b8a84c 100644
--- a/keama/tests/subclassbinsel4.out
+++ b/keama/tests/subclassbinsel4.out
@@ -1,8 +1,8 @@
{
+ # subclass declaration config
+ # authoritative is mandatory
"Dhcp4": {
"option-def": [
- # subclass declaration config
- # authoritative is mandatory
# options
{
"space": "dhcp4",
diff --git a/keama/tests/subclassbinsel6.out b/keama/tests/subclassbinsel6.out
index ed4984a0..f89d99ad 100644
--- a/keama/tests/subclassbinsel6.out
+++ b/keama/tests/subclassbinsel6.out
@@ -1,8 +1,8 @@
{
+ # subclass declaration config
+ # authoritative is mandatory
"Dhcp6": {
"option-def": [
- # subclass declaration config
- # authoritative is mandatory
# options
{
"space": "dhcp6",
diff --git a/keama/tests/subnet4.in4 b/keama/tests/subnet4.in4
new file mode 100644
index 00000000..c19a275b
--- /dev/null
+++ b/keama/tests/subnet4.in4
@@ -0,0 +1,19 @@
+# DHCPv4 subnet declaration config
+
+# authoritative is mandatory
+authoritative;
+
+# parameter which will be changed in subnet
+default-lease-time 1800;
+
+# DHCPv4 subnet declaration
+subnet 10.5.5.0 netmask 255.255.255.224 {
+ # at least one pool is required
+ pool {
+ range 10.5.5.5 10.5.5.10;
+ }
+ option domain-search "example.com", "example.org";
+ default-lease-time 3600;
+ ignore-client-uids false;
+}
+
diff --git a/keama/tests/subnet4.out b/keama/tests/subnet4.out
new file mode 100644
index 00000000..b9a6ac2d
--- /dev/null
+++ b/keama/tests/subnet4.out
@@ -0,0 +1,29 @@
+{
+ # DHCPv4 subnet declaration config
+ # authoritative is mandatory
+ "Dhcp4": {
+ "valid-lifetime": 1800,
+ "subnet4": [
+ # DHCPv4 subnet declaration
+ {
+ "subnet": "10.5.5.0/27",
+ "pools": [
+ # at least one pool is required
+ {
+ "pool": "10.5.5.5 - 10.5.5.10"
+ }
+ ],
+ "option-data": [
+ {
+ "space": "dhcp4",
+ "name": "domain-search",
+ "code": 119,
+ "data": "example.com, example.org"
+ }
+ ],
+ "valid-lifetime": 3600,
+ "match-client-id": true
+ }
+ ]
+ }
+}
diff --git a/keama/tests/subnet42if.err4 b/keama/tests/subnet42if.err4
new file mode 100644
index 00000000..b65c5d72
--- /dev/null
+++ b/keama/tests/subnet42if.err4
@@ -0,0 +1,8 @@
+# bad (2 interfaces) DHCPv4 subnet declaration config
+
+# DHCPv4 subnet declaration
+subnet 10.5.5.0 netmask 255.255.255.224 {
+ interface "foo";
+ interface "bar";
+}
+
diff --git a/keama/tests/subnet42if.msg b/keama/tests/subnet42if.msg
new file mode 100644
index 00000000..22cd15dc
--- /dev/null
+++ b/keama/tests/subnet42if.msg
@@ -0,0 +1 @@
+subnet42if.err4 line 6: A subnet can't be connected to two interfaces.
diff --git a/keama/tests/subnet4badmask.err4 b/keama/tests/subnet4badmask.err4
new file mode 100644
index 00000000..979f5cbb
--- /dev/null
+++ b/keama/tests/subnet4badmask.err4
@@ -0,0 +1,7 @@
+# bad (bad netmask) DHCPv4 subnet declaration config
+
+# DHCPv4 subnet declaration
+subnet 10.5.5.0 netmask 255.255.255.96 {
+ default-lease-time 1800;
+}
+
diff --git a/keama/tests/subnet4badmask.msg b/keama/tests/subnet4badmask.msg
new file mode 100644
index 00000000..860aec2d
--- /dev/null
+++ b/keama/tests/subnet4badmask.msg
@@ -0,0 +1 @@
+subnet4badmask.err4 line 4: can't get a prefix from 10.5.5.0 mask 255.255.255.96
diff --git a/keama/tests/subnet4nomask.err4 b/keama/tests/subnet4nomask.err4
new file mode 100644
index 00000000..42266d03
--- /dev/null
+++ b/keama/tests/subnet4nomask.err4
@@ -0,0 +1,7 @@
+# bad (no netmask) DHCPv4 subnet declaration config
+
+# DHCPv4 subnet declaration
+subnet 10.5.5.0/27 {
+ default-lease-time 1800;
+}
+
diff --git a/keama/tests/subnet4nomask.msg b/keama/tests/subnet4nomask.msg
new file mode 100644
index 00000000..2d786c10
--- /dev/null
+++ b/keama/tests/subnet4nomask.msg
@@ -0,0 +1 @@
+subnet4nomask.err4 line 4: Expecting netmask
diff --git a/keama/tests/subnet6.in6 b/keama/tests/subnet6.in6
new file mode 100644
index 00000000..c2c126bf
--- /dev/null
+++ b/keama/tests/subnet6.in6
@@ -0,0 +1,22 @@
+# DHCPv6 subnet declaration config
+
+# authoritative is mandatory
+authoritative;
+
+# parameter which will be changed in subnet
+default-lease-time 1800;
+
+# DHCPv4 subnet declaration
+subnet6 2001::/64 {
+ # at least one pool is required
+ pool6 {
+ range6 2001::100 2001::200;
+ }
+ option dhcp6.domain-search "example.com", "example.org";
+ default-lease-time 3600;
+ # in future it will be possible to use the same pool6
+ pool6 {
+ prefix6 2001:0:0:10:: 2001:0:0:1f:: /64;
+ }
+}
+
diff --git a/keama/tests/subnet6.out b/keama/tests/subnet6.out
new file mode 100644
index 00000000..48e9b811
--- /dev/null
+++ b/keama/tests/subnet6.out
@@ -0,0 +1,37 @@
+{
+ # DHCPv6 subnet declaration config
+ # authoritative is mandatory
+ "Dhcp6": {
+ "valid-lifetime": 1800,
+ "subnet6": [
+ # DHCPv4 subnet declaration
+ {
+ "subnet": "2001::/64",
+ "pools": [
+ # at least one pool is required
+ {
+ "pool": "2001::100 - 2001::200"
+ },
+ # in future it will be possible to use the same pool6
+ { }
+ ],
+ "option-data": [
+ {
+ "space": "dhcp6",
+ "name": "domain-search",
+ "code": 24,
+ "data": "example.com, example.org"
+ }
+ ],
+ "valid-lifetime": 3600,
+ "pd-pools": [
+ {
+ "prefix": "2001:0:0:10::",
+ "delegated-len": 64,
+ "prefix-len": 60
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/keama/tests/subnet62if.err6 b/keama/tests/subnet62if.err6
new file mode 100644
index 00000000..37fdc3f9
--- /dev/null
+++ b/keama/tests/subnet62if.err6
@@ -0,0 +1,8 @@
+# bad (2 interfaces) DHCPv6 subnet declaration config
+
+# DHCPv6 subnet declaration
+subnet6 2001::/64 {
+ interface "foo";
+ interface "bar";
+}
+
diff --git a/keama/tests/subnet62if.msg b/keama/tests/subnet62if.msg
new file mode 100644
index 00000000..66f6b900
--- /dev/null
+++ b/keama/tests/subnet62if.msg
@@ -0,0 +1 @@
+subnet62if.err6 line 6: A subnet can't be connected to two interfaces.
diff --git a/keama/tests/subnet6nolen.err6 b/keama/tests/subnet6nolen.err6
new file mode 100644
index 00000000..1a71ac79
--- /dev/null
+++ b/keama/tests/subnet6nolen.err6
@@ -0,0 +1,7 @@
+# bad (no length) DHCPv6 subnet declaration config
+
+# DHCPv6 subnet declaration
+subnet6 2001::/ {
+ default-lease-time 1800;
+}
+
diff --git a/keama/tests/subnet6nolen.msg b/keama/tests/subnet6nolen.msg
new file mode 100644
index 00000000..cc36f0e1
--- /dev/null
+++ b/keama/tests/subnet6nolen.msg
@@ -0,0 +1 @@
+subnet6nolen.err6 line 4: Expecting a number.
diff --git a/keama/tests/subnet6noslash.err6 b/keama/tests/subnet6noslash.err6
new file mode 100644
index 00000000..2083eab6
--- /dev/null
+++ b/keama/tests/subnet6noslash.err6
@@ -0,0 +1,7 @@
+# bad (no /) DHCPv6 subnet declaration config
+
+# DHCPv6 subnet declaration
+subnet6 2001:: {
+ default-lease-time 1800;
+}
+
diff --git a/keama/tests/subnet6noslash.msg b/keama/tests/subnet6noslash.msg
new file mode 100644
index 00000000..63fa81c6
--- /dev/null
+++ b/keama/tests/subnet6noslash.msg
@@ -0,0 +1 @@
+subnet6noslash.err6 line 4: Expecting a '/'.
diff --git a/keama/tests/temporary.in6 b/keama/tests/temporary.in6
new file mode 100644
index 00000000..1be8e94e
--- /dev/null
+++ b/keama/tests/temporary.in6
@@ -0,0 +1,13 @@
+# DHCPv6 temporary (aka IA_TA) range config
+
+# authoritative is mandatory
+authoritative;
+
+# subnet declaration
+subnet6 2001::/64 {
+ # range declaration
+ option dhcp6.domain-search "example.com", "example.org";
+ default-lease-time 1800;
+ range6 2001::100 temporary;
+ range6 2001::1000/116 temporary;
+}
diff --git a/keama/tests/temporary.out b/keama/tests/temporary.out
new file mode 100644
index 00000000..5ab6c9da
--- /dev/null
+++ b/keama/tests/temporary.out
@@ -0,0 +1,30 @@
+{
+ # DHCPv6 temporary (aka IA_TA) range config
+ # authoritative is mandatory
+ "Dhcp6": {
+ "subnet6": [
+ # subnet declaration
+ {
+ "subnet": "2001::/64",
+ "option-data": [
+ # range declaration
+ {
+ "space": "dhcp6",
+ "name": "domain-search",
+ "code": 24,
+ "data": "example.com, example.org"
+ }
+ ],
+ "valid-lifetime": 1800,
+ "pools": [
+ {
+// "pool": "2001::100/64 temporary"
+ },
+ {
+// "pool": "2001::1000/116 temporary"
+ }
+ ]
+ }
+ ]
+ }
+}