FreeSWITCH API Documentation  1.7.0
Functions
switch_caller.c File Reference
#include <switch.h>
#include <switch_caller.h>
+ Include dependency graph for switch_caller.c:

Go to the source code of this file.

Functions

switch_caller_profile_tswitch_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_caller_profile_tswitch_caller_profile_dup (switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
 
switch_caller_profile_tswitch_caller_profile_clone (switch_core_session_t *session, switch_caller_profile_t *tocopy)
 
const char * switch_caller_get_field_by_name (switch_caller_profile_t *caller_profile, const char *name)
 
void switch_caller_profile_event_set_data (switch_caller_profile_t *caller_profile, const char *prefix, switch_event_t *event)
 
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_extension_tswitch_caller_extension_new (switch_core_session_t *session, const char *extension_name, const char *extension_number)
 
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,...)
 
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)
 

Function Documentation

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 
)

Definition at line 534 of file switch_caller.c.

References switch_caller_application::application_data, switch_caller_application::application_name, switch_caller_application::next, switch_assert, SWITCH_CHANNEL_SESSION_LOG, switch_core_session_alloc, switch_core_session_strdup, switch_log_printf(), and SWITCH_LOG_WARNING.

Referenced by switch_caller_extension_add_application_printf().

537 {
538  switch_caller_application_t *caller_application = NULL;
539 
540  switch_assert(session != NULL);
541 
542  if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application_t))) != 0) {
543  caller_application->application_name = switch_core_session_strdup(session, application_name);
544  caller_application->application_data = switch_core_session_strdup(session, application_data);
545 
546 
547 
548  if (caller_application->application_data && strstr(caller_application->application_data, "\\'")) {
549  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
550  caller_application->application_data);
551  return;
552  }
553 
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;
558  }
559 
560  caller_extension->last_application = caller_application;
561  caller_extension->current_application = caller_extension->applications;
562  }
563 
564 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
An Abstract Representation of a dialplan Application.
switch_caller_application_t * last_application
struct switch_caller_application * next
switch_caller_application_t * applications
switch_caller_application_t * current_application
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
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.
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
#define switch_assert(expr)
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,
  ... 
)

Definition at line 512 of file switch_caller.c.

References switch_buffer::data, switch_caller_extension_add_application(), SWITCH_CHANNEL_SESSION_LOG, switch_log_printf(), SWITCH_LOG_WARNING, switch_safe_free, and switch_vasprintf().

515 {
516  va_list ap;
517  char *data = NULL;
518 
519  va_start(ap, fmt);
520  if ( switch_vasprintf(&data, fmt, ap) != -1 ) {
521  if (strstr(data, "\\'")) {
522  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
523  data);
524  } else {
525  switch_caller_extension_add_application(session, caller_extension, application_name, data);
526  }
527  }
528  va_end(ap);
529 
530  switch_safe_free(data);
531 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:789
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
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)
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 
)

Definition at line 497 of file switch_caller.c.

References switch_caller_extension::applications, switch_caller_extension::current_application, switch_caller_extension::extension_name, switch_caller_extension::extension_number, switch_caller_extension::last_application, switch_core_session_alloc, and switch_core_session_strdup.

499 {
500  switch_caller_extension_t *caller_extension = NULL;
501 
502  if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension_t))) != 0) {
503  caller_extension->extension_name = switch_core_session_strdup(session, extension_name);
504  caller_extension->extension_number = switch_core_session_strdup(session, extension_number);
505  caller_extension->current_application = caller_extension->last_application = caller_extension->applications;
506  }
507 
508  return caller_extension;
509 }
An Abstract Representation of a dialplan extension.
switch_caller_application_t * last_application
switch_caller_application_t * applications
switch_caller_application_t * current_application
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
const char* switch_caller_get_field_by_name ( switch_caller_profile_t caller_profile,
const char *  name 
)

Definition at line 187 of file switch_caller.c.

References switch_core_sprintf(), SWITCH_CPF_HIDE_NAME, SWITCH_CPF_HIDE_NUMBER, SWITCH_CPF_SCREEN, switch_test_flag, and SWITCH_TIME_T_FMT.

