39 const
char *caller_id_name,
40 const
char *caller_id_number,
41 const
char *network_addr,
45 const
char *source, const
char *context, const
char *destination_number)
52 memset(profile, 0,
sizeof(*profile));
61 if (
zstr(caller_id_name)) {
65 if (
zstr(caller_id_number)) {
71 ani = caller_id_number;
136 profile->
ani_ton = tocopy->ani_ton;
142 profile->
flags = tocopy->flags;
156 for (pn = tocopy->soft; pn; pn = pn->
next) {
162 if (!profile->
soft) {
189 if (!strcasecmp(name,
"dialplan")) {
190 return caller_profile->dialplan;
192 if (!strcasecmp(name,
"username")) {
193 return caller_profile->username;
195 if (!strcasecmp(name,
"caller_id_name")) {
196 return caller_profile->caller_id_name;
198 if (!strcasecmp(name,
"caller_id_number")) {
199 return caller_profile->caller_id_number;
201 if (!strcasecmp(name,
"orig_caller_id_name")) {
202 return caller_profile->orig_caller_id_name;
204 if (!strcasecmp(name,
"orig_caller_id_number")) {
205 return caller_profile->orig_caller_id_number;
207 if (!strcasecmp(name,
"callee_id_name")) {
208 return caller_profile->callee_id_name;
210 if (!strcasecmp(name,
"callee_id_number")) {
211 return caller_profile->callee_id_number;
213 if (!strcasecmp(name,
"ani")) {
214 return caller_profile->ani;
216 if (!strcasecmp(name,
"aniii")) {
217 return caller_profile->aniii;
219 if (!strcasecmp(name,
"network_addr")) {
220 return caller_profile->network_addr;
222 if (!strcasecmp(name,
"rdnis")) {
223 return caller_profile->rdnis;
225 if (!strcasecmp(name,
"destination_number")) {
226 return caller_profile->destination_number;
228 if (!strcasecmp(name,
"uuid")) {
229 return caller_profile->uuid;
231 if (!strcasecmp(name,
"source")) {
232 return caller_profile->source;
234 if (!strcasecmp(name,
"transfer_source")) {
235 return caller_profile->transfer_source;
237 if (!strcasecmp(name,
"context")) {
238 return caller_profile->context;
241 if (!strcasecmp(name,
"chan_name")) {
242 return caller_profile->chan_name;
245 if (!strcasecmp(name,
"profile_index")) {
246 return caller_profile->profile_index;
249 if (!strcasecmp(name,
"caller_ton")) {
252 if (!strcasecmp(name,
"caller_numplan")) {
255 if (!strcasecmp(name,
"destination_number_ton")) {
256 return switch_core_sprintf(caller_profile->pool,
"%u", caller_profile->destination_number_ton);
258 if (!strcasecmp(name,
"destination_number_numplan")) {
259 return switch_core_sprintf(caller_profile->pool,
"%u", caller_profile->destination_number_numplan);
261 if (!strcasecmp(name,
"ani_ton")) {
264 if (!strcasecmp(name,
"ani_numplan")) {
267 if (!strcasecmp(name,
"rdnis_ton")) {
270 if (!strcasecmp(name,
"rdnis_numplan")) {
273 if (!strcasecmp(name,
"screen_bit")) {
276 if (!strcasecmp(name,
"privacy_hide_name")) {
279 if (!strcasecmp(name,
"privacy_hide_number")) {
282 if (!strcasecmp(name,
"profile_created_time")) {
285 if (!strcasecmp(name,
"created_time")) {
288 if (!strcasecmp(name,
"answered_time")) {
291 if (!strcasecmp(name,
"progress_time")) {
294 if (!strcasecmp(name,
"progress_media_time")) {
297 if (!strcasecmp(name,
"hungup_time")) {
300 if (!strcasecmp(name,
"transferred_time")) {
310 char header_name[1024];
313 switch_snprintf(header_name,
sizeof(header_name),
"%s-Direction", prefix);
315 "inbound" :
"outbound");
317 switch_snprintf(header_name,
sizeof(header_name),
"%s-Logical-Direction", prefix);
319 "inbound" :
"outbound");
321 if (!
zstr(caller_profile->username)) {
322 switch_snprintf(header_name,
sizeof(header_name),
"%s-Username", prefix);
325 if (!
zstr(caller_profile->dialplan)) {
326 switch_snprintf(header_name,
sizeof(header_name),
"%s-Dialplan", prefix);
329 if (!
zstr(caller_profile->caller_id_name)) {
330 switch_snprintf(header_name,
sizeof(header_name),
"%s-Caller-ID-Name", prefix);
333 if (!
zstr(caller_profile->caller_id_number)) {
334 switch_snprintf(header_name,
sizeof(header_name),
"%s-Caller-ID-Number", prefix);
337 if (!
zstr(caller_profile->caller_id_name)) {
338 switch_snprintf(header_name,
sizeof(header_name),
"%s-Orig-Caller-ID-Name", prefix);
341 if (!
zstr(caller_profile->caller_id_number)) {
342 switch_snprintf(header_name,
sizeof(header_name),
"%s-Orig-Caller-ID-Number", prefix);
345 if (!
zstr(caller_profile->callee_id_name)) {
346 switch_snprintf(header_name,
sizeof(header_name),
"%s-Callee-ID-Name", prefix);
349 if (!
zstr(caller_profile->callee_id_number)) {
350 switch_snprintf(header_name,
sizeof(header_name),
"%s-Callee-ID-Number", prefix);
353 if (!
zstr(caller_profile->network_addr)) {
354 switch_snprintf(header_name,
sizeof(header_name),
"%s-Network-Addr", prefix);
357 if (!
zstr(caller_profile->ani)) {
361 if (!
zstr(caller_profile->aniii)) {
362 switch_snprintf(header_name,
sizeof(header_name),
"%s-ANI-II", prefix);
365 if (!
zstr(caller_profile->destination_number)) {
366 switch_snprintf(header_name,
sizeof(header_name),
"%s-Destination-Number", prefix);
369 if (!
zstr(caller_profile->uuid)) {
370 switch_snprintf(header_name,
sizeof(header_name),
"%s-Unique-ID", prefix);
373 if (!
zstr(caller_profile->source)) {
374 switch_snprintf(header_name,
sizeof(header_name),
"%s-Source", prefix);
377 if (!
zstr(caller_profile->transfer_source)) {
378 switch_snprintf(header_name,
sizeof(header_name),
"%s-Transfer-Source", prefix);
381 if (!
zstr(caller_profile->context)) {
382 switch_snprintf(header_name,
sizeof(header_name),
"%s-Context", prefix);
385 if (!
zstr(caller_profile->rdnis)) {
389 if (!
zstr(caller_profile->chan_name)) {
390 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Name", prefix);
393 if (!
zstr(caller_profile->profile_index)) {
394 switch_snprintf(header_name,
sizeof(header_name),
"%s-Profile-Index", prefix);
398 if (caller_profile->soft) {
401 for (pn = caller_profile->soft; pn; pn = pn->
next) {
407 if (!(times = caller_profile->times)) {
408 times = caller_profile->old_times;
413 switch_snprintf(header_name,
sizeof(header_name),
"%s-Profile-Created-Time", prefix);
415 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Created-Time", prefix);
417 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Answered-Time", prefix);
419 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Progress-Time", prefix);
421 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Progress-Media-Time", prefix);
423 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Hangup-Time", prefix);
425 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Transfer-Time", prefix);
427 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Resurrect-Time", prefix);
429 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Bridged-Time", prefix);
431 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Last-Hold", prefix);
433 switch_snprintf(header_name,
sizeof(header_name),
"%s-Channel-Hold-Accum", prefix);
437 switch_snprintf(header_name,
sizeof(header_name),
"%s-Screen-Bit", prefix);
440 switch_snprintf(header_name,
sizeof(header_name),
"%s-Privacy-Hide-Name", prefix);
443 switch_snprintf(header_name,
sizeof(header_name),
"%s-Privacy-Hide-Number", prefix);
461 for (ap = orig->applications; ap; ap = ap->next) {
464 if (ap == orig->current_application) {
483 if (ap == orig->current_application) {
488 *new_ext = caller_extension;
498 const
char *extension_number)
508 return caller_extension;
514 const
char *fmt, ...)
521 if (strstr(data,
"\\'")) {
536 const
char *application_data)
554 if (!caller_extension->applications) {
555 caller_extension->applications = caller_application;
556 }
else if (caller_extension->last_application) {
557 caller_extension->last_application->
next = caller_application;
560 caller_extension->last_application = caller_application;
561 caller_extension->current_application = caller_extension->applications;
#define SWITCH_DEFAULT_CLID_NUMBER
#define SWITCH_CHANNEL_SESSION_LOG(x)
An Abstract Representation of a dialplan extension.
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
#define SWITCH_NUMPLAN_UNDEF
const char * orig_caller_id_name
const char * switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
const char * network_addr
switch_memory_pool_t * pool
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
An Abstract Representation of a dialplan Application.
void switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, const char *prefix, switch_event_t *event)
switch_caller_application_t * last_application
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
struct switch_caller_application * next
#define SWITCH_DEFAULT_CLID_NAME
switch_caller_profile_t * switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
const char * orig_caller_id_number
const char * callee_id_number
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
switch_caller_profile_t * switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
switch_caller_application_t * applications
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
uint8_t destination_number_ton
const char * caller_id_name
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
#define SWITCH_BLANK_STRING
struct profile_node_s * next
switch_call_direction_t direction
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
uint8_t destination_number_numplan
switch_status_t switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, switch_memory_pool_t *pool)
switch_caller_application_t * current_application
switch_caller_profile_flag_t flags
switch_status_t
Common return values.
#define profile_dup(a, b, p)
struct switch_channel_timetable * old_times
char * switch_uuid_str(char *buf, switch_size_t len)
void switch_caller_extension_add_application(switch_core_session_t *session, switch_caller_extension_t *caller_extension, const char *application_name, const char *application_data)
char * destination_number
const char * caller_id_number
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
void switch_caller_extension_add_application_printf(switch_core_session_t *session, switch_caller_extension_t *caller_extension, const char *application_name, const char *fmt,...)
struct apr_pool_t switch_memory_pool_t
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_caller_extension_t * switch_caller_extension_new(switch_core_session_t *session, const char *extension_name, const char *extension_number)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
char * switch_core_sprintf(_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the pool ...
#define profile_dup_clean(a, b, p)
const char * callee_id_name
switch_caller_profile_t * switch_caller_profile_new(switch_memory_pool_t *pool, const char *username, const char *dialplan, const char *caller_id_name, const char *caller_id_number, const char *network_addr, const char *ani, const char *aniii, const char *rdnis, const char *source, const char *context, const char *destination_number)
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
#define SWITCH_UUID_FORMATTED_LENGTH
switch_memory_pool_t * pool