forked from FreeRADIUS/freeradius-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Firebird is not compatible with MS SQL queries
It is a fork of InterBase rather Sybase
- Loading branch information
Showing
5 changed files
with
774 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
# -*- text -*- | ||
# | ||
# ippool/firebird/queries.conf -- Firebird queries for rlm_sqlippool | ||
# | ||
# $Id$ | ||
|
||
# | ||
# Using SKIP LOCKED significantly speeds up the allocation queries | ||
# however it requires Firebird >= 5.0 | ||
# | ||
# If you are using an older version of Firebird change the following | ||
# to be a blank string | ||
skip_locked = "SKIP LOCKED" | ||
|
||
# | ||
# RADIUS (Accounting-Start) | ||
# DHCPv4 (Discover) | ||
# | ||
|
||
# | ||
# This sequence of queries allocate an IP address from the Pool | ||
# | ||
# Firebird is inherently transaction based, and each of the queries | ||
# making up the allocation sequence are executed within a single | ||
# transaction - so there is no need to specifically start the transaction. | ||
# | ||
alloc_begin = "" | ||
|
||
# | ||
# This query attempts to re-allocate the most recent IP address | ||
# for the client | ||
alloc_existing = "\ | ||
UPDATE ${ippool_table} \ | ||
SET expiry_time = DATEADD(${offer_duration} SECOND TO CURRENT_TIMESTAMP), \ | ||
gateway = '${gateway}' \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND owner = '${owner}' \ | ||
AND status_id IN (SELECT status_id FROM fr_ippool_status WHERE status IN ('dynamic', 'static')) \ | ||
ORDER BY expiry_time DESC \ | ||
ROWS 1 ${skip_locked} \ | ||
RETURNING address" | ||
|
||
# | ||
# If the preceding query doesn't find an address then the following | ||
# can be used to check for the address requested by the client | ||
# | ||
alloc_requested = "\ | ||
UPDATE ${ippool_table} \ | ||
SET owner = '${owner}', \ | ||
expiry_time = DATEADD(${offer_duration} SECOND TO CURRENT_TIMESTAMP), \ | ||
gateway = '${gateway}' \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND address = '%{${requested_address} || 0.0.0.0}' \ | ||
AND expiry_time < CURRENT_TIMESTAMP \ | ||
AND status_id IN (SELECT status_id FROM fr_ippool_status WHERE status = 'dynamic') \ | ||
ROWS 1 ${skip_locked} \ | ||
RETURNING address" | ||
|
||
# | ||
# If the preceding query doesn't find an address the following one | ||
# is used for finding one from the pool | ||
# | ||
alloc_find = "\ | ||
UPDATE ${ippool_table} \ | ||
SET owner = '${owner}', \ | ||
expiry_time = DATEADD(${offer_duration} SECOND TO CURRENT_TIMESTAMP), \ | ||
gateway = '${gateway}' \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND expiry_time < CURRENT_TIMESTAMP \ | ||
AND status_id IN (SELECT status_id FROM fr_ippool_status WHERE status = 'dynamic') \ | ||
ORDER BY expiry_time \ | ||
ROWS 1 ${skip_locked} \ | ||
RETURNING address" | ||
|
||
# | ||
# This query marks the IP address handed out by "alloc_find" as used | ||
# for the period of "offer_duration" after which time it may be reused. | ||
# It is only needed if the SELECT query does not perform the update. | ||
# | ||
#alloc_update = "\ | ||
# UPDATE ${ippool_table} \ | ||
# SET \ | ||
# gateway = '${gateway}', \ | ||
# owner = '${owner}', \ | ||
# expiry_time = DATEADD(${offer_duration} SECOND TO CURRENT_TIMESTAMP), \ | ||
# WHERE address = '%{${allocated_address_attr}}' \ | ||
# AND pool_name = '%{${pool_name}}'" | ||
|
||
# | ||
# The transaction used to execute the previous queries is automatically | ||
# committed when a successful allocation has happened - so there is | ||
# no requirement to call COMMIT. | ||
# | ||
alloc_commit = "" | ||
|
||
# | ||
# If an IP could not be allocated, check to see whether the pool exists or not | ||
# This allows the module to differentiate between a full pool and no pool | ||
# Note: If you are not running redundant pool modules this query may be commented | ||
# out to save running this query every time an ip is not allocated. | ||
# | ||
pool_check = "\ | ||
SELECT id \ | ||
FROM ${ippool_table} \ | ||
WHERE pool_name='%{${pool_name}}' \ | ||
FETCH FIRST ROW ONLY" | ||
|
||
# | ||
# RADIUS (Interim-Update) | ||
# DHCPv4 (Request) | ||
# | ||
|
||
# | ||
# Query used to clear any other addresses that have been offered to the client | ||
# | ||
update_free = "\ | ||
UPDATE ${ippool_table} \ | ||
SET \ | ||
gateway = '', \ | ||
owner = '', \ | ||
expiry_time = DATEADD(-1 SECOND TO CURRENT_TIMESTAMP) \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND owner = '${owner}' \ | ||
AND address <> '${requested_address}' \ | ||
AND expiry_time > 'now'::timestamp(0) \ | ||
AND status_id IN (SELECT status_id FROM fr_ippool_status WHERE status = 'dynamic')" | ||
|
||
# | ||
# Queries to update a lease. | ||
# This query must update a row when a lease is successfully requested - | ||
# queries that update no rows will result in a "notfound" response to | ||
# the module which by default will give a NAK reply. In this example | ||
# incrementing "counter" is used to achieve this. | ||
# | ||
update_update = "\ | ||
UPDATE ${ippool_table} \ | ||
SET \ | ||
expiry_time = DATEADD(${lease_duration} SECOND TO CURRENT_TIMESTAMP), \ | ||
gateway = '${gateway}', \ | ||
counter = counter + 1 \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND owner = '${owner}' \ | ||
AND address = '${requested_address}'" | ||
|
||
# | ||
# RADIUS (Accounting-Stop) | ||
# DHCPv4 (Release) | ||
# | ||
|
||
# | ||
# Queries to release a lease. | ||
# | ||
release_clear = "\ | ||
UPDATE ${ippool_table} \ | ||
SET gateway = '', \ | ||
owner = '', \ | ||
expiry_time = DATEADD(-1 SECOND TO CURRENT_TIMESTAMP) \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND owner = '${owner}' \ | ||
AND address = '${requested_address}'" | ||
|
||
|
||
# | ||
# DHCPv4 (Decline) | ||
# | ||
|
||
# | ||
# Queries to mark leases as "bad" | ||
# | ||
mark_update = "\ | ||
UPDATE ${ippool_table} \ | ||
SET status = 'declined' \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND address = '${requested_address}' \ | ||
AND owner = '${owner}'" | ||
|
||
# | ||
# RADIUS (Accounting-On) | ||
# RADIUS (Accounting-Off) | ||
# | ||
|
||
# | ||
# Frees all IPs allocated to a gateway | ||
# | ||
bulk_release_clear = "\ | ||
UPDATE ${ippool_table} \ | ||
SET gateway = '', \ | ||
owner = '', \ | ||
expiry_time = DATEADD(-1 SECOND TO CURRENT_TIMESTAMP) \ | ||
WHERE pool_name = '%{${pool_name}}' \ | ||
AND gateway = '${gateway}'" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
CREATE TABLE fr_ippool_status ( | ||
status_id INTEGER PRIMARY KEY, | ||
status VARCHAR(10) NOT NULL | ||
); | ||
|
||
INSERT INTO fr_ippool_status (status_id, status) VALUES (1, 'dynamic'); | ||
INSERT INTO fr_ippool_status (status_id, status) VALUES (2, 'static'); | ||
INSERT INTO fr_ippool_status (status_id, status) VALUES (3, 'declined'); | ||
INSERT INTO fr_ippool_status (status_id, status) VALUES (4, 'disabled'); | ||
|
||
COMMIT; | ||
|
||
# | ||
# Table structure for table 'fr_ippool' | ||
# | ||
CREATE TABLE fr_ippool ( | ||
id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
pool_name VARCHAR(30) NOT NULL, | ||
address VARCHAR(43) DEFAULT '' NOT NULL, | ||
owner VARCHAR(128) DEFAULT '' NOT NULL, | ||
gateway VARCHAR(128) DEFAULT '' NOT NULL, | ||
expiry_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
status_id INTEGER DEFAULT 1 REFERENCES fr_ippool_status (status_id), | ||
counter INTEGER DEFAULT 1 NOT NULL | ||
); | ||
|
||
CREATE INDEX fr_ippool_poolname_expire ON fr_ippool (pool_name, expiry_time); | ||
CREATE INDEX fr_ippool_address ON fr_ippool (address); | ||
CREATE INDEX fr_ippool_poolname_poolkey ON fr_ippool (pool_name, owner, address); | ||
|
||
COMMIT; |
Oops, something went wrong.