76 #define RADIUS_NAS_PORTS 30 112 Octstr *client_ip, *msisdn;
117 client_ip = msisdn =
type = session_id = NULL;
120 if (pdu->
type == 0x04) {
133 if (client_ip == NULL || msisdn == NULL) {
134 warning(0,
"RADIUS: NAS did either not send 'Framed-IP-Address' or/and " 135 "'Calling-Station-Id', dropping mapping but will forward.");
147 Octstr *old_session_id, *old_client_ip;
168 info(0,
"RADIUS: Mapping `%s <-> %s' for session id <%s> added.",
173 warning(0,
"RADIUS: Duplicate mapping `%s <-> %s' for session " 174 "id <%s> received, ignoring.",
188 info(0,
"RADIUS: Mapping `%s <-> %s' for session id <%s> removed.",
196 warning(0,
"RADIUS: Could not find mapping for `%s' session " 197 "id <%s>, ignoring.",
202 error(0,
"RADIUS: unknown Acct-Status-Type `%s' received, ignoring.",
230 fl = fcntl(cs, F_GETFL);
231 fcntl(cs, F_SETFL, fl | O_NONBLOCK);
239 fl = fcntl(ss, F_GETFL);
240 fcntl(ss, F_SETFL, fl | O_NONBLOCK);
243 panic(0,
"RADIUS: Couldn't set up server socket for port %ld.",
our_port);
248 Octstr *from_nas, *from_radius;
251 data = rdata = from_nas = from_radius = NULL;
262 error(0,
"RADIUS: Couldn't receive request data from NAS");
267 info(0,
"RADIUS: Got data from NAS <%s:%d>",
274 warning(0,
"RADIUS: Couldn't unpack PDU from NAS, ignoring.");
281 warning(0,
"RADIUS: Authentication failed for PDU from NAS, ignoring.");
297 r->
u.Accounting_Response.identifier = pdu->
u.Accounting_Request.identifier;
298 r->
u.Accounting_Response.authenticator =
313 error(0,
"RADIUS: Couldn't send to remote RADIUS <%s:%ld>.",
317 error(0,
"RADIUS: Timeout for response from remote RADIUS <%s:%ld>.",
321 error(0,
"RADIUS: Couldn't receive from remote RADIUS <%s:%ld>.",
324 info(0,
"RADIUS: Got data from remote RADIUS <%s:%d>.",
335 error(0,
"RADIUS: Couldn't send response data to NAS <%s:%d>.",
346 debug(
"radius.proxy", 0,
"RADIUS: Mapping table contains %ld elements",
348 debug(
"radius.proxy", 0,
"RADIUS: Session table contains %ld elements",
350 debug(
"radius.proxy", 0,
"RADIUS: Client table contains %ld elements",
395 panic(0,
"RADIUS: No shared secret `secret-radius' for remote RADIUS in `radius-acct' provided.");
406 panic(0,
"RADIUS: No shared secret `secret-nas' for NAS in `radius-acct' provided.");
411 info(0,
"RADIUS: local RADIUS accounting proxy at <%s:%ld>",
414 info(0,
"RADIUS: remote RADIUS accounting server is absent");
416 info(0,
"RADIUS: remote RADIUS accounting server at <%s:%ld>",
420 info(0,
"RADIUS: initializing internal hash tables with %ld buckets.", nas_ports);
455 info(0,
"RADIUS: accounting proxy stopped.");
Dict * dict_create(long size_hint, void(*destroy_value)(void *))
void error(int err, const char *fmt,...)
void info(int err, const char *fmt,...)
Octstr * radius_acct_get_msisdn(Octstr *client_ip)
static Mutex * radius_mutex
void dict_put(Dict *dict, Octstr *key, void *value)
RADIUS_PDU * radius_pdu_unpack(Octstr *data_without_len)
static Octstr * unified_prefix
int udp_get_port(Octstr *addr)
static int update_tables(RADIUS_PDU *pdu)
#define cfg_get(grp, varname)
static void proxy_thread(void *arg)
static Octstr * secret_radius
void radius_acct_init(CfgGroup *grp)
#define octstr_get_cstr(ostr)
void gwthread_join_every(gwthread_func_t *func)
void radius_pdu_destroy(RADIUS_PDU *pdu)
int radius_authenticate_pdu(RADIUS_PDU *pdu, Octstr **data, Octstr *secret)
Octstr * octstr_imm(const char *cstr)
void * dict_remove(Dict *dict, Octstr *key)
int udp_bind(int port, const char *source_addr)
int udp_client_socket(void)
void * dict_get(Dict *dict, Octstr *key)
#define octstr_duplicate(ostr)
#define octstr_dump(ostr, level,...)
long dict_key_count(Dict *dict)
static Dict * session_table
void warning(int err, const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define gwthread_create(func, arg)
#define octstr_create(cstr)
void radius_acct_shutdown(void)
void mutex_destroy(Mutex *mutex)
void dict_destroy(Dict *dict)
RADIUS_PDU * radius_pdu_create(int type, RADIUS_PDU *req)
static Dict * radius_table
int read_available(int fd, long wait_usec)
void debug(const char *place, int err, const char *fmt,...)
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
int normalize_number(char *dial_prefixes, Octstr **number)
static Octstr * secret_nas
static long remote_timeout
int udp_sendto(int s, Octstr *datagram, Octstr *addr)
Octstr * radius_pdu_pack(RADIUS_PDU *pdu)
static Octstr * remote_host
static Dict * client_table
int udp_recvfrom(int s, Octstr **datagram, Octstr **addr)
Octstr * udp_create_address(Octstr *host_or_ip, int port)
Octstr * udp_get_ip(Octstr *addr)
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)