188 {
189  if (!strcasecmp(name, "dialplan")) {
190  return caller_profile->dialplan;
191  }
192  if (!strcasecmp(name, "username")) {
193  return caller_profile->username;
194  }
195  if (!strcasecmp(name, "caller_id_name")) {
196  return caller_profile->caller_id_name;
197  }
198  if (!strcasecmp(name, "caller_id_number")) {
199  return caller_profile->caller_id_number;
200  }
201  if (!strcasecmp(name, "orig_caller_id_name")) {
202  return caller_profile->orig_caller_id_name;
203  }
204  if (!strcasecmp(name, "orig_caller_id_number")) {
205  return caller_profile->orig_caller_id_number;
206  }
207  if (!strcasecmp(name, "callee_id_name")) {
208  return caller_profile->callee_id_name;
209  }
210  if (!strcasecmp(name, "callee_id_number")) {
211  return caller_profile->callee_id_number;
212  }
213  if (!strcasecmp(name, "ani")) {
214  return caller_profile->ani;
215  }
216  if (!strcasecmp(name, "aniii")) {
217  return caller_profile->aniii;
218  }
219  if (!strcasecmp(name, "network_addr")) {
220  return caller_profile->network_addr;
221  }
222  if (!strcasecmp(name, "rdnis")) {
223  return caller_profile->rdnis;
224  }
225  if (!strcasecmp(name, "destination_number")) {
226  return caller_profile->destination_number;
227  }
228  if (!strcasecmp(name, "uuid")) {
229  return caller_profile->uuid;
230  }
231  if (!strcasecmp(name, "source")) {
232  return caller_profile->source;
233  }
234  if (!strcasecmp(name, "transfer_source")) {
235  return caller_profile->transfer_source;
236  }
237  if (!strcasecmp(name, "context")) {
238  return caller_profile->context;
239  }
240 
241  if (!strcasecmp(name, "chan_name")) {
242  return caller_profile->chan_name;
243  }
244 
245  if (!strcasecmp(name, "profile_index")) {
246  return caller_profile->profile_index;
247  }
248 
249  if (!strcasecmp(name, "caller_ton")) {
250  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
251  }
252  if (!strcasecmp(name, "caller_numplan")) {
253  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
254  }
255  if (!strcasecmp(name, "destination_number_ton")) {
256  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
257  }
258  if (!strcasecmp(name, "destination_number_numplan")) {
259  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
260  }
261  if (!strcasecmp(name, "ani_ton")) {
262  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
263  }
264  if (!strcasecmp(name, "ani_numplan")) {
265  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
266  }
267  if (!strcasecmp(name, "rdnis_ton")) {
268  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
269  }
270  if (!strcasecmp(name, "rdnis_numplan")) {
271  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
272  }
273  if (!strcasecmp(name, "screen_bit")) {
274  return switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false";
275  }
276  if (!strcasecmp(name, "privacy_hide_name")) {
277  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false";
278  }
279  if (!strcasecmp(name, "privacy_hide_number")) {
280  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false";
281  }
282  if (!strcasecmp(name, "profile_created_time")) {
283  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
284  }
285  if (!strcasecmp(name, "created_time")) {
286  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
287  }
288  if (!strcasecmp(name, "answered_time")) {
289  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
290  }
291  if (!strcasecmp(name, "progress_time")) {
292  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);
293  }
294  if (!strcasecmp(name, "progress_media_time")) {
295  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);
296  }
297  if (!strcasecmp(name, "hungup_time")) {
298  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
299  }
300  if (!strcasecmp(name, "transferred_time")) {
301  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
302  }
303 
304 
305  return NULL;
306 }
const char * orig_caller_id_name
Definition: switch_caller.h:83
const char * network_addr
Definition: switch_caller.h:93
const char * dialplan
Definition: switch_caller.h:77
const char * username
Definition: switch_caller.h:75
const char * orig_caller_id_number
Definition: switch_caller.h:85
const char * callee_id_number
Definition: switch_caller.h:89
const char * caller_id_name
Definition: switch_caller.h:79
#define SWITCH_TIME_T_FMT
switch_time_t profile_created
uint8_t destination_number_numplan
const char * profile_index
struct switch_channel_timetable * times
const char * caller_id_number
Definition: switch_caller.h:81
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624
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 ...
const char * callee_id_name
Definition: switch_caller.h:87
switch_time_t progress_media
switch_memory_pool_t * pool
switch_caller_profile_t* switch_caller_profile_clone ( switch_core_session_t session,
switch_caller_profile_t tocopy 
)

