34 #include RADIUS_HEADER_STR
44 #define DATE_FORMAT "%Y-%m-%d %T %z"
46 #define VENDOR_CODE 22736
49 PW_AST_ACCT_CODE = 101,
53 PW_AST_CIDRDNIS = 105,
57 PW_AST_CHANNAME = 109,
60 PW_AST_EVENT_TIME = 112,
61 PW_AST_AMA_FLAGS = 113,
62 PW_AST_UNIQUE_ID = 114,
63 PW_AST_USER_NAME = 115,
64 PW_AST_LINKED_ID = 116,
78 #ifdef FREERADIUS_CLIENT
79 static char radiuscfg[PATH_MAX] =
"/etc/radiusclient/radiusclient.conf";
81 static char radiuscfg[PATH_MAX] =
"/etc/radiusclient-ng/radiusclient.conf";
86 static rc_handle *rh = NULL;
88 #define RADIUS_BACKEND_NAME "CEL Radius Logging"
90 #define ADD_VENDOR_CODE(x,y) (rc_avpair_add(rh, send, x, (void *)y, strlen(y), VENDOR_CODE))
94 int recordtype = PW_STATUS_STOP;
99 if (!rc_avpair_add(rh, send, PW_ACCT_STATUS_TYPE, &recordtype, 0, 0)) {
103 if (!ADD_VENDOR_CODE(PW_AST_ACCT_CODE, record->account_code)) {
107 if (!ADD_VENDOR_CODE(PW_AST_CIDNUM, record->caller_id_num)) {
111 if (!ADD_VENDOR_CODE(PW_AST_EXTEN, record->extension)) {
115 if (!ADD_VENDOR_CODE(PW_AST_CONTEXT, record->context)) {
119 if (!ADD_VENDOR_CODE(PW_AST_CIDNAME, record->caller_id_name)) {
123 if (!ADD_VENDOR_CODE(PW_AST_CIDANI, record->caller_id_ani)) {
127 if (!ADD_VENDOR_CODE(PW_AST_CIDRDNIS, record->caller_id_rdnis)) {
131 if (!ADD_VENDOR_CODE(PW_AST_CIDDNID, record->caller_id_dnid)) {
135 if (!ADD_VENDOR_CODE(PW_AST_CHANNAME, record->channel_name)) {
139 if (!ADD_VENDOR_CODE(PW_AST_APPNAME, record->application_name)) {
143 if (!ADD_VENDOR_CODE(PW_AST_APPDATA, record->application_data)) {
150 if (!rc_avpair_add(rh, send, PW_AST_EVENT_TIME, timestr, strlen(timestr), VENDOR_CODE)) {
155 if (!rc_avpair_add(rh, send, PW_AST_AMA_FLAGS, amaflags, strlen(amaflags), VENDOR_CODE)) {
160 if (!ADD_VENDOR_CODE(PW_AST_UNIQUE_ID, record->unique_id)) {
165 if (!ADD_VENDOR_CODE(PW_AST_LINKED_ID, record->linked_id)) {
171 if (!rc_avpair_add(rh, send, PW_USER_NAME, (
void *)record->channel_name,
172 strlen(record->channel_name), 0)) {
180 int result = ERROR_RC;
181 VALUE_PAIR *send = NULL;
190 if (build_radius_record(&send, &record)) {
191 ast_debug(1,
"Unable to create RADIUS record. CEL not recorded!\n");
195 result = rc_acct(rh, 0, send);
196 if (result != OK_RC) {
197 ast_log(LOG_ERROR,
"Failed to record Radius CEL record!\n");
202 rc_avpair_free(send);
206 static int unload_module(
void)
216 static int load_module(
void)
224 if ((tmp = ast_variable_retrieve(cfg,
"radius",
"radiuscfg"))) {
233 if (!(rh = rc_read_config(radiuscfg))) {
234 ast_log(LOG_NOTICE,
"Cannot load radiusclient-ng configuration file %s.\n", radiuscfg);
239 if (rc_read_dictionary(rh, rc_conf_str(rh,
"dictionary"))) {
240 ast_log(LOG_NOTICE,
"Cannot load radiusclient-ng dictionary file.\n");
255 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"RADIUS CEL Backend",
256 .support_level = AST_MODULE_SUPPORT_EXTENDED,
258 .unload = unload_module,
Helper struct for getting the fields out of a CEL event.
A container that holds all config-related information.
Asterisk main include file. File version handling, generic pbx functions.
int ast_cel_backend_register(const char *name, ast_cel_backend_cb backend_callback)
Register a CEL backend.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
#define ast_config_load(filename, flags)
Load a config file.
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
uint32_t version
struct ABI version
#define ast_debug(level,...)
Log a DEBUG message.
int ast_cel_backend_unregister(const char *name)
Unregister a CEL backend.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Support for logging to various files, console and syslog Configuration in file logger.conf.
Module has failed to load, may be in an inconsistent state.
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
#define AST_CEL_EVENT_RECORD_VERSION
struct ABI version
Structure used to handle boolean flags.
static struct ast_flags global_flags[1]
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Options provided by main asterisk program.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
int ast_cel_fill_record(const struct ast_event *event, struct ast_cel_event_record *r)
Fill in an ast_cel_event_record from a CEL event.