2005-11-19 20:07:43 +00:00
/*
* FreeSWITCH Modular Media Switching Software Library / Soft - Switch Application
2014-02-05 15:02:28 -06:00
* Copyright ( C ) 2005 - 2014 , Anthony Minessale II < anthm @ freeswitch . org >
2005-11-19 20:07:43 +00:00
*
* Version : MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 ( the " License " ) ; you may not use this file except in compliance with
* the License . You may obtain a copy of the License at
* http : //www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an " AS IS " basis ,
* WITHOUT WARRANTY OF ANY KIND , either express or implied . See the License
* for the specific language governing rights and limitations under the
* License .
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft - Switch Application
*
* The Initial Developer of the Original Code is
2009-02-04 21:20:54 +00:00
* Anthony Minessale II < anthm @ freeswitch . org >
2005-11-19 20:07:43 +00:00
* Portions created by the Initial Developer are Copyright ( C )
* the Initial Developer . All Rights Reserved .
*
* Contributor ( s ) :
*
2009-02-04 21:20:54 +00:00
* Anthony Minessale II < anthm @ freeswitch . org >
2005-11-19 20:07:43 +00:00
*
*
* switch_caller . h - - Caller Identification
*
*/
2006-01-10 20:10:38 +00:00
/**
* @ file switch_caller . h
* @ brief Caller Identification
* @ see caller
2006-04-12 15:04:26 +00:00
*/
2006-01-10 20:10:38 +00:00
/**
* @ defgroup caller Caller Identity / Dialplan
2006-04-12 16:34:34 +00:00
* @ ingroup core1
2006-01-10 20:10:38 +00:00
*
* 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 .
* @ {
*/
2006-01-01 15:23:12 +00:00
2005-11-19 20:07:43 +00:00
# ifndef SWITCH_CALLER_H
# define SWITCH_CALLER_H
# include <switch.h>
2006-09-07 14:23:31 +00:00
SWITCH_BEGIN_EXTERN_C
2011-05-13 15:29:40 -05:00
2013-07-19 21:50:55 -05:00
# 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; }
2011-05-13 15:29:40 -05:00
typedef struct profile_node_s {
char * var ;
char * val ;
struct profile_node_s * next ;
} profile_node_t ;
2006-04-12 15:04:26 +00:00
/*! \brief Call Specific Data
*/
2007-03-29 22:31:56 +00:00
struct switch_caller_profile {
2006-05-26 16:00:08 +00:00
/*! The Call's User Name */
2007-11-01 11:28:26 +00:00
const char * username ;
2006-04-12 15:04:26 +00:00
/*! The name of the dialplan */
2007-11-01 11:28:26 +00:00
const char * dialplan ;
2006-04-12 15:04:26 +00:00
/*! Caller ID Name */
2007-11-01 11:28:26 +00:00
const char * caller_id_name ;
2006-04-12 15:04:26 +00:00
/*! Caller ID Number */
2007-11-01 11:28:26 +00:00
const char * caller_id_number ;
2013-04-03 17:17:01 -05:00
/*! Original Caller ID Name */
const char * orig_caller_id_name ;
/*! Original Caller ID Number */
const char * orig_caller_id_number ;
2009-10-07 22:35:21 +00:00
/*! Callee ID Name */
const char * callee_id_name ;
/*! Callee ID Number */
const char * callee_id_number ;
2007-08-21 14:01:24 +00:00
uint8_t caller_ton ;
uint8_t caller_numplan ;
2006-04-12 15:04:26 +00:00
/*! Caller Network Address (when applicable) */
2007-11-01 11:28:26 +00:00
const char * network_addr ;
2006-04-12 15:04:26 +00:00
/*! ANI (when applicable) */
2007-11-01 11:28:26 +00:00
const char * ani ;
2007-08-21 14:01:24 +00:00
uint8_t ani_ton ;
uint8_t ani_numplan ;
2006-04-12 15:04:26 +00:00
/*! ANI II (when applicable) */
2007-11-01 11:28:26 +00:00
const char * aniii ;
2006-04-21 22:31:08 +00:00
/*! RDNIS */
2007-11-01 11:28:26 +00:00
const char * rdnis ;
2007-08-21 14:01:24 +00:00
uint8_t rdnis_ton ;
uint8_t rdnis_numplan ;
2006-04-12 15:04:26 +00:00
/*! Destination Number */
char * destination_number ;
2007-08-21 14:01:24 +00:00
uint8_t destination_number_ton ;
uint8_t destination_number_numplan ;
2006-04-21 22:31:08 +00:00
/*! channel type */
2007-11-01 11:28:26 +00:00
const char * source ;
2006-04-12 15:04:26 +00:00
/*! channel name */
char * chan_name ;
/*! unique id */
char * uuid ;
2006-04-28 19:46:57 +00:00
/*! context */
2007-11-01 11:28:26 +00:00
const char * context ;
2008-02-26 23:29:58 +00:00
/*! profile index */
const char * profile_index ;
2006-10-16 04:39:00 +00:00
/*! flags */
switch_caller_profile_flag_t flags ;
2006-12-01 15:26:37 +00:00
struct switch_caller_profile * originator_caller_profile ;
struct switch_caller_profile * originatee_caller_profile ;
2010-09-08 13:19:56 -05:00
struct switch_caller_profile * origination_caller_profile ;
2009-06-05 01:05:11 +00:00
struct switch_caller_profile * hunt_caller_profile ;
2006-12-01 15:26:37 +00:00
struct switch_channel_timetable * times ;
2012-10-11 11:04:09 -05:00
struct switch_channel_timetable * old_times ;
2007-02-07 17:19:06 +00:00
struct switch_caller_extension * caller_extension ;
2007-08-28 16:41:38 +00:00
switch_memory_pool_t * pool ;
2006-04-28 19:46:57 +00:00
struct switch_caller_profile * next ;
2010-08-17 17:26:36 -05:00
switch_call_direction_t direction ;
2013-10-31 15:28:24 -05:00
switch_call_direction_t logical_direction ;
2011-05-13 15:29:40 -05:00
profile_node_t * soft ;
2011-10-11 15:13:23 -05:00
char * uuid_str ;
char * clone_of ;
char * transfer_source ;
2006-04-12 15:04:26 +00:00
} ;
/*! \brief An Abstract Representation of a dialplan Application */
struct switch_caller_application {
/*! The name of the registered application to call */
char * application_name ;
/*! An optional argument string to pass to the application */
char * application_data ;
/*! A function pointer to the application */
2006-04-29 23:43:28 +00:00
switch_application_function_t application_function ;
2006-04-12 15:04:26 +00:00
struct switch_caller_application * next ;
} ;
/*! \brief An Abstract Representation of a dialplan extension */
struct switch_caller_extension {
/*! The name of the extension */
char * extension_name ;
/*! The number of the extension */
char * extension_number ;
/*! Pointer to the current application for this extension */
2006-04-29 06:05:03 +00:00
switch_caller_application_t * current_application ;
2006-04-12 15:04:26 +00:00
/*! Pointer to the last application for this extension */
2006-04-29 06:05:03 +00:00
switch_caller_application_t * last_application ;
2006-04-12 15:04:26 +00:00
/*! Pointer to the entire stack of applications for this extension */
2006-04-29 06:05:03 +00:00
switch_caller_application_t * applications ;
2007-04-21 01:03:58 +00:00
struct switch_caller_profile * children ;
2006-06-03 17:06:06 +00:00
struct switch_caller_extension * next ;
2006-04-12 15:04:26 +00:00
} ;
/*!
\ brief Create a new extension with desired parameters
\ param session session associated with the extension ( bound by scope )
\ param extension_name extension name
\ param extension_number extension number
\ return a new extension object allocated from the session ' s memory pool
*/
2007-12-20 03:07:00 +00:00
SWITCH_DECLARE ( switch_caller_extension_t * ) switch_caller_extension_new ( _In_ switch_core_session_t * session ,
2008-05-27 04:30:03 +00:00
_In_z_ const char * extension_name , _In_z_ const char * extension_number ) ;
2006-04-12 15:04:26 +00:00
2010-02-06 03:38:24 +00:00
SWITCH_DECLARE ( switch_status_t ) switch_caller_extension_clone ( switch_caller_extension_t * * new_ext , switch_caller_extension_t * orig ,
2008-08-13 21:46:06 +00:00
switch_memory_pool_t * pool ) ;
2006-04-12 15:04:26 +00:00
/*!
\ brief Add an application ( instruction ) to the given extension
\ param session session associated with the extension ( bound by scope )
\ param caller_extension extension to add the application to
\ param application_name the name of the application
\ param extra_data optional argument to the application
*/
2007-12-20 03:07:00 +00:00
SWITCH_DECLARE ( void ) switch_caller_extension_add_application ( _In_ switch_core_session_t * session ,
_In_ switch_caller_extension_t * caller_extension ,
2008-05-27 04:30:03 +00:00
_In_z_ const char * application_name , _In_z_ const char * extra_data ) ;
2006-04-12 15:04:26 +00:00
2009-11-26 21:28:28 +00:00
/*!
\ brief Add an application ( instruction ) to the given extension
\ param session session associated with the extension ( bound by scope )
\ param caller_extension extension to add the application to
\ param application_name the name of the application
\ param fmt optional argument to the application ( printf format string )
*/
SWITCH_DECLARE ( void ) switch_caller_extension_add_application_printf ( _In_ switch_core_session_t * session ,
2010-02-06 03:38:24 +00:00
_In_ switch_caller_extension_t * caller_extension ,
_In_z_ const char * application_name , _In_z_ const char * fmt , . . . ) ;
2009-11-26 21:28:28 +00:00
2006-04-12 15:04:26 +00:00
2006-05-10 03:23:05 +00:00
/*!
\ brief Get the value of a field in a caller profile based on it ' s name
\ param caller_profile The caller profile
\ param name the name
\ note this function is meant for situations where the name paramater is the contents of the variable
*/
2008-05-27 04:30:03 +00:00
_Check_return_ _Ret_opt_z_ SWITCH_DECLARE ( const char * ) switch_caller_get_field_by_name ( _In_ switch_caller_profile_t * caller_profile ,
_In_z_ const char * name ) ;
2006-05-10 03:23:05 +00:00
2006-04-12 15:04:26 +00:00
/*!
\ brief Create a new caller profile object
\ param pool memory pool to use
2006-06-03 17:06:39 +00:00
\ param username tne username of the caller
2006-04-12 15:04:26 +00:00
\ param dialplan name of the dialplan module in use
\ param caller_id_name caller ID name
\ param caller_id_number caller ID number
\ param network_addr network address
\ param ani ANI information
2006-10-17 23:33:32 +00:00
\ param aniii ANI II information
2006-04-24 16:19:11 +00:00
\ param rdnis RDNIS
\ param source the source
2006-04-29 21:36:10 +00:00
\ param context a logical context
2006-04-12 15:04:26 +00:00
\ param destination_number destination number
\ return a new profile object allocated from the session ' s memory pool
*/
2007-12-20 03:07:00 +00:00
SWITCH_DECLARE ( 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 ,
2008-05-27 04:30:03 +00:00
_In_opt_z_ const char * context , _In_opt_z_ const char * destination_number ) ;
2006-04-12 15:04:26 +00:00
/*!
\ brief Clone an existing caller profile object
\ param session session associated with the profile ( bound by scope )
\ param tocopy the existing profile
*/
2007-12-20 03:07:00 +00:00
SWITCH_DECLARE ( switch_caller_profile_t * ) switch_caller_profile_clone ( _In_ switch_core_session_t * session , _In_ switch_caller_profile_t * tocopy ) ;
2006-04-12 15:04:26 +00:00
2007-08-28 16:41:38 +00:00
/*!
\ brief Duplicate an existing caller profile object
\ param pool pool to duplicate with
\ param tocopy the existing profile
*/
2007-12-20 03:07:00 +00:00
SWITCH_DECLARE ( switch_caller_profile_t * ) switch_caller_profile_dup ( _In_ switch_memory_pool_t * pool , _In_ switch_caller_profile_t * tocopy ) ;
2007-08-28 16:41:38 +00:00
2006-04-12 15:04:26 +00:00
/*!
\ brief Add headers to an existing event in regards to a specific profile
\ param caller_profile the desired profile
\ param prefix a prefix string to all of the field names ( for uniqueness )
\ param event the event to add the information to
*/
2006-01-05 21:03:22 +00:00
2007-12-20 03:07:00 +00:00
SWITCH_DECLARE ( void ) switch_caller_profile_event_set_data ( _In_ switch_caller_profile_t * caller_profile ,
2008-05-27 04:30:03 +00:00
_In_opt_z_ const char * prefix , _In_ switch_event_t * event ) ;
2005-11-19 20:07:43 +00:00
2006-09-07 15:15:39 +00:00
SWITCH_END_EXTERN_C
2006-01-10 20:10:38 +00:00
/** @} */
2005-11-19 20:07:43 +00:00
# endif
2006-11-27 22:30:48 +00:00
/* For Emacs:
* Local Variables :
* mode : c
2008-02-03 22:14:57 +00:00
* indent - tabs - mode : t
2006-11-27 22:30:48 +00:00
* tab - width : 4
* c - basic - offset : 4
* End :
* For VIM :
2013-06-25 11:50:17 -05:00
* vim : set softtabstop = 4 shiftwidth = 4 tabstop = 4 noet :
2006-11-27 22:30:48 +00:00
*/