Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

radius_acct.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

void radius_acct_init (CfgGroup *grp)
void radius_acct_shutdown (void)
Octstrradius_acct_get_msisdn (Octstr *client_ip)


Function Documentation

Octstr* radius_acct_get_msisdn Octstr client_ip  ) 
 

Definition at line 363 of file radius_acct.c.

References dict_get(), m, mutex_lock, mutex_unlock, normalize_number(), octstr_duplicate, octstr_get_cstr, radius_mutex, radius_table, and unified_prefix.

Referenced by add_msisdn(), and start_fetch().

00364 {
00365     Octstr *m, *r;
00366     char *uf;
00367 
00368     /* if no proxy thread is running, then pass NULL as result */
00369     if (radius_table == NULL || client_ip == NULL)
00370         return NULL;
00371 
00372     mutex_lock(radius_mutex);
00373     m = dict_get(radius_table, client_ip);
00374     mutex_unlock(radius_mutex);
00375     r = m ? octstr_duplicate(m) : NULL;
00376 
00377     /* apply number normalization */
00378     uf = unified_prefix ? octstr_get_cstr(unified_prefix) : NULL;
00379     normalize_number(uf, &r);
00380 
00381     return r;
00382 }

Here is the call graph for this function:

void radius_acct_init CfgGroup grp  ) 
 

Definition at line 384 of file radius_acct.c.

References cfg_get, cfg_get_integer(), client_table, dict_create(), gwthread_create, info(), mutex_create, octstr_create, octstr_destroy(), octstr_get_cstr, octstr_imm(), our_host, our_port, panic, proxy_thread(), radius_mutex, radius_table, remote_host, remote_port, remote_timeout, secret_nas, secret_radius, session_table, and unified_prefix.

Referenced by init_wapbox().

00385 {
00386     long nas_ports = 0;
00387 
00388     /* get configured parameters */
00389     if ((our_host = cfg_get(grp, octstr_imm("our-host"))) == NULL) {
00390         our_host = octstr_create("0.0.0.0");
00391     }
00392     if ((remote_host = cfg_get(grp, octstr_imm("remote-host"))) != NULL) {
00393         cfg_get_integer(&remote_port, grp, octstr_imm("remote-port"));
00394         if ((secret_radius = cfg_get(grp, octstr_imm("secret-radius"))) == NULL) {
00395             panic(0, "RADIUS: No shared secret `secret-radius' for remote RADIUS in `radius-acct' provided.");
00396         }
00397     }
00398     cfg_get_integer(&our_port, grp, octstr_imm("our-port"));
00399     cfg_get_integer(&remote_timeout, grp, octstr_imm("remote-timeout"));
00400 
00401     if ((cfg_get_integer(&nas_ports, grp, octstr_imm("nas-ports"))) == -1) {
00402         nas_ports = RADIUS_NAS_PORTS;
00403     }
00404 
00405     if ((secret_nas = cfg_get(grp, octstr_imm("secret-nas"))) == NULL) {
00406         panic(0, "RADIUS: No shared secret `secret-nas' for NAS in `radius-acct' provided.");
00407     }
00408 
00409     unified_prefix = cfg_get(grp, octstr_imm("unified-prefix"));
00410 
00411     info(0, "RADIUS: local RADIUS accounting proxy at <%s:%ld>",
00412          octstr_get_cstr(our_host), our_port);
00413     if (remote_host == NULL) {
00414         info(0, "RADIUS: remote RADIUS accounting server is absent");
00415     } else {
00416         info(0, "RADIUS: remote RADIUS accounting server at <%s:%ld>",
00417              octstr_get_cstr(remote_host), remote_port);
00418     }
00419 
00420     info(0, "RADIUS: initializing internal hash tables with %ld buckets.", nas_ports);
00421 
00422     radius_mutex = mutex_create();
00423 
00424     /* init hash tables */
00425     radius_table = dict_create(nas_ports, (void (*)(void *))octstr_destroy);
00426     session_table = dict_create(nas_ports, (void (*)(void *))octstr_destroy);
00427     client_table = dict_create(nas_ports, (void (*)(void *))octstr_destroy);
00428 
00429     gwthread_create(proxy_thread, NULL);
00430 }

Here is the call graph for this function:

void radius_acct_shutdown void   ) 
 

Definition at line 432 of file radius_acct.c.

References client_table, dict_destroy(), gwthread_join_every(), info(), mutex_destroy(), mutex_lock, mutex_unlock, octstr_destroy(), our_host, proxy_thread(), radius_mutex, radius_table, remote_host, run_thread, secret_nas, secret_radius, session_table, and unified_prefix.

Referenced by main().

00433 {
00434     if (radius_mutex == NULL) /* haven't init'ed at all */
00435         return ;
00436 
00437     mutex_lock(radius_mutex);
00438     run_thread = 0;
00439     mutex_unlock(radius_mutex);
00440 
00441     gwthread_join_every(proxy_thread);
00442 
00443     dict_destroy(radius_table);
00444     dict_destroy(session_table);
00445     dict_destroy(client_table);
00446 
00447     mutex_destroy(radius_mutex);
00448 
00449     octstr_destroy(our_host);
00450     octstr_destroy(remote_host);
00451     octstr_destroy(secret_nas);
00452     octstr_destroy(secret_radius);
00453     octstr_destroy(unified_prefix);
00454 
00455     info(0, "RADIUS: accounting proxy stopped.");
00456 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.