Definition at line 178 of file switch_caller.c.

References pool, switch_caller_profile_dup(), and switch_core_session_get_pool().

179 {
181 
182  pool = switch_core_session_get_pool(session);
183 
184  return switch_caller_profile_dup(pool, tocopy);
185 }
switch_memory_pool_t * pool
switch_caller_profile_t * switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
struct apr_pool_t switch_memory_pool_t
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
switch_caller_profile_t* switch_caller_profile_dup ( switch_memory_pool_t pool,
switch_caller_profile_t tocopy 
)

Definition at line 104 of file switch_caller.c.

References switch_caller_profile::ani, switch_caller_profile::ani_numplan, switch_caller_profile::ani_ton, switch_caller_profile::aniii, switch_caller_profile::callee_id_name, switch_caller_profile::callee_id_number, switch_caller_profile::caller_id_name, switch_caller_profile::caller_id_number, switch_caller_profile::caller_numplan, switch_caller_profile::caller_ton, switch_caller_profile::chan_name, switch_caller_profile::clone_of, switch_caller_profile::context, switch_caller_profile::destination_number, switch_caller_profile::destination_number_numplan, switch_caller_profile::destination_number_ton, switch_caller_profile::dialplan, switch_caller_profile::direction, switch_caller_profile::flags, switch_caller_profile::network_addr, profile_node_s::next, switch_caller_profile::old_times, switch_caller_profile::orig_caller_id_name, switch_caller_profile::orig_caller_id_number, pool, switch_caller_profile::pool, profile_dup, switch_caller_profile::rdnis, switch_caller_profile::rdnis_numplan, switch_caller_profile::rdnis_ton, switch_caller_profile::soft, switch_caller_profile::source, switch_assert, switch_core_alloc, switch_core_strdup, SWITCH_UUID_FORMATTED_LENGTH, switch_uuid_str(), switch_caller_profile::username, switch_caller_profile::uuid, switch_caller_profile::uuid_str, profile_node_s::val, and profile_node_s::var.

Referenced by switch_caller_profile_clone().

105 {
106  switch_caller_profile_t *profile = NULL;
107  char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
108 
109  profile = switch_core_alloc(pool, sizeof(*profile));
110  switch_assert(profile != NULL);
111 
112  switch_uuid_str(uuid_str, sizeof(uuid_str));
113  profile->uuid_str = switch_core_strdup(pool, uuid_str);
114  profile->clone_of = switch_core_strdup(pool, tocopy->uuid_str);
115 
116  profile_dup(tocopy->username, profile->username, pool);
117  profile_dup(tocopy->dialplan, profile->dialplan, pool);
118  profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool);
120  profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool);
124  profile_dup(tocopy->network_addr, profile->network_addr, pool);
125  profile_dup(tocopy->ani, profile->ani, pool);
126  profile_dup(tocopy->aniii, profile->aniii, pool);
127  profile_dup(tocopy->rdnis, profile->rdnis, pool);
128  profile_dup(tocopy->source, profile->source, pool);
129  profile_dup(tocopy->context, profile->context, pool);
131  profile_dup(tocopy->uuid, profile->uuid, pool);
132  profile_dup(tocopy->chan_name, profile->chan_name, pool);
133 
134  profile->caller_ton = tocopy->caller_ton;
135  profile->caller_numplan = tocopy->caller_numplan;
136  profile->ani_ton = tocopy->ani_ton;
137  profile->ani_numplan = tocopy->ani_numplan;
138  profile->rdnis_ton = tocopy->rdnis_ton;
139  profile->rdnis_numplan = tocopy->rdnis_numplan;
142  profile->flags = tocopy->flags;
143  profile->pool = pool;
144  profile->direction = tocopy->direction;
145 
146  if (tocopy->times) {
148  *profile->old_times = *tocopy->times;
149  } else {
150  tocopy->times = (switch_channel_timetable_t *) switch_core_alloc(tocopy->pool, sizeof(*tocopy->times));
151  }
152 
153  if (tocopy->soft) {
154  profile_node_t *pn;
155 
156  for (pn = tocopy->soft; pn; pn = pn->next) {
157  profile_node_t *pp, *n = switch_core_alloc(profile->pool, sizeof(*n));
158 
159  n->var = switch_core_strdup(profile->pool, pn->var);
160  n->val = switch_core_strdup(profile->pool, pn->val);
161 
162  if (!profile->soft) {
163  profile->soft = n;
164  } else {
165  for(pp = profile->soft; pp && pp->next; pp = pp->next);
166 
167  if (pp) {
168  pp->next = n;
169  }
170  }
171  }
172 
173  }
174 
175  return profile;
176 }
Call Specific Data.
Definition: switch_caller.h:73
const char * orig_caller_id_name
Definition: switch_caller.h:83
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
const char * network_addr
Definition: switch_caller.h:93
switch_memory_pool_t * pool
const char * dialplan
Definition: switch_caller.h:77
const char * username
Definition: switch_caller.h:75
const char * orig_caller_id_number
Definition: switch_caller.h:85
const char * callee_id_number
Definition: switch_caller.h:89
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
const char * caller_id_name
Definition: switch_caller.h:79
struct profile_node_s * next
Definition: switch_caller.h:66
switch_call_direction_t direction
uint8_t destination_number_numplan
switch_caller_profile_flag_t flags
#define profile_dup(a, b, p)
Definition: switch_caller.h:60
struct switch_channel_timetable * old_times
char * switch_uuid_str(char *buf, switch_size_t len)
struct switch_channel_timetable * times
const char * caller_id_number
Definition: switch_caller.h:81
profile_node_t * soft
#define switch_assert(expr)
const char * callee_id_name
Definition: switch_caller.h:87
#define SWITCH_UUID_FORMATTED_LENGTH
Definition: switch_apr.h:545
switch_memory_pool_t * pool
void switch_caller_profile_event_set_data ( switch_caller_profile_t caller_profile,
const char *  prefix,
switch_event_t event 
)

