diff options
author | Francis Dupont <fdupont@isc.org> | 2018-12-07 14:15:39 +0100 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2019-11-12 09:02:23 +0100 |
commit | 5c5754e41a259028b6a6a1c7a220d95c713b67ab (patch) | |
tree | 6d81dff1fe7669dee3d45ea298eaf77d74baa8ae | |
parent | 4c68fea71d1171cedd02e230f9fceb4dec2f3811 (diff) | |
download | isc-dhcp-5c5754e41a259028b6a6a1c7a220d95c713b67ab.tar.gz |
Added sample by Jordan T.
-rw-r--r-- | keama/tests/jt/dhcpd.conf | 63 | ||||
-rw-r--r-- | keama/tests/jt/kea.json | 112 | ||||
-rw-r--r-- | keama/tests/jt/run.sh | 32 | ||||
-rw-r--r-- | keama/tests/runall.sh | 2 |
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 |