From: Arran Cudbard-Bell Date: Sun, 29 Nov 2020 02:11:59 +0000 (-0700) Subject: Create a TLV and additional identifiers for IP-Pool attirbutes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cf1ba652f460c4017c4ebf50e467660a43e837d;p=thirdparty%2Ffreeradius-server.git Create a TLV and additional identifiers for IP-Pool attirbutes --- diff --git a/doc/antora/modules/howto/pages/modules/sqlippool/index.adoc b/doc/antora/modules/howto/pages/modules/sqlippool/index.adoc index 701db305d1b..a2b4ed6be31 100644 --- a/doc/antora/modules/howto/pages/modules/sqlippool/index.adoc +++ b/doc/antora/modules/howto/pages/modules/sqlippool/index.adoc @@ -56,13 +56,13 @@ an individual IP address, MAC address, etc. === `Access-Request`: A device connects to the NAS with correct credentials . FreeRADIUS receives an `Access-Request` from the NAS. After some -processing (modules. `unlang`, etc.), the `Pool-Name` attribute is +processing (modules. `unlang`, etc.), the `IP-Pool.Name` attribute is added to the `control` list. This attribute indicates that the IP address should be allocated from the named pool. This attribute can be added from any module, database, `unlang`, etc. . When the `sqlippool` module is eventually run, it looks for the -`Pool-Name` attribute, and runs the various SQL queries in order to +`IP-Pool.Name` attribute, and runs the various SQL queries in order to perform IP address allocation. If the module is configured to place address into the `Framed-IP-Address` attribute (as it is by default), and that attribute already exists, the module does nothing, and @@ -70,13 +70,13 @@ returns `noop`. . The module then runs the `alloc_existing` query, which looks for the IP address last assigned to the device from the pool indicated by -`Pool-Name`. The device is identified using the `pool_key` +`IP-Pool.Name`. The device is identified using the `pool_key` configuration item (typically `NAS-Port`) and a NAS identifier (the `NAS-IP-Address`). . If no address was found using `alloc_existing`, the module then runs the `alloc_find` query, which chooses a free IP address from -the pool indicated by `Pool-Name`. If `alloc_find` does not return +the pool indicated by `IP-Pool.Name`. If `alloc_find` does not return an IP address, the `pool_check` query is run in order to determine why the allocation failed. For example, either the requested pool is empty (i.e. no free addresses), or it is non-existent. This @@ -495,24 +495,24 @@ interval). === 7. Enable a pool user -For a request to acquire an address from the pool you must set a `Pool-Name` +For a request to acquire an address from the pool you must set a `IP-Pool.Name` check attribute, either directly in the virtual server configuration or via a data source such as `sql` (for example using the `radcheck` table). -.Example of setting a Pool-Name attribute using the `radcheck` table +.Example of setting a IP-Pool.Name attribute using the `radcheck` table ============================================= [source,shell] ---- echo "INSERT INTO radcheck (username,attribute,op,value) \ - VALUES ('bob','Pool-Name',':=','internet');" \ + VALUES ('bob','IP-Pool.Name',':=','internet');" \ | mysql radius ---- ============================================= -.Example of setting a Pool-Name attribute using in the server config +.Example of setting a IP-Pool.Name attribute using in the server config ============================================= .[raddb]/sites-enabled/default @@ -521,7 +521,7 @@ echo "INSERT INTO radcheck (username,attribute,op,value) \ send Access-Accept { ... update control { - &Pool-Name := 'internet' + &IP-Pool.Name := 'internet' } sqlippool @@ -531,7 +531,7 @@ send Access-Accept { ============================================= -NOTE: Recall that if `sqlippool` is invoked without a `Pool-Name` check +NOTE: Recall that if `sqlippool` is invoked without a `IP-Pool.Name` check attribute then no action is taken. Also recall that if `sqlippool` is invoked whilst the attribute configured in the `attribute_name` configuration item (e.g. `Framed-IP-Address`) already exists then no action is taken. diff --git a/doc/antora/modules/raddb/pages/mods-available/dhcp_sqlippool.adoc b/doc/antora/modules/raddb/pages/mods-available/dhcp_sqlippool.adoc index aac4095cc6f..5f52cf8b787 100644 --- a/doc/antora/modules/raddb/pages/mods-available/dhcp_sqlippool.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/dhcp_sqlippool.adoc @@ -52,9 +52,9 @@ sqlippool dhcp_sqlippool { $INCLUDE ${modconfdir}/sql/ippool-dhcp/mysql/queries.conf # $INCLUDE ${modconfdir}/sql/ippool-dhcp/sqlite/queries.conf sqlippool_log_exists = "DHCP: Existing IP: %{reply.${..attribute_name}} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" - sqlippool_log_success = "DHCP: Allocated IP: %{reply.${..attribute_name}} from %{control.Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + sqlippool_log_success = "DHCP: Allocated IP: %{reply.${..attribute_name}} from %{control.IP-Pool.Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" sqlippool_log_clear = "DHCP: Released IP %{${..attribute_name}} (did %{Called-Station-Id} cli %{Calling-Station-Id} user %{User-Name})" - sqlippool_log_failed = "DHCP: IP Allocation FAILED from %{control.Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" - sqlippool_log_nopool = "DHCP: No Pool-Name defined (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + sqlippool_log_failed = "DHCP: IP Allocation FAILED from %{control.IP-Pool.Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + sqlippool_log_nopool = "DHCP: No IP-Pool.Name defined (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" } ``` diff --git a/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc b/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc index 74b9b5880fb..74f8cd70aec 100644 --- a/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/redis_ippool.adoc @@ -116,7 +116,7 @@ NOTE: See the `redis` module for more information. ``` redis_ippool { - pool_name = &control.Pool-Name + pool_name = &control.IP-Pool.Name offer_time = 30 lease_time = 3600 # wait_num = 10 diff --git a/doc/antora/modules/raddb/pages/mods-available/sqlippool.adoc b/doc/antora/modules/raddb/pages/mods-available/sqlippool.adoc index b8ff96f6569..7de3e27e214 100644 --- a/doc/antora/modules/raddb/pages/mods-available/sqlippool.adoc +++ b/doc/antora/modules/raddb/pages/mods-available/sqlippool.adoc @@ -84,10 +84,10 @@ sqlippool { pool_key = "%{NAS-Port}" messages { exists = "Existing IP: %{reply.${..attribute_name}} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" - success = "Allocated IP: %{reply.${..attribute_name}} from %{control.Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + success = "Allocated IP: %{reply.${..attribute_name}} from %{control.IP-Pool.Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" clear = "Released IP %{${..attribute_name}} (did %{Called-Station-Id} cli %{Calling-Station-Id} user %{User-Name})" - failed = "IP Allocation FAILED from %{control.Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" - nopool = "No Pool-Name defined (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + failed = "IP Allocation FAILED from %{control.IP-Pool.Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + nopool = "No IP-Pool.Name defined (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" } $INCLUDE ${modconfdir}/sql/ippool/${dialect}/queries.conf } diff --git a/doc/antora/modules/raddb/pages/sites-available/default.adoc b/doc/antora/modules/raddb/pages/sites-available/default.adoc index 4249c7cfd61..1a7fb390a99 100644 --- a/doc/antora/modules/raddb/pages/sites-available/default.adoc +++ b/doc/antora/modules/raddb/pages/sites-available/default.adoc @@ -1272,7 +1272,7 @@ be incorrect. There is little we can do about it. Refresh leases when we see a start or alive. Return an address to the IP Pool when we see a stop record. -Ensure that &control.Pool-Name is set to determine which +Ensure that &control.IP-Pool.Name is set to determine which pool of IPs are used. diff --git a/doc/antora/modules/raddb/pages/sites-available/dhcp.adoc b/doc/antora/modules/raddb/pages/sites-available/dhcp.adoc index 40479ba86be..3c181d03e80 100644 --- a/doc/antora/modules/raddb/pages/sites-available/dhcp.adoc +++ b/doc/antora/modules/raddb/pages/sites-available/dhcp.adoc @@ -286,7 +286,7 @@ recv Discover { &DHCP-DHCP-Server-Identifier = 192.0.2.1 } # update control { -# &Pool-Name := "local" +# &IP-Pool.Name := "local" # } # dhcp_sqlippool ok @@ -304,7 +304,7 @@ recv Request { &DHCP-DHCP-Server-Identifier = 192.0.2.1 } # update control { -# &Pool-Name := "local" +# &IP-Pool.Name := "local" # } # dhcp_sqlippool ok diff --git a/raddb/mods-available/redis_ippool b/raddb/mods-available/redis_ippool index 61afa5e90d8..1b079b82dfe 100644 --- a/raddb/mods-available/redis_ippool +++ b/raddb/mods-available/redis_ippool @@ -31,7 +31,7 @@ redis_ippool { # # pool_name:: Name of the pool from which leases are allocated. # - pool_name = &control.Pool-Name + pool_name = &control.IP-Pool.Name # # offer_time:: How long a lease is reserved for after making an offer. diff --git a/raddb/mods-available/sqlippool b/raddb/mods-available/sqlippool index 18b114588e1..3e5902a9ecf 100644 --- a/raddb/mods-available/sqlippool +++ b/raddb/mods-available/sqlippool @@ -149,13 +149,13 @@ sqlippool { messages { exists = "Existing IP: %{reply.${..attribute_name}} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" - success = "Allocated IP: %{reply.${..attribute_name}} from %{control.Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + success = "Allocated IP: %{reply.${..attribute_name}} from %{control.IP-Pool.Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" clear = "Released IP %{${..attribute_name}} (did %{Called-Station-Id} cli %{Calling-Station-Id} user %{User-Name})" - failed = "IP Allocation FAILED from %{control.Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + failed = "IP Allocation FAILED from %{control.IP-Pool.Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" - nopool = "No Pool-Name defined (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" + nopool = "No IP-Pool.Name defined (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})" } # diff --git a/raddb/mods-config/sql/ippool/mysql/queries.conf b/raddb/mods-config/sql/ippool/mysql/queries.conf index 4b64dfe02db..3382f594497 100644 --- a/raddb/mods-config/sql/ippool/mysql/queries.conf +++ b/raddb/mods-config/sql/ippool/mysql/queries.conf @@ -107,7 +107,7 @@ alloc_find = "\ pool_check = "\ SELECT id \ FROM ${ippool_table} \ - WHERE pool_name='%{control.${pool-name}}' \ + WHERE pool_name='%{control.${IP-Pool.Name}}' \ LIMIT 1" # diff --git a/raddb/mods-config/sql/ippool/oracle/queries.conf b/raddb/mods-config/sql/ippool/oracle/queries.conf index 829dca92ca3..996d366a391 100644 --- a/raddb/mods-config/sql/ippool/oracle/queries.conf +++ b/raddb/mods-config/sql/ippool/oracle/queries.conf @@ -95,7 +95,7 @@ pool_check = "\ FROM (\ SELECT id \ FROM ${ippool_table} \ - WHERE pool_name = '%{control.Pool-Name}'\ + WHERE pool_name = '%{control.IP-Pool.Name}'\ ) WHERE ROWNUM = 1" # diff --git a/raddb/mods-config/sql/ippool/sqlite/queries.conf b/raddb/mods-config/sql/ippool/sqlite/queries.conf index 3963a811db9..0fbe61e0624 100644 --- a/raddb/mods-config/sql/ippool/sqlite/queries.conf +++ b/raddb/mods-config/sql/ippool/sqlite/queries.conf @@ -91,7 +91,7 @@ alloc_find = "\ pool_check = "\ SELECT id \ FROM ${ippool_table} \ - WHERE pool_name='%{control.Pool-Name}' \ + WHERE pool_name='%{control.IP-Pool.Name}' \ LIMIT 1" # diff --git a/raddb/sites-available/decoupled-accounting b/raddb/sites-available/decoupled-accounting index 5e866f24a41..e9e2526e40f 100644 --- a/raddb/sites-available/decoupled-accounting +++ b/raddb/sites-available/decoupled-accounting @@ -92,7 +92,7 @@ send Accounting-Response { # # Return an address to the IP Pool when we see a stop record. # - # Ensure that &control.Pool-Name is set to determine which + # Ensure that &control.IP-Pool.Name is set to determine which  # pool of IPs are used. # sqlippool diff --git a/raddb/sites-available/default b/raddb/sites-available/default index 8b7e97d08e2..a1674bf20ce 100644 --- a/raddb/sites-available/default +++ b/raddb/sites-available/default @@ -1544,7 +1544,7 @@ send Accounting-Response { # Refresh leases when we see a start or alive. Return an address to # the IP Pool when we see a stop record. # - # Ensure that &control.Pool-Name is set to determine which + # Ensure that &control.IP-Pool.Name is set to determine which # pool of IPs are used. # # sqlippool diff --git a/raddb/sites-available/dhcp b/raddb/sites-available/dhcp index e0480b45168..dc0205fa0bd 100644 --- a/raddb/sites-available/dhcp +++ b/raddb/sites-available/dhcp @@ -151,7 +151,7 @@ recv Discover { # Or, allocate IPs from the DHCP pool in SQL. You may need to # set the pool name here if you haven't set it elsewhere. # update control { -# &Pool-Name := "local" +# &IP-Pool.Name := "local" # } # dhcp_sqlippool @@ -219,7 +219,7 @@ recv Request { # Or, allocate IPs from the DHCP pool in SQL. You may need to # set the pool name here if you haven't set it elsewhere. # update control { -# &Pool-Name := "local" +# &IP-Pool.Name := "local" # } # dhcp_sqlippool @@ -249,7 +249,7 @@ recv Decline { # If using IPs from a DHCP pool in SQL then you may need to set the # pool name here if you haven't set it elsewhere and mark the IP as declined. # update control { -# &Pool-Name := "local" +# &IP-Pool.Name := "local" # } # dhcp_sqlippool @@ -285,7 +285,7 @@ recv Release { # If using IPs from a DHCP pool in SQL then you may need to set the # pool name here if you haven't set it elsewhere and release the IP. # update control { -# &Pool-Name := "local" +# &IP-Pool.Name := "local" # } # dhcp_sqlippool diff --git a/share/dictionary/freeradius/dictionary.freeradius.internal.ippool b/share/dictionary/freeradius/dictionary.freeradius.internal.ippool index a95561e9c48..d0b6884d653 100644 --- a/share/dictionary/freeradius/dictionary.freeradius.internal.ippool +++ b/share/dictionary/freeradius/dictionary.freeradius.internal.ippool @@ -3,7 +3,7 @@ # This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0 # Version $Id$ # -# Attributes used by ippool modules (5100-5199) +# Attributes used by IP-Pool modules (5100-5199) # # $Id$ # @@ -13,14 +13,23 @@ # FLAGS internal -ATTRIBUTE Pool-Name 5100 string +ATTRIBUTE IP-Pool 5100 tlv -ATTRIBUTE Pool-Action 5101 integer -ATTRIBUTE Pool-Range 5102 string +BEGIN-TLV IP-Pool +ATTRIBUTE Name 1 string # Generic identifier for the IP pool to allocate from +ATTRIBUTE Name-NA 2 string # DHCPv6 - Non-Temporary association pool +ATTRIBUTE Name-PD 3 string # DHCPv6 - Prefix-deligation pool +ATTRIBUTE Name-TA 4 string # DHCPv6 - Temporary association pool +ATTRIBUTE Action 5 integer -VALUE Pool-Action Allocate 1 +VALUE Action Allocate 1 # Renew == Update (they're the same action) -VALUE Pool-Action Renew 2 -VALUE Pool-Action Update 2 -VALUE Pool-Action Release 3 -VALUE Pool-Action Bulk-Release 4 +VALUE Action Renew 2 +VALUE Action Update 2 +VALUE Action Release 3 +VALUE Action Bulk-Release 4 + +ATTRIBUTE Range 6 string +END-TLV IP-Pool + + diff --git a/src/tests/modules/redis_ippool/alloc.unlang b/src/tests/modules/redis_ippool/alloc.unlang index f0b03a77e3b..c6537ff4ac2 100644 --- a/src/tests/modules/redis_ippool/alloc.unlang +++ b/src/tests/modules/redis_ippool/alloc.unlang @@ -4,14 +4,14 @@ $INCLUDE cluster_reset.inc update control { - &Pool-Name := 'test_alloc' + &IP-Pool.Name := 'test_alloc' } # # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # @@ -37,13 +37,13 @@ update request { &Tmp-Date-0 := "%l" } -if ("%{expr:%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" > 20) { +if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" > 20) { test_pass } else { test_fail } -if ("%{expr:%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" < 40) { +if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" < 40) { test_pass } else { test_fail @@ -52,19 +52,19 @@ if ("%{expr:%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Add # # Verify the IP hash has been set # -if ("%{redis:HGET '{%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { +if ("%{redis:HGET '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { test_pass } else { test_fail @@ -79,7 +79,7 @@ if (&reply.Pool-Range == '192.168.0.0') { # # Verify the lease has been associated with the device # -if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}") { +if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}") { test_pass } else { test_fail @@ -105,7 +105,7 @@ update { # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.1.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.1.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.1.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.1.0` } # diff --git a/src/tests/modules/redis_ippool/module.conf b/src/tests/modules/redis_ippool/module.conf index ed61d754195..1df0071de9f 100644 --- a/src/tests/modules/redis_ippool/module.conf +++ b/src/tests/modules/redis_ippool/module.conf @@ -10,7 +10,7 @@ redis_ippool { device = &Calling-Station-ID gateway = &NAS-IP-Address - pool_name = &control.Pool-Name + pool_name = &control.IP-Pool.Name offer_time = 30 lease_time = 60 diff --git a/src/tests/modules/redis_ippool/pool_tool_delete.unlang b/src/tests/modules/redis_ippool/pool_tool_delete.unlang index 8c48b2f42fa..22b5974c3e6 100644 --- a/src/tests/modules/redis_ippool/pool_tool_delete.unlang +++ b/src/tests/modules/redis_ippool/pool_tool_delete.unlang @@ -4,14 +4,14 @@ $INCLUDE cluster_reset.inc update control { - &Pool-Name := 'test_delete' + &IP-Pool.Name := 'test_delete' } # # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # @@ -36,13 +36,13 @@ if (&reply.Framed-IP-Address == 192.168.0.1) { # Delete the IP address # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -d 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -d 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # # Verify the association with the device has been removed # -if ("%{redis:EXISTS '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}" == '0') { +if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == '0') { test_pass } else { test_fail @@ -51,14 +51,14 @@ if ("%{redis:EXISTS '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}" == # # Verify the hash information is removed # -if ("%{redis:EXISTS '{%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address}'}" == '0') { +if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}'}" == '0') { test_pass } else { test_fail } # Check the ZSCORE -if ("%{redis:ZCOUNT '{%{control.Pool-Name}%}:pool' -inf +inf}" == 0) { +if ("%{redis:ZCOUNT '{%{control.IP-Pool.Name}%}:pool' -inf +inf}" == 0) { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/pool_tool_modify.unlang b/src/tests/modules/redis_ippool/pool_tool_modify.unlang index ecd533883b9..3f8c23117d9 100644 --- a/src/tests/modules/redis_ippool/pool_tool_modify.unlang +++ b/src/tests/modules/redis_ippool/pool_tool_modify.unlang @@ -4,20 +4,20 @@ $INCLUDE cluster_reset.inc update control { - &Pool-Name := 'test_update' + &IP-Pool.Name := 'test_update' } # # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # # Verify the range was set OK # -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:192.168.0.1 range}" == '192.168.0.0') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:192.168.0.1 range}" == '192.168.0.0') { test_pass } else { test_fail @@ -27,13 +27,13 @@ if ("%{redis:HGET {%{control.Pool-Name}%}:ip:192.168.0.1 range}" == '192.168.0.0 # Modify the range # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -m 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 10.0.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -m 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 10.0.0.0` } # # Check it was updated # -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:192.168.0.1 range}" == '10.0.0.0') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:192.168.0.1 range}" == '10.0.0.0') { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/pool_tool_release.unlang b/src/tests/modules/redis_ippool/pool_tool_release.unlang index 0f27e075ec9..556027b8fe1 100644 --- a/src/tests/modules/redis_ippool/pool_tool_release.unlang +++ b/src/tests/modules/redis_ippool/pool_tool_release.unlang @@ -4,14 +4,14 @@ $INCLUDE cluster_reset.inc update control { - &Pool-Name := 'test_update' + &IP-Pool.Name := 'test_update' } # # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # @@ -36,13 +36,13 @@ if (&reply.Framed-IP-Address == 192.168.0.1) { # Release the IP address # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -r 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -r 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # # Verify the association with the device has been removed # -if ("%{redis:EXISTS '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}" == '0') { +if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == '0') { test_pass } else { test_fail @@ -51,26 +51,26 @@ if ("%{redis:EXISTS '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}" == # # Verify the hash information is retained # -if ("%{redis:HGET '{%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { +if ("%{redis:HGET '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { test_pass } else { test_fail } # Check the ZSCORE -if ("%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Address}'}" == 0) { +if ("%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'}" == 0) { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/release.unlang b/src/tests/modules/redis_ippool/release.unlang index a280a016522..05ef38d6758 100644 --- a/src/tests/modules/redis_ippool/release.unlang +++ b/src/tests/modules/redis_ippool/release.unlang @@ -4,14 +4,14 @@ $INCLUDE cluster_reset.inc update control { - &Pool-Name := 'test_update' + &IP-Pool.Name := 'test_update' } # # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # @@ -51,7 +51,7 @@ if (updated) { # # Verify the association with the device has been removed # -if ("%{redis:EXISTS '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}" == '0') { +if ("%{redis:EXISTS '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == '0') { test_pass } else { test_fail @@ -60,19 +60,19 @@ if ("%{redis:EXISTS '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}" == # # Verify the hash information is retained # -if ("%{redis:HGET '{%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { +if ("%{redis:HGET '{%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address}' 'device'}" == '00:11:22:33:44:55') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { test_pass } else { test_fail } -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} range}" == '192.168.0.0') { test_pass } else { test_fail @@ -83,13 +83,13 @@ update request { &Tmp-Date-0 := "%l" } -if ("%{expr:%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" > 0) { +if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" > 0) { test_pass } else { test_fail } -if ("%{expr:%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" < 10) { +if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" < 10) { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/update.unlang b/src/tests/modules/redis_ippool/update.unlang index faaf911ed29..d215e626ae8 100644 --- a/src/tests/modules/redis_ippool/update.unlang +++ b/src/tests/modules/redis_ippool/update.unlang @@ -4,14 +4,14 @@ $INCLUDE cluster_reset.inc update control { - &Pool-Name := 'test_update' + &IP-Pool.Name := 'test_update' } # # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # 1. Check allocation @@ -37,7 +37,7 @@ if (&reply.Session-Timeout == 30) { } # 4. Verify the gateway was set -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { test_pass } else { test_fail @@ -45,7 +45,7 @@ if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} gateway} # 5. Add another IP addresses update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.1.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.1.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.1.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.1.0` } # 6. Verify that the lease time is extended @@ -73,35 +73,35 @@ update request { &Tmp-Date-0 := "%l" } -if ("%{expr:%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" > 50) { +if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" > 50) { test_pass } else { test_fail } # 9. -if ("%{expr:%{redis:ZSCORE '{%{control.Pool-Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" < 70) { +if ("%{expr:%{redis:ZSCORE '{%{control.IP-Pool.Name}%}:pool' '%{reply.Framed-IP-Address}'} - %{integer:&Tmp-Date-0}}" < 70) { test_pass } else { test_fail } # 10. Verify the lease is still associated with the device -if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}") { +if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}") { test_pass } else { test_fail } # 11. And that the device object will expire a suitable number of seconds into the future -if ("%{redis:TTL '{%{control.Pool-Name}%}:device:%{Calling-Station-ID}'}" == 60) { +if ("%{redis:TTL '{%{control.IP-Pool.Name}%}:device:%{Calling-Station-ID}'}" == 60) { test_pass } else { test_fail } # 12. Verify the gateway was updated -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{request.Framed-IP-Address} gateway}" == '127.0.0.2') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{request.Framed-IP-Address} gateway}" == '127.0.0.2') { test_pass } else { test_fail @@ -145,7 +145,7 @@ if (invalid) { } # 16. Verify the lease is still associated with the previous device -if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.Pool-Name}%}:device:00:11:22:33:44:55'}") { +if (&reply.Framed-IP-Address == "%{redis:GET '{%{control.IP-Pool.Name}%}:device:00:11:22:33:44:55'}") { test_pass } else { test_fail diff --git a/src/tests/modules/redis_ippool/update_alloc.unlang b/src/tests/modules/redis_ippool/update_alloc.unlang index 45469d43304..82a1a17bc6b 100644 --- a/src/tests/modules/redis_ippool/update_alloc.unlang +++ b/src/tests/modules/redis_ippool/update_alloc.unlang @@ -4,14 +4,14 @@ $INCLUDE cluster_reset.inc update control { - &Pool-Name := 'test_update' + &IP-Pool.Name := 'test_update' } # # Add IP addresses # update request { - &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.Pool-Name} 192.168.0.0` + &Tmp-String-0 := `./build/bin/local/rlm_redis_ippool_tool -a 192.168.0.1/32 $ENV{REDIS_IPPOOL_TEST_SERVER}:30001 %{control.IP-Pool.Name} 192.168.0.0` } # 1. Check allocation @@ -40,7 +40,7 @@ if (&reply.Session-Timeout == 60) { } # 4. Verify the gateway was set -if ("%{redis:HGET {%{control.Pool-Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { +if ("%{redis:HGET {%{control.IP-Pool.Name}%}:ip:%{reply.Framed-IP-Address} gateway}" == '127.0.0.1') { test_pass } else { test_fail