Definition at line 308 of file switch_caller.c.

References switch_channel_timetable::answered, switch_channel_timetable::bridged, switch_channel_timetable::created, switch_channel_timetable::hold_accum, switch_channel_timetable::hungup, switch_channel_timetable::last_hold, profile_node_s::next, switch_channel_timetable::profile_created, switch_channel_timetable::progress, switch_channel_timetable::progress_media, switch_channel_timetable::resurrected, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CPF_HIDE_NAME, SWITCH_CPF_HIDE_NUMBER, SWITCH_CPF_SCREEN, switch_event_add_header(), switch_event_add_header_string(), switch_snprintf(), SWITCH_STACK_BOTTOM, switch_test_flag, SWITCH_TIME_T_FMT, switch_channel_timetable::transferred, profile_node_s::val, profile_node_s::var, and zstr.

309 {
310  char header_name[1024];
311  switch_channel_timetable_t *times = NULL;
312 
313  switch_snprintf(header_name, sizeof(header_name), "%s-Direction", prefix);
315  "inbound" : "outbound");
316 
317  switch_snprintf(header_name, sizeof(header_name), "%s-Logical-Direction", prefix);
319  "inbound" : "outbound");
320 
321  if (!zstr(caller_profile->username)) {
322  switch_snprintf(header_name, sizeof(header_name), "%s-Username", prefix);
323  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->username);
324  }
325  if (!zstr(caller_profile->dialplan)) {
326  switch_snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix);
327  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->dialplan);
328  }
329  if (!zstr(caller_profile->caller_id_name)) {
330  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Name", prefix);
331  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_name);
332  }
333  if (!zstr(caller_profile->caller_id_number)) {
334  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
335  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number);
336  }
337  if (!zstr(caller_profile->caller_id_name)) {
338  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Name", prefix);
339  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_name);
340  }
341  if (!zstr(caller_profile->caller_id_number)) {
342  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Number", prefix);
343  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_number);
344  }
345  if (!zstr(caller_profile->callee_id_name)) {
346  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Name", prefix);
347  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_name);
348  }
349  if (!zstr(caller_profile->callee_id_number)) {
350  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Number", prefix);
351  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_number);
352  }
353  if (!zstr(caller_profile->network_addr)) {
354  switch_snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix);
355  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->network_addr);
356  }
357  if (!zstr(caller_profile->ani)) {
358  switch_snprintf(header_name, sizeof(header_name), "%s-ANI", prefix);
359  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->ani);
360  }
361  if (!zstr(caller_profile->aniii)) {
362  switch_snprintf(header_name, sizeof(header_name), "%s-ANI-II", prefix);
363  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->aniii);
364  }
365  if (!zstr(caller_profile->destination_number)) {
366  switch_snprintf(header_name, sizeof(header_name), "%s-Destination-Number", prefix);
367  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->destination_number);
368  }
369  if (!zstr(caller_profile->uuid)) {
370  switch_snprintf(header_name, sizeof(header_name), "%s-Unique-ID", prefix);
371  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->uuid);
372  }
373  if (!zstr(caller_profile->source)) {
374  switch_snprintf(header_name, sizeof(header_name), "%s-Source", prefix);
375  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->source);
376  }
377  if (!zstr(caller_profile->transfer_source)) {
378  switch_snprintf(header_name, sizeof(header_name), "%s-Transfer-Source", prefix);
379  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->transfer_source);
380  }
381  if (!zstr(caller_profile->context)) {
382  switch_snprintf(header_name, sizeof(header_name), "%s-Context", prefix);
383  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->context);
384  }
385  if (!zstr(caller_profile->rdnis)) {
386  switch_snprintf(header_name, sizeof(header_name), "%s-RDNIS", prefix);
387  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->rdnis);
388  }
389  if (!zstr(caller_profile->chan_name)) {
390  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
391  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->chan_name);
392  }
393  if (!zstr(caller_profile->profile_index)) {
394  switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
395  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->profile_index);
396  }
397 
398  if (caller_profile->soft) {
399  profile_node_t *pn;
400 
401  for (pn = caller_profile->soft; pn; pn = pn->next) {
403  }
404 
405  }
406 
407  if (!(times = caller_profile->times)) {
408  times = caller_profile->old_times;
409  }
410 
411 
412  if (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);
416  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->created);
417  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
418  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->answered);
419  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Time", prefix);
420  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->progress);
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);
424  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->hungup);
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);
430  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->bridged);
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);
435  }
436 
437  switch_snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
438  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false");
439 
440  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Name", prefix);
441  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false");
442 
443  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
444  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false");
445 }
switch_call_direction_t logical_direction
const char * orig_caller_id_name
Definition: switch_caller.h:83
const char * network_addr
Definition: switch_caller.h:93
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.
const char * dialplan
Definition: switch_caller.h:77
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
const char * username
Definition: switch_caller.h:75
#define zstr(x)
Definition: switch_utils.h:281
const char * orig_caller_id_number
Definition: switch_caller.h:85
const char * callee_id_number
Definition: switch_caller.h:89
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.
const char * caller_id_name
Definition: switch_caller.h:79
#define SWITCH_TIME_T_FMT
struct profile_node_s * next
Definition: switch_caller.h:66
switch_time_t profile_created
switch_call_direction_t direction
const char * profile_index
struct switch_channel_timetable * old_times
struct switch_channel_timetable * times
const char * caller_id_number
Definition: switch_caller.h:81
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624
profile_node_t * soft
const char * callee_id_name
Definition: switch_caller.h:87
switch_time_t progress_media
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 
)

