Browse code

default DB uris replaced with a #define now

Jiri Kuthan authored on 05/04/2003 14:06:10
Showing 16 changed files
... ...
@@ -32,6 +32,7 @@
32 32
  * 2003-03-11: New module interface (janakj)
33 33
  * 2003-03-16: flags export parameter added (janakj)
34 34
  * 2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
35
+ * 2003-04-05: default_uri #define used (jiri)
35 36
  */
36 37
 
37 38
 #include <stdio.h>
... ...
@@ -77,7 +78,7 @@ int (*sl_reply)(struct sip_msg* _msg, char* _str1, char* _str2);
77 78
 /*
78 79
  * Module parameter variables
79 80
  */
80
-char* db_url           = "sql://serro:47serro11@localhost/ser";
81
+char* db_url           = DEFAULT_RODB_URL;
81 82
 char* user_column      = "username";
82 83
 char* domain_column    = "domain";
83 84
 char* pass_column      = "ha1";
... ...
@@ -30,6 +30,7 @@
30 30
  * -------
31 31
  * 2003-03-11: New module interface (janakj)
32 32
  * 2003-03-16: flags export parameter added (janakj)
33
+ * 2003-04-05: default_uri #define used (jiri)
33 34
  */
34 35
 
35 36
 
... ...
@@ -51,7 +52,7 @@ static int child_init(int rank);
51 52
 /*
52 53
  * Module parameter variables
53 54
  */
54
-char* db_url = "sql://serro:47serro11@localhost/ser";
55
+char* db_url = DEFAULT_RODB_URL;
55 56
 int db_mode = 0;			/* Database usage mode: 0 = no cache, 1 = cache */
56 57
 char* domain_table = "domain";          /* Name of domain table */
57 58
 char* domain_col = "domain";            /* Name of domain column */
... ...
@@ -32,6 +32,7 @@
32 32
  *  2003-03-11 - New module interface (janakj)
33 33
  *  2003-03-16 - flags export parameter added (janakj)
34 34
  *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free
35
+ *  2003-04-05 default_uri #define used (jiri)
35 36
  */
36 37
 
37 38
 
... ...
@@ -72,7 +73,7 @@ static int hf_fixup(void** param, int param_no);
72 73
 /*
73 74
  * Module parameter variables
74 75
  */
75
-char* db_url       = "sql://serro:47serro11@localhost/ser";
76
+char* db_url       = DEFAULT_RODB_URL;
76 77
 
77 78
 char* table        = "grp";    /* Table name where group definitions are stored */
78 79
 char* user_col     = "username";
... ...
@@ -32,6 +32,7 @@
32 32
  * 2003-03-11  updated to the new module interface (andrei)
33 33
  *             removed non-constant intializers to some strs (andrei)
34 34
  * 2003-03-16  flags parameter added (janakj)
35
+ * 2003-04-05: default_uri #define used (jiri)
35 36
  */
36 37
 
37 38
 #include <stdio.h>
... ...
@@ -121,7 +122,7 @@ struct tm_binds tmb;
121 122
 
122 123
 /** parameters */
123 124
 
124
-char *db_url="sql://root@127.0.0.1/msilo";
125
+char *db_url=DEFAULT_DB_URL;
125 126
 char *db_table="silo";
126 127
 char *registrar=NULL; //"sip:registrar@iptel.org";
127 128
 int  expire_time=259200;
