]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Rename mod_extend as mod_update, plus associated queries
authorNick Porter <nick@portercomputing.co.uk>
Tue, 25 Aug 2020 09:22:10 +0000 (10:22 +0100)
committerAlan DeKok <aland@freeradius.org>
Wed, 9 Sep 2020 12:45:16 +0000 (08:45 -0400)
raddb/mods-config/sql/ippool-dhcp/mssql/queries.conf
raddb/mods-config/sql/ippool-dhcp/mysql/queries.conf
raddb/mods-config/sql/ippool-dhcp/oracle/queries.conf
raddb/mods-config/sql/ippool-dhcp/postgresql/queries.conf
raddb/mods-config/sql/ippool-dhcp/sqlite/queries.conf
raddb/mods-config/sql/ippool/mssql/queries.conf
raddb/mods-config/sql/ippool/mysql/queries.conf
raddb/mods-config/sql/ippool/oracle/queries.conf
raddb/mods-config/sql/ippool/postgresql/queries.conf
raddb/mods-config/sql/ippool/sqlite/queries.conf
src/modules/rlm_sqlippool/rlm_sqlippool.c

index a0d5053e29e76fe408217125c90319e73d071614..f8197eb3f56db989f01fe3f27edf671fd72925e4 100644 (file)
@@ -148,9 +148,9 @@ pool_check = "\
 #alloc_commit = ""
 
 #
-#  Queries to extend a lease - used in response to DHCP-Request packets
+#  Queries to update a lease - used in response to DHCP-Request packets
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET expiry_time = DATEADD(SECOND,${lease_duration},CURRENT_TIMESTAMP) \
        WHERE pool_name = '%{control:${pool_name}}' \
index de38d38182785a44057b13be367e8f010216cb40..485d2e4ceef22048a091fe47c178dbf01286487f 100644 (file)
@@ -113,9 +113,9 @@ alloc_update = "\
 #alloc_commit = ""
 
 #
-#  Queries to extend a lease - used in response to DHCP-Request packets
+#  Queries to update a lease - used in response to DHCP-Request packets
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET expiry_time = 'now'::timesheet(0) + '${lease_duration} second'::interval \
        WHERE pool_name = '%{control:${pool_name}}' \
index c21ed0fdc0d37083f180a1a7ca5cd238a46b6771..fcc0cbc5ef4dcd6d8b2f6e41982bf99bb9976383 100644 (file)
@@ -103,16 +103,16 @@ pool_check = "\
 #      WHERE framedipaddress = '%I'"
 
 #
-#  Queries to extend a lease - used in response to DHCP-Request packets
+#  Queries to update a lease - used in response to DHCP-Request packets
 #
-extend_begin = "commit"
-extend_update = "\
+update_begin = "commit"
+update_update = "\
        UPDATE ${ippool_table} \
        SET expiry_time = current_timestamp + INTERVAL '${lease_duration}' second(1) \
        WHERE pool_name = '%{control:${pool_name}}' \
        AND pool_key = '${pool_key}' \
        AND framedipaddress = '%{DHCP-Requested-IP-Address}'"
-extend_commit = "commit"
+update_commit = "commit"
 
 #
 #  Queries to release a lease - used in response to DHCP-Release packets
index 61c0fe3d46b50b25e212a7a5174162209febbd11..195aa2199db336ced8e0dc94b4b356ad6909350f 100644 (file)
@@ -131,9 +131,9 @@ pool_check = "\
 #alloc_commit = ""
 
 #
-#  Queries to extend a lease - used in response to DHCP-Request packets
+#  Queries to update a lease - used in response to DHCP-Request packets
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET expiry_time = 'now'::timesheet(0) + '${lease_duration} second'::interval \
        WHERE pool_name = '%{control:${pool_name}}' \
index ed33801054ce14dd8ed11ad951f2db2c1ede8d20..46696f040550a8560bf06dd0ab72ff59b87bab32 100644 (file)
@@ -99,9 +99,9 @@ alloc_update = "\
        AND expiry_time IS NULL"
 
 #
-#  Queries to extend a lease - used in response to DHCP-Request packets
+#  Queries to update a lease - used in response to DHCP-Request packets
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET expiry_time = datetime(strftime('%%s', 'now') + ${lease_duration}, 'unixepoch') \
        WHERE pool_name = '%{control:${pool_name}}' \
index 1922adb5c33d3fcb21ac1ca303e5f5ca204c0e8b..52bcce24863f00eb949a73c445bdc52ba33de6dc 100644 (file)
@@ -114,9 +114,9 @@ pool_check = "\
 #alloc_commit = ""
 
 #
