]> git.pld-linux.org Git - packages/freeradius-server.git/blame - failed_calls_accounting.patch
Up to 3.0.17, work in progress
[packages/freeradius-server.git] / failed_calls_accounting.patch
CommitLineData
7d859cd4
MM
1Index: man/man5/rlm_sql.5
2===================================================================
3RCS file: /source/radiusd/man/man5/rlm_sql.5,v
4retrieving revision 1.4
5diff -u -r1.4 rlm_sql.5
6--- man/man5/rlm_sql.5 16 Mar 2008 15:39:10 -0000 1.4
7+++ man/man5/rlm_sql.5 22 Jul 2009 13:09:15 -0000
8@@ -118,6 +118,8 @@
9 .IP accounting_stop_query_alt
10 The query to be run when receiving an Accounting Stop packet. If the
11 primary query fails, the alt query is run.
12+.IP accounting_failed_query
13+The query to be run when receiving a Failed Packet.
14 .IP simul_count_query
15 The query to be run to return the number simultaneous sessions for the
16 purposes of limiting Simultaneous Use.
17Index: raddb/sql/mssql/dialup.conf
18===================================================================
19RCS file: /source/radiusd/raddb/sql/mssql/dialup.conf,v
20retrieving revision 1.4
21diff -u -r1.4 dialup.conf
22--- raddb/sql/mssql/dialup.conf 30 Apr 2008 08:33:39 -0000 1.4
23+++ raddb/sql/mssql/dialup.conf 22 Jul 2009 13:09:15 -0000
24@@ -66,6 +66,7 @@
25 # accounting_stop_query_alt - query for Accounting start packets
26 # (alternate in case first query doesn't
27 # affect any existing rows in the table)
28+ # accounting_failed_query - query for Accounting failed packets
29 #######################################################################
30 accounting_onoff_query = "UPDATE ${acct_table1} SET AcctStopTime='%S', AcctSessionTime=unix_timestamp('%S') - unix_timestamp(AcctStartTime), AcctTerminateCause='%{Acct-Terminate-Cause}', AcctStopDelay = %{Acct-Delay-Time:-0} WHERE AcctStopTime=0 AND NASIPAddress= '%{NAS-IP-Address}' AND AcctStartTime <= '%S'"
31
32@@ -88,3 +89,7 @@
33 # removed. These fields are processing by a database
34 accounting_stop_query_alt = "INSERT into ${acct_table2} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPort, NASPortType, AcctStopTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay) values('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port-Id}', '%{NAS-Port-Type}', '%S', '%{Acct-Session-Time}', '%{Acct-Authentic}', '', '%{Connect-Info}', '%{Acct-Input-Octets}', '%{Acct-Output-Octets}', '%{Called-Station-Id}', '%{Calling-Station-Id}', '%{Acct-Terminate-Cause}', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '0', '%{Acct-Delay-Time:-0}')"
35
36+ # accounting_failed_query: Inserting of RadAcctId and AcctStopTime was
37+ # removed. These fields are processing by a database
38+ accounting_start_query = "INSERT into ${acct_table1} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPort, NASPortType, AcctStartTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay, XAscendSessionSvrKey) \
39+ VALUES('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port-Id}', '%{NAS-Port-Type}', '%S', '0', '%{Acct-Authentic}', '%{Connect-Info}', '', '0', '0', '%{Called-Station-Id}', '%{Calling-Station-Id}', '', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '%{Acct-Delay-Time}', '0', '%{X-Ascend-Session-Svr-Key}')"
40Index: raddb/sql/mysql/dialup.conf
41===================================================================
42RCS file: /source/radiusd/raddb/sql/mysql/dialup.conf,v
43retrieving revision 1.8
44diff -u -r1.8 dialup.conf
45--- raddb/sql/mysql/dialup.conf 3 May 2008 17:16:07 -0000 1.8
46+++ raddb/sql/mysql/dialup.conf 22 Jul 2009 13:09:15 -0000
47@@ -135,6 +135,7 @@
48 # accounting_stop_query_alt - query for Accounting start packets
49 # (alternate in case first query doesn't
50 # affect any existing rows in the table)
51+ # accounting_failed_query - query for Accounting failed packets
52 #######################################################################
53 accounting_onoff_query = "\
54 UPDATE ${acct_table1} \
55@@ -263,6 +264,27 @@
56 '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', \
57 '0', '%{%{Acct-Delay-Time}:-0}')"
58
59+ accounting_failed_query = " \
60+ INSERT INTO ${acct_table1} \
61+ (acctsessionid, acctuniqueid, username, \
62+ realm, nasipaddress, nasportid, \
63+ nasporttype, acctstarttime, acctstoptime, \
64+ acctsessiontime, acctauthentic, connectinfo_start, \
65+ connectinfo_stop, acctinputoctets, acctoutputoctets, \
66+ calledstationid, callingstationid, acctterminatecause, \
67+ servicetype, framedprotocol, framedipaddress, \
68+ acctstartdelay, acctstopdelay, xascendsessionsvrkey) \
69+ VALUES \
70+ ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
71+ '%{SQL-User-Name}', \
72+ '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
73+ '%{NAS-Port-Type}', '%S', NULL, \
74+ '0', '%{Acct-Authentic}', '%{Connect-Info}', \
75+ '', '0', '0', \
76+ '%{Called-Station-Id}', '%{Calling-Station-Id}', '', \
77+ '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', \
78+ '%{%{Acct-Delay-Time}:-0}', '0', '%{X-Ascend-Session-Svr-Key}')"
79+
80 #######################################################################
81 # Simultaneous Use Checking Queries
82 #######################################################################
83Index: raddb/sql/oracle/dialup.conf
84===================================================================
85RCS file: /source/radiusd/raddb/sql/oracle/dialup.conf,v
86retrieving revision 1.4
87diff -u -r1.4 dialup.conf
88--- raddb/sql/oracle/dialup.conf 30 Apr 2008 08:33:39 -0000 1.4
89+++ raddb/sql/oracle/dialup.conf 22 Jul 2009 13:09:15 -0000
90@@ -95,6 +95,7 @@
91 # accounting_stop_query_alt - query for Accounting start packets
92 # (alternate in case first query doesn't
93 # affect any existing rows in the table)
94+ # accounting_failed_query - query for Accounting failed packets
95 #######################################################################
96 accounting_onoff_query = "UPDATE ${acct_table1} SET AcctStopTime=TO_DATE('%S','yyyy-mm-dd hh24:mi:ss'), AcctSessionTime=((TO_DATE('%S','yyyy-mm-dd hh24:mi:ss') - AcctStartTime)*86400), AcctTerminateCause='%{Acct-Terminate-Cause}', AcctStopDelay = %{Acct-Delay-Time:-0} WHERE AcctStopTime IS NULL AND NASIPAddress = '%{NAS-IP-Address}' AND AcctStartTime <= TO_DATE('%S','yyyy-mm-dd hh24:mi:ss')"
97
98@@ -142,6 +143,9 @@
99 '%{Called-Station-Id}', '%{Calling-Station-Id}', '%{Acct-Terminate-Cause}', '%{Service-Type}', \
100 '%{Framed-Protocol}', '%{Framed-IP-Address}', '0', '%{Acct-Delay-Time:-0}')"
101
102+accounting_failed_query = "INSERT into ${acct_table1} (RadAcctId, AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctStopTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay, XAscendSessionSvrKey) \
103+ VALUES('', '%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port-Id}', '%{NAS-Port-Type}', TO_DATE('%S','yyyy-mm-dd hh24:mi:ss'), NULL, '0', '%{Acct-Authentic}', '%{Connect-Info}', '', '0', '0', '%{Called-Station-Id}', '%{Calling-Station-Id}', '', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '%{Acct-Delay-Time}', '0', '%{X-Ascend-Session-Svr-Key}')"
104+
105 #######################################################################
106 # Simultaneous Use Checking Queries
107 #######################################################################
108Index: raddb/sql/postgresql/dialup.conf
109===================================================================
110RCS file: /source/radiusd/raddb/sql/postgresql/dialup.conf,v
111retrieving revision 1.9
112diff -u -r1.9 dialup.conf
113--- raddb/sql/postgresql/dialup.conf 30 Apr 2008 08:33:40 -0000 1.9
114+++ raddb/sql/postgresql/dialup.conf 22 Jul 2009 13:09:15 -0000
115@@ -153,6 +153,7 @@
116 # accounting_stop_query_alt - query for Accounting start packets
117 # (alternate in case first query doesn't
118 # affect any existing rows in the table)
119+# accounting_failed_query - query for Accounting failed packets
120 #######################################################################
121
122 accounting_onoff_query = "UPDATE ${acct_table1} \
123@@ -262,6 +263,29 @@
124 '%{Framed-Protocol}', \
125 NULLIF('%{Framed-IP-Address}', '')::inet, 0)"
126
127+accounting_failed_query = "INSERT INTO ${acct_table1} \
128+ (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, \
129+ NASPortId, NASPortType, AcctStartTime, AcctAuthentic, \
130+ ConnectInfo_start, CalledStationId, CallingStationId, ServiceType, \
131+ FramedProtocol, FramedIPAddress, AcctStartDelay, XAscendSessionSvrKey) \
132+ VALUES('%{Acct-Session-Id}', \
133+ '%{Acct-Unique-Session-Id}', \
134+ '%{SQL-User-Name}', \
135+ NULLIF('%{Realm}', ''), \
136+ '%{NAS-IP-Address}', \
137+ %{%{NAS-Port}:-NULL}::integer, \
138+ '%{NAS-Port-Type}', \
139+ ('%S'::timestamp - '%{%{Acct-Delay-Time}:-0}'::interval), \
140+ '%{Acct-Authentic}', \
141+ '%{Connect-Info}', \
142+ '%{Called-Station-Id}', \
143+ '%{Calling-Station-Id}', \
144+ '%{Service-Type}', \
145+ '%{Framed-Protocol}', \
146+ NULLIF('%{Framed-IP-Address}', '')::inet, \
147+ 0, \
148+ '%{X-Ascend-Session-Svr-Key}')"
149+
150 #######################################################################
151 # Group Membership Queries
152 #######################################################################
153Index: src/include/radius.h
154===================================================================
155RCS file: /source/radiusd/src/include/radius.h,v
156retrieving revision 1.93
157diff -u -r1.93 radius.h
158--- src/include/radius.h 25 Apr 2008 06:20:55 -0000 1.93
159+++ src/include/radius.h 22 Jul 2009 13:09:15 -0000
160@@ -286,6 +286,7 @@
161 #define PW_STATUS_ALIVE 3
162 #define PW_STATUS_ACCOUNTING_ON 7
163 #define PW_STATUS_ACCOUNTING_OFF 8
164+#define PW_STATUS_FAILED 15
165
166 /*
167 * Vendor Private Enterprise Codes
168Index: src/modules/rlm_sql/conf.h
169===================================================================
170RCS file: /source/radiusd/src/modules/rlm_sql/conf.h,v
171retrieving revision 1.25
172diff -u -r1.25 conf.h
173--- src/modules/rlm_sql/conf.h 14 Nov 2006 21:22:29 -0000 1.25
174+++ src/modules/rlm_sql/conf.h 22 Jul 2009 13:09:16 -0000
175@@ -32,6 +32,7 @@
176 char *accounting_start_query_alt;
177 char *accounting_stop_query;
178 char *accounting_stop_query_alt;
179+ char *accounting_failed_query;
180 char *simul_count_query;
181 char *simul_verify_query;
182 char *groupmemb_query;
183@@ -74,7 +75,7 @@
184
185 #define ASCEND_PORT_HACK
186 #define ASCEND_CHANNELS_PER_LINE 23
187-#define CISCO_ACCOUNTING_HACK
188+/* #define CISCO_ACCOUNTING_HACK */
189
190 /* SQL defines */
191 #define MAX_QUERY_LEN 4096
192Index: src/modules/rlm_sql/rlm_sql.c
193===================================================================
194RCS file: /source/radiusd/src/modules/rlm_sql/rlm_sql.c,v
195retrieving revision 1.182
196diff -u -r1.182 rlm_sql.c
197--- src/modules/rlm_sql/rlm_sql.c 13 Jun 2008 12:30:07 -0000 1.182
198+++ src/modules/rlm_sql/rlm_sql.c 22 Jul 2009 13:09:16 -0000
199@@ -89,6 +89,8 @@
200 offsetof(SQL_CONFIG,accounting_stop_query), NULL, ""},
201 {"accounting_stop_query_alt", PW_TYPE_STRING_PTR,
202 offsetof(SQL_CONFIG,accounting_stop_query_alt), NULL, ""},
203+ {"accounting_failed_query", PW_TYPE_STRING_PTR,
204+ offsetof(SQL_CONFIG,accounting_failed_query), NULL, ""},
205 {"group_membership_query", PW_TYPE_STRING_PTR,
206 offsetof(SQL_CONFIG,groupmemb_query), NULL, NULL},
207 {"connect_failure_retry_delay", PW_TYPE_INTEGER,
208@@ -1287,6 +1289,32 @@
209 }
210 break;
211
212+ /*
213+ * Got accounting failed packet
214+ */
215+ case PW_STATUS_FAILED:
216+ /*
217+ * Set, escape, and check the user attr here
218+ */
219+ sql_set_user(inst, request, sqlusername, NULL);
220+
221+ radius_xlat(querystr, sizeof(querystr), inst->config->accounting_failed_query, request, sql_escape_func);
222+ query_log(request, inst, querystr);
223+
224+ sqlsocket = sql_get_socket(inst);
225+ if (sqlsocket == NULL)
226+ return(RLM_MODULE_FAIL);
227+ if (*querystr) { /* non-empty query */
228+ if (rlm_sql_query(sqlsocket, inst, querystr)) {
229+ radlog(L_ERR, "rlm_sql (%s): Couldn't insert SQL accounting FAILED record - %s",
230+ inst->config->xlat_name,
231+ (char *)(inst->module->sql_error)(sqlsocket, inst->config));
232+ ret = RLM_MODULE_FAIL;
233+ }
234+ (inst->module->sql_finish_query)(sqlsocket, inst->config);
235+ }
236+ break;
237+
238 /*
239 * Anything else is ignored.
240 */
This page took 0.061248 seconds and 4 git commands to generate.