FreeSWITCH API Documentation  1.7.0
Data Structures | Macros | Typedefs | Functions
Caller Identity / Dialplan
+ Collaboration diagram for Caller Identity / Dialplan:

Data Structures

struct  profile_node_s
 
struct  switch_caller_profile
 Call Specific Data. More...
 
struct  switch_caller_application
 An Abstract Representation of a dialplan Application. More...
 
struct  switch_caller_extension
 An Abstract Representation of a dialplan extension. More...
 

Macros

#define profile_dup(a, b, p)   if (!zstr(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; }
 
#define profile_dup_clean(a, b, p)   if (!zstr(a)) { b = switch_var_clean_string(switch_clean_string(switch_core_strdup(p, a)));} else { b = SWITCH_BLANK_STRING; }
 

Typedefs

typedef struct profile_node_s profile_node_t
 

Functions

switch_caller_extension_tswitch_caller_extension_new (_In_ switch_core_session_t *session, _In_z_ const char *extension_name, _In_z_ const char *extension_number)
 Create a new extension with desired parameters. More...
 
switch_status_t switch_caller_extension_clone (switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, switch_memory_pool_t *pool)
 
void switch_caller_extension_add_application (_In_ switch_core_session_t *session, _In_ switch_caller_extension_t *caller_extension, _In_z_ const char *application_name, _In_z_ const char *extra_data)
 Add an application (instruction) to the given extension. More...
 
void switch_caller_extension_add_application_printf (_In_ switch_core_session_t *session, _In_ switch_caller_extension_t *caller_extension, _In_z_ const char *application_name, _In_z_ const char *fmt,...)
 Add an application (instruction) to the given extension. More...
 
_Check_return_ _Ret_opt_z_
const char * 
switch_caller_get_field_by_name (_In_ switch_caller_profile_t *caller_profile, _In_z_ const char *name)
 Get the value of a field in a caller profile based on it's name. More...
 
switch_caller_profile_tswitch_caller_profile_new (_In_ switch_memory_pool_t *pool, _In_opt_z_ const char *username, _In_opt_z_ const char *dialplan, _In_opt_z_ const char *caller_id_name, _In_opt_z_ const char *caller_id_number, _In_opt_z_ const char *network_addr, _In_opt_z_ const char *ani, _In_opt_z_ const char *aniii, _In_opt_z_ const char *rdnis, _In_opt_z_ const char *source, _In_opt_z_ const char *context, _In_opt_z_ const char *destination_number)
 Create a new caller profile object. More...
 
switch_caller_profile_tswitch_caller_profile_clone (_In_ switch_core_session_t *session, _In_ switch_caller_profile_t *tocopy)
 Clone an existing caller profile object. More...
 
switch_caller_profile_tswitch_caller_profile_dup (_In_ switch_memory_pool_t *pool, _In_ switch_caller_profile_t *tocopy)
 Duplicate an existing caller profile object. More...
 
void switch_caller_profile_event_set_data (_In_ switch_caller_profile_t *caller_profile, _In_opt_z_ const char *prefix, _In_ switch_event_t *event)
 Add headers to an existing event in regards to a specific profile. More...
 

Detailed Description

This module implements a caller profile which is a group of information about a connected endpoint such as common caller id and other useful information such as ip address and destination number. A connected session's channel has up to 3 profiles: It's own, that of the session who spawned it and that of the session it has spawned.

In addition, this module implements an abstract interface for extensions and applications. A connected session's channel has one extension object which may have one or more applications linked into a stack which will be executed in order by the session's state machine when the current state is CS_EXECUTE.

Macro Definition Documentation

#define profile_dup (   a,
  b,
 
)    if (!zstr(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; }

Definition at line 60 of file switch_caller.h.

Referenced by switch_caller_profile_dup().

#define profile_dup_clean (   a,
  b,
 
)    if (!zstr(a)) { b = switch_var_clean_string(switch_clean_string(switch_core_strdup(p, a)));} else { b = SWITCH_BLANK_STRING; }

Definition at line 61 of file switch_caller.h.

Referenced by switch_caller_profile_new().

Typedef Documentation

Function Documentation

void switch_caller_extension_add_application ( _In_ switch_core_session_t session,
_In_ switch_caller_extension_t caller_extension,
_In_z_ const char *  application_name,
_In_z_ const char *  extra_data 
)

Add an application (instruction) to the given extension.

Parameters
sessionsession associated with the extension (bound by scope)
caller_extensionextension to add the application to
application_namethe name of the application
extra_dataoptional argument to the application

Referenced by audio_bridge_thread(), recover_callback(), switch_channel_caller_extension_masquerade(), and switch_ivr_parse_event().

void switch_caller_extension_add_application_printf ( _In_ switch_core_session_t session,
_In_ switch_caller_extension_t caller_extension,
_In_z_ const char *  application_name,
_In_z_ const char *  fmt,
  ... 
)

Add an application (instruction) to the given extension.

Parameters
sessionsession associated with the extension (bound by scope)
caller_extensionextension to add the application to
application_namethe name of the application
fmtoptional argument to the application (printf format string)
switch_status_t switch_caller_extension_clone ( switch_caller_extension_t **  new_ext,
switch_caller_extension_t orig,
switch_memory_pool_t pool 
)