Definition at line 36 of file switch_caller.c.

References switch_caller_profile::ani, switch_caller_profile::ani_numplan, switch_caller_profile::ani_ton, switch_caller_profile::aniii, switch_caller_profile::callee_id_name, switch_caller_profile::callee_id_number, switch_caller_profile::caller_id_name, switch_caller_profile::caller_id_number, switch_caller_profile::caller_numplan, switch_caller_profile::caller_ton, switch_caller_profile::chan_name, switch_caller_profile::context, switch_caller_profile::destination_number, switch_caller_profile::destination_number_numplan, switch_caller_profile::destination_number_ton, switch_caller_profile::dialplan, memset(), switch_caller_profile::network_addr, switch_caller_profile::orig_caller_id_name, switch_caller_profile::orig_caller_id_number, pool, switch_caller_profile::pool, profile_dup_clean, switch_caller_profile::rdnis, switch_caller_profile::rdnis_numplan, switch_caller_profile::rdnis_ton, switch_caller_profile::source, switch_assert, SWITCH_BLANK_STRING, switch_core_alloc, switch_core_strdup, SWITCH_CPF_SCREEN, SWITCH_DEFAULT_CLID_NAME, SWITCH_DEFAULT_CLID_NUMBER, SWITCH_NUMPLAN_UNDEF, switch_set_flag, SWITCH_TON_UNDEF, SWITCH_UUID_FORMATTED_LENGTH, switch_uuid_str(), switch_caller_profile::username, switch_caller_profile::uuid, switch_caller_profile::uuid_str, and zstr.