-#  This series of queries extends an IP lease when an accounting START / ALIVE record arrives.
+#  This query updates an IP lease when an accounting START / ALIVE record arrives.
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET \
                expiry_time = DATEADD(SECOND,${lease_duration},CURRENT_TIMESTAMP) \
index b4b781140a0057fb946ad3cdc01015fc9ac6fc0f..e3c5c559085672cfdff486e8c7323213479a2235 100644 (file)
@@ -136,9 +136,9 @@ alloc_update = "\
 #alloc_commit = ""
 
 #
-#  start_update updates allocation info when an accounting START / ALIVE record arrives.
+#  update_update updates allocation info when an accounting START / ALIVE record arrives.
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET \
                expiry_time = NOW() + INTERVAL ${lease_duration} SECOND \
index 0c080d0c54cf53b41ac8838ac162368287aefe49..c91baadbd7dc40f34ba86999f81f718f91053383 100644 (file)
@@ -130,8 +130,8 @@ alloc_update = "\
 #  This query extends an IP address lease by "lease_duration" when an accounting
 #  START / ALIVE record arrives
 #
-extend_begin = "commit"
-extend_update = "\
+update_begin = "commit"
+update_update = "\
        UPDATE ${ippool_table} \
        SET \
                expiry_time = current_timestamp + INTERVAL '${lease_duration}' second(1) \
@@ -140,7 +140,7 @@ extend_update = "\
        AND framedipaddress = '%{${attribute_name}}' \
        AND username = '%{SQL-User-Name}' \
        AND callingstationid = '%{%{Calling-Station-Id}:-0}'"
-extend_commit = "commit"
+update_commit = "commit"
 
 #
 #  This query frees an IP address when an accounting STOP record arrives
index 312ff60ea6a55784c64853fc9136d26f03394a72..a9321eda8bcdab4dc1439c6c59375be160817505 100644 (file)
@@ -138,7 +138,7 @@ pool_check = "\
 #  This query extends an IP address lease by "lease_duration" when an accounting
 #  START / ALIVE record arrives
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET \
                expiry_time = 'now'::timestamp(0) + '${lease_duration} second'::interval \
index 2164a65a5a23b1d75b118568fe74e0d2032767d1..7681f8a7e5677102051ef99b75dbaa8cdfbf15eb 100644 (file)
@@ -85,9 +85,9 @@ alloc_update = "\
        WHERE framedipaddress = '%I'"
 
 #
-#  Extend an IP when an accounting START / ALIVE record arrives
+#  Update an IP when an accounting START / ALIVE record arrives
 #
-extend_update = "\
+update_update = "\
        UPDATE ${ippool_table} \
        SET \
                expiry_time = datetime(strftime('%%s', 'now') + ${lease_duration}, 'unixepoch') \