Definition at line 447 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::extension_name, switch_caller_extension::extension_number, switch_caller_extension::last_application, switch_caller_application::next, switch_core_alloc, switch_core_strdup, SWITCH_STATUS_MEMERR, and SWITCH_STATUS_SUCCESS.

Referenced by switch_channel_set_caller_profile().

449 {
450  switch_caller_extension_t *caller_extension = NULL;
451  switch_caller_application_t *caller_application = NULL, *ap = NULL;
452 
453  *new_ext = NULL;
454 
455  if ((caller_extension = switch_core_alloc(pool, sizeof(switch_caller_extension_t))) != 0) {
456  int match = 0;
457 
458  caller_extension->extension_name = switch_core_strdup(pool, orig->extension_name);
459  caller_extension->extension_number = switch_core_strdup(pool, orig->extension_number);
460 
461  for (ap = orig->applications; ap; ap = ap->next) {
462 
463  if (!match) {
464  if (ap == orig->current_application) {
465  match++;
466  } else {
467  continue;
468  }
469  }
470  caller_application = switch_core_alloc(pool, sizeof(switch_caller_application_t));
471 
472  caller_application->application_name = switch_core_strdup(pool, ap->application_name);
473  caller_application->application_data = switch_core_strdup(pool, ap->application_data);
474 
475  if (!caller_extension->applications) {
476  caller_extension->applications = caller_application;
477  } else if (caller_extension->last_application) {
478  caller_extension->last_application->next = caller_application;
479  }
480 
481  caller_extension->last_application = caller_application;
482 
483  if (ap == orig->current_application) {
484  caller_extension->current_application = caller_application;
485  }
486  }
487 
488  *new_ext = caller_extension;
489 
490  return SWITCH_STATUS_SUCCESS;
491  }
492 
493 
494  return SWITCH_STATUS_MEMERR;
495 }
An Abstract Representation of a dialplan extension.
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
switch_memory_pool_t * pool
An Abstract Representation of a dialplan Application.
switch_caller_application_t * last_application
struct switch_caller_application * next
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
switch_caller_application_t * applications
switch_caller_application_t * current_application
switch_caller_extension_t* switch_caller_extension_new ( _In_ switch_core_session_t session,
_In_z_ const char *  extension_name,
_In_z_ const char *  extension_number 
)

Create a new extension with desired parameters.

Parameters
sessionsession associated with the extension (bound by scope)
extension_nameextension name
extension_numberextension number
Returns
a new extension object allocated from the session's memory pool

Referenced by audio_bridge_thread(), recover_callback(), switch_channel_caller_extension_masquerade(), and switch_ivr_parse_event().

_Check_return_ _Ret_opt_z_ const char* switch_caller_get_field_by_name ( _In_ switch_caller_profile_t caller_profile,
_In_z_ const char *  name 
)

Get the value of a field in a caller profile based on it's name.

Parameters
caller_profileThe caller profile
namethe name
Note
this function is meant for situations where the name paramater is the contents of the variable

Referenced by switch_channel_get_variable_dup().

switch_caller_profile_t* switch_caller_profile_clone ( _In_ switch_core_session_t session,
_In_ switch_caller_profile_t tocopy 
)

Clone an existing caller profile object.

Parameters
sessionsession associated with the profile (bound by scope)
tocopythe existing profile

Referenced by switch_channel_caller_extension_masquerade(), switch_channel_step_caller_profile(), switch_core_session_execute_exten(), switch_core_session_outgoing_channel(), switch_ivr_originate(), switch_ivr_session_transfer(), and switch_ivr_uuid_bridge().

switch_caller_profile_t* switch_caller_profile_dup ( _In_ switch_memory_pool_t pool,
_In_ switch_caller_profile_t tocopy 
)

Duplicate an existing caller profile object.

Parameters
poolpool to duplicate with
tocopythe existing profile

Referenced by process_device_hup(), switch_ivr_enterprise_originate(), and switch_ivr_originate().

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

Add headers to an existing event in regards to a specific profile.

Parameters
caller_profilethe desired profile
prefixa prefix string to all of the field names (for uniqueness)
eventthe event to add the information to

Referenced by switch_channel_clear_device_record(), switch_channel_event_set_basic_data(), and switch_ivr_uuid_bridge().

switch_caller_profile_t* switch_caller_profile_new ( _In_ switch_memory_pool_t pool,
_In_opt_z_ const char *  username,
_In_opt_z_ const char *  dialplan,
_In_opt_z_ const char *  caller_id_name,
_In_opt_z_ const char *  caller_id_number,
_In_opt_z_ const char *  network_addr,
_In_opt_z_ const char *  ani,
_In_opt_z_ const char *  aniii,
_In_opt_z_ const char *  rdnis,
_In_opt_z_ const char *  source,
_In_opt_z_ const char *  context,
_In_opt_z_ const char *  destination_number 
)

Create a new caller profile object.

Parameters
poolmemory pool to use
usernametne username of the caller
dialplanname of the dialplan module in use
caller_id_namecaller ID name
caller_id_numbercaller ID number
network_addrnetwork address
aniANI information
aniiiANI II information
rdnisRDNIS
sourcethe source
contexta logical context
destination_numberdestination number
Returns
a new profile object allocated from the session's memory pool

Referenced by switch_core_session_request_xml(), and switch_ivr_originate().