RTS API Documentation  1.10.11
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

◆ switch_caller_extension_add_application()

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 553 of file switch_caller.c.

References switch_caller_application::application_data, switch_caller_application::application_name, switch_caller_extension::applications, switch_caller_extension::current_application, switch_caller_extension::last_application, 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().

556 {
557  switch_caller_application_t *caller_application = NULL;
558 
559  switch_assert(session != NULL);
560 
561  if ((caller_application = switch_core_session_alloc(session, sizeof(switch_caller_application_t))) != 0) {
562  caller_application->application_name = switch_core_session_strdup(session, application_name);
563  caller_application->application_data = switch_core_session_strdup(session, application_data);
564 
565 
566 
567  if (caller_application->application_data && strstr(caller_application->application_data, "\\'")) {
568  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
569  caller_application->application_data);
570  return;
571  }
572 
573  if (!caller_extension->applications) {
574  caller_extension->applications = caller_application;
575  } else if (caller_extension->last_application) {
576  caller_extension->last_application->next = caller_application;
577  }
578 
579  caller_extension->last_application = caller_application;
580  caller_extension->current_application = caller_extension->applications;
581  }
582 
583 }
#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&#39;s pool.
Definition: switch_core.h:696
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&#39;s pool.
Definition: switch_core.h:719
#define switch_assert(expr)

◆ switch_caller_extension_add_application_printf()

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 531 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().

534 {
535  va_list ap;
536  char *data = NULL;
537 
538  va_start(ap, fmt);
539  if ( switch_vasprintf(&data, fmt, ap) != -1 ) {
540  if (strstr(data, "\\'")) {
541  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
542  data);
543  } else {
544  switch_caller_extension_add_application(session, caller_extension, application_name, data);
545  }
546  }
547  va_end(ap);
548 
549  switch_safe_free(data);
550 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
int cJSON_bool fmt
Definition: switch_cJSON.h:150
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
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_new()

switch_caller_extension_t* switch_caller_extension_new ( switch_core_session_t session,
const char *  extension_name,
const char *  extension_number 
)

Definition at line 516 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.

518 {
519  switch_caller_extension_t *caller_extension = NULL;
520 
521  if ((caller_extension = switch_core_session_alloc(session, sizeof(switch_caller_extension_t))) != 0) {
522  caller_extension->extension_name = switch_core_session_strdup(session, extension_name);
523  caller_extension->extension_number = switch_core_session_strdup(session, extension_number);
524  caller_extension->current_application = caller_extension->last_application = caller_extension->applications;
525  }
526 
527  return caller_extension;
528 }
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&#39;s pool.
Definition: switch_core.h:696
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719

◆ switch_caller_get_field_by_name()

const char* switch_caller_get_field_by_name ( switch_caller_profile_t caller_profile,
const char *  name 
)

Definition at line 193 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_channel_timetable::answered, 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_channel_timetable::created, switch_caller_profile::destination_number, switch_caller_profile::destination_number_numplan, switch_caller_profile::destination_number_ton, switch_caller_profile::dialplan, switch_channel_timetable::hungup, switch_caller_profile::network_addr, profile_node_s::next, switch_caller_profile::orig_caller_id_name, switch_caller_profile::orig_caller_id_number, switch_caller_profile::pool, switch_channel_timetable::profile_created, switch_caller_profile::profile_index, switch_channel_timetable::progress, switch_channel_timetable::progress_media, switch_caller_profile::rdnis, switch_caller_profile::rdnis_numplan, switch_caller_profile::rdnis_ton, switch_caller_profile::soft, switch_caller_profile::source, switch_core_sprintf(), SWITCH_CPF_HIDE_NAME, SWITCH_CPF_HIDE_NUMBER, SWITCH_CPF_SCREEN, SWITCH_CPF_SOFT_LOOKUP, switch_test_flag, SWITCH_TIME_T_FMT, switch_caller_profile::times, switch_caller_profile::transfer_source, switch_channel_timetable::transferred, switch_caller_profile::username, switch_caller_profile::uuid, profile_node_s::val, and profile_node_s::var.

