Reorganise SQL files
[freeradius.git] / raddb / sql / main / postgresql / extras / voip-postpaid.conf
1 # -*- text -*-
2 ##
3 ## voip-postpaid.conf -- PostgreSQL configuration for H323 VoIP billingx
4 ##                       (cisco_h323_db_schema.sql)
5 ##
6 ##      $Id$
7
8 sql pgsql-voip {
9
10         # Database type currently must be rlm_sql_postgresql to work with this setup.
11         driver = "rlm_sql_postgresql"
12
13         # Connect info
14         server = "localhost"
15         login = "postgres"
16         password = ""
17         
18         # Database configuration
19         radius_db = "radius"
20                 
21         # Database table configuration
22         acct_table1 = "Start"
23         acct_table2 = "Stop"
24                 
25         authcheck_table = "radcheck"
26         authreply_table = "radreply"
27         
28         groupcheck_table = "radgroupcheck"
29         groupreply_table = "radgroupreply"
30         
31         usergroup_table = "radusergroup"
32         
33         # Remove stale session if checkrad does not see a double login
34         deletestalesessions = yes
35
36         # Print all SQL statements when in debug mode (-x)
37         sqltrace = no
38         sqltracefile = ${logdir}/sqltrace.sql
39
40         # number of sql connections to make to server
41         num_sql_socks = 25
42         
43         # Radius server name so you can tell which radius server handled a request
44         # when you have multiple radius servers and one database.
45         radius_server_name = FreeRADIUS
46
47         #######################################################################
48         #  Query config:  Username
49         #######################################################################
50         # This is the username that will get substituted, escaped, and added 
51         # as attribute 'SQL-User-Name'.  '%{SQL-User-Name}' should be used below 
52         # everywhere a username substitution is needed so you you can be sure 
53         # the username passed from the client is escaped properly.  
54         #
55         #  Uncomment the next line, if you want the sql_user_name to mean:
56         #
57         #    Use Stripped-User-Name, if it's there.
58         #    Else use User-Name, if it's there,
59         #    Else use hard-coded string "none" as the user name.
60         #
61         #sql_user_name = "%{Stripped-User-Name:-%{User-Name:-none}}"
62         #
63         sql_user_name = "%{User-Name}"
64
65
66         #######################################################################
67         #  Accounting Queries
68         #######################################################################
69         # accounting_onoff_query        - query for Accounting On/Off packets 
70         # accounting_update_query       - query for Accounting update packets 
71         # accounting_update_query_alt   - query for Accounting update packets 
72         #                               (alternate in case first query fails)
73         # accounting_start_query        - query for Accounting start packets 
74         # accounting_start_query_alt    - query for Accounting start packets 
75         #                               (alternate in case first query fails)
76         # accounting_stop_query         - query for Accounting stop packets 
77         # accounting_stop_query_alt     - query for Accounting start packets 
78         #                               (alternate in case first query doesn't
79         #                                affect any existing rows in the table)
80         #######################################################################
81
82         # Note: The VoIP accouting does not need Alternate queries in the shipped
83         # configuration as all queries are INSERTS, hence should always work.
84         # If they do not work then you probably have duplicate records in your table.
85         
86
87         accounting_start_query = "INSERT into ${acct_table1}%{h323-call-type} \
88                 (RadiusServerName, UserName, NASIPAddress, AcctTime, CalledStationId, \
89                 CallingStationId, AcctDelayTime, h323gwid, h323callorigin, h323setuptime, H323ConnectTime, callid) \
90                 values('${radius_server_name}', '%{SQL-User-Name}', \
91                 '%{NAS-IP-Address}', now(), '%{Called-Station-Id}', \
92                 '%{Calling-Station-Id}', '%{Acct-Delay-Time:-0}', '%{h323-gw-id}', \
93                 '%{h323-call-origin}', strip_dot('%{h323-setup-time}'), strip_dot('%{h323-connect-time}'), pick_id('%{h323-conf-id}', '%{call-id}'))"
94
95
96         accounting_stop_query = "INSERT into ${acct_table2}%{h323-call-type} \
97                 (RadiusServerName, UserName, NASIPAddress, AcctTime, \
98                 AcctSessionTime, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, \
99                 AcctDelayTime, H323RemoteAddress, H323VoiceQuality, CiscoNASPort, h323callorigin, callid, \
100                 h323connecttime, h323disconnectcause, h323disconnecttime, h323gwid, h323setuptime) \
101                 values('${radius_server_name}', '%{SQL-User-Name}', '%{NAS-IP-Address}', now(), '%{Acct-Session-Time:-0}', \
102                 '%{Acct-Input-Octets:-0}', '%{Acct-Output-Octets:-0}', '%{Called-Station-Id}', '%{Calling-Station-Id}', \
103                 '%{Acct-Delay-Time:-0}', NULLIF('%{h323-remote-address}', '')::inet, NULLIF('%{h323-voice-quality}','')::integer, NULLIF('%{Cisco-NAS-Port}', ''), \
104                 '%{h323-call-origin}', pick_id('%{h323-conf-id}', '%{call-id}'), strip_dot('%{h323-connect-time}'), '%{h323-disconnect-cause}', \
105                 strip_dot('%{h323-disconnect-time}'), '%{h323-gw-id}', strip_dot('%{h323-setup-time}'))"
106  
107
108 }