From: Piotrek Zadroga Date: Tue, 9 May 2023 15:06:28 +0000 (+0200) Subject: [#2536] Moving detailed examples to separate files X-Git-Tag: Kea-2.3.8~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f624ab14c43135df76bcddc74acdcfe8a33ec131;p=thirdparty%2Fkea.git [#2536] Moving detailed examples to separate files --- diff --git a/doc/Makefile.am b/doc/Makefile.am index 18b3b59235..1c971b9b9b 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -25,6 +25,7 @@ nobase_dist_doc_DATA += examples/kea4/classify2.json nobase_dist_doc_DATA += examples/kea4/comments.json nobase_dist_doc_DATA += examples/kea4/config-backend.json nobase_dist_doc_DATA += examples/kea4/dhcpv4-over-dhcpv6.json +nobase_dist_doc_DATA += examples/kea4/dnr.json nobase_dist_doc_DATA += examples/kea4/global-reservations.json nobase_dist_doc_DATA += examples/kea4/ha-load-balancing-server1-mt-with-tls.json nobase_dist_doc_DATA += examples/kea4/ha-load-balancing-server2-mt.json @@ -51,6 +52,7 @@ nobase_dist_doc_DATA += examples/kea6/classify2.json nobase_dist_doc_DATA += examples/kea6/comments.json nobase_dist_doc_DATA += examples/kea6/config-backend.json nobase_dist_doc_DATA += examples/kea6/dhcpv4-over-dhcpv6.json +nobase_dist_doc_DATA += examples/kea6/dnr.json nobase_dist_doc_DATA += examples/kea6/duid.json nobase_dist_doc_DATA += examples/kea6/global-reservations.json nobase_dist_doc_DATA += examples/kea6/ha-hot-standby-server1-with-tls.json diff --git a/doc/examples/kea4/all-options.json b/doc/examples/kea4/all-options.json index e9b4dd5786..81efb9504c 100644 --- a/doc/examples/kea4/all-options.json +++ b/doc/examples/kea4/all-options.json @@ -1567,18 +1567,13 @@ */ // Type: uint16, uint16, uint8, FQDN, binary { - // only one DNR instance ADN only mode - IP address(es) and SvcParams are missing on purpose. + // Only one DNR instance ADN only mode - IP address(es) and SvcParams are missing on purpose. + // For more detailed example with IP addresses and SvcParams included, please check dnr.json example. "code": 162, "name": "v4-dnr", "data": "26, 1234, 23, example.some.host.org., " // please notice comma and space at the end put on purpose // this means empty last type of the record - binary type }, - { - // 2 DNR instances with IP address(es) and SvcParams included as binary type. - "code": 162, - "name": "v4-dnr", // addresses len=8 | IPv4 1 | IPv4 2 | SvcParams "key1=val1 key2=val2" |Len2 |Prio2| | ADN with Len=21=15hex myhost1.example.com | | IPv4 1 | IPv4 2 | SvcParams "key3=val3 key4=val4" | - "data": "54, 3234, 23, example.some.host.org., 08 c0 a8 00 01 c0 a8 00 02 6b 65 79 31 3d 76 61 6c 31 20 6b 65 79 32 3d 76 61 6c 32 00 34 10 e1 15 07 6D 79 68 6F 73 74 31 07 65 78 61 6D 70 6C 65 03 63 6F 6D 00 08 c0 a9 00 01 c0 a9 00 02 6b 65 79 33 3d 76 61 6c 33 20 6b 65 79 34 3d 76 61 6c 34" - }, // Option codes 163-209 are unassigned. diff --git a/doc/examples/kea4/dnr.json b/doc/examples/kea4/dnr.json new file mode 100644 index 0000000000..d386d07660 --- /dev/null +++ b/doc/examples/kea4/dnr.json @@ -0,0 +1,76 @@ +// This is an example configuration file for the DHCPv4 server in Kea. +// The purpose of this example is to showcase how to configure +// DHCP option for the Discovery of Network-designated Resolvers (DNR) +// (code 162) draft-ietf-add-dnr. + + +{ + "Dhcp4": { + // Option data defined globally + "option-data": [ + /* + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | OPTION_V4_DNR | Length | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ~ DNR Instance Data #1 ~ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ --- + . ... . | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ optional + ~ DNR Instance Data #n ~ | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ --- + + DNR Instance Data Format: + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | DNR Instance Data Length | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Service Priority | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | ADN Length | | + +-+-+-+-+-+-+-+-+ | + ~ authentication-domain-name ~ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Addr Length | | + +-+-+-+-+-+-+-+-+ | + ~ IPv4 Address(es) ~ + | +-+-+-+-+-+-+-+-+ + | | | + +-+-+-+-+-+-+-+-+ | + ~Service Parameters (SvcParams) ~ + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + // Type: uint16, uint16, uint8, FQDN, binary + { + // 2 DNR instances with IP address(es) and SvcParams included as binary type. + "code": 162, + "name": "v4-dnr", // addresses len=8 | IPv4 1 | IPv4 2 | SvcParams "key1=val1 key2=val2" |Len2 |Prio2| | ADN with Len=21=15hex myhost1.example.com | | IPv4 1 | IPv4 2 | SvcParams "key3=val3 key4=val4" | + "data": "54, 3234, 23, example.some.host.org., 08 c0 a8 00 01 c0 a8 00 02 6b 65 79 31 3d 76 61 6c 31 20 6b 65 79 32 3d 76 61 6c 32 00 34 10 e1 15 07 6D 79 68 6F 73 74 31 07 65 78 61 6D 70 6C 65 03 63 6F 6D 00 08 c0 a9 00 01 c0 a9 00 02 6b 65 79 33 3d 76 61 6c 33 20 6b 65 79 34 3d 76 61 6c 34" + } + ], + // Kea is told to listen on eth0 interface only. + "interfaces-config": { + "interfaces": [ + "eth0" + ] + }, + // We need to specify the database used to store leases. + "lease-database": { + "type": "memfile" + }, + // The following list defines subnets. We have only one subnet + // here. We tell Kea that it is directly available over local interface. + "subnet4": [ + { + "interface": "eth0", + "pools": [ + { + "pool": "192.0.2.50-192.0.2.50" + } + ], + "subnet": "192.0.2.0/24" + } + ] + } +} diff --git a/doc/examples/kea6/all-options.json b/doc/examples/kea6/all-options.json index ba9fea9dc4..98636e4610 100644 --- a/doc/examples/kea6/all-options.json +++ b/doc/examples/kea6/all-options.json @@ -1784,18 +1784,13 @@ // Type: uint16, uint16, FQDN, binary { // DNR ADN only mode - IP address(es) and SvcParams are missing on purpose. + // For more detailed example with IP addresses and SvcParams included, please check dnr.json example. "code": 144, "name": "v6-dnr", "data": "1234, 23, example.some.host.org., " // please notice comma and space at the end put on purpose // this means empty last type of the record - binary type }, - { - // DNR with IP address(es) and SvcParams included as binary type. - "code": 144, - "name": "v6-dnr", // addresses len=32 | 1st IPv6 | 2nd IPv6 | SvcParams "key1=val1 key2=val2" | - "data": "3234, 23, example.some.host.org., 00 20 20 01 0d b8 00 01 00 00 00 00 00 00 de ad be ef ff 02 00 00 00 00 00 00 00 00 00 00 fa ce b0 0c 6b 65 79 31 3d 76 61 6c 31 20 6b 65 79 32 3d 76 61 6c 32" - }, // Option codes 145-65535 are unassigned. diff --git a/doc/examples/kea6/dnr.json b/doc/examples/kea6/dnr.json new file mode 100644 index 0000000000..b43fe23062 --- /dev/null +++ b/doc/examples/kea6/dnr.json @@ -0,0 +1,85 @@ +// This is an example configuration file for the DHCPv6 server in Kea. +// The purpose of this example is to showcase how to configure +// DHCP option for the Discovery of Network-designated Resolvers (DNR) +// (code 144) draft-ietf-add-dnr. +{ + "Dhcp6": { + // Option data defined globally + "option-data": [ + /* + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Option-code | Option-length | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Service Priority | ADN Length | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ~ authentication-domain-name ~ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Addr Length | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | + ~ ipv6-address(es) ~ + | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | + ~ Service Parameters (SvcParams) ~ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + // Type: uint16, uint16, FQDN, binary + { + // DNR with IP address(es) and SvcParams included as binary type. + "code": 144, + "name": "v6-dnr", // addresses len=32 | 1st IPv6 | 2nd IPv6 | SvcParams "key1=val1 key2=val2" | + "data": "3234, 23, example.some.host.org., 00 20 20 01 0d b8 00 01 00 00 00 00 00 00 de ad be ef ff 02 00 00 00 00 00 00 00 00 00 00 fa ce b0 0c 6b 65 79 31 3d 76 61 6c 31 20 6b 65 79 32 3d 76 61 6c 32" + } + ], + // Kea is told to listen on eth0 interface only. + "interfaces-config": { + "interfaces": [ "eth0" ] + }, + + // We need to specify the database used to store leases. + // We'll use memfile because it doesn't require any prior set up. + "lease-database": { + "type": "memfile", + "persist": true, + "lfc-interval": 3600 + }, + + // Addresses will be assigned with preferred and valid lifetimes + // being 3000 and 4000, respectively. Client is told to start + // renewing after 1000 seconds. If the server does not respond + // after 2000 seconds since the lease was granted, client is supposed + // to start REBIND procedure (emergency renewal that allows switching + // to a different server). + "preferred-lifetime": 3000, + "valid-lifetime": 4000, + "renew-timer": 1000, + "rebind-timer": 2000, + + // The following list defines subnets. Each subnet consists of at + // least subnet and pool entries. + "subnet6": [ + { + "pools": [ { "pool": "2001:db8:1::/80" } ], + "subnet": "2001:db8:1::/64", + "interface": "eth0" + } + ], + + // The following configures logging. It assumes that messages with at + // least informational level (info, warn, error and fatal) should be + // logged to stdout. + "loggers": [ + { + "name": "kea-dhcp6", + "output_options": [ + { + "output": "stdout" + } + ], + "debuglevel": 0, + "severity": "INFO" + } + ] + } +} \ No newline at end of file diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index 3d327dbb2d..648bd83556 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -2964,6 +2964,7 @@ Dhcpv4SrvTest::checkConfigFiles() { "config-backend.json", #endif "dhcpv4-over-dhcpv6.json", + "dnr.json", "global-reservations.json", "ha-load-balancing-server1-mt-with-tls.json", "ha-load-balancing-server2-mt.json", diff --git a/src/bin/dhcp4/tests/parser_unittest.cc b/src/bin/dhcp4/tests/parser_unittest.cc index a176ff194d..f9a58494f7 100644 --- a/src/bin/dhcp4/tests/parser_unittest.cc +++ b/src/bin/dhcp4/tests/parser_unittest.cc @@ -285,6 +285,7 @@ TEST(ParserTest, file) { "classify2.json", "comments.json", "dhcpv4-over-dhcpv6.json", + "dnr.json", "global-reservations.json", "hooks.json", "leases-expiration.json", diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index 64c974b1b5..ee4eb465e1 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -337,6 +337,7 @@ Dhcpv6SrvTest::checkConfigFiles() { "config-backend.json", #endif "dhcpv4-over-dhcpv6.json", + "dnr.json", "duid.json", "global-reservations.json", "ha-hot-standby-server1-with-tls.json", diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index 01d142fd06..f82ed13cda 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -291,6 +291,7 @@ TEST(ParserTest, file) { configs.push_back("classify2.json"); configs.push_back("comments.json"); configs.push_back("dhcpv4-over-dhcpv6.json"); + configs.push_back("dnr.json"); configs.push_back("duid.json"); configs.push_back("global-reservations.json"); configs.push_back("hooks.json"); diff --git a/src/lib/yang/tests/config_unittests.cc b/src/lib/yang/tests/config_unittests.cc index 5e871fb3f0..2568b45435 100644 --- a/src/lib/yang/tests/config_unittests.cc +++ b/src/lib/yang/tests/config_unittests.cc @@ -306,6 +306,7 @@ TEST_F(ConfigTestKeaV4, examples4) { "comments.json", "config-backend.json", "dhcpv4-over-dhcpv6.json", + "dnr.json", "global-reservations.json", "ha-load-balancing-server1-mt-with-tls.json", "ha-load-balancing-server2-mt.json", @@ -346,6 +347,7 @@ TEST_F(ConfigTestKeaV6, examples6) { "comments.json", "config-backend.json", "dhcpv4-over-dhcpv6.json", + "dnr.json", "duid.json", "global-reservations.json", "ha-hot-standby-server1-with-tls.json",