194 {
195  if (!strcasecmp(name, "dialplan")) {
196  return caller_profile->dialplan;
197  }
198  if (!strcasecmp(name, "username")) {
199  return caller_profile->username;
200  }
201  if (!strcasecmp(name, "caller_id_name")) {
202  return caller_profile->caller_id_name;
203  }
204  if (!strcasecmp(name, "caller_id_number")) {
205  return caller_profile->caller_id_number;
206  }
207  if (!strcasecmp(name, "orig_caller_id_name")) {
208  return caller_profile->orig_caller_id_name;
209  }
210  if (!strcasecmp(name, "orig_caller_id_number")) {
211  return caller_profile->orig_caller_id_number;
212  }
213  if (!strcasecmp(name, "callee_id_name")) {
214  return caller_profile->callee_id_name;
215  }
216  if (!strcasecmp(name, "callee_id_number")) {
217  return caller_profile->callee_id_number;
218  }
219  if (!strcasecmp(name, "ani")) {
220  return caller_profile->ani;
221  }
222  if (!strcasecmp(name, "aniii")) {
223  return caller_profile->aniii;
224  }
225  if (!strcasecmp(name, "network_addr")) {
226  return caller_profile->network_addr;
227  }
228  if (!strcasecmp(name, "rdnis")) {
229  return caller_profile->rdnis;
230  }
231  if (!strcasecmp(name, "destination_number")) {
232  return caller_profile->destination_number;
233  }
234  if (!strcasecmp(name, "uuid")) {
235  return caller_profile->uuid;
236  }
237  if (!strcasecmp(name, "source")) {
238  return caller_profile->source;
239  }
240  if (!strcasecmp(name, "transfer_source")) {
241  return caller_profile->transfer_source;
242  }
243  if (!strcasecmp(name, "context")) {
244  return caller_profile->context;
245  }
246 
247  if (!strcasecmp(name, "chan_name")) {
248  return caller_profile->chan_name;
249  }
250 
251  if (!strcasecmp(name, "profile_index")) {
252  return caller_profile->profile_index;
253  }
254 
255  if (!strcasecmp(name, "caller_ton")) {
256  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
257  }
258  if (!strcasecmp(name, "caller_numplan")) {
259  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
260  }
261  if (!strcasecmp(name, "destination_number_ton")) {
262  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
263  }
264  if (!strcasecmp(name, "destination_number_numplan")) {
265  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
266  }
267  if (!strcasecmp(name, "ani_ton")) {
268  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
269  }
270  if (!strcasecmp(name, "ani_numplan")) {
271  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
272  }
273  if (!strcasecmp(name, "rdnis_ton")) {
274  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
275  }
276  if (!strcasecmp(name, "rdnis_numplan")) {
277  return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
278  }
279  if (!strcasecmp(name, "screen_bit")) {
280  return switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false";
281  }
282  if (!strcasecmp(name, "privacy_hide_name")) {
283  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false";
284  }
285  if (!strcasecmp(name, "privacy_hide_number")) {
286  return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false";
287  }
288  if (!strcasecmp(name, "profile_created_time")) {
289  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
290  }
291  if (!strcasecmp(name, "created_time")) {
292  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
293  }
294  if (!strcasecmp(name, "answered_time")) {
295  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
296  }
297  if (!strcasecmp(name, "progress_time")) {
298  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);
299  }
300  if (!strcasecmp(name, "progress_media_time")) {
301  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);
302  }
303  if (!strcasecmp(name, "hungup_time")) {
304  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
305  }
306  if (!strcasecmp(name, "transferred_time")) {
307  return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
308  }
309 
310  if (caller_profile->soft && switch_test_flag(caller_profile, SWITCH_CPF_SOFT_LOOKUP)) {
311  profile_node_t *pn;
312  for (pn = caller_profile->soft; pn; pn = pn->next) {
313  if (!strcasecmp(name, pn->var)) {
314  return pn->val;
315  }
316  }
317  }
318 
319  return NULL;
320 }
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
struct profile_node_s * next
Definition: switch_caller.h:66
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:693
profile_node_t * soft
const char *const name
Definition: switch_cJSON.h:250
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_clone()

switch_caller_profile_t* switch_caller_profile_clone ( switch_core_session_t session,
switch_caller_profile_t tocopy 
)

Definition at line 184 of file switch_caller.c.

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

185 {
187 
188  pool = switch_core_session_get_pool(session);
189 
190  return switch_caller_profile_dup(pool, tocopy);
191 }
switch_memory_pool_t * pool
switch_caller_profile_t * switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
struct fspr_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_dup()

switch_caller_profile_t* switch_caller_profile_dup ( switch_memory_pool_t pool,
switch_caller_profile_t tocopy 
)

Definition at line 110 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::times, 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().

