Doxygen Updates - Title update
[asterisk/asterisk.git] / cdr / cdr_radius.c
index 3a61909..92ec8a4 100644 (file)
  * \brief RADIUS CDR Support
  *
  * \author Philippe Sultan
- * \extref The Radius Client Library - http://developer.berlios.de/projects/radiusclient-ng/
+ * The Radius Client Library
+ *     http://developer.berlios.de/projects/radiusclient-ng/
  *
  * \arg See also \ref AstCDR
  * \ingroup cdr_drivers
  */
 
+/*! \li \ref cdr_radius.c uses the configuration file \ref cdr.conf
+ * \addtogroup configuration_file Configuration Files
+ */
+
 /*** MODULEINFO
        <depend>radius</depend>
+       <support_level>extended</support_level>
  ***/
 
 #include "asterisk.h"
@@ -186,7 +192,8 @@ static int build_radius_record(VALUE_PAIR **tosend, struct ast_cdr *cdr)
        }
 
        /* Setting Acct-Session-Id & User-Name attributes for proper generation
-          of Acct-Unique-Session-Id on server side */
+        * of Acct-Unique-Session-Id on server side 
+        */
        /* Channel */
        if (!rc_avpair_add(rh, tosend, PW_USER_NAME, &cdr->channel, strlen(cdr->channel), 0))
                return -1;
@@ -224,6 +231,10 @@ return_cleanup:
 static int unload_module(void)
 {
        ast_cdr_unregister(name);
+       if (rh) {
+               rc_destroy(rh);
+               rh = NULL;
+       }
        return 0;
 }
 
@@ -243,8 +254,17 @@ static int load_module(void)
        } else
                return AST_MODULE_LOAD_DECLINE;
 
-       /* start logging */
-       rc_openlog("asterisk");
+       /*
+        * start logging
+        *
+        * NOTE: Yes this causes a slight memory leak if the module is
+        * unloaded.  However, it is better than a crash if cdr_radius
+        * and cel_radius are both loaded.
+        */
+       tmp = ast_strdup("asterisk");
+       if (tmp) {
+               rc_openlog((char *) tmp);
+       }
 
        /* read radiusclient-ng config file */
        if (!(rh = rc_read_config(radiuscfg))) {
@@ -255,11 +275,18 @@ static int load_module(void)
        /* read radiusclient-ng dictionaries */
        if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary"))) {
                ast_log(LOG_NOTICE, "Cannot load radiusclient-ng dictionary file.\n");
+               rc_destroy(rh);
+               rh = NULL;
                return AST_MODULE_LOAD_DECLINE;
        }
 
-       ast_cdr_register(name, desc, radius_log);
-       return AST_MODULE_LOAD_SUCCESS;
+       if (ast_cdr_register(name, desc, radius_log)) {
+               rc_destroy(rh);
+               rh = NULL;
+               return AST_MODULE_LOAD_DECLINE;
+       } else {
+               return AST_MODULE_LOAD_SUCCESS;
+       }
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "RADIUS CDR Backend",