Browse code

Merge pull request #353 from ycaner06/patch-2

misc_radis : more logging

Daniel-Constantin Mierla authored on 05/10/2015 05:46:59
Showing 1 changed files
... ...
@@ -263,34 +263,39 @@ int radius_load_caller_avps(struct sip_msg* _m, char* _caller, char* _s2)
263 263
 					val_arr[i].s, val_arr[i].len );
264 264
 		}
265 265
 	}
266
-
267
-	if ((res = rc_auth(rh, 0, send, &received, msg)) == OK_RC) {
268
-		LM_DBG("success\n");
269
-		rc_avpair_free(send);
270
-		if (common_response) {
271
-			generate_avps_rad(received);
272
-		} else {
273
-			generate_avps(caller_attrs, received);
274
-		}
275
-		rc_avpair_free(received);
276
-		return 1;
277
-	} else {
278
-		rc_avpair_free(send);
279
-		if (common_response) generate_avps_rad(received);
280
-		rc_avpair_free(received);
281
-#ifdef REJECT_RC
282
-		if (res == REJECT_RC) {
283
-			LM_DBG("rejected\n");
284
-			return -1;
285
-		} else {
286
-			LM_ERR("failure\n");
287
-			return -2;
288
-		}
289
-#else
290
-		LM_DBG("failure\n");
291
-		return -1;
292
-#endif
293
-	}
266
+	
267
+ 	res = rc_auth(rh, 0, send, &received, msg);
268
+
269
+        if (res == OK_RC) {
270
+                LM_DBG("Radius Load Caller Success\n");
271
+                rc_avpair_free(send);
272
+                if (common_response) {
273
+                        generate_avps_rad(received);
274
+                } else {
275
+                        generate_avps(caller_attrs, received);
276
+                }
277
+                rc_avpair_free(received);
278
+                return 1;
279
+        } else if(res == BADRESP_RC){
280
+                LM_ERR("Authz radius - Load Caller - BAD RESPONSE \n");
281
+        } else if(res == ERROR_RC){
282
+                LM_ERR("Authz radius - Load Caller - ERROR \n");
283
+        } else if(res == TIMEOUT_RC){
284
+                LM_ERR("Authz radius - Load Caller - TIMEOUT \n");
285
+        } else if(res == REJECT_RC){
286
+                LM_ERR("Authz radius - Load Caller - REJECTED \n");
287
+        } else{
288
+                LM_ERR("Authz radius - Load Caller - Unkown Response \n");
289
+        }
290
+
291
+        rc_avpair_free(send);
292
+
293
+        if (common_response){
294
+                generate_avps_rad(received);
295
+        }
296
+        
297
+	rc_avpair_free(received);
298
+        return -1;
294 299
 
295 300
 error:
296 301
 	rc_avpair_free(send);
... ...
@@ -350,33 +355,38 @@ int radius_load_callee_avps(struct sip_msg* _m, char* _callee, char* _s2)
350 355
 		}
351 356
 	}
352 357
 
353
-	if ((res = rc_auth(rh, 0, send, &received, msg)) == OK_RC) {
354
-		LM_DBG("success\n");
355
-		rc_avpair_free(send);
356
-		if (common_response) {
357
-			generate_avps_rad(received);
358
-		} else {
359
-			generate_avps(callee_attrs, received);
360
-		}
361
-		rc_avpair_free(received);
362
-		return 1;
363
-	} else {
364
-		rc_avpair_free(send);
365
-		if (common_response) generate_avps_rad(received);
366
-		rc_avpair_free(received);
367
-#ifdef REJECT_RC
368
-		if (res == REJECT_RC) {
369
-			LM_DBG("rejected\n");
370
-			return -1;
371
-		} else {
372
-			LM_ERR("failure\n");
373
-			return -2;
374
-		}
375
-#else
376
-		LM_DBG("failure\n");
377
-		return -1;
378
-#endif
379
-	}
358
+        res = rc_auth(rh, 0, send, &received, msg);
359
+
360
+        if (res == OK_RC) {
361
+                LM_DBG("Radius Load Callee Success\n");
362
+                rc_avpair_free(send);
363
+                if (common_response) {
364
+                        generate_avps_rad(received);
365
+                } else {
366
+                        generate_avps(callee_attrs, received);
367
+                }
368
+                rc_avpair_free(received);
369
+                return 1;
370
+        } else if(res == BADRESP_RC){
371
+                LM_ERR("Authz radius - Load Callee - BAD RESPONSE \n");
372
+        } else if(res == ERROR_RC){
373
+                LM_ERR("Authz radius - Load Callee - ERROR \n");
374
+        } else if(res == TIMEOUT_RC){
375
+                LM_ERR("Authz radius - Load Callee - TIMEOUT \n");
376
+        } else if(res == REJECT_RC){
377
+                LM_ERR("Authz radius - Load Callee - REJECTED \n");
378
+        } else {
379
+                LM_ERR("Authz radius - Load Callee - Unkown response \n");
380
+        }
381
+        rc_avpair_free(send);
382
+
383
+        if (common_response){
384
+                generate_avps_rad(received);
385
+        }
386
+
387
+        rc_avpair_free(received);
388
+        return -1;
389
+
380 390
 