111 {
112  switch_caller_profile_t *profile = NULL;
113  char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
114 
115  profile = switch_core_alloc(pool, sizeof(*profile));
116  switch_assert(profile != NULL);
117 
118  switch_uuid_str(uuid_str, sizeof(uuid_str));
119  profile->uuid_str = switch_core_strdup(pool, uuid_str);
120  profile->clone_of = switch_core_strdup(pool, tocopy->uuid_str);
121 
122  profile_dup(tocopy->username, profile->username, pool);
123  profile_dup(tocopy->dialplan, profile->dialplan, pool);
124  profile_dup(tocopy->caller_id_name, profile->caller_id_name, pool);
126  profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool);
130  profile_dup(tocopy->network_addr, profile->network_addr, pool);
131  profile_dup(tocopy->ani, profile->ani, pool);
132  profile_dup(tocopy->aniii, profile->aniii, pool);
133  profile_dup(tocopy->rdnis, profile->rdnis, pool);
134  profile_dup(tocopy->source, profile->source, pool);
135  profile_dup(tocopy->context, profile->context, pool);
137  profile_dup(tocopy->uuid, profile->uuid, pool);
138  profile_dup(tocopy->chan_name, profile->chan_name, pool);
139 
140  profile->caller_ton = tocopy->caller_ton;
141  profile->caller_numplan = tocopy->caller_numplan;
142  profile->ani_ton = tocopy->ani_ton;
143  profile->ani_numplan = tocopy->ani_numplan;
144  profile->rdnis_ton = tocopy->rdnis_ton;
145  profile->rdnis_numplan = tocopy->rdnis_numplan;
148  profile->flags = tocopy->flags;
149  profile->pool = pool;
150  profile->direction = tocopy->direction;
151 
152  if (tocopy->times) {
154  *profile->old_times = *tocopy->times;
155  } else {
156  tocopy->times = (switch_channel_timetable_t *) switch_core_alloc(tocopy->pool, sizeof(*tocopy->times));
157  }
158 
159  if (tocopy->soft) {
160  profile_node_t *pn;
161 
162  for (pn = tocopy->soft; pn; pn = pn->next) {
163  profile_node_t *pp, *n = switch_core_alloc(profile->pool, sizeof(*n));
164 
165  n->var = switch_core_strdup(profile->pool, pn->var);
166  n->val = switch_core_strdup(profile->pool, pn->val);
167 
168  if (!profile->soft) {
169  profile->soft = n;
170  } else {
171  for(pp = profile->soft; pp && pp->next; pp = pp->next);
172 
173  if (pp) {
174  pp->next = n;
175  }
176  }
177  }
178 
179  }
180 
181  return profile;
182 }
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:733
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:684
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

◆ switch_caller_profile_event_set_data()

void switch_caller_profile_event_set_data ( switch_caller_profile_t caller_profile,
const char *  prefix,
switch_event_t event 
)

Definition at line 322 of file switch_caller.c.

References switch_caller_profile::ani, switch_caller_profile::aniii, switch_channel_timetable::answered, switch_channel_timetable::bridged, 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::chan_name, switch_caller_profile::context, switch_channel_timetable::created, switch_caller_profile::destination_number, switch_caller_profile::dialplan, switch_caller_profile::direction, switch_channel_timetable::hold_accum, switch_channel_timetable::hungup, switch_channel_timetable::last_hold, switch_caller_profile::logical_direction, 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, switch_channel_timetable::profile_created, switch_caller_profile::profile_index, switch_channel_timetable::progress, switch_channel_timetable::progress_media, switch_caller_profile::rdnis, switch_channel_timetable::resurrected, switch_caller_profile::soft, switch_caller_profile::source, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CPF_HIDE_NAME, SWITCH_CPF_HIDE_NUMBER, SWITCH_CPF_SCREEN, SWITCH_CPF_SOFT_PREFIX, switch_event_add_header(), switch_event_add_header_string(), switch_snprintf(), SWITCH_STACK_BOTTOM, switch_test_flag, SWITCH_TIME_T_FMT, switch_caller_profile::times, switch_caller_profile::transfer_source, switch_channel_timetable::transferred, switch_caller_profile::username, switch_caller_profile::uuid, profile_node_s::val, profile_node_s::var, and zstr.

