# # SQL connection information # sql-instance-name = "sql" # # This series of queries initialize an IP pool # init-query = "SELECT ip_address FROM radippool WHERE pool_name = '%P' ORDER BY ip_address FOR UPDATE" init-delete = "DELETE FROM radippool WHERE ip_address = '%I'" init-insert = "INSERT INTO radippool (pool_name, ip_address, nas_ip_address, nas_port, calling_station_id, expiry_time) VALUES ('%P', '%I', '', 0, '', NOW()-1)" # # This series of queries allocates an IP number # allocate-clear = "UPDATE radippool SET nas_ip_address = '', nas_port = 0, calling_station_id = '', expiry_time = NOW()-1 WHERE nas_ip_address = '%n' AND nas_port = '%p'" #NOTE to the "order by" section - #it'll _tries_ to leas the same IP for a user, when #he reconnect... allocate-find = "SELECT ip_address FROM radippool WHERE pool_name = '%P' AND expiry_time < NOW() ORDER BY pool_name, (username <> '%u'), (calling_station_id <> '%i'), expiry_time LIMIT 1 FOR UPDATE" allocate-update = "UPDATE radippool SET nas_ip_address = '%n', nas_port = '%p', calling_station_id = '%i', username = '%u', expiry_time = NOW()+'%J' WHERE ip_address = '%I'" # # This series of queries frees an IP number when an accounting # START record arrives # start-update = "UPDATE radippool SET expiry_time = NOW()+'%J' WHERE nas_ip_address = '%n' AND nas_port = '%p' AND pool_name = '%P'" # # This series of queries frees an IP number when an accounting # STOP record arrives # stop-clear = "UPDATE radippool SET nas_ip_address = '', nas_port = 0, calling_station_id = '', expiry_time = NOW()-1 WHERE nas_ip_address = '%n' AND nas_port = '%p' AND pool_name = '%P'" # # This series of queries frees an IP number when an accounting # ALIVE record arrives # alive-update = "UPDATE radippool SET expiry_time = NOW()+'%J' WHERE nas_ip_address = '%n' AND nas_port = '%p' AND pool_name = '%P'" # # This series of queries frees the IP numbers allocate to a # NAS when an accounting ON record arrives # on-clear = "UPDATE radippool SET nas_ip_address = '', nas_port = 0, calling_station_id = '', expiry_time = NOW()-1 WHERE nas_ip_address = '%n' AND pool_name = '%P'" # # This series of queries frees the IP numbers allocate to a # NAS when an accounting OFF record arrives # off-clear = "UPDATE radippool SET nas_ip_address = '', nas_port = 0, calling_station_id = '', expiry_time = NOW()-1 WHERE nas_ip_address = '%n' AND pool_name = '%P'"