46 {
47  switch_caller_profile_t *profile = NULL;
48  char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
49 
50  profile = switch_core_alloc(pool, sizeof(*profile));
51  switch_assert(profile != NULL);
52  memset(profile, 0, sizeof(*profile));
53 
54  switch_uuid_str(uuid_str, sizeof(uuid_str));
55  profile->uuid_str = switch_core_strdup(pool, uuid_str);
56 
57  if (!context) {
58  context = "default";
59  }
60 
61  if (zstr(caller_id_name)) {
62  caller_id_name = SWITCH_DEFAULT_CLID_NAME;
63  }
64 
65  if (zstr(caller_id_number)) {
66  caller_id_number = SWITCH_DEFAULT_CLID_NUMBER;
67  }
68 
69  /* ANI defaults to Caller ID Number when not specified */
70  if (zstr(ani)) {
71  ani = caller_id_number;
72  }
73 
74  profile_dup_clean(username, profile->username, pool);
75  profile_dup_clean(dialplan, profile->dialplan, pool);
76  profile_dup_clean(caller_id_name, profile->caller_id_name, pool);
77  profile_dup_clean(caller_id_number, profile->caller_id_number, pool);
78  profile_dup_clean(caller_id_name, profile->orig_caller_id_name, pool);
79  profile_dup_clean(caller_id_number, profile->orig_caller_id_number, pool);
80  profile->caller_ton = SWITCH_TON_UNDEF;
82  profile_dup_clean(network_addr, profile->network_addr, pool);
83  profile_dup_clean(ani, profile->ani, pool);
84  profile->ani_ton = SWITCH_TON_UNDEF;
86  profile_dup_clean(aniii, profile->aniii, pool);
87  profile_dup_clean(rdnis, profile->rdnis, pool);
88  profile->rdnis_ton = SWITCH_TON_UNDEF;
90  profile_dup_clean(source, profile->source, pool);
91  profile_dup_clean(context, profile->context, pool);
92  profile_dup_clean(destination_number, profile->destination_number, pool);
95  profile->uuid = SWITCH_BLANK_STRING;
96  profile->chan_name = SWITCH_BLANK_STRING;
100  profile->pool = pool;
101  return profile;
102 }
#define SWITCH_DEFAULT_CLID_NUMBER
Definition: switch_types.h:114
Call Specific Data.
Definition: switch_caller.h:73
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:631
#define SWITCH_NUMPLAN_UNDEF
Definition: switch_types.h:49
const char * orig_caller_id_name
Definition: switch_caller.h:83
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
const char * network_addr
Definition: switch_caller.h:93
switch_memory_pool_t * pool
const char * dialplan
Definition: switch_caller.h:77
const char * username
Definition: switch_caller.h:75
#define zstr(x)
Definition: switch_utils.h:281
#define SWITCH_DEFAULT_CLID_NAME
Definition: switch_types.h:113
const char * orig_caller_id_number
Definition: switch_caller.h:85
const char * callee_id_number
Definition: switch_caller.h:89
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
const char * caller_id_name
Definition: switch_caller.h:79
#define SWITCH_BLANK_STRING
Definition: switch_types.h:47
uint8_t destination_number_numplan
#define SWITCH_TON_UNDEF
Definition: switch_types.h:48
char * switch_uuid_str(char *buf, switch_size_t len)
const char * caller_id_number
Definition: switch_caller.h:81
#define switch_assert(expr)
memset(buf, 0, buflen)
#define profile_dup_clean(a, b, p)
Definition: switch_caller.h:61
const char * callee_id_name
Definition: switch_caller.h:87
#define SWITCH_UUID_FORMATTED_LENGTH
Definition: switch_apr.h:545
switch_memory_pool_t * pool