Parsing IP and PHONE NUMBER from ACCOUNTING packet
zhongwei feng
fengzhw at gmail.com
Tue Dec 29 00:29:28 CET 2009
Hi, Michael Joyner:
1, read man unlang , more and more ;
2, understand regular express ...... importance ;
regular express can extract what you need .
3, mysql support regular express , or , use unlang .
processing maybe below:
accounting {
....
#Calling-Station-Id ="<sip:4784711856 at 192.168.32.19;user=phone>;tag=20c013a8+1+99ff0002+fdf42201"
if (Calling-Station-Id =~/@([^;]+);user=([a-z]+)>) {
update request {
orig_ip := %{1}
orig_phone := %{2}
}
}
sql
}
>
>Here are sample ATTRIBUTE VALUES:
>
>
>
>Calling-Station-Id =
>"<sip:4784711856 at 192.168.32.19;user=phone>;tag=20c013a8+1+99ff0002+fdf42201"
>
>
>
> PHONE NUMBER : 4784711856 ... To a
>variable %{orig_number}
>
> IP :
>192.168.32.19 ... To a variable %{orig_ip}
>
>
>
> Called-Station-Id =
>"<sip:14787458977 at 192.168.35.237;user=phone>"
>
>
>
> PHONE NUMBER : 14787458977 ... To a variable
>%{dest_number}
>
> IP :
>192.168.35.237... To a variable %{dest_ip}
>
>
>
>My goal is to include the new values in the SQL statement :
>
>
>
>.... the new fields above are in the UPDATE statement
>
> accounting_start_query_alt = "UPDATE ${acct_table1} SET orig_ip =
>'%{orig_ip}', orig_phone = '%{orig_phone}', dest_ip = '%{dest_ip}',
>dest_phone = '%{dest_phone}', AcctStartTime = '%S', AcctStartDelay =
>'%{Acct-Delay-Time}', ConnectInfo_start = '%{Connect-Info}' WHERE
>AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' AND
>NASIPAddress = '%{NAS-IP-Address}'"
>
>Thanks in advance for your assistance.
>
More information about the Freeradius-Users
mailing list