]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
just assign DHCP-Your-IP-Address natively
authorAlan T. DeKok <aland@freeradius.org>
Tue, 14 Nov 2017 20:18:42 +0000 (15:18 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 14 Nov 2017 20:19:02 +0000 (15:19 -0500)
raddb/mods-available/dhcp_sqlippool
raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf
raddb/mods-config/sql/ippool-dhcp/oracle/queries.conf
raddb/mods-config/sql/ippool-dhcp/sqlite/queries.conf
raddb/policy.d/dhcp

index 7739a6066ba5ee794c04324179b62f047724e5d1..c0c1d716913b0c59018260a48857e35b3da20e2a 100644 (file)
@@ -22,6 +22,9 @@ sqlippool dhcp_sqlippool {
        # Client's MAC address is mapped to Calling-Station-Id in policy.conf
        pool_key = "%{Calling-Station-Id}"
 
+       # Attribute name
+       attribute_name = DHCP-Your-IP-Address
+
        # For now, it works with MySQL.
        $INCLUDE ${modconfdir}/sql/ippool-dhcp/mysql/queries.conf
 
@@ -31,11 +34,11 @@ sqlippool dhcp_sqlippool {
        # raddb/mods-config/sql/main/sqlite/queries.conf.
        # $INCLUDE ${modconfdir}/sql/ippool-dhcp/sqlite/queries.conf
 
-       sqlippool_log_exists = "DHCP: Existing IP: %{reply:Framed-IP-Address} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})"
+       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:Framed-IP-Address} 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:Pool-Name} (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} user %{User-Name})"
 
-       sqlippool_log_clear = "DHCP: Released IP %{Framed-IP-Address} (did %{Called-Station-Id} cli %{Calling-Station-Id} 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})"
 
index d4d390afc633cf220ba00f796bb5d6ac453e0c49..2b7add4c8e4cb7fcd373c1a2f6bcba11af026e48 100644 (file)
@@ -107,7 +107,7 @@ start_update = "\
        AND pool_key = '${pool_key}' \
        AND username = '%{User-Name}' \
        AND callingstationid = '%{Calling-Station-Id}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This series of queries frees an IP number when an accounting
@@ -124,7 +124,7 @@ stop_clear = "UPDATE ${ippool_table} \
        AND pool_key = '${pool_key}' \
        AND username = '%{User-Name}' \
        AND callingstationid = '%{Calling-Station-Id}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This series of queries frees an IP number when an accounting
@@ -138,7 +138,7 @@ alive_update = "\
        AND pool_key = '${pool_key}' \
        AND username = '%{User-Name}' \
        AND callingstationid = '%{Calling-Station-Id}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This series of queries frees the IP numbers allocate to a
index 673547bb9aa4fb52966e81424e1a67600b047dcc..dacdcd86ef3eefcbf4064bb6a114e93aa606a5dc 100644 (file)
@@ -130,7 +130,7 @@ start_update = "\
        WHERE nasipaddress = '%{NAS-IP-Address}' \
        AND pool_name = '%{control:Pool-Name}' \
        AND pool_key = '${pool_key}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This query frees an IP address when an accounting
@@ -152,7 +152,7 @@ alive_update = "\
                expiry_time = CURRENT_TIMESTAMP + INTERVAL '${lease_duration}' SECOND(1) \
        WHERE pool_key = '${pool_key}' \
        AND pool_name = '%{control:Pool-Name}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This query frees all IP addresses allocated to a NAS when an
index a42713506e55972346e02727cbd0a36a3f72644b..a5544416957d7434bdfa62cb939c075e33b68b31 100644 (file)
@@ -104,7 +104,7 @@ start_update = "\
        AND pool_key = '${pool_key}' \
        AND username = '%{User-Name}' \
        AND callingstationid = '%{Calling-Station-Id}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This series of queries frees an IP number when an accounting STOP record arrives
@@ -121,7 +121,7 @@ stop_clear = "\
        AND pool_key = '${pool_key}' \
        AND username = '%{User-Name}' \
        AND callingstationid = '%{Calling-Station-Id}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This series of queries frees an IP number when an accounting ALIVE record arrives
@@ -134,7 +134,7 @@ alive_update = "\
        AND pool_key = '${pool_key}' \
        AND username = '%{User-Name}' \
        AND callingstationid = '%{Calling-Station-Id}' \
-       AND framedipaddress = '%{Framed-IP-Address}'"
+       AND framedipaddress = '%{${attribute_name}}'"
 
 #
 #  This series of queries frees the IP numbers allocate to a
index 8ed03a664c6dc4a10cf9da0335cf79bbce6dff20..44f560e80aa7fcb4af570a9930f611fd166bbb80 100644 (file)
@@ -13,13 +13,5 @@ dhcp_sqlippool.post-auth {
 
        #  Call the actual module
        dhcp_sqlippool
-
-       #  Convert Framed-IP-Address to DHCP, but only if we
-       #  actually allocated an address.
-       if (ok) {
-               update reply {
-                       &DHCP-Your-IP-Address = "%{reply:Framed-IP-Address}"
-               }
-       }
 }