128 129
deleted file mode 100644
... ...
@@ -1,12 +0,0 @@
1
-#
2
-# acc module makefile
3
-#
4
-#
5
-# WARNING: do not run this directly, it should be run by the master Makefile
6
-
7
-auto_gen=
8
-NAME=radius_acc.so
9
-DEFS += -I$(LOCALBASE)/include
10
-LIBS=-L$(LOCALBASE)/lib -lradiusclient
11
-
12
-include ../../Makefile.modules
13 0
deleted file mode 100644
... ...
@@ -1,956 +0,0 @@
1
-/*
2
- * Radius accounting module. We log requests and replies by 
3
- * attaching to the callbacks in the transaction module. The 
4
- * accounting requests are constructed using the radiusclient
5
- * library into standard value pairs and sent to radius server.
6
- * All the retransmissions and server backup information is administered
7
- * by radiusclient either by the libray it self or the configuration
8
- * files. Look at the Radius AAA report for details.
9
- * 
10
- * @author Stelios Sidiroglou-Douskos <ssi@fokus.gmd.de>
11
- * $Id$
12
- *
13
- * Copyright (C) 2001-2003 Fhg Fokus
14
- *
15
- * This file is part of ser, a free SIP server.
16
- *
17
- * ser is free software; you can redistribute it and/or modify
18
- * it under the terms of the GNU General Public License as published by
19
- * the Free Software Foundation; either version 2 of the License, or
20
- * (at your option) any later version
21
- *
22
- * For a license to use the ser software under conditions
23
- * other than those described here, or to purchase support for this
24
- * software, please contact iptel.org by e-mail at the following addresses:
25
- *    info@iptel.org
26
- *
27
- * ser is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
- * GNU General Public License for more details.
31
- *
32
- * You should have received a copy of the GNU General Public License 
33
- * along with this program; if not, write to the Free Software 
34
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
- */
36
-
37
-
38
-#include <radiusclient.h>
39
-#include "../../parser/msg_parser.h"
40
-#include "../../str.h"
41
-#include <stdlib.h>
42
-#include "../../sr_module.h"
43
-#include "../../dprint.h"
44
-#include <string.h>
45
-#include "../../ut.h"
46
-#include "../../error.h"
47
-#include "../tm/t_hooks.h"
48
-#include "../tm/tm_load.h"
49
-#include "../../config.h"
50
-#include <ctype.h> 								/*isdigit */
51
-#include "acc_mod.h"	
52
-#include "../../parser/digest/digest.h" 		/*digest parser*/
53
-#include "../../parser/digest/digest_parser.h"  /*digest struct*/
54
-#include "../../parser/parse_from.h"			/*from parser*/
55
-#include "dict.h"
56
-#include "utils.h"								/*auth_get_username*/
57
-#define SIP_SERVICE_TYPE 15
58
-#define TMP_SIZE		 256
59
-#define CALL_MISSED		 16						/*see rad_acc_request*/
60
-
61
-/******************************************************************************
62
- *  Sends a "start" or "stop" accounting message to the RADIUS server.
63
- *  Params:struct cell* t          callback object
64
- *         struct sip_msg* msg     Sip message object
65
- *  returns: 0 on success
66
- *  		 -1 on failure
67
- *****************************************************************************/
68
-int radius_log_reply(struct cell* t, struct sip_msg* msg)
69
-{
70
-	UINT4 av_type;							/* value pair integer */
71
-  	int result;                           	/* Acct request status */
72
-  	VALUE_PAIR *send = NULL;              	/* Radius Value pairs */
73
-  	UINT4 client_port;                    	/* sip port */
74
-  	int len;							/* parse uri variables */
75
-	char *tmp;								/* Temporary buffer */
76
-	char *buf;								/* ibid */
77
-	int stop = 0;                         	/* Acount status STOP flag */
78
- 	struct to_body *to;						/* Structs containing tags */
79
-  	struct sip_msg *rq;					  	/* Reply structure */
80
-	struct to_body *from;
81
-	struct cseq_body *cseq;					/* Cseq body--for Numeric */
82
-	auth_body_t *cred;						/* Digital Credentials*/
83
-	str	username;							/* Username string */
84
-	
85
-	DBG("**************radius_log_reply() CALLED \n");
86
-  	rq =  t->uas.request;	
87
-
88
-	/* 
89
-   	 * Add status type, Accounting START in our case 
90
-   	 *                   1: START
91
-   	 *                   2: STOP
92
-     *                   3: INTERIM-UPDATE
93
-     *                   7: ACC ON
94
-     *                   8: ACC OFF
95
-     *                   15: RESERVED FOR FAILURES.
96
-     * I need to add more logic here...
97
-     */
98
-  	if (rq->REQ_METHOD == METHOD_INVITE) {
99
-    	av_type = PW_STATUS_START;
100
-  	} else if ((rq->REQ_METHOD == METHOD_BYE) || 
101
-						(rq->REQ_METHOD == METHOD_CANCEL)) {
102
-    	av_type = PW_STATUS_STOP;
103
-    	stop = 1; /* set stop flag look down for details*/
104
-  	} else {
105
-		DBG("WARNING: Radius accounting not started, method: %d...\n", 
106
-							rq->REQ_METHOD);
107
-		return(ERROR_RC);
108
-	}
109
-  	if (rc_avpair_add(&send, PW_ACCT_STATUS_TYPE, &av_type, 0) == NULL) {
110
-    	DBG("radius_log_reply(): ERROR:PW_ACCT_STATUS_TYPE \n");
111
-		return(ERROR_RC);
112
-  	}
113
-	
114
-  	/* Add service type, always SIP */
115
-  	av_type = SIP_SERVICE_TYPE; 
116
-  	if (rc_avpair_add(&send, PW_SERVICE_TYPE, &av_type, 0) == NULL) {
117
-    	DBG("radius_log_reply(): ERROR:PW_SERVICE_TYPE \n");
118
-		return(ERROR_RC);
119
-  	}
120
-
121
-  	/* Add sip method */  
122
-  	if (rq->first_line.type == SIP_REQUEST) {
123
-    	av_type = rq->REQ_METHOD;
124
-    	if (rc_avpair_add(&send, PW_SIP_METHOD, &av_type, 0) == NULL) {
125
-      		DBG("radius_log_reply(): ERROR:PW_SIP_METHOD \n");
126
-			return(ERROR_RC);
127
-    	}
128
-  	}
129
-	
130
-  	/* Add sip response code -- status code ,integer only if no method*/
131
-  	if (rq->first_line.type == SIP_REPLY) {
132
-		/* take a reply from message -- that's safe and we don't need to be
133
-		   worried about TM reply status being changed concurrently */
134
-    	av_type = rq->REPLY_STATUS;
135
-   		if (rc_avpair_add(&send, PW_SIP_RESPONSE_CODE, &av_type, 0) == NULL) {
136
-      		DBG("radius_log_reply(): ERROR:PW_SIP_RESPONSE_CODE \n");
137
-			return(ERROR_RC);
138
-		}
139
-	}
140
-
141
-	/* Add calling station ID, URL in FROM string */
142
-	if ( parse_from_header( msg )==-1 ) {
143
-		DBG("radius_log_reply(): Error getting from body \n");
144
-		return(ERROR_RC);
145
-	}
146
-	from = (struct to_body *)msg->from->parsed;
147
-	tmp = cleanbody(from->uri);
148
-
149
-	/*If the parsing's OK then we can safely add the tags */
150
-	if (rc_avpair_add(&send,PW_SIP_FROM_TAG,&from->tag_value.s[0],0)==NULL) {
151
-		DBG("radius_log_reply(): ERROR:PW_SIP_FROM_TAG \n");
152
-		return(ERROR_RC);
153
-	}
154
-
155
-	if (rc_avpair_add(&send, PW_CALLING_STATION_ID, tmp, 0) == NULL) {
156
-		DBG("radius_log_reply(): ERROR:PW_CALLING_STATION_ID %s \n",
157
-			rq->from->body.s);
158
-		return(ERROR_RC);
159
-	}
160
-
161
-	/* 
162
-	 * Add called station ID, URL in TO string parse_to_param
163
-	 */
164
-	to = (struct to_body *) msg->to->parsed;
165
-	if (to->error == PARSE_OK) {
166
-		tmp = cleanbody(to->uri);
167
-		
168
-		/*
169
-		 * If the parsing's OK then we can safely add the tags 
170
-		 * Actually, we still have to check if the tag was parsed correctly,
171
-		 * make sure it's not NULL. That's why I memset the structure...
172
-		 */
173
-		if (rq->REQ_METHOD != METHOD_INVITE) {
174
-			if (rc_avpair_add(&send,PW_SIP_TO_TAG,
175
-		    					&to->tag_value.s[0], 0) == NULL) {
176
-				DBG("radius_log_reply(): ERROR:PW_SIP_TO_TAG\n"); 
177
-    			return(ERROR_RC);
178
-			}
179
-		}
180
-	} else {
181
-		DBG("radius_log_reply(): Error parsing to body \n");
182
-		/* 
183
-		 * Since the from body wasn't parsed correctly, copy the
184
-		 * TO body 
185
-		 */
186
-		tmp = &rq->to->body.s[0];
187
-	}
188
-
189
-  	if (rc_avpair_add(&send, PW_CALLED_STATION_ID, tmp, 0) == NULL) {
190
-		DBG("radius_log_reply(): ERROR:PW_CALLED_STATION_ID %.*s]\n", 
191
-									rq->to->body.len, rq->to->body.s);
192
-		return(ERROR_RC);
193
-  	}
194
-							
195
-	/* Parse the cseq numeric part */
196
-  	cseq = get_cseq(rq);
197
-	tmp = cleanbody(cseq->number);
198
-  	if (rc_avpair_add(&send,PW_SIP_CSEQ , tmp, 0) == NULL) {
199
-		DBG("radius_log_reply(): ERROR:PW_SIP_CSEQ \n");
200
-		return(ERROR_RC);
201
-  	}
202
-
203
-	/* Add Reply Status... The method of the original request... */
204
-	av_type = rq->REPLY_STATUS;
205
-   	if (rc_avpair_add(&send, PW_SIP_RESPONSE_CODE, &av_type, 0) == NULL) {
206
-   		DBG("radius_log_ack(): ERROR:PW_SIP_RESPONSE_CODE \n");
207
-		return(ERROR_RC);
208
-	}
209
-	
210
-	/*
211
-	 * Parse uri structure...
212
-	 */
213
-  	if (rq->new_uri.s) {
214
-    	buf = rq->new_uri.s;
215
-    	len = rq->new_uri.len;
216
-  	} else{
217
-    	buf = rq->first_line.u.request.uri.s;
218
-    	len = rq->first_line.u.request.uri.len;
219
-  	}
220
-
221
-	/*
222
-	 * If available, take user-name from digest else extract the FROM field.
223
-	 */
224
-
225
-	if (!(rq->authorization)) {
226
-		     /* No credentials parsed yet */
227
-		if (parse_headers(rq, HDR_AUTHORIZATION, 0) == -1) {
228
-			LOG(L_ERR, "radis_log_reply: Error while parsing auth headers\n");
229
-			return -2;
230
-		}
231
-	}
232
-	
233
-	/* Parse only if there's something there... */
234
-	if (rq->authorization) {
235
-		if (parse_credentials(rq->authorization) != -1) {
236
-			cred = (auth_body_t*)(rq->authorization->parsed);
237
-			if (check_dig_cred(&(cred->digest)) != E_DIG_OK) {
238
-				LOG(L_ERR, "radius_log_reply: Credentials missing\n");
239
-				return(ERROR_RC);
240
-			} else {
241
-				tmp = cleanbody(cred->digest.username);
242
-			}
243
-		}
244
-	} else {
245
-		/* Extract username from uri */
246
-		username.s = from->uri.s;
247
-		username.len = from->uri.len;
248
-		if (auth_get_username(&username) < 0) {
249
-        	LOG(L_ERR, "radius_log_reply: "
250
-							"Error while extracting username\n");
251
-       	    return(ERROR_RC);
252
-		}
253
-		tmp = cleanbody(username);
254
-	}
255
-		
256
-	if (rc_avpair_add(&send, PW_USER_NAME, tmp, 0) == NULL) {
257
-    	DBG("radius_log_reply(): ERROR: \n");
258
-		return(ERROR_RC);
259
-	}
260
-	
261
-  	/* Add sip-translated-request-uri string*/
262
-	if (msg->new_uri.s) 
263
-		tmp = cleanbody(rq->new_uri);     
264
-    else
265
-    	tmp = cleanbody(rq->first_line.u.request.uri);
266
-
267
-  	if (rc_avpair_add(&send, PW_SIP_TRANSLATED_REQ_URI, 
268
-						tmp, 0) == NULL) {
269
-  		DBG("radius_log_reply(): ERROR:PW_SIP_TRANSLATED_REQ_URI \n");
270
-		return(ERROR_RC);
271
-  	}
272
-	
273
-	/* 
274
-	 * ADD ACCT-SESSION ID ---> CALL-ID 
275
-     * start and stop must have the same callid...
276
-     */
277
-	tmp = cleanbody(rq->callid->body);
278
-	if (rc_avpair_add(&send, PW_ACCT_SESSION_ID, tmp, 0) == NULL) {
279
-		DBG("radius_log_reply(): ERROR:PW_ACCT_SESSION_ID \n");
280
-		return(ERROR_RC); 
281
-  	}
282
-
283
-  	/*FIXME: Dorgham and Jiri said that we don't need this
284
-   	 * Acct-session-time
285
-     * Can only be present in Accounting-Request records
286
-     * where Acct-status-type is set to STOP.
287
-     * Represents the time between the arrival of 200 OK
288
-     * in response to an invite from caller until the the
289
-     * arrival of the corresponding BYE request by either 
290
-     * party. 
291
-     */
292
-	if (stop) {
293
-    	av_type = 0; /* Add session time here... */
294
-    	if (rc_avpair_add(&send, PW_ACCT_SESSION_TIME,
295
-			      &av_type, 0) == NULL) {
296
-      		DBG("radius_log_reply(): ERROR:PW_ACCT_SESSION_TIME \n");
297
-			return(ERROR_RC); 
298
-    	}
299
-  	}
300
-
301
-	/* FIXME: Dorgham said that we don't need this...
302
-   	 * Acct-Terminate-Cause 
303
-   	 * Termination cause only if Acct-status type is STOP
304
-   	 * 1   User Request (BYE)
305
-   	 * 3   Lost Service
306
-   	 * 4   Idle Timeout (e.g., loss of RTP or RTCP)
307
-     * 5   Session Timeout (e.g., SIP session timer)
308
-     * 6   Admin Reset
309
-     * 7   Admin Reboot
310
-     * 8   Port Error
311
-     * 9   NAS Error
312
-     * 10  NAS Request
313
-     * 11  NAS Reboot
314
-     * 15  Service Unavailable
315
-     */
316
-	if (stop) {
317
-    	av_type = 0; /* Add session terminate cause here... */
318
-    	if (rc_avpair_add(&send, PW_ACCT_TERMINATE_CAUSE,
319
-					      &av_type, 0) == NULL) {
320
-      		DBG("radius_log_reply(): ERROR:PW_ACCT_TERMINATE_CAUSE \n");
321
-			return(ERROR_RC); 
322
-    	}
323
-  	}
324
-  
325
-	/* Radius authentication... This is not needed */
326
-  	av_type = PW_RADIUS;
327
-  	if (rc_avpair_add(&send, PW_ACCT_AUTHENTIC, &av_type, 0) == NULL) {
328
-    	DBG("radius_log_reply(): ERROR:PW_ACCT_AUTHENTIC \n");
329
-		return(ERROR_RC);	
330
-  	}
331
-    
332
-  	/* Send Request to Radius Server */
333
-	client_port = SIP_PORT;
334
-  	result = rc_acct(client_port, send);
335
-
336
-	/* I think that is done automatically but it doesn't hurt */
337
-  	rc_avpair_free(send);
338
-  
339
-  	if (result != OK_RC) {
340
-    	/* RADIUS server could be down so make this a warning */
341
-    	DBG("radius_acct_start(): Error: Accounting Request Rejected\n");
342
-  	} else {
343
-    	DBG("RADIUS Accounting Request Received... \n");
344
-  	}
345
-  
346
-  	return result;
347
-}
348
-
349
-/***********************************************************
350
- *  Sends a "start" accounting message to the RADIUS server.
351
- *  Params:struct cell* t          callback object
352
- *         struct sip_msg* msg     Sip message object
353
- *  returns: 0 on success
354
- *  		 -1 on failure
355
- ***********************************************************/
356
-int radius_log_ack(struct cell* t, struct sip_msg* msg)
357
-{
358
-	UINT4 av_type;							/* value pair integer */
359
-  	int result;                           	/* Acct request status */
360
-  	VALUE_PAIR *send = NULL;              	/* Radius Value pairs */
361
-  	UINT4 client_port;                    	/* sip port */
362
-  	int len ;							/* parse uri variables */
363
-	char *tmp;								/* Temporary buffer */
364
-	char *buf;								/* ibid */
365
-  	int stop = 0;                         	/* Acount status STOP flag */
366
- 	struct to_body *to;						/* Structs containing TO tags */
367
-  	struct sip_msg *rq;					  	/* Reply structure */
368
-	struct to_body *from;					/* struct to hold FROM tags */
369
- 	struct cseq_body *cseq;					/* Cseq body--for Numeric */
370
-	auth_body_t *cred;						/* Digital Credentials*/
371
-	str	username;							/* Username string */
372
-
373
-	DBG("**************radius_log_ack() CALLED \n");
374
-
375
-  	rq =  t->uas.request;	
376
-	  	    
377
-  	/*
378
-	 * Add status type, Accounting START in our case 
379
-   	 *                   1: START
380
-   	 *                   2: STOP
381
-     *                   3: INTERIM-UPDATE
382
-     *                   7: ACC ON
383
-     *                   8: ACC OFF
384
-     *                   15: RESERVED FOR FAILURES.
385
-     * I need to add more logic here...
386
-     */
387
-  	if (rq->REQ_METHOD == METHOD_INVITE) {
388
-    	av_type = PW_STATUS_START;
389
-  	} else if (rq->REQ_METHOD == METHOD_BYE) {
390
-    	av_type = PW_STATUS_STOP;
391
-    	stop = 1; /* set stop flag look down for details*/
392
-  	} else {
393
-		DBG("WARNING: Radius accounting not started, method: %d...\n", 
394
-							msg->REQ_METHOD);
395
-		return(ERROR_RC);
396
-	}
397
-  	if (rc_avpair_add(&send, PW_ACCT_STATUS_TYPE, &av_type, 0) == NULL) {
398
-    	DBG("radius_log_ack(): ERROR:PW_ACCT_STATUS_TYPE \n");
399
-		return(ERROR_RC);
400
-  	}
401
-
402
-  	/* Add service type, always SIP */
403
-  	av_type = SIP_SERVICE_TYPE; 
404
-  	if (rc_avpair_add(&send, PW_SERVICE_TYPE, &av_type, 0) == NULL) {
405
-    	DBG("radius_log_ack(): ERROR:PW_SERVICE_TYPE \n");
406
-		return(ERROR_RC);
407
-  	}
408
-
409
-  	/* Add sip method */  
410
-  	if (msg->first_line.type == SIP_REQUEST) {
411
-    	av_type = msg->REQ_METHOD;
412
-    	if (rc_avpair_add(&send, PW_SIP_METHOD, &av_type, 0) == NULL) {
413
-      		DBG("radius_log_ack(): ERROR:PW_SIP_METHOD \n");
414
-			return(ERROR_RC);
415
-    	}
416
-  	}
417
-
418
-	/* Add Reply Status... The method of the original request... */
419
-	av_type = rq->REPLY_STATUS;
420
-   	if (rc_avpair_add(&send, PW_SIP_RESPONSE_CODE, &av_type, 0) == NULL) {
421
-   		DBG("radius_log_ack(): ERROR:PW_SIP_RESPONSE_CODE \n");
422
-		return(ERROR_RC);
423
-	}
424
-
425
-	/* Add calling station ID, URL in FROM string */
426
-	if ( parse_from_header( msg )==-1 ) {
427
-		DBG("radius_log_ack(): Error getting from body \n");
428
-		return(ERROR_RC);
429
-	}
430
-	from = (struct to_body *)msg->from->parsed;
431
-	tmp = cleanbody(from->uri);
432
-
433
-	/*If the parsing's OK then we can safely add the tags */
434
-	if (rc_avpair_add(&send,PW_SIP_FROM_TAG,&from->tag_value.s[0],0)==NULL) {
435
-		DBG("radius_log_ack(): ERROR:PW_SIP_FROM_TAG \n");
436
-		return(ERROR_RC);
437
-	}
438
-
439
-	if (rc_avpair_add(&send, PW_CALLING_STATION_ID, tmp, 0) == NULL) {
440
-    	DBG("radius_log_ack(): ERROR:PW_CALLING_STATION_ID %s \n", 
441
-									msg->from->body.s);
442
-		return(ERROR_RC);
443
-	}
444
-	
445
-									
446
-	/* Add calling station ID, URL in TO string */
447
-  	to = (struct to_body *)msg->to->parsed;
448
-	
449
-	if (to->error == PARSE_OK) {
450
-		tmp = cleanbody(to->uri);
451
-		
452
-		/*Add sip-to-tag string */
453
-		if (rc_avpair_add(&send,PW_SIP_TO_TAG  ,
454
-		    	&to->tag_value.s[0], 0) == NULL) {
455
-    		DBG("radius_log_ack(): ERROR: PW_SIP_TO_TAG \n");
456
-			return(ERROR_RC);
457
-    	} 
458
-	} else {
459
-		DBG("radius_log_ack(): Error parsing to body \n");
460
-		/* 
461
-		 * Since the from body wasn't parsed correctly, copy the
462
-		 * From body 
463
-		 */
464
-		tmp = &msg->to->body.s[0];
465
-	}
466
-
467
-	if (rc_avpair_add(&send, PW_CALLED_STATION_ID, tmp, 0) == NULL) {
468
-		DBG("radius_log_ack(): ERROR:PW_CALLED_STATION_ID %.*s]\n", 
469
-									msg->to->body.len, msg->to->body.s);
470
-		return(ERROR_RC);
471
-  	}
472
-   		
473
-  	/* Add sip-cseq string*/
474
-	cseq = get_cseq(msg);
475
-	tmp = cleanbody(cseq->number);
476
-  	if (rc_avpair_add(&send, PW_SIP_CSEQ, tmp, 0) == NULL) {
477
-		DBG("radius_log_ack(): ERROR:PW_SIP_CSEQ \n");
478
-		return(ERROR_RC);
479
-  	}  
480
-    
481
-
482
-	/*
483
-	 * Parse the uri structure, if there's a new changed uri parse that one.
484
-	 */
485
-  	if (msg->new_uri.s) {
486
-    	buf = msg->new_uri.s;
487
-    	len = msg->new_uri.len;
488
-  	} else{
489
-    	buf = msg->first_line.u.request.uri.s;
490
-    	len = msg->first_line.u.request.uri.len;
491
-  	}
492
-
493
-  	/*
494
-	 * If available, take user-name from digest else extract the FROM field.
495
-	 */
496
-
497
-	if (!(msg->authorization)) {
498
-		     /* No credentials parsed yet */
499
-		if (parse_headers(msg, HDR_AUTHORIZATION, 0) == -1) {
500
-			LOG(L_ERR, "radis_log_reply: Error while parsing auth headers\n");
501
-			return -2;
502
-		}
503
-	}
504
-	
505
-	/* Parse only if there's something there... */
506
-	if (msg->authorization) {
507
-		if (parse_credentials(msg->authorization) != -1) {
508
-			cred = (auth_body_t*)(msg->authorization->parsed);
509
-			if (check_dig_cred(&(cred->digest)) != E_DIG_OK) {
510
-				LOG(L_ERR, "radius_log_reply: Credentials missing\n");
511
-				return(ERROR_RC);
512
-			} else {
513
-				tmp = cleanbody(cred->digest.username);
514
-			}
515
-		}
516
-	} else {
517
-		/* Extract username from uri */
518
-		username.s = from->uri.s;
519
-		username.len = from->uri.len;
520
-		if (auth_get_username(&username) < 0) {
521
-        	LOG(L_ERR, "radius_log_reply: "
522
-							"Error while extracting username\n");
523
-       	    return(ERROR_RC);
524
-		}
525
-		tmp = cleanbody(username);
526
-	}
527
-
528
-  	if (rc_avpair_add(&send, PW_USER_NAME, tmp, 0) == NULL) {
529
-    	DBG("radius_log_ack(): ERROR: \n");
530
-		return(ERROR_RC);
531
-  	}
532
-
533
-	
534
-  	
535
-	/* Add sip-translated-request-uri string*/
536
-	if (msg->new_uri.s) {
537
-		tmp = cleanbody(msg->new_uri);     
538
-	}
539
-    else
540
-    	tmp = cleanbody(msg->first_line.u.request.uri);
541
-
542
-	tmp = cleanbody(msg->new_uri);
543
-  	if (rc_avpair_add(&send, PW_SIP_TRANSLATED_REQ_URI, 
544
-							tmp, 0) == NULL) {
545
-  		DBG("radius_log_ack(): ERROR:PW_SIP_TRANSLATED_REQ_URI \n");
546
-		return(ERROR_RC);
547
-  	}
548
-
549
-	/* 
550
-	 * ADD ACCT-SESSION ID ---> CALL-ID 
551
-     * start and stop must have the same callid...
552
-     */
553
-	
554
-	tmp = cleanbody(msg->callid->body);
555
-	if (rc_avpair_add(&send, PW_ACCT_SESSION_ID, 
556
-						tmp, 0) == NULL) {
557
-		DBG("radius_log_ack(): ERROR:PW_ACCT_SESSION_ID \n");
558
-		return(ERROR_RC); 
559
-  	}
560
-
561
-  	/*FIXME: Dorgham and Jiri said that we don't need this
562
-   	 * Acct-session-time
563
-     * Can only be present in Accounting-Request records
564
-     * where Acct-status-type is set to STOP.
565
-     * Represents the time between the arrival of 200 OK
566
-     * in response to an invite from caller until the the
567
-     * arrival of the corresponding BYE request by either 
568
-     * party. 
569
-     */
570
-	if (stop) {
571
-    	av_type = 0; /* Add session time here... */
572
-    	if (rc_avpair_add(&send, PW_ACCT_SESSION_TIME,
573
-			      &av_type, 0) == NULL) {
574
-      		DBG("radius_log_ack(): ERROR:PW_ACCT_SESSION_TIME \n");
575
-			return(ERROR_RC); 
576
-    	}
577
-  	}
578
-
579
-	/* FIXME: Dorgham said that we don't need this...
580
-   	 * Acct-Terminate-Cause 
581
-   	 * Termination cause only if Acct-status type is STOP
582
-   	 * 1   User Request (BYE)
583
-   	 * 3   Lost Service
584
-   	 * 4   Idle Timeout (e.g., loss of RTP or RTCP)
585
-     * 5   Session Timeout (e.g., SIP session timer)
586
-     * 6   Admin Reset
587
-     * 7   Admin Reboot
588
-     * 8   Port Error
589
-     * 9   NAS Error
590
-     * 10  NAS Request
591
-     * 11  NAS Reboot
592
-     * 15  Service Unavailable
593
-     */
594
-	if (stop) {
595
-    	av_type = 0; /* Add session terminate cause here... */
596
-    	if (rc_avpair_add(&send, PW_ACCT_TERMINATE_CAUSE,
597
-					      &av_type, 0) == NULL) {
598
-      		DBG("radius_log_ack(): ERROR:PW_ACCT_TERMINATE_CAUSE \n");
599
-			return(ERROR_RC); 
600
-    	}
601
-  	}
602
-  
603
-	/* Radius authentication... This is not needed */
604
-  	av_type = PW_RADIUS;
605
-  	if (rc_avpair_add(&send, PW_ACCT_AUTHENTIC, &av_type, 0) == NULL) {
606
-    	DBG("radius_log_ack(): ERROR:PW_ACCT_AUTHENTIC \n");
607
-		return(ERROR_RC);	
608
-  	}
609
-
610
-    /* Send Request to Radius Server */
611
-  	client_port = SIP_PORT;
612
-  	result = rc_acct(client_port, send);
613
-
614
-	/* I think that is done automatically but it doesn't hurt */
615
-  	rc_avpair_free(send);
616
-  
617
-  	if (result != OK_RC) {
618
-    	/* RADIUS server could be down so make this a warning */
619
-    	DBG("radius_acct_start(): Error, Accounting Request failed\n");
620
-  	} else {
621
-    	DBG("RADIUS Accounting Request Accepted... \n");
622
-  	}
623
-  
624
-  	return result;
625
-}
626
-
627
-/***********************************************************
628
- *  Sends a CALL_MISSED accounting message to the RADIUS server.
629
- *  Params:struct cell* t          callback object
630
- *         struct sip_msg* msg     Sip message object
631
- *  returns: 0 on success
632
- *  		 -1 on failure
633
- ***********************************************************/
634
-int rad_acc_request( struct sip_msg *rq, char * comment, char  *foo)
635
-{
636
-	UINT4 av_type;							/* value pair integer */
637
-  	int result;                           	/* Acct request status */
638
-  	VALUE_PAIR *send = NULL;              	/* Radius Value pairs */
639
-  	UINT4 client_port;                    	/* sip port */
640
-  	int len ;							/* parse uri variables */
641
-	char *tmp;								/* Temporary buffer */
642
-	char *buf;								/* ibid */
643
-	int stop = 0;                         	/* Acount status STOP flag */
644
- 	struct to_body *to;						/* Structs containing tags */
645
-//  	struct sip_msg *rq;					  	/* Reply structure */
646
-	struct to_body *from;	/* !!! MIGHT BE USED unititialized 
647
-							   	**** *** *** ***
648
-								**** *** *** ***
649
-							*/
650
-	struct cseq_body *cseq;					/* Cseq body--for Numeric */
651
-	auth_body_t *cred;						/* Digital Credentials*/
652
-	str	username;							/* Username string */
653
-	
654
-	DBG("**************rad_acc_request() CALLED \n");
655
-
656
-	/* 
657
-   	 * Add status type, Accounting START in our case 
658
-   	 *                   1: START
659
-   	 *                   2: STOP
660
-     *                   3: INTERIM-UPDATE
661
-     *                   7: ACC ON
662
-     *                   8: ACC OFF
663
-     *                   15: RESERVED FOR FAILURES.
664
-	 *                   16: CALL_MISSED
665
-     * A new field not specified in the RFC is added here to help account
666
-	 * status types which cannot be clearly identified by the above specified
667
-	 * accounting types. Any number above 15, which is the last reserved number
668
-	 * can be used for our purposes. The raddb file 
669
-	 * /usr/local/etc/raddb/dictionary needs to be edited so that the number can
670
-	 * be translated into something that is human-readable. For more details 
671
-	 * on this please refer to the radius accounting FAQ.
672
-	 * 
673
-	 */
674
-  	av_type = CALL_MISSED;
675
-  	if (rc_avpair_add(&send, PW_ACCT_STATUS_TYPE, &av_type, 0) == NULL) {
676
-    	DBG("rad_acc_request(): ERROR:PW_ACCT_STATUS_TYPE \n");
677
-		return(ERROR_RC);
678
-  	}
679
-	
680
-  	/* Add service type, always SIP */
681
-  	av_type = SIP_SERVICE_TYPE; 
682
-  	if (rc_avpair_add(&send, PW_SERVICE_TYPE, &av_type, 0) == NULL) {
683
-    	DBG("rad_acc_request(): ERROR:PW_SERVICE_TYPE \n");
684
-		return(ERROR_RC);
685
-  	}
686
-
687
-  	/* Add sip method */  
688
-  	if (rq->first_line.type == SIP_REQUEST) {
689
-    	av_type = rq->REQ_METHOD;
690
-    	if (rc_avpair_add(&send, PW_SIP_METHOD, &av_type, 0) == NULL) {
691
-      		DBG("rad_acc_request(): ERROR:PW_SIP_METHOD \n");
692
-			return(ERROR_RC);
693
-    	}
694
-  	}
695
-	
696
-  	/* FIXME: Add sip response code -- status code ,integer only if no method*/
697
-  	if (rq->first_line.type == SIP_REPLY) {
698
-		/* take a reply from message -- that's safe and we don't need to be
699
-		   worried about TM reply status being changed concurrently */
700
-    	av_type = rq->REPLY_STATUS;
701
-   		if (rc_avpair_add(&send, PW_SIP_RESPONSE_CODE, &av_type, 0) == NULL) {
702
-      		DBG("rad_acc_request(): ERROR:PW_SIP_RESPONSE_CODE \n");
703
-			return(ERROR_RC);
704
-		}
705
-	}
706
-
707
-	/* Add calling station ID, URL in FROM string */
708
-	if ( parse_from_header( rq )==-1 ) {
709
-		DBG("radius_log_request(): Error getting from body \n");
710
-		return(ERROR_RC);
711
-	}
712
-	from = (struct to_body *)rq->from->parsed;
713
-	tmp = cleanbody(from->uri);
714
-
715
-	/*If the parsing's OK then we can safely add the tags */
716
-	if (rc_avpair_add(&send,PW_SIP_FROM_TAG,&from->tag_value.s[0],0)==NULL) {
717
-		DBG("radius_log_request(): ERROR:PW_SIP_FROM_TAG \n");
718
-		return(ERROR_RC);
719
-	}
720
-
721
-	if (rc_avpair_add(&send, PW_CALLING_STATION_ID, tmp, 0) == NULL) {
722
-		DBG("rad_acc_request(): ERROR:PW_CALLING_STATION_ID %s \n",
723
-			rq->from->body.s);
724
-		return(ERROR_RC);
725
-	}
726
-								
727
-	/* 
728
-	 * Add called station ID, URL in TO string parse_to_param
729
-	 */
730
-	to = (struct to_body *) rq->to->parsed;
731
-	if (to->error == PARSE_OK) {
732
-		tmp = cleanbody(to->uri);
733
-		
734
-		/*
735
-		 * If the parsing's OK then we can safely add the tags 
736
-		 * Actually, we still have to check if the tag was parsed correctly,
737
-		 * make sure it's not NULL. That's why I memset the structure...
738
-		 */
739
-		if (rq->REQ_METHOD != METHOD_INVITE) {
740
-			if (rc_avpair_add(&send,PW_SIP_TO_TAG,
741
-		    					&to->tag_value.s[0], 0) == NULL) {
742
-				DBG("rad_acc_request(): ERROR:PW_SIP_TO_TAG\n"); 
743
-    			return(ERROR_RC);
744
-			}
745
-		}
746
-	} else {
747
-		DBG("rad_acc_request(): Error parsing to body \n");
748
-		/* 
749
-		 * Since the from body wasn't parsed correctly, copy the
750
-		 * TO body 
751
-		 */
752
-		tmp = &rq->to->body.s[0];
753
-	}
754
-
755
-  	if (rc_avpair_add(&send, PW_CALLED_STATION_ID, tmp, 0) == NULL) {
756
-		DBG("rad_acc_request(): ERROR:PW_CALLED_STATION_ID %.*s]\n", 
757
-									rq->to->body.len, rq->to->body.s);
758
-		return(ERROR_RC);
759
-  	}
760
-							
761
-	/* Parse the cseq numeric part */
762
-  	cseq = get_cseq(rq);
763
-	tmp = cleanbody(cseq->number);
764
-  	if (rc_avpair_add(&send,PW_SIP_CSEQ , tmp, 0) == NULL) {
765
-		DBG("rad_acc_request(): ERROR:PW_SIP_CSEQ \n");
766
-		return(ERROR_RC);
767
-  	}
768
-
769
-	/* Add Reply Status... The method of the original request... */
770
-	av_type = rq->REPLY_STATUS;
771
-   	if (rc_avpair_add(&send, PW_SIP_RESPONSE_CODE, &av_type, 0) == NULL) {
772
-   		DBG("radius_log_ack(): ERROR:PW_SIP_RESPONSE_CODE \n");
773
-		return(ERROR_RC);
774
-	}
775
-	
776
-	/*
777
-	 * Parse uri structure...
778
-	 */
779
-  	if (rq->new_uri.s) {
780
-    	buf = rq->new_uri.s;
781
-    	len = rq->new_uri.len;
782
-  	} else{
783
-    	buf = rq->first_line.u.request.uri.s;
784
-    	len = rq->first_line.u.request.uri.len;
785
-  	}
786
-
787
-	/*
788
-	 * If available, take user-name from digest else extract the FROM field.
789
-	 */
790
-
791
-	if (!(rq->authorization)) {
792
-		     /* No credentials parsed yet */
793
-		if (parse_headers(rq, HDR_AUTHORIZATION, 0) == -1) {
794
-			LOG(L_ERR, "radis_log_reply: Error while parsing auth headers\n");
795
-			return -2;
796
-		}
797
-	}
798
-	
799
-	/* Parse only if there's something there... */
800
-	if (rq->authorization) {
801
-		if (parse_credentials(rq->authorization) != -1) {
802
-			cred = (auth_body_t*)(rq->authorization->parsed);
803
-			if (check_dig_cred(&(cred->digest)) != E_DIG_OK) {
804
-				LOG(L_ERR, "rad_acc_request: Credentials missing\n");
805
-				return(ERROR_RC);
806
-			} else {
807
-				/* Extract username from uri */
808
-				username.s = from->uri.s;
809
-				username.len = from->uri.len;
810
-				if (auth_get_username(&username) < 0) {
811
-            	    LOG(L_ERR, "rad_acc_request: "
812
-									"Error while extracting username\n");
813
-        	        return(ERROR_RC);
814
-		        }
815
-				tmp = cleanbody(username);
816
-			}
817
-		}
818
-	} else {
819
-		/* Extract username from uri */
820
-		username.s = from->uri.s;
821
-		username.len = from->uri.len;
822
-		if (auth_get_username(&username) < 0) {
823
-        	LOG(L_ERR, "rad_acc_request: "
824
-							"Error while extracting username\n");
825
-       	    return(ERROR_RC);
826
-		}
827
-		tmp = cleanbody(username);
828
-	}
829
-		
830
-	if (rc_avpair_add(&send, PW_USER_NAME, tmp, 0) == NULL) {
831
-    	DBG("rad_acc_request(): ERROR: \n");
832
-		return(ERROR_RC);
833
-	}
834
-	
835
-  	/* Add sip-translated-request-uri string*/
836
-	if (rq->new_uri.s) 
837
-		tmp = cleanbody(rq->new_uri);     
838
-    else
839
-    	tmp = cleanbody(rq->first_line.u.request.uri);
840
-
841
-  	if (rc_avpair_add(&send, PW_SIP_TRANSLATED_REQ_URI, 
842
-						tmp, 0) == NULL) {
843
-  		DBG("rad_acc_request(): ERROR:PW_SIP_TRANSLATED_REQ_URI \n");
844
-		return(ERROR_RC);
845
-  	}
846
-	
847
-	/* 
848
-	 * ADD ACCT-SESSION ID ---> CALL-ID 
849
-     * start and stop must have the same callid...
850
-     */
851
-	tmp = cleanbody(rq->callid->body);
852
-	if (rc_avpair_add(&send, PW_ACCT_SESSION_ID, tmp, 0) == NULL) {
853
-		DBG("rad_acc_request(): ERROR:PW_ACCT_SESSION_ID \n");
854
-		return(ERROR_RC); 
855
-  	}
856
-
857
-  	/*FIXME: Dorgham and Jiri said that we don't need this
858
-   	 * Acct-session-time
859
-     * Can only be present in Accounting-Request records
860
-     * where Acct-status-type is set to STOP.
861
-     * Represents the time between the arrival of 200 OK
862
-     * in response to an invite from caller until the the
863
-     * arrival of the corresponding BYE request by either 
864
-     * party. 
865
-     */
866
-	if (stop) {
867
-    	av_type = 0; /* Add session time here... */
868
-    	if (rc_avpair_add(&send, PW_ACCT_SESSION_TIME,
869
-			      &av_type, 0) == NULL) {
870
-      		DBG("rad_acc_request(): ERROR:PW_ACCT_SESSION_TIME \n");
871
-			return(ERROR_RC); 
872
-    	}
873
-  	}
874
-
875
-	/* FIXME: Dorgham said that we don't need this...
876
-   	 * Acct-Terminate-Cause 
877
-   	 * Termination cause only if Acct-status type is STOP
878
-   	 * 1   User Request (BYE)
879
-   	 * 3   Lost Service
880
-   	 * 4   Idle Timeout (e.g., loss of RTP or RTCP)
881
-     * 5   Session Timeout (e.g., SIP session timer)
882
-     * 6   Admin Reset
883
-     * 7   Admin Reboot
884
-     * 8   Port Error
885
-     * 9   NAS Error
886
-     * 10  NAS Request
887
-     * 11  NAS Reboot
888
-     * 15  Service Unavailable
889
-     */
890
-	if (stop) {
891
-    	av_type = 0; /* Add session terminate cause here... */
892
-    	if (rc_avpair_add(&send, PW_ACCT_TERMINATE_CAUSE,
893
-					      &av_type, 0) == NULL) {
894
-      		DBG("rad_acc_request(): ERROR:PW_ACCT_TERMINATE_CAUSE \n");
895
-			return(ERROR_RC); 
896
-    	}
897
-  	}
898
-  
899
-	/* Radius authentication... This is not needed */
900
-  	av_type = PW_RADIUS;
901
-  	if (rc_avpair_add(&send, PW_ACCT_AUTHENTIC, &av_type, 0) == NULL) {
902
-    	DBG("rad_acc_request(): ERROR:PW_ACCT_AUTHENTIC \n");
903
-		return(ERROR_RC);	
904
-  	}
905
-    
906
-  	/* Send Request to Radius Server */
907
-	client_port = SIP_PORT;
908
-  	result = rc_acct(client_port, send);
909
-
910
-	/* I think that is done automatically but it doesn't hurt */
911
-  	rc_avpair_free(send);
912
-  
913
-  	if (result != OK_RC) {
914
-    	/* RADIUS server could be down so make this a warning */
915
-    	DBG("rad_acc_request(): Error: Accounting Request Rejected\n");
916
-  	} else {
917
-    	DBG("RADIUS Accounting Request Received... \n");
918
-  	}
919
-  
920
-  	return result;
921
-}
922
-
923
-/*
924
- *
925
- *
926
- */
927
-void rad_acc_missed_report( struct cell* t, struct sip_msg *reply,
928
-	unsigned int code )
929
-{
930
-	struct sip_msg *rq;
931
-	str acc_text;
932
-
933
-	rq =  t->uas.request;
934
-	/* it is coming from TM -- it must be already parsed ! */
935
-	if (! rq->from ) {
936
-		LOG(L_ERR, "ERROR: TM request for accounting not parsed\n");
937
-		return;
938
-	}
939
-
940
-	get_reply_status(&acc_text, reply, code);
941
-	if (acc_text.s==0) {
942
-		LOG(L_ERR, "ERROR: acc_missed_report: get_reply_status failed\n" );
943
-		return;
944
-	}
945
-
946
-	rad_acc_request(rq, acc_text.s , 0 /* foo */);
947
-	pkg_free(acc_text.s);
948
-
949
-	/* zdravime vsechny cechy -- jestli jste se dostali se ctenim 
950
-	   kodu az sem a rozumite mu, jste na tom lip, nez autor!
951
-	   prijmete uprimne blahoprani
952
-	*/
953
-}
954
-
955
-
956
-
957 0
deleted file mode 100644
... ...
@@ -1,40 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * authenticate header
5
- *
6
- * Copyright (C) 2001-2003 Fhg Fokus
7
- *
8
- * This file is part of ser, a free SIP server.
9
- *
10
- * ser is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * For a license to use the ser software under conditions
16
- * other than those described here, or to purchase support for this
17
- * software, please contact iptel.org by e-mail at the following addresses:
18
- *    info@iptel.org
19
- *
20
- * ser is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
- */
29
-
30
-
31
-/*#include "../../parser/msg_parser.h"
32
-*/
33
-
34
-int radius_log_reply(struct cell* t, struct sip_msg* msg);
35
-int radius_log_ack(struct cell* t, struct sip_msg* msg);
36
-int rad_acc_request( struct sip_msg *rq, char * comment, char  *foo);
37
-void rad_acc_missed_report( struct cell* t, struct sip_msg *reply,
38
-	unsigned int code );
39
-
40
-
41 0
deleted file mode 100644
... ...
@@ -1,263 +0,0 @@
1
-/*
2
- * Radius Accounting module
3
- *
4
- * $Id$
5
- *
6
- * Copyright (C) 2001-2003 Fhg Fokus
7
- *
8
- * This file is part of ser, a free SIP server.
9
- *
10
- * ser is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * For a license to use the ser software under conditions
16
- * other than those described here, or to purchase support for this
17
- * software, please contact iptel.org by e-mail at the following addresses:
18
- *    info@iptel.org
19
- *
20
- * ser is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
- */
29
-/* History:
30
- * --------
31
- *  2003-03-16  flags export parameter added (janakj)
32
- *  2003-03-11  updated to the new module exports interface (andrei)
33
- *  2003-03-06  aligned to new callback names (jiri)
34
- */
35
-
36
-
37
-#include <stdio.h>
38
-
39
-#include "../../sr_module.h"
40
-#include "../../dprint.h"
41
-#include "../../mem/mem.h"
42
-#include "../tm/t_hooks.h"
43
-#include "../tm/tm_load.h"
44
-#include "../tm/h_table.h"
45
-#include "../../parser/msg_parser.h"
46
-
47
-#include "acc_mod.h"
48
-#include "acc.h"
49
-#include "../tm/tm_load.h"
50
-#include <radiusclient.h>
51
-
52
-/* Defines for radiusclient library */
53
-#define CONFIG_FILE 	 "etc/radiusclient.conf"
54
-
55
-struct tm_binds tmb;
56
-
57
-static int mod_init( void );
58
-
59
-/* ----- Parameter variables ----------- */
60
-
61
-/* Flag if we are using a database or log facilities, default is log */
62
-int use_db = 0;
63
-
64
-/* Database url */
65
-char *db_url;
66
-
67
-/* name of user id (==digest uid) column */
68
-char *uid_column="uid";
69
-
70
-/* name of database table, default=="acc" */
71
-char *db_table="acc";
72
-
73
-/* noisiness level logging facilities are used */
74
-int log_level=L_NOTICE;
75
-
76
-/* should early media replies (183) be logged ? default==no */
77
-int early_media = 0;
78
-
79
-/* should failed replies (>=3xx) be logged ? default==no */
80
-int failed_transactions = 0;
81
-
82
-/* flag which is needed for reporting: 0=any, 1 .. MAX_FLAG flag number */
83
-int acc_flag = 1;
84
-
85
-/* flag which is needed for reporting missed calls */
86
-int missed_flag = 2;
87
-
88
-/* report e2e ACKs too */
89
-int report_ack = 1;
90
-
91
-/* ------------- Callback handlers --------------- */
92
-
93
-static void rad_acc_onreply( struct cell* t,  struct sip_msg *msg,
94
-								int code, void *param );
95
-
96
-static void rad_acc_onack( struct cell* t,  struct sip_msg *msg,
97
-								int code, void *param );
98
-
99
-static void rad_acc_onreq( struct cell* t, struct sip_msg *msg,
100
-								int code, void *param ) ;
101
-
102
-
103
-static  cmd_exports_t cmds[]={
104
-	{"rad_acc_request", rad_acc_request, 1, 0, REQUEST_ROUTE},
105
-	{0,0,0,0,0}
106
-};
107
-
108
-static param_exports_t params[]={
109
-	{"use_database",        INT_PARAM,   &use_db      },
110
-	{"db_table",            STR_PARAM,   &db_table    },
111
-	{"db_url",              STR_PARAM,   &db_url      },
112
-	{"uid_column",          STR_PARAM,   &uid_column  },
113
-	{"log_level",           INT_PARAM,   &log_level   },
114
-	{"early_media",         INT_PARAM,   &early_media },
115
-	{"failed_transactions", INT_PARAM,   &failed_transactions },
116
-	{"acc_flag",            INT_PARAM,   &acc_flag    },
117
-	{"report_ack",          INT_PARAM,   &report_ack  },
118
-	{"missed_flag",         INT_PARAM,   &missed_flag },
119
-	{0,0,0}
120
-};
121
-
122
-
123
-struct module_exports exports= {
124
-	"radius_acc",
125
-	
126
-	cmds,
127
-	/* exported variables */
128
-	params,
129
-	
130
-	mod_init, 	/* initialization module */
131
-	0,			/* response function */
132
-	0,			/* destroy function */
133
-	0,			/* oncancel function */
134
-	0			/* per-child init function */
135
-};
136
-
137
-
138
-/*
139
- * Initialize the module by registering the call-back
140
- * methods for reply and ack
141
- * returns -1 on failure
142
- */
143
-static int mod_init( void )
144
-{
145
-
146
-	load_tm_f	load_tm;
147
-
148
-	fprintf( stderr, "radius_acc - initializing\n");
149
-
150
-	/* import the TM auto-loading function */
151
-	if ( !(load_tm=(load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) {
152
-		LOG(L_ERR, "ERROR: radius_acc: mod_init: can't import load_tm\n");
153
-		return -1;
154
-	}
155
-	/* let the auto-loading function load all TM stuff */
156
-	if (load_tm( &tmb )==-1) return -1;
157
-
158
-	/* register callbacks */
159
-	if (tmb.register_tmcb( TMCB_REPLY_OUT, rad_acc_onreply, 
160
-								0 /* empty param */ ) <= 0) 
161
-		return -1;
162
-	if (tmb.register_tmcb( TMCB_E2EACK, rad_acc_onack, 
163
-								0 /* empty param */ ) <=0 )
164
-		return -1;
165
-	if (tmb.register_tmcb( TMCB_REQUEST_OUT, rad_acc_onreq, 
166
-								0 /* empty param */ ) <=0 )
167
-		return -1;
168
-
169
-	/* Read the configuration file */
170
-  	if (rc_read_config(CONFIG_FILE) != 0) {
171
-    	LOG(L_ERR,"Error:radius_acc: mod_init: opening configuration file \n");
172
-    	return(-1);
173
-  	}
174
-  
175
-	/* Read the dictionaray file from the configuration file loaded above */
176
-	if (rc_read_dictionary(rc_conf_str("dictionary")) != 0) {
177
-    	DBG("Error: acc: mod_init: opening dictionary file \n");
178
-    	return(-1);
179
-  	}
180
-	
181
-	return 0;
182
-}
183
-
184
-
185
-
186
-static void rad_acc_onreq( struct cell* t, struct sip_msg *msg, int code, 
187
-								void *param )
188
-{
189
-	/* disable C timer for accounted calls */
190
-	if (isflagset( msg, acc_flag) == 1 || 
191
-				(t->is_invite && isflagset( msg, missed_flag))) {
192
-#		ifdef EXTRA_DEBUG
193
-		DBG("DEBUG: noisy_timer set for accounting\n");
194
-#		endif
195
-		t->noisy_ctimer = 1;
196
-	}
197
-}
198
-
199
-
200
-/*
201
- * Function that gets called on reply
202
- * params: struct cell* t The callback structure
203
- *         struct sip_msg *msg The sip message.
204
- *         int code The status code
205
- *         void* param Passed parameter
206
- * returns: nothing
207
- */
208
-static void rad_acc_onreply( struct cell* t, struct sip_msg *reply, int code, 
209
-								void *param ) 
210
-{
211
-
212
-	struct sip_msg *rq;
213
-
214
-	rq = t->uas.request;
215
-
216
-	if (t->is_invite && missed_flag && isflagset( rq, missed_flag)==1
217
-			&& ((code>=400 && code<500) || code>=600))
218
-				rad_acc_missed_report( t, reply, code);
219
-
220
-
221
-	/* if acc enabled for flagged transaction, check if flag matches */
222
-	if (acc_flag && isflagset( rq, acc_flag )==-1) return;
223
-	/* early media is reported only if explicitely demanded, 
224
-	   other provisional responses are always dropped  */
225
-	if (code < 200 && ! (early_media && code==183)) 
226
-		return;
227
-	/* negative transactions reported only if explicitely demanded */
228
-	if (!failed_transactions && code >=300) return;
229
-
230
-	/* anything else, i.e., 2xx, always reported */
231
-	radius_log_reply(t, reply);
232
-
233
-}
234
-
235
-/*
236
- * Function that gets called on reply
237
- * params: struct cell* t The callback structure
238
- *         struct sip_msg *msg The sip message.
239
- *         int code The status code
240
- *         void* param Passed parameter
241
- * returns: nothing
242
- */
243
-static void rad_acc_onack( struct cell* t , struct sip_msg *ack, int code, 
244
-								void *param )
245
-{
246
-  	struct sip_msg *rq;
247
-	rq = t->uas.request;
248
-
249
-	if (!report_ack) return;
250
-	/* if acc enabled for flagged transaction, check if flag matches */
251
-	if (acc_flag && isflagset( rq, acc_flag )==-1) return;
252
-
253
-	radius_log_ack(t, ack);
254
-}
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264 0
deleted file mode 100644
... ...
@@ -1,44 +0,0 @@
1
-/*
2
- * Accounting module
3
- *
4
- * $Id$
5
- *
6
- * Copyright (C) 2001-2003 Fhg Fokus
7
- *
8
- * This file is part of ser, a free SIP server.
9
- *
10
- * ser is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * For a license to use the ser software under conditions
16
- * other than those described here, or to purchase support for this
17
- * software, please contact iptel.org by e-mail at the following addresses:
18
- *    info@iptel.org
19
- *
20
- * ser is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
- */
29
-
30
-
31
-#ifndef _ACC_H
32
-#define _ACC_H
33
-
34
-/* module parameter declaration */
35
-extern int use_db;
36
-extern char *db_url;
37
-extern char *uid_column;
38
-extern char *db_table;
39
-extern int log_level;
40
-extern int early_media;
41
-extern int failed_transactions;
42
-extern int flagged_only;
43
-
44
-#endif
45 0
deleted file mode 100644
... ...
@@ -1,49 +0,0 @@
1
-/*
2
- * Include file for Radius 
3
- *
4
- * Copyright (C) 2001-2003 Fhg Fokus
5
- *
6
- * This file is part of ser, a free SIP server.
7
- *
8
- * ser is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version