index 66303f25bfaba1b31068c54c89914dfe862f45f4..ad135e1fee36fd8c78f62751fd39e668f2d030d5 100644 (file)
@@ -59,10 +59,10 @@ typedef struct {
 
        char const      *pool_check;            //!< Query to check for the existence of the pool.
 
-                                               /* Extend sequence */
-       char const      *extend_begin;          //!< SQL query to begin.
-       char const      *extend_update;         //!< SQL query to update an IP entry.
-       char const      *extend_commit;         //!< SQL query to commit.
+                                               /* Update sequence */
+       char const      *update_begin;          //!< SQL query to begin.
+       char const      *update_update;         //!< SQL query to update an IP entry.
+       char const      *update_commit;         //!< SQL query to commit.
 
                                                /* Release sequence */
        char const      *release_begin;         //!< SQL query to begin.
@@ -126,11 +126,11 @@ static CONF_PARSER module_config[] = {
        { FR_CONF_OFFSET("pool_check", FR_TYPE_STRING | FR_TYPE_XLAT, rlm_sqlippool_t, pool_check) },
 
 
-       { FR_CONF_OFFSET("extend_begin", FR_TYPE_STRING | FR_TYPE_XLAT, rlm_sqlippool_t, extend_begin) },
+       { FR_CONF_OFFSET("update_begin", FR_TYPE_STRING | FR_TYPE_XLAT, rlm_sqlippool_t, update_begin) },
 
-       { FR_CONF_OFFSET("extend_update", FR_TYPE_STRING | FR_TYPE_XLAT , rlm_sqlippool_t, extend_update) },
+       { FR_CONF_OFFSET("update_update", FR_TYPE_STRING | FR_TYPE_XLAT , rlm_sqlippool_t, update_update) },
 
-       { FR_CONF_OFFSET("extend_commit", FR_TYPE_STRING | FR_TYPE_XLAT, rlm_sqlippool_t, extend_commit) },
+       { FR_CONF_OFFSET("update_commit", FR_TYPE_STRING | FR_TYPE_XLAT, rlm_sqlippool_t, update_commit) },
 
 
        { FR_CONF_OFFSET("release_begin", FR_TYPE_STRING | FR_TYPE_XLAT, rlm_sqlippool_t, release_begin) },
@@ -620,9 +620,9 @@ static rlm_rcode_t CC_HINT(nonnull) mod_alloc(module_ctx_t const *mctx, REQUEST
 }
 
 /*
- *     Extend a lease.
+ *     Update a lease.
  */
-static rlm_rcode_t CC_HINT(nonnull) mod_extend(module_ctx_t const *mctx, REQUEST *request)
+static rlm_rcode_t CC_HINT(nonnull) mod_update(module_ctx_t const *mctx, REQUEST *request)
 {
        rlm_sqlippool_t         *inst = talloc_get_type_abort(mctx->instance, rlm_sqlippool_t);
        rlm_sql_handle_t        *handle;
@@ -638,9 +638,9 @@ static rlm_rcode_t CC_HINT(nonnull) mod_extend(module_ctx_t const *mctx, REQUEST
                return RLM_MODULE_FAIL;
        }
 
-       DO_PART(extend_begin);
+       DO_PART(update_begin);
 
-       affected = sqlippool_command(inst->extend_update, &handle, inst, request, NULL, 0);
+       affected = sqlippool_command(inst->update_update, &handle, inst, request, NULL, 0);
 
        if (affected < 0) {
        error:
@@ -648,18 +648,18 @@ static rlm_rcode_t CC_HINT(nonnull) mod_extend(module_ctx_t const *mctx, REQUEST
                return RLM_MODULE_FAIL;
        }
 
-       DO_PART(extend_commit);
+       DO_PART(update_commit);
 
        if (handle) fr_pool_connection_release(inst->sql_inst->pool, request, handle);
 
        if (affected > 0) {
                /*
-                * The lease has been extended - return OK
+                * The lease has been updated - return OK
                 */
                return do_logging(inst, request, inst->log_success, RLM_MODULE_OK);
        } else {
                /*
-                * The lease could not be extended - return notfound
+                * The lease could not be updated - return notfound
                 */
                return do_logging(inst, request, inst->log_failed, RLM_MODULE_NOTFOUND);
        }
@@ -729,9 +729,9 @@ static rlm_rcode_t CC_HINT(nonnull) mod_mark(module_ctx_t const *mctx, REQUEST *
 static int mod_accounting_start(rlm_sql_handle_t **handle,
                                rlm_sqlippool_t const *inst, REQUEST *request)
 {
-       DO(extend_begin);
-       DO(extend_update);
-       DO(extend_commit);
+       DO(update_begin);
+       DO(update_update);
+       DO(update_commit);
 
        return RLM_MODULE_OK;
 }
@@ -739,9 +739,9 @@ static int mod_accounting_start(rlm_sql_handle_t **handle,
 static int mod_accounting_alive(rlm_sql_handle_t **handle,
                                rlm_sqlippool_t const *inst, REQUEST *request)
 {
-       DO(extend_begin);
-       DO(extend_update);
-       DO(extend_commit);
+       DO(update_begin);
+       DO(update_update);
+       DO(update_commit);
        return RLM_MODULE_OK;
 }
 
@@ -819,11 +819,8 @@ static rlm_rcode_t CC_HINT(nonnull) mod_accounting(module_ctx_t const *mctx, REQ
 
        switch (acct_status_type) {
        case FR_STATUS_START:
-               rcode = mod_accounting_start(&handle, inst, request);
-               break;
-
        case FR_STATUS_ALIVE:
-               rcode = mod_accounting_alive(&handle, inst, request);
+               rcode = mod_update(mctx, request);
                break;
 
        case FR_STATUS_STOP:
@@ -866,7 +863,7 @@ module_t rlm_sqlippool = {
        },
        .method_names = (module_method_names_t[]){
                { "recv",       "DHCP-Discover",        mod_alloc },
-               { "recv",       "DHCP-Request",         mod_extend },
+               { "recv",       "DHCP-Request",         mod_update },
                { "recv",       "DHCP-Release",         mod_release },
                { "recv",       "DHCP-Decline",         mod_mark },