323 {
324  char header_name[1024];
325  switch_channel_timetable_t *times = NULL;
326 
327  switch_snprintf(header_name, sizeof(header_name), "%s-Direction", prefix);
329  "inbound" : "outbound");
330 
331  switch_snprintf(header_name, sizeof(header_name), "%s-Logical-Direction", prefix);
333  "inbound" : "outbound");
334 
335  if (!zstr(caller_profile->username)) {
336  switch_snprintf(header_name, sizeof(header_name), "%s-Username", prefix);
337  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->username);
338  }
339  if (!zstr(caller_profile->dialplan)) {
340  switch_snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix);
341  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->dialplan);
342  }
343  if (!zstr(caller_profile->caller_id_name)) {
344  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Name", prefix);
345  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_name);
346  }
347  if (!zstr(caller_profile->caller_id_number)) {
348  switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
349  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number);
350  }
351  if (!zstr(caller_profile->caller_id_name)) {
352  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Name", prefix);
353  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_name);
354  }
355  if (!zstr(caller_profile->caller_id_number)) {
356  switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Number", prefix);
357  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_number);
358  }
359  if (!zstr(caller_profile->callee_id_name)) {
360  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Name", prefix);
361  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_name);
362  }
363  if (!zstr(caller_profile->callee_id_number)) {
364  switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Number", prefix);
365  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_number);
366  }
367  if (!zstr(caller_profile->network_addr)) {
368  switch_snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix);
369  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->network_addr);
370  }
371  if (!zstr(caller_profile->ani)) {
372  switch_snprintf(header_name, sizeof(header_name), "%s-ANI", prefix);
373  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->ani);
374  }
375  if (!zstr(caller_profile->aniii)) {
376  switch_snprintf(header_name, sizeof(header_name), "%s-ANI-II", prefix);
377  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->aniii);
378  }
379  if (!zstr(caller_profile->destination_number)) {
380  switch_snprintf(header_name, sizeof(header_name), "%s-Destination-Number", prefix);
381  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->destination_number);
382  }
383  if (!zstr(caller_profile->uuid)) {
384  switch_snprintf(header_name, sizeof(header_name), "%s-Unique-ID", prefix);
385  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->uuid);
386  }
387  if (!zstr(caller_profile->source)) {
388  switch_snprintf(header_name, sizeof(header_name), "%s-Source", prefix);
389  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->source);
390  }
391  if (!zstr(caller_profile->transfer_source)) {
392  switch_snprintf(header_name, sizeof(header_name), "%s-Transfer-Source", prefix);
393  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->transfer_source);
394  }
395  if (!zstr(caller_profile->context)) {
396  switch_snprintf(header_name, sizeof(header_name), "%s-Context", prefix);
397  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->context);
398  }
399  if (!zstr(caller_profile->rdnis)) {
400  switch_snprintf(header_name, sizeof(header_name), "%s-RDNIS", prefix);
401  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->rdnis);
402  }
403  if (!zstr(caller_profile->chan_name)) {
404  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
405  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->chan_name);
406  }
407  if (!zstr(caller_profile->profile_index)) {
408  switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
409  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->profile_index);
410  }
411 
412  if (caller_profile->soft) {
413  profile_node_t *pn;
414 
415  for (pn = caller_profile->soft; pn; pn = pn->next) {
416  if (switch_test_flag(caller_profile, SWITCH_CPF_SOFT_PREFIX)) {
417  switch_snprintf(header_name, sizeof(header_name), "%s-%s", prefix, pn->var);
418  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, pn->val);
419  } else {
421  }
422  }
423 
424  }
425 
426  if (!(times = caller_profile->times)) {
427  times = caller_profile->old_times;
428  }
429 
430 
431  if (times) {
432  switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Created-Time", prefix);
434  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Created-Time", prefix);
435  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->created);
436  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
437  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->answered);
438  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Time", prefix);
439  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->progress);
440  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Media-Time", prefix);
442  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hangup-Time", prefix);
443  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->hungup);
444  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Transfer-Time", prefix);
446  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Resurrect-Time", prefix);
448  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Bridged-Time", prefix);
449  switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, times->bridged);
450  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Last-Hold", prefix);
452  switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hold-Accum", prefix);
454  }
455 
456  switch_snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
457  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "true" : "false");
458 
459  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Name", prefix);
460  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "true" : "false");
461 
462  switch_snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
463  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false");
464 }
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:314
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:693
profile_node_t * soft
const char * callee_id_name
Definition: switch_caller.h:87
switch_time_t progress_media

◆ switch_caller_profile_new()

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, SCF_CPF_SOFT_LOOKUP, SCF_CPF_SOFT_PREFIX, switch_caller_profile::source, switch_assert, SWITCH_BLANK_STRING, switch_core_alloc, switch_core_strdup, switch_core_test_flag(), SWITCH_CPF_SCREEN, SWITCH_CPF_SOFT_LOOKUP, SWITCH_CPF_SOFT_PREFIX, 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;
102  }
105  }
106  profile->pool = pool;
107  return profile;
108 }
#define SWITCH_DEFAULT_CLID_NUMBER
Definition: switch_types.h:115
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:700
#define SWITCH_NUMPLAN_UNDEF
Definition: switch_types.h:50
const char * orig_caller_id_name
Definition: switch_caller.h:83
int switch_core_test_flag(int flag)
Definition: switch_core.c:1792
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
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:314
#define SWITCH_DEFAULT_CLID_NAME
Definition: switch_types.h:114
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:684
const char * caller_id_name
Definition: switch_caller.h:79
#define SWITCH_BLANK_STRING
Definition: switch_types.h:48
uint8_t destination_number_numplan
#define SWITCH_TON_UNDEF
Definition: switch_types.h:49
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