1 CREATE OR REPLACE FUNCTION msqlippool(user varchar2, pool varchar2)
\r
4 PRAGMA AUTONOMOUS_TRANSACTION;
\r
5 ip_temp varchar2(20);
\r
8 -- If the user's pool is dynamic, get an ipaddress (oldest one) from the corresponding pool
\r
10 if pool = 'Dynamic' then
\r
11 select framedipaddress into ip_temp from (select framedipaddress from radippool where expiry_time < current_timestamp and pool_name = pool ORDER BY expiry_time) where rownum = 1;
\r
14 -- Else, then get the static ipaddress for that user from the corresponding pool
\r
17 select framedipaddress into ip_temp from radippool where username = user and pool_name = pool;
\r
23 -- This block is executed if there's no free ipaddresses or no static ip assigned to the user
\r
25 when NO_DATA_FOUND then
\r
26 if pool = 'Dynamic' then
\r
27 return(''); -- so sqlippool can log it on radius.log
\r
30 -- Else, grabs a free IP from the static pool and saves it in radippool so the user will always get the same IP the next time
\r
32 select framedipaddress into ip_temp from (select framedipaddress from radippool where expiry_time < current_timestamp and username is null and pool_name = pool) where rownum = 1;
\r
33 UPDATE radippool SET username = user where framedipaddress = ip_temp;
\r
38 then return('Oracle Exception');
\r