summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2018-12-07 14:15:39 +0100
committerFrancis Dupont <fdupont@isc.org>2018-12-07 14:15:39 +0100
commit45172762ef7eb620472d97a7b916e9fdde0a23ad (patch)
treed196cbe21ccac56380f41bf0aaa01d423e6f77a5
parent8b058db1bd8eab22eaa17d226517a97b72b4ac89 (diff)
downloadisc-dhcp-rt44949.tar.gz
Added sample by Jordan T.rt44949
-rw-r--r--keama/tests/jt/dhcpd.conf63
-rw-r--r--keama/tests/jt/kea.json112
-rw-r--r--keama/tests/jt/run.sh32
-rw-r--r--keama/tests/runall.sh2
4 files changed, 208 insertions, 1 deletions
diff --git a/keama/tests/jt/dhcpd.conf b/keama/tests/jt/dhcpd.conf
new file mode 100644
index 00000000..1402ee41
--- /dev/null
+++ b/keama/tests/jt/dhcpd.conf
@@ -0,0 +1,63 @@
+class "APPLE" {
+
+ match if ( substring (hardware,1,3) = b0:19:c6 ) or
+ ( substring (hardware,1,3) = d8:a2:5e ) or
+ ( substring (hardware,1,3) = b8:c7:5d ) or
+ ( substring (hardware,1,3) = 6c:70:9f ) or
+ ( substring (hardware,1,3) = 88:1f:a1 );
+
+}
+
+class "BELKIN" {
+ match if ( substring (hardware,1,3) = 60:38:e0 ) or
+ ( substring (hardware,1,3) = 58:ef:58 ) or
+ ( substring (hardware,1,3) = 58:ef:68 );
+
+}
+
+
+
+
+## Pool 1
+shared-network "pool 1" {
+subnet 192.168.1.0 netmask 255.255.255.0 {
+
+ option domain-name-servers 8.8.8.8, 8.8.4.4;
+ option routers 192.168.1.1;
+ option broadcast-address 192.168.1.255;
+ default-lease-time 259200;
+ max-lease-time 259200;
+
+ pool {
+
+ range 192.168.1.2 192.168.1.254;
+
+
+ allow members of "APPLE";
+ allow members of "BELKIN";
+
+}
+}
+}
+
+## Pool 2
+shared-network "pool 2" {
+subnet 192.168.2.0 netmask 255.255.255.0 {
+
+ option domain-name-servers 8.8.8.8, 8.8.4.4;
+ option routers 192.168.2.1;
+ option broadcast-address 192.168.2.255;
+ default-lease-time 259200;
+ max-lease-time 259200;
+
+ pool {
+
+ range 192.168.2.2 192.168.2.254;
+
+
+ allow members of "APPLE";
+ allow members of "BELKIN";
+
+}
+}
+}
diff --git a/keama/tests/jt/kea.json b/keama/tests/jt/kea.json
new file mode 100644
index 00000000..9a36e3c7
--- /dev/null
+++ b/keama/tests/jt/kea.json
@@ -0,0 +1,112 @@
+{
+ /// This configuration declares some subnets but has no interfaces-config
+ /// Reference Kea #245
+ "Dhcp4": {
+ "client-classes": [
+ {
+ "name": "APPLE",
+ /// from: match if ((substring(hardware, 1, 3)) = 0xb019c6) or ((substring(hardware, 1, 3)) = 0xd8a25e) or ((substring(hardware, 1, 3)) = 0xb8c75d) or ((substring(hardware, 1, 3)) = 0x6c709f) or ((substring(hardware, 1, 3)) = 0x881fa1)
+ "test": "((((substring(pkt4.mac,0,3) == 0xb019c6) or (substring(pkt4.mac,0,3) == 0xd8a25e)) or (substring(pkt4.mac,0,3) == 0xb8c75d)) or (substring(pkt4.mac,0,3) == 0x6c709f)) or (substring(pkt4.mac,0,3) == 0x881fa1)"
+ },
+ {
+ "name": "BELKIN",
+ /// from: match if ((substring(hardware, 1, 3)) = 0x6038e0) or ((substring(hardware, 1, 3)) = 0x58ef58) or ((substring(hardware, 1, 3)) = 0x58ef68)
+ "test": "((substring(pkt4.mac,0,3) == 0x6038e0) or (substring(pkt4.mac,0,3) == 0x58ef58)) or (substring(pkt4.mac,0,3) == 0x58ef68)"
+ },
+ {
+ "name": "gen#APPLE#BELKIN#",
+ "test": "member('APPLE') or member('BELKIN')"
+ }
+ ],
+ "subnet4": [
+ {
+ "id": 1,
+ "subnet": "192.168.1.0/24",
+ "option-data": [
+ {
+ "space": "dhcp4",
+ "name": "domain-name-servers",
+ "code": 6,
+ "data": "8.8.8.8, 8.8.4.4"
+ },
+ {
+ "space": "dhcp4",
+ "name": "routers",
+ "code": 3,
+ "data": "192.168.1.1"
+ },
+ {
+ "space": "dhcp4",
+ "name": "broadcast-address",
+ "code": 28,
+ "data": "192.168.1.255"
+ }
+ ],
+ "valid-lifetime": 259200,
+// "config": [
+// /// max-lease-time is not supported
+// /// use default-lease-time instead
+// /// Reference Kea #221
+// {
+// "name": "max-lease-time",
+// "code": 2,
+// "value": 259200
+// }
+// ],
+ "pools": [
+ {
+ "pool": "192.168.1.2 - 192.168.1.254",
+ /// From:
+ /// allow APPLE
+ /// allow BELKIN
+ "client-class": "gen#APPLE#BELKIN#"
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "subnet": "192.168.2.0/24",
+ "option-data": [
+ {
+ "space": "dhcp4",
+ "name": "domain-name-servers",
+ "code": 6,
+ "data": "8.8.8.8, 8.8.4.4"
+ },
+ {
+ "space": "dhcp4",
+ "name": "routers",
+ "code": 3,
+ "data": "192.168.2.1"
+ },
+ {
+ "space": "dhcp4",
+ "name": "broadcast-address",
+ "code": 28,
+ "data": "192.168.2.255"
+ }
+ ],
+ "valid-lifetime": 259200,
+// "config": [
+// /// max-lease-time is not supported
+// /// use default-lease-time instead
+// /// Reference Kea #221
+// {
+// "name": "max-lease-time",
+// "code": 2,
+// "value": 259200
+// }
+// ],
+ "pools": [
+ {
+ "pool": "192.168.2.2 - 192.168.2.254",
+ /// From:
+ /// allow APPLE
+ /// allow BELKIN
+ "client-class": "gen#APPLE#BELKIN#"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/keama/tests/jt/run.sh b/keama/tests/jt/run.sh
new file mode 100644
index 00000000..4acb5ea4
--- /dev/null
+++ b/keama/tests/jt/run.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#set -x
+
+if [ $# -ne 0 ]; then
+ echo "usage: $0" >&2
+ exit 1
+fi
+
+cd "$(dirname "$0")"
+cd ..
+
+# Use a sample provided by Jordan Tinsley <jtinsley@lrecok.coop>
+
+file=jt/dhcpd.conf
+expected=jt/kea.json
+out=/tmp/jt.out$$
+
+../keama -4 -i $file -o $out >&2
+status=$?
+if [ $status -eq 255 ]; then
+ echo "JT config raised an error" >&2
+ exit 1
+fi
+
+diff --brief $out $expected
+if [ $? -ne 0 ]; then
+ echo "JT config doesn't provide expected output" >&2
+ exit 1
+fi
+
+exit $status
diff --git a/keama/tests/runall.sh b/keama/tests/runall.sh
index 13c81bf6..8fc2f631 100644
--- a/keama/tests/runall.sh
+++ b/keama/tests/runall.sh
@@ -5,7 +5,7 @@
cd "$(dirname "$0")"
echo subdirs:
-for d in fordhcp dhcp3 czb ws ba gcet
+for d in fordhcp dhcp3 czb ws ba gcet jt
do
echo $d
/bin/sh $d/run.sh