| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#include "cdrel.h" |
| 28 |
#include "asterisk/cel.h" |
| 29 |
|
| 30 |
static int cel_get_string(void *record, struct cdrel_config *config, |
| 31 |
struct cdrel_field *field, struct cdrel_value *value) |
| 32 |
{ |
| 33 |
struct ast_event *event = record; |
| 34 |
value->data_type = cdrel_type_string; |
| 35 |
value->field_name = field->name; |
| 36 |
value->values.string = (char *)ast_event_get_ie_str(event, field->field_id); |
| 37 |
return 0; |
| 38 |
} |
| 39 |
|
| 40 |
static int cel_get_literal(void *record, struct cdrel_config *config, |
| 41 |
struct cdrel_field *field, struct cdrel_value *value) |
| 42 |
{ |
| 43 |
value->data_type = cdrel_type_string; |
| 44 |
value->field_name = field->name; |
| 45 |
value->values.string = field->data; |
| 46 |
return 0; |
| 47 |
} |
| 48 |
|
| 49 |
static int cel_get_timeval(void *record, struct cdrel_config *config, |
| 50 |
struct cdrel_field *field, struct cdrel_value *value) |
| 51 |
{ |
| 52 |
struct ast_event *event = record; |
| 53 |
value->data_type = cdrel_type_timeval; |
| 54 |
value->field_name = field->name; |
| 55 |
value->values.tv.tv_sec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME); |
| 56 |
value->values.tv.tv_usec = ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC); |
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
static int cel_get_uint32(void *record, struct cdrel_config *config, |
| 61 |
struct cdrel_field *field, struct cdrel_value *value) |
| 62 |
{ |
| 63 |
struct ast_event *event = record; |
| 64 |
value->data_type = cdrel_type_uint32; |
| 65 |
value->field_name = field->name; |
| 66 |
value->values.uint32 = ast_event_get_ie_uint(event, field->field_id); |
| 67 |
return 0; |
| 68 |
} |
| 69 |
|
| 70 |
static int cel_get_event_type(void *record, struct cdrel_config *config, |
| 71 |
struct cdrel_field *field, struct cdrel_value *value) |
| 72 |
{ |
| 73 |
struct ast_event *event = record; |
| 74 |
const char *val = NULL; |
| 75 |
value->data_type = cdrel_type_string; |
| 76 |
value->field_name = field->name; |
| 77 |
|
| 78 |
if (ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE) == AST_CEL_USER_DEFINED) { |
| 79 |
val = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME); |
| 80 |
} else { |
| 81 |
val = ast_cel_get_type_name(ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE)); |
| 82 |
} |
| 83 |
value->values.string = (char *)val; |
| 84 |
return 0; |
| 85 |
} |
| 86 |
|
| 87 |
static int cel_get_event_enum(void *record, struct cdrel_config *config, |
| 88 |
struct cdrel_field *field, struct cdrel_value *value) |
| 89 |
{ |
| 90 |
struct ast_event *event = record; |
| 91 |
value->data_type = cdrel_type_string; |
| 92 |
value->field_name = field->name; |
| 93 |
value->values.string = (char *)ast_cel_get_type_name(ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE)); |
| 94 |
return 0; |
| 95 |
} |
| 96 |
|
| 97 |
static struct ast_channel *dummy_chan_alloc_cel(struct cdrel_config *config, void *data) |
| 98 |
{ |
| 99 |
struct ast_event *event = data; |
| 100 |
|
| 101 |
return ast_cel_fabricate_channel_from_event(event); |
| 102 |
} |
| 103 |
|
| 104 |
int load_cel(void) |
| 105 |
{ |
| 106 |
ast_debug(1, "Loading CEL getters\n"); |
| 107 |
cdrel_field_getters[cdrel_record_cel][cdrel_type_string] = cel_get_string; |
| 108 |
cdrel_field_getters[cdrel_record_cel][cdrel_type_literal] = cel_get_literal; |
| 109 |
cdrel_field_getters[cdrel_record_cel][cdrel_type_uint32] = cel_get_uint32; |
| 110 |
cdrel_field_getters[cdrel_record_cel][cdrel_type_timeval] = cel_get_timeval; |
| 111 |
cdrel_field_getters[cdrel_record_cel][cdrel_type_event_type] = cel_get_event_type; |
| 112 |
cdrel_field_getters[cdrel_record_cel][cdrel_type_event_enum] = cel_get_event_enum; |
| 113 |
cdrel_dummy_channel_allocators[cdrel_record_cel] = dummy_chan_alloc_cel; |
| 114 |
|
| 115 |
return 0; |
| 116 |
} |