381 391
 error:
382 392
 	rc_avpair_free(send);
... ...
@@ -449,28 +459,29 @@ int radius_is_user_in(struct sip_msg* _m, char* _user, char* _group)
449 459
 		}
450 460
 	}
451 461
 
452
-	if ((res = rc_auth(rh, 0, send, &received, msg)) == OK_RC) {
453
-		LM_DBG("success\n");
454
-		rc_avpair_free(send);
455
-		generate_avps(group_attrs, received);
456
-		rc_avpair_free(received);
457
-		return 1;
458
-	} else {
459
-		rc_avpair_free(send);
460
-		rc_avpair_free(received);
461
-#ifdef REJECT_RC
462
-		if (res == REJECT_RC) {
463
-			LM_DBG("rejected\n");
464
-			return -1;
465
-		} else {
466
-			LM_ERR("failure\n");
467
-			return -2;
468
-		}
469
-#else
470
-		LM_DBG("failure\n");
471
-		return -1;
472
-#endif
473
-	}
462
+	res = rc_auth(rh, 0, send, &received, msg);
463
+
464
+        if (res == OK_RC) {
465
+                LM_DBG("Authz radius - success\n");
466
+                rc_avpair_free(send);
467
+                generate_avps(group_attrs, received);
468
+                rc_avpair_free(received);
469
+                return 1;
470
+        } else if(res == BADRESP_RC){
471
+                LM_ERR("Authz radius - BAD RESPONSE \n");
472
+        } else if(res == ERROR_RC){
473
+                LM_ERR("Authz radius - ERROR \n");
474
+        } else if(res == TIMEOUT_RC){
475
+                LM_ERR("Authz radius - TIMEOUT \n");
476
+        } else if(res == REJECT_RC){
477
+                LM_ERR("Authz radius - REJECTED \n");
478
+        } else{
479
+                LM_ERR("Authz radius - Unkown Response \n");
480
+        }
481
+
482
+        rc_avpair_free(send);
483
+        rc_avpair_free(received);
484
+        return -1;
474 485
 
475 486
 error:
476 487
 	rc_avpair_free(send);
... ...
@@ -691,30 +702,31 @@ int radius_does_uri_user_exist(struct sip_msg* _m, str user)
691 702
 					val_arr[i].s, val_arr[i].len );
692 703
 		}
693 704
 	}
705
+	
706
+	res = rc_auth(rh, 0, send, &received, msg);
694 707
 
695
-	if ((res = rc_auth(rh, 0, send, &received, msg)) == OK_RC) {
696
-		LM_DBG("success\n");
708
+	if (res == OK_RC) {
709
+		LM_DBG("Radius Success\n");
697 710
 		rc_avpair_free(send);
698 711
 		generate_avps(uri_attrs, received);
699 712
 		rc_avpair_free(received);
700 713
 		return 1;
701
-	} else {
702
-		rc_avpair_free(send);
703
-		rc_avpair_free(received);
704
-#ifdef REJECT_RC
705
-		if (res == REJECT_RC) {
706
-			LM_DBG("rejected\n");
707
-			return -1;
708
-		} else {
709
-			LM_ERR("failure\n");
710
-			return -2;
711
-		}
712
-#else
713
-		LM_DBG("failure\n");
714
-		return -1;
715
-#endif
716
-	}
717
-
714
+	} else if(res == BADRESP_RC){
715
+                LM_ERR("Authz radius  - BAD RESPONSE \n");
716
+        } else if(res == ERROR_RC){
717
+                LM_ERR("Authz radius  - ERROR \n");
718
+        } else if(res == TIMEOUT_RC){
719
+                LM_ERR("Authz radius  - TIMEOUT \n");
720
+        } else if(res == REJECT_RC){
721
+                LM_ERR("Authz radius  - REJECTED \n");
722
+        } else {
723
+                LM_ERR("Authz radius  - Unkown response \n");
724
+        }
725
+ 	
726
+ 	rc_avpair_free(send);
727
+	rc_avpair_free(received);
728
+	
729
+	return -1;
718 730
 error:
719 731
 	rc_avpair_free(send);
720 732
 	return -1;