Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
radius_acct.h File Reference

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(), mutex_lock, mutex_unlock, normalize_number(), octstr_duplicate, and octstr_get_cstr.

Referenced by add_msisdn(), and start_fetch().

364 {
365  Octstr *m, *r;
366  char *uf;
367 
368  /* if no proxy thread is running, then pass NULL as result */
369  if (radius_table == NULL || client_ip == NULL)
370  return NULL;
371 
373  m = dict_get(radius_table, client_ip);
375  r = m ? octstr_duplicate(m) : NULL;
376 
377  /* apply number normalization */
379  normalize_number(uf, &r);
380 
381  return r;
382 }
static Mutex * radius_mutex
Definition: radius_acct.c:78
#define mutex_unlock(m)
Definition: thread.h:136
static Octstr * unified_prefix
Definition: radius_acct.c:96
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void * dict_get(Dict *dict, Octstr *key)
Definition: dict.c:286
#define octstr_duplicate(ostr)
Definition: octstr.h:187
Definition: octstr.c:118
static Dict * radius_table
Definition: radius_acct.c:71
int normalize_number(char *dial_prefixes, Octstr **number)
Definition: utils.c:882
#define mutex_lock(m)
Definition: thread.h:130
void radius_acct_init ( CfgGroup grp)

Definition at line 384 of file radius_acct.c.

References cfg_get, cfg_get_integer(), dict_create(), gwthread_create, info(), mutex_create, octstr_create, octstr_destroy(), octstr_get_cstr, octstr_imm(), our_port, panic, proxy_thread(), RADIUS_NAS_PORTS, remote_port, and remote_timeout.

Referenced by init_wapbox().

385 {
386  long nas_ports = 0;
387 
388  /* get configured parameters */
389  if ((our_host = cfg_get(grp, octstr_imm("our-host"))) == NULL) {
390  our_host = octstr_create("0.0.0.0");
391  }
392  if ((remote_host = cfg_get(grp, octstr_imm("remote-host"))) != NULL) {
393  cfg_get_integer(&remote_port, grp, octstr_imm("remote-port"));
394  if ((secret_radius = cfg_get(grp, octstr_imm("secret-radius"))) == NULL) {
395  panic(0, "RADIUS: No shared secret `secret-radius' for remote RADIUS in `radius-acct' provided.");
396  }
397  }
398  cfg_get_integer(&our_port, grp, octstr_imm("our-port"));
399  cfg_get_integer(&remote_timeout, grp, octstr_imm("remote-timeout"));
400 
401  if ((cfg_get_integer(&nas_ports, grp, octstr_imm("nas-ports"))) == -1) {
402  nas_ports = RADIUS_NAS_PORTS;
403  }
404 
405  if ((secret_nas = cfg_get(grp, octstr_imm("secret-nas"))) == NULL) {
406  panic(0, "RADIUS: No shared secret `secret-nas' for NAS in `radius-acct' provided.");
407  }
408 
409  unified_prefix = cfg_get(grp, octstr_imm("unified-prefix"));
410 
411  info(0, "RADIUS: local RADIUS accounting proxy at <%s:%ld>",
413  if (remote_host == NULL) {
414  info(0, "RADIUS: remote RADIUS accounting server is absent");
415  } else {
416  info(0, "RADIUS: remote RADIUS accounting server at <%s:%ld>",
418  }
419 
420  info(0, "RADIUS: initializing internal hash tables with %ld buckets.", nas_ports);
421 
423 
424  /* init hash tables */
425  radius_table = dict_create(nas_ports, (void (*)(void *))octstr_destroy);
426  session_table = dict_create(nas_ports, (void (*)(void *))octstr_destroy);
427  client_table = dict_create(nas_ports, (void (*)(void *))octstr_destroy);
428 
430 }
Dict * dict_create(long size_hint, void(*destroy_value)(void *))
Definition: dict.c:192
void info(int err, const char *fmt,...)
Definition: log.c:636
static long our_port
Definition: radius_acct.c:87
static Mutex * radius_mutex
Definition: radius_acct.c:78
static Octstr * unified_prefix
Definition: radius_acct.c:96
#define mutex_create()
Definition: thread.h:96
#define cfg_get(grp, varname)
Definition: cfg.h:86
static void proxy_thread(void *arg)
Definition: radius_acct.c:215
static Octstr * secret_radius
Definition: radius_acct.c:93
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
static Octstr * our_host
Definition: radius_acct.c:86
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
#define RADIUS_NAS_PORTS
Definition: radius_acct.c:76
static Dict * session_table
Definition: radius_acct.c:72
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define octstr_create(cstr)
Definition: octstr.h:125
static Dict * radius_table
Definition: radius_acct.c:71
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:739
#define panic
Definition: log.h:87
static Octstr * secret_nas
Definition: radius_acct.c:92
static long remote_timeout
Definition: radius_acct.c:99
static long remote_port
Definition: radius_acct.c:89
static Octstr * remote_host
Definition: radius_acct.c:88
static Dict * client_table
Definition: radius_acct.c:73
void radius_acct_shutdown ( void  )

Definition at line 432 of file radius_acct.c.

References dict_destroy(), gwthread_join_every(), info(), mutex_destroy(), mutex_lock, mutex_unlock, octstr_destroy(), proxy_thread(), and run_thread.

Referenced by main().

433 {
434  if (radius_mutex == NULL) /* haven't init'ed at all */
435  return ;
436 
438  run_thread = 0;
440 
442 
446 
448 
454 
455  info(0, "RADIUS: accounting proxy stopped.");
456 }
void info(int err, const char *fmt,...)
Definition: log.c:636
static Mutex * radius_mutex
Definition: radius_acct.c:78
#define mutex_unlock(m)
Definition: thread.h:136
static Octstr * unified_prefix
Definition: radius_acct.c:96
static void proxy_thread(void *arg)
Definition: radius_acct.c:215
static Octstr * secret_radius
Definition: radius_acct.c:93
void gwthread_join_every(gwthread_func_t *func)
static Octstr * our_host
Definition: radius_acct.c:86
static Dict * session_table
Definition: radius_acct.c:72
static int run_thread
Definition: radius_acct.c:79
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
void mutex_destroy(Mutex *mutex)
Definition: thread.c:97
void dict_destroy(Dict *dict)
Definition: dict.c:215
static Dict * radius_table
Definition: radius_acct.c:71
static Octstr * secret_nas
Definition: radius_acct.c:92
#define mutex_lock(m)
Definition: thread.h:130
static Octstr * remote_host
Definition: radius_acct.c:88
static Dict * client_table
Definition: radius_acct.c:73
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.