root/src/include/freetdm.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. FTDM_STR2ENUM_P
  2. FTDM_STR2ENUM_P
  3. FTDM_STR2ENUM_P

   1 /*
   2  * Copyright (c) 2007, Anthony Minessale II
   3  * All rights reserved.
   4  * 
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 
   9  * * Redistributions of source code must retain the above copyright
  10  * notice, this list of conditions and the following disclaimer.
  11  * 
  12  * * Redistributions in binary form must reproduce the above copyright
  13  * notice, this list of conditions and the following disclaimer in the
  14  * documentation and/or other materials provided with the distribution.
  15  * 
  16  * * Neither the name of the original author; nor the names of any contributors
  17  * may be used to endorse or promote products derived from this software
  18  * without specific prior written permission.
  19  * 
  20  * 
  21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  25  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  *
  33  * Contributors: 
  34  *
  35  * Moises Silva <moy@sangoma.com>
  36  *
  37  */
  38 
  39 #ifndef FREETDM_H
  40 #define FREETDM_H
  41 
  42 
  43 #include "ftdm_declare.h"
  44 
  45 /*! \brief Max number of channels per physical span */
  46 #define FTDM_MAX_CHANNELS_PHYSICAL_SPAN 32
  47 
  48 /*! \brief Max number of physical spans per logical span */
  49 #define FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN 32
  50 
  51 /*! \brief Max number of channels a logical span can contain */
  52 #define FTDM_MAX_CHANNELS_SPAN FTDM_MAX_CHANNELS_PHYSICAL_SPAN * FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN
  53 
  54 /*! \brief Max number of logical spans */
  55 #define FTDM_MAX_SPANS_INTERFACE 128
  56 
  57 /*! \brief Max number of channels per hunting group */
  58 #define FTDM_MAX_CHANNELS_GROUP 1024
  59 
  60 /*! \brief Max number of groups */
  61 #define FTDM_MAX_GROUPS_INTERFACE FTDM_MAX_SPANS_INTERFACE
  62 
  63 #define FTDM_INVALID_INT_PARM 0xFF
  64 
  65 /*! \brief FreeTDM APIs possible return codes */
  66 typedef enum {
  67         FTDM_SUCCESS, /*!< Success */
  68         FTDM_FAIL, /*!< Failure, generic error return code, use ftdm_channel_get_last_error or ftdm_span_get_last_error for details */
  69         FTDM_MEMERR, /*!< Memory error, most likely allocation failure */
  70         FTDM_TIMEOUT, /*!< Operation timed out (ie: polling on a device)*/
  71         FTDM_NOTIMPL, /*!< Operation not implemented */
  72         FTDM_BREAK, /*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */
  73         FTDM_EINVAL /*!< Invalid argument */
  74 } ftdm_status_t;
  75 
  76 /*! \brief FreeTDM bool type. */
  77 typedef enum {
  78         FTDM_FALSE,
  79         FTDM_TRUE
  80 } ftdm_bool_t;
  81 
  82 /*! \brief Thread/Mutex OS abstraction API. */
  83 #include "ftdm_os.h"
  84 
  85 #ifdef __cplusplus
  86 extern "C" {
  87 #endif
  88 
  89 /*! \brief Limit to span names */
  90 #define FTDM_MAX_NAME_STR_SZ 80
  91 
  92 /*! \brief Limit to channel number strings */
  93 #define FTDM_MAX_NUMBER_STR_SZ 20
  94 
  95 /*! \brief Hangup cause codes */
  96 typedef enum {
  97         FTDM_CAUSE_NONE = 0,
  98         FTDM_CAUSE_UNALLOCATED = 1,
  99         FTDM_CAUSE_NO_ROUTE_TRANSIT_NET = 2,
 100         FTDM_CAUSE_NO_ROUTE_DESTINATION = 3,
 101         FTDM_CAUSE_CHANNEL_UNACCEPTABLE = 6,
 102         FTDM_CAUSE_CALL_AWARDED_DELIVERED = 7,
 103         FTDM_CAUSE_NORMAL_CLEARING = 16,
 104         FTDM_CAUSE_USER_BUSY = 17,
 105         FTDM_CAUSE_NO_USER_RESPONSE = 18,
 106         FTDM_CAUSE_NO_ANSWER = 19,
 107         FTDM_CAUSE_SUBSCRIBER_ABSENT = 20,
 108         FTDM_CAUSE_CALL_REJECTED = 21,
 109         FTDM_CAUSE_NUMBER_CHANGED = 22,
 110         FTDM_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23,
 111         FTDM_CAUSE_EXCHANGE_ROUTING_ERROR = 25,
 112         FTDM_CAUSE_DESTINATION_OUT_OF_ORDER = 27,
 113         FTDM_CAUSE_INVALID_NUMBER_FORMAT = 28,
 114         FTDM_CAUSE_FACILITY_REJECTED = 29,
 115         FTDM_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30,
 116         FTDM_CAUSE_NORMAL_UNSPECIFIED = 31,
 117         FTDM_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34,
 118         FTDM_CAUSE_NETWORK_OUT_OF_ORDER = 38,
 119         FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE = 41,
 120         FTDM_CAUSE_SWITCH_CONGESTION = 42,
 121         FTDM_CAUSE_ACCESS_INFO_DISCARDED = 43,
 122         FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL = 44,
 123         FTDM_CAUSE_PRE_EMPTED = 45,
 124         FTDM_CAUSE_FACILITY_NOT_SUBSCRIBED = 50,
 125         FTDM_CAUSE_OUTGOING_CALL_BARRED = 52,
 126         FTDM_CAUSE_INCOMING_CALL_BARRED = 54,
 127         FTDM_CAUSE_BEARERCAPABILITY_NOTAUTH = 57,
 128         FTDM_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58,
 129         FTDM_CAUSE_SERVICE_UNAVAILABLE = 63,
 130         FTDM_CAUSE_BEARERCAPABILITY_NOTIMPL = 65,
 131         FTDM_CAUSE_CHAN_NOT_IMPLEMENTED = 66,
 132         FTDM_CAUSE_FACILITY_NOT_IMPLEMENTED = 69,
 133         FTDM_CAUSE_SERVICE_NOT_IMPLEMENTED = 79,
 134         FTDM_CAUSE_INVALID_CALL_REFERENCE = 81,
 135         FTDM_CAUSE_INCOMPATIBLE_DESTINATION = 88,
 136         FTDM_CAUSE_INVALID_MSG_UNSPECIFIED = 95,
 137         FTDM_CAUSE_MANDATORY_IE_MISSING = 96,
 138         FTDM_CAUSE_MESSAGE_TYPE_NONEXIST = 97,
 139         FTDM_CAUSE_WRONG_MESSAGE = 98,
 140         FTDM_CAUSE_IE_NONEXIST = 99,
 141         FTDM_CAUSE_INVALID_IE_CONTENTS = 100,
 142         FTDM_CAUSE_WRONG_CALL_STATE = 101,
 143         FTDM_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
 144         FTDM_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
 145         FTDM_CAUSE_PROTOCOL_ERROR = 111,
 146         FTDM_CAUSE_INTERWORKING = 127,
 147         FTDM_CAUSE_SUCCESS = 142,
 148         FTDM_CAUSE_ORIGINATOR_CANCEL = 487,
 149         FTDM_CAUSE_CRASH = 500,
 150         FTDM_CAUSE_SYSTEM_SHUTDOWN = 501,
 151         FTDM_CAUSE_LOSE_RACE = 502,
 152         FTDM_CAUSE_MANAGER_REQUEST = 503,
 153         FTDM_CAUSE_BLIND_TRANSFER = 600,
 154         FTDM_CAUSE_ATTENDED_TRANSFER = 601,
 155         FTDM_CAUSE_ALLOTTED_TIMEOUT = 602,
 156         FTDM_CAUSE_USER_CHALLENGE = 603,
 157         FTDM_CAUSE_MEDIA_TIMEOUT = 604
 158 } ftdm_call_cause_t;
 159 
 160 /*! \brief Hunting direction (when hunting for free channels) */
 161 typedef enum {
 162         FTDM_TOP_DOWN,
 163         FTDM_BOTTOM_UP
 164 } ftdm_direction_t;
 165 
 166 /*! \brief I/O channel type */
 167 typedef enum {
 168         FTDM_CHAN_TYPE_B, /*!< Bearer channel */
 169         FTDM_CHAN_TYPE_DQ921, /*< DQ921 channel (D-channel) */
 170         FTDM_CHAN_TYPE_DQ931, /*!< DQ931 channel */
 171         FTDM_CHAN_TYPE_FXS, /*!< FXS analog channel */
 172         FTDM_CHAN_TYPE_FXO, /*!< FXO analog channel */
 173         FTDM_CHAN_TYPE_EM, /*!< E & M channel */
 174         FTDM_CHAN_TYPE_CAS, /*!< CAS channel */
 175         FTDM_CHAN_TYPE_COUNT /*!< Count of channel types */
 176 } ftdm_chan_type_t;
 177 #define CHAN_TYPE_STRINGS "B", "DQ921", "DQ931", "FXS", "FXO", "EM", "CAS", "INVALID"
 178 /*! \brief transform from channel type to string and from string to channel type 
 179  * ftdm_str2ftdm_chan_type transforms a channel string (ie: "FXO" to FTDM_CHAN_TYPE_FXO) 
 180  * ftdm_chan_type2str transforms a channel type to string (ie: FTDM_CHAN_TYPE_B to "B")
 181  */
 182 FTDM_STR2ENUM_P(ftdm_str2ftdm_chan_type, ftdm_chan_type2str, ftdm_chan_type_t)
 183 
 184 /*! \brief Test if a channel is a voice channel */
 185 #define FTDM_IS_VOICE_CHANNEL(ftdm_chan) ((ftdm_chan)->type != FTDM_CHAN_TYPE_DQ921 && (ftdm_chan)->type != FTDM_CHAN_TYPE_DQ931)
 186 
 187 /*! \brief Test if a channel is a D-channel */
 188 #define FTDM_IS_DCHAN(ftdm_chan) ((ftdm_chan)->type == FTDM_CHAN_TYPE_DQ921 || (ftdm_chan)->type == FTDM_CHAN_TYPE_DQ931)
 189 
 190 /*! \brief Logging function prototype to be used for all FreeTDM logs 
 191  *  you should use ftdm_global_set_logger to set your own logger
 192  */
 193 typedef void (*ftdm_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
 194 
 195 /*! \brief Data queue operation functions
 196  *  you can use ftdm_global_set_queue_handler if you want to override the default implementation (not recommended)
 197  */
 198 typedef ftdm_status_t (*ftdm_queue_create_func_t)(ftdm_queue_t **queue, ftdm_size_t capacity);
 199 typedef ftdm_status_t (*ftdm_queue_enqueue_func_t)(ftdm_queue_t *queue, void *obj);
 200 typedef void *(*ftdm_queue_dequeue_func_t)(ftdm_queue_t *queue);
 201 typedef ftdm_status_t (*ftdm_queue_wait_func_t)(ftdm_queue_t *queue, int ms);
 202 typedef ftdm_status_t (*ftdm_queue_get_interrupt_func_t)(ftdm_queue_t *queue, ftdm_interrupt_t **interrupt);
 203 typedef ftdm_status_t (*ftdm_queue_destroy_func_t)(ftdm_queue_t **queue);
 204 typedef struct ftdm_queue_handler {
 205         ftdm_queue_create_func_t create;
 206         ftdm_queue_enqueue_func_t enqueue;
 207         ftdm_queue_dequeue_func_t dequeue;
 208         ftdm_queue_wait_func_t wait;
 209         ftdm_queue_get_interrupt_func_t get_interrupt;
 210         ftdm_queue_destroy_func_t destroy;
 211 } ftdm_queue_handler_t;
 212 
 213 
 214 /*! \brief Type Of Number (TON) */
 215 typedef enum {
 216         FTDM_TON_UNKNOWN = 0,
 217         FTDM_TON_INTERNATIONAL,
 218         FTDM_TON_NATIONAL,
 219         FTDM_TON_NETWORK_SPECIFIC,
 220         FTDM_TON_SUBSCRIBER_NUMBER,
 221         FTDM_TON_ABBREVIATED_NUMBER,
 222         FTDM_TON_RESERVED,
 223         FTDM_TON_INVALID = 255
 224 } ftdm_ton_t;
 225 
 226 /*! Numbering Plan Identification (NPI) */
 227 typedef enum {
 228         FTDM_NPI_UNKNOWN = 0,
 229         FTDM_NPI_ISDN = 1,
 230         FTDM_NPI_DATA = 3,
 231         FTDM_NPI_TELEX = 4,
 232         FTDM_NPI_NATIONAL = 8,
 233         FTDM_NPI_PRIVATE = 9,
 234         FTDM_NPI_RESERVED = 10,
 235         FTDM_NPI_INVALID = 255
 236 } ftdm_npi_t;
 237 
 238 /*! \brief Number abstraction */
 239 typedef struct {
 240         char digits[25];
 241         uint8_t type;
 242         uint8_t plan;
 243 } ftdm_number_t;
 244 
 245 /*! \brief bearer capability */
 246 typedef enum {
 247         FTDM_BEARER_CAP_SPEECH = 0x00,
 248         FTDM_BEARER_CAP_64K_UNRESTRICTED = 0x02,
 249         FTDM_BEARER_CAP_3_1KHZ_AUDIO = 0x03
 250 } ftdm_bearer_cap_t;
 251 
 252 /*! \brief user information layer 1 protocol */
 253 typedef enum {
 254         FTDM_USER_LAYER1_PROT_V110 = 0x01,
 255         FTDM_USER_LAYER1_PROT_ULAW = 0x02,
 256         FTDM_USER_LAYER1_PROT_ALAW = 0x03,
 257 } ftdm_user_layer1_prot_t;
 258 
 259 /*! \brief Caller information */
 260 typedef struct ftdm_caller_data {
 261         char cid_date[8]; /*!< Caller ID date */
 262         char cid_name[80]; /*!< Caller ID name */
 263         ftdm_number_t cid_num; /*!< Caller ID number */
 264         ftdm_number_t ani; /*!< ANI (Automatic Number Identification) */
 265         ftdm_number_t dnis; /*!< DNIS (Dialed Number Identification Service) */
 266         ftdm_number_t rdnis; /*!< RDNIS (Redirected Dialed Number Identification Service) */
 267         char aniII[25]; /*! ANI II */
 268         uint8_t screen; /*!< Screening */
 269         uint8_t pres; /*!< Presentation*/
 270         char collected[25]; /*!< Collected digits so far */
 271         int hangup_cause; /*!< Hangup cause */
 272         char raw_data[1024]; /*!< Protocol specific raw caller data */
 273         uint32_t raw_data_len; /* !< Raw data length */
 274         /* these 2 are undocumented right now, only used by boost: */
 275         /* bearer capability */
 276         ftdm_bearer_cap_t bearer_capability;
 277         /* user information layer 1 protocol */
 278         ftdm_user_layer1_prot_t bearer_layer1;
 279 } ftdm_caller_data_t;
 280 
 281 /*! \brief Tone type */
 282 typedef enum {
 283         FTDM_TONE_DTMF = (1 << 0)
 284 } ftdm_tone_type_t;
 285 
 286 /*! \brief Signaling messages sent by the stacks */
 287 typedef enum {
 288         FTDM_SIGEVENT_START, /*!< Incoming call (ie: incoming SETUP msg or Ring) */
 289         FTDM_SIGEVENT_STOP, /*!< Hangup */
 290         FTDM_SIGEVENT_UP, /*!< Outgoing call has been answered */
 291         FTDM_SIGEVENT_FLASH, /*< Flash event  (typically on-hook/off-hook for analog devices) */
 292         FTDM_SIGEVENT_PROGRESS, /*!< Outgoing call is making progress */
 293         FTDM_SIGEVENT_PROGRESS_MEDIA, /*!< Outgoing call is making progress and there is media available */
 294         FTDM_SIGEVENT_ALARM_TRAP, /*!< Hardware alarm ON */
 295         FTDM_SIGEVENT_ALARM_CLEAR, /*!< Hardware alarm OFF */
 296         FTDM_SIGEVENT_COLLECTED_DIGIT, /*!< Digit collected (in signalings where digits are collected one by one) */
 297         FTDM_SIGEVENT_ADD_CALL, /*!< New call should be added to the channel */
 298         FTDM_SIGEVENT_RESTART, /*!< Restart has been requested. Typically you hangup your call resources here */
 299         FTDM_SIGEVENT_SIGSTATUS_CHANGED, /*!< Signaling protocol status changed (ie: D-chan up), see new status in raw_data ftdm_sigmsg_t member */
 300         FTDM_SIGEVENT_COLLISION, /*!< Outgoing call was dropped because an incoming call arrived at the same time */
 301         FTDM_SIGEVENT_INVALID
 302 } ftdm_signal_event_t;
 303 #define SIGNAL_STRINGS "START", "STOP", "UP", "FLASH", "PROGRESS", \
 304                 "PROGRESS_MEDIA", "ALARM_TRAP", "ALARM_CLEAR", \
 305                 "COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "INVALID"
 306 
 307 /*! \brief Move from string to ftdm_signal_event_t and viceversa */
 308 FTDM_STR2ENUM_P(ftdm_str2ftdm_signal_event, ftdm_signal_event2str, ftdm_signal_event_t)
 309 
 310 /*! \brief Span trunk types */
 311 typedef enum {
 312         FTDM_TRUNK_E1,
 313         FTDM_TRUNK_T1,
 314         FTDM_TRUNK_J1,
 315         FTDM_TRUNK_BRI,
 316         FTDM_TRUNK_BRI_PTMP,
 317         FTDM_TRUNK_FXO,
 318         FTDM_TRUNK_FXS,
 319         FTDM_TRUNK_EM,
 320         FTDM_TRUNK_NONE
 321 } ftdm_trunk_type_t;
 322 #define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "NONE"
 323 
 324 /*! \brief Move from string to ftdm_trunk_type_t and viceversa */
 325 FTDM_STR2ENUM_P(ftdm_str2ftdm_trunk_type, ftdm_trunk_type2str, ftdm_trunk_type_t)
 326 
 327 /*! \brief Basic channel configuration provided to ftdm_configure_span_channels */
 328 typedef struct ftdm_channel_config {    
 329         char name[FTDM_MAX_NAME_STR_SZ];
 330         char number[FTDM_MAX_NUMBER_STR_SZ];
 331         char group_name[FTDM_MAX_NAME_STR_SZ];
 332         ftdm_chan_type_t type;
 333         float rxgain;
 334         float txgain;
 335 } ftdm_channel_config_t;
 336 
 337 /*!
 338   \brief Signaling status on a given span or specific channel on protocols that support it
 339  */
 340 typedef enum {
 341         /* The signaling link is down (no d-chans up in the span/group, MFC-R2 bit pattern unidentified) */
 342         FTDM_SIG_STATE_DOWN,
 343         /* The signaling link is suspended (MFC-R2 bit pattern blocked, ss7 blocked?) */
 344         FTDM_SIG_STATE_SUSPENDED,
 345         /* The signaling link is ready and calls can be placed (ie: d-chan up) */
 346         FTDM_SIG_STATE_UP,
 347         /* Invalid status */
 348         FTDM_SIG_STATE_INVALID
 349 } ftdm_signaling_status_t;
 350 #define SIGSTATUS_STRINGS "DOWN", "SUSPENDED", "UP", "INVALID"
 351 
 352 /*! \brief Move from string to ftdm_signaling_status_t and viceversa */
 353 FTDM_STR2ENUM_P(ftdm_str2ftdm_signaling_status, ftdm_signaling_status2str, ftdm_signaling_status_t)
 354 
 355 /*! \brief Generic signaling message */
 356 struct ftdm_sigmsg {
 357         ftdm_signal_event_t event_id; /*!< The type of message */
 358         ftdm_channel_t *channel; /*!< Related channel */
 359         uint32_t chan_id; /*!< easy access to chan id */
 360         uint32_t span_id; /*!< easy access to span_id */
 361         ftdm_signaling_status_t sigstatus; /*!< Signaling status (valid if event_id is FTDM_SIGEVENT_SIGSTATUS_CHANGED) */
 362         void *raw_data; /*!< Message specific data if any */
 363         uint32_t raw_data_len; /*!< Data len in case is needed */
 364 };
 365 
 366 /*! \brief Crash policy 
 367  *  Useful for debugging only, default policy is never, if you wish to crash on asserts then use ftdm_global_set_crash_policy */
 368 typedef enum {
 369         FTDM_CRASH_NEVER = 0,
 370         FTDM_CRASH_ON_ASSERT
 371 } ftdm_crash_policy_t;
 372 
 373 /*! \brief I/O waiting flags */
 374 typedef enum {
 375         FTDM_NO_FLAGS = 0,
 376         FTDM_READ =  (1 << 0),
 377         FTDM_WRITE = (1 << 1),
 378         FTDM_EVENTS = (1 << 2)
 379 } ftdm_wait_flag_t;
 380 
 381 /*! \brief Signaling configuration parameter for the stacks (variable=value pair) */
 382 typedef struct ftdm_conf_parameter {
 383         const char *var;
 384         const char *val;
 385         void *ptr;
 386 } ftdm_conf_parameter_t;
 387 
 388 /*! \brief Opaque general purpose iterator */
 389 typedef struct ftdm_iterator ftdm_iterator_t;
 390 
 391 /*! \brief Channel commands that can be executed through ftdm_channel_command() */
 392 typedef enum {
 393         FTDM_COMMAND_NOOP,
 394         FTDM_COMMAND_SET_INTERVAL,
 395         FTDM_COMMAND_GET_INTERVAL,
 396         FTDM_COMMAND_SET_CODEC,
 397         FTDM_COMMAND_GET_CODEC,
 398         FTDM_COMMAND_SET_NATIVE_CODEC,
 399         FTDM_COMMAND_GET_NATIVE_CODEC,
 400         FTDM_COMMAND_ENABLE_DTMF_DETECT,
 401         FTDM_COMMAND_DISABLE_DTMF_DETECT,
 402         FTDM_COMMAND_SEND_DTMF,
 403         FTDM_COMMAND_SET_DTMF_ON_PERIOD,
 404         FTDM_COMMAND_GET_DTMF_ON_PERIOD,
 405         FTDM_COMMAND_SET_DTMF_OFF_PERIOD,
 406         FTDM_COMMAND_GET_DTMF_OFF_PERIOD,
 407         FTDM_COMMAND_GENERATE_RING_ON,
 408         FTDM_COMMAND_GENERATE_RING_OFF,
 409         FTDM_COMMAND_OFFHOOK,
 410         FTDM_COMMAND_ONHOOK,
 411         FTDM_COMMAND_FLASH,
 412         FTDM_COMMAND_WINK,
 413         FTDM_COMMAND_ENABLE_PROGRESS_DETECT,
 414         FTDM_COMMAND_DISABLE_PROGRESS_DETECT,
 415         FTDM_COMMAND_TRACE_INPUT,
 416         FTDM_COMMAND_TRACE_OUTPUT,
 417         FTDM_COMMAND_TRACE_END_ALL,
 418         FTDM_COMMAND_ENABLE_CALLERID_DETECT,
 419         FTDM_COMMAND_DISABLE_CALLERID_DETECT,
 420         FTDM_COMMAND_ENABLE_ECHOCANCEL,
 421         FTDM_COMMAND_DISABLE_ECHOCANCEL,
 422         FTDM_COMMAND_ENABLE_ECHOTRAIN,
 423         FTDM_COMMAND_DISABLE_ECHOTRAIN,
 424         FTDM_COMMAND_SET_CAS_BITS,
 425         FTDM_COMMAND_GET_CAS_BITS,
 426         FTDM_COMMAND_SET_RX_GAIN,
 427         FTDM_COMMAND_GET_RX_GAIN,
 428         FTDM_COMMAND_SET_TX_GAIN,
 429         FTDM_COMMAND_GET_TX_GAIN,
 430         FTDM_COMMAND_FLUSH_TX_BUFFERS,
 431         FTDM_COMMAND_FLUSH_RX_BUFFERS,
 432         FTDM_COMMAND_FLUSH_BUFFERS,
 433         FTDM_COMMAND_SET_PRE_BUFFER_SIZE,
 434         FTDM_COMMAND_SET_LINK_STATUS,
 435         FTDM_COMMAND_GET_LINK_STATUS,
 436         FTDM_COMMAND_ENABLE_LOOP,
 437         FTDM_COMMAND_DISABLE_LOOP,
 438         FTDM_COMMAND_COUNT
 439 } ftdm_command_t;
 440 
 441 /*! \brief Custom memory handler hooks. Not recommended to use unless you need memory allocation customizations */
 442 typedef void *(*ftdm_malloc_func_t)(void *pool, ftdm_size_t len);
 443 typedef void *(*ftdm_calloc_func_t)(void *pool, ftdm_size_t elements, ftdm_size_t len);
 444 typedef void *(*ftdm_realloc_func_t)(void *pool, void *buff, ftdm_size_t len);
 445 typedef void (*ftdm_free_func_t)(void *pool, void *ptr);
 446 struct ftdm_memory_handler {
 447         void *pool;
 448         ftdm_malloc_func_t malloc;
 449         ftdm_calloc_func_t calloc;
 450         ftdm_realloc_func_t realloc;
 451         ftdm_free_func_t free;
 452 };
 453 
 454 /*! \brief FreeTDM I/O layer interface argument macros 
 455  * You don't need these unless your implementing an I/O interface module (most users don't) */
 456 #define FIO_CHANNEL_REQUEST_ARGS (ftdm_span_t *span, uint32_t chan_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan)
 457 #define FIO_CHANNEL_OUTGOING_CALL_ARGS (ftdm_channel_t *ftdmchan)
 458 #define FIO_CHANNEL_SET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
 459 #define FIO_CHANNEL_GET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status)
 460 #define FIO_SPAN_SET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status)
 461 #define FIO_SPAN_GET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t *status)
 462 #define FIO_SPAN_POLL_EVENT_ARGS (ftdm_span_t *span, uint32_t ms)
 463 #define FIO_SPAN_NEXT_EVENT_ARGS (ftdm_span_t *span, ftdm_event_t **event)
 464 #define FIO_SIGNAL_CB_ARGS (ftdm_sigmsg_t *sigmsg)
 465 #define FIO_EVENT_CB_ARGS (ftdm_channel_t *ftdmchan, ftdm_event_t *event)
 466 #define FIO_CONFIGURE_SPAN_ARGS (ftdm_span_t *span, const char *str, ftdm_chan_type_t type, char *name, char *number)
 467 #define FIO_CONFIGURE_ARGS (const char *category, const char *var, const char *val, int lineno)
 468 #define FIO_OPEN_ARGS (ftdm_channel_t *ftdmchan)
 469 #define FIO_CLOSE_ARGS (ftdm_channel_t *ftdmchan)
 470 #define FIO_CHANNEL_DESTROY_ARGS (ftdm_channel_t *ftdmchan)
 471 #define FIO_SPAN_DESTROY_ARGS (ftdm_span_t *span)
 472 #define FIO_COMMAND_ARGS (ftdm_channel_t *ftdmchan, ftdm_command_t command, void *obj)
 473 #define FIO_WAIT_ARGS (ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t to)
 474 #define FIO_GET_ALARMS_ARGS (ftdm_channel_t *ftdmchan)
 475 #define FIO_READ_ARGS (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen)
 476 #define FIO_WRITE_ARGS (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen)
 477 #define FIO_IO_LOAD_ARGS (ftdm_io_interface_t **fio)
 478 #define FIO_IO_UNLOAD_ARGS (void)
 479 #define FIO_SIG_LOAD_ARGS (void)
 480 #define FIO_SIG_CONFIGURE_ARGS (ftdm_span_t *span, fio_signal_cb_t sig_cb, va_list ap)
 481 #define FIO_CONFIGURE_SPAN_SIGNALING_ARGS (ftdm_span_t *span, fio_signal_cb_t sig_cb, ftdm_conf_parameter_t *ftdm_parameters)
 482 #define FIO_SIG_UNLOAD_ARGS (void)
 483 #define FIO_API_ARGS (ftdm_stream_handle_t *stream, const char *data)
 484 
 485 /*! \brief FreeTDM I/O layer interface function typedefs
 486  * You don't need these unless your implementing an I/O interface module (most users don't) */
 487 typedef ftdm_status_t (*fio_channel_request_t) FIO_CHANNEL_REQUEST_ARGS ;
 488 typedef ftdm_status_t (*fio_channel_outgoing_call_t) FIO_CHANNEL_OUTGOING_CALL_ARGS ;
 489 typedef ftdm_status_t (*fio_channel_set_sig_status_t) FIO_CHANNEL_SET_SIG_STATUS_ARGS;
 490 typedef ftdm_status_t (*fio_channel_get_sig_status_t) FIO_CHANNEL_GET_SIG_STATUS_ARGS;
 491 typedef ftdm_status_t (*fio_span_set_sig_status_t) FIO_SPAN_SET_SIG_STATUS_ARGS;
 492 typedef ftdm_status_t (*fio_span_get_sig_status_t) FIO_SPAN_GET_SIG_STATUS_ARGS;
 493 typedef ftdm_status_t (*fio_span_poll_event_t) FIO_SPAN_POLL_EVENT_ARGS ;
 494 typedef ftdm_status_t (*fio_span_next_event_t) FIO_SPAN_NEXT_EVENT_ARGS ;
 495 typedef ftdm_status_t (*fio_signal_cb_t) FIO_SIGNAL_CB_ARGS ;
 496 typedef ftdm_status_t (*fio_event_cb_t) FIO_EVENT_CB_ARGS ;
 497 typedef ftdm_status_t (*fio_configure_span_t) FIO_CONFIGURE_SPAN_ARGS ;
 498 typedef ftdm_status_t (*fio_configure_t) FIO_CONFIGURE_ARGS ;
 499 typedef ftdm_status_t (*fio_open_t) FIO_OPEN_ARGS ;
 500 typedef ftdm_status_t (*fio_close_t) FIO_CLOSE_ARGS ;
 501 typedef ftdm_status_t (*fio_channel_destroy_t) FIO_CHANNEL_DESTROY_ARGS ;
 502 typedef ftdm_status_t (*fio_span_destroy_t) FIO_SPAN_DESTROY_ARGS ;
 503 typedef ftdm_status_t (*fio_get_alarms_t) FIO_GET_ALARMS_ARGS ;
 504 typedef ftdm_status_t (*fio_command_t) FIO_COMMAND_ARGS ;
 505 typedef ftdm_status_t (*fio_wait_t) FIO_WAIT_ARGS ;
 506 typedef ftdm_status_t (*fio_read_t) FIO_READ_ARGS ;
 507 typedef ftdm_status_t (*fio_write_t) FIO_WRITE_ARGS ;
 508 typedef ftdm_status_t (*fio_io_load_t) FIO_IO_LOAD_ARGS ;
 509 typedef ftdm_status_t (*fio_sig_load_t) FIO_SIG_LOAD_ARGS ;
 510 typedef ftdm_status_t (*fio_sig_configure_t) FIO_SIG_CONFIGURE_ARGS ;
 511 typedef ftdm_status_t (*fio_configure_span_signaling_t) FIO_CONFIGURE_SPAN_SIGNALING_ARGS ;
 512 typedef ftdm_status_t (*fio_io_unload_t) FIO_IO_UNLOAD_ARGS ;
 513 typedef ftdm_status_t (*fio_sig_unload_t) FIO_SIG_UNLOAD_ARGS ;
 514 typedef ftdm_status_t (*fio_api_t) FIO_API_ARGS ;
 515 
 516 
 517 /*! \brief FreeTDM I/O layer interface function prototype wrapper macros
 518  * You don't need these unless your implementing an I/O interface module (most users don't) */
 519 #define FIO_CHANNEL_REQUEST_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_REQUEST_ARGS
 520 #define FIO_CHANNEL_OUTGOING_CALL_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_OUTGOING_CALL_ARGS
 521 #define FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_SET_SIG_STATUS_ARGS
 522 #define FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_GET_SIG_STATUS_ARGS
 523 #define FIO_SPAN_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_SPAN_SET_SIG_STATUS_ARGS
 524 #define FIO_SPAN_GET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_SPAN_GET_SIG_STATUS_ARGS
 525 #define FIO_SPAN_POLL_EVENT_FUNCTION(name) ftdm_status_t name FIO_SPAN_POLL_EVENT_ARGS
 526 #define FIO_SPAN_NEXT_EVENT_FUNCTION(name) ftdm_status_t name FIO_SPAN_NEXT_EVENT_ARGS
 527 #define FIO_SIGNAL_CB_FUNCTION(name) ftdm_status_t name FIO_SIGNAL_CB_ARGS
 528 #define FIO_EVENT_CB_FUNCTION(name) ftdm_status_t name FIO_EVENT_CB_ARGS
 529 #define FIO_CONFIGURE_SPAN_FUNCTION(name) ftdm_status_t name FIO_CONFIGURE_SPAN_ARGS
 530 #define FIO_CONFIGURE_FUNCTION(name) ftdm_status_t name FIO_CONFIGURE_ARGS
 531 #define FIO_OPEN_FUNCTION(name) ftdm_status_t name FIO_OPEN_ARGS
 532 #define FIO_CLOSE_FUNCTION(name) ftdm_status_t name FIO_CLOSE_ARGS
 533 #define FIO_CHANNEL_DESTROY_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_DESTROY_ARGS
 534 #define FIO_SPAN_DESTROY_FUNCTION(name) ftdm_status_t name FIO_SPAN_DESTROY_ARGS
 535 #define FIO_GET_ALARMS_FUNCTION(name) ftdm_status_t name FIO_GET_ALARMS_ARGS
 536 #define FIO_COMMAND_FUNCTION(name) ftdm_status_t name FIO_COMMAND_ARGS
 537 #define FIO_WAIT_FUNCTION(name) ftdm_status_t name FIO_WAIT_ARGS
 538 #define FIO_READ_FUNCTION(name) ftdm_status_t name FIO_READ_ARGS
 539 #define FIO_WRITE_FUNCTION(name) ftdm_status_t name FIO_WRITE_ARGS
 540 #define FIO_IO_LOAD_FUNCTION(name) ftdm_status_t name FIO_IO_LOAD_ARGS
 541 #define FIO_SIG_LOAD_FUNCTION(name) ftdm_status_t name FIO_SIG_LOAD_ARGS
 542 #define FIO_SIG_CONFIGURE_FUNCTION(name) ftdm_status_t name FIO_SIG_CONFIGURE_ARGS
 543 #define FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(name) ftdm_status_t name FIO_CONFIGURE_SPAN_SIGNALING_ARGS
 544 #define FIO_IO_UNLOAD_FUNCTION(name) ftdm_status_t name FIO_IO_UNLOAD_ARGS
 545 #define FIO_SIG_UNLOAD_FUNCTION(name) ftdm_status_t name FIO_SIG_UNLOAD_ARGS
 546 #define FIO_API_FUNCTION(name) ftdm_status_t name FIO_API_ARGS
 547 
 548 /*! \brief FreeTDM I/O layer function prototype wrapper macros
 549  * You don't need these unless your implementing an I/O interface module (most users don't) */
 550 struct ftdm_io_interface {
 551         const char *name; /*!< I/O module name */
 552         fio_configure_span_t configure_span; /*!< Configure span I/O */
 553         fio_configure_t configure; /*!< Configure the module */
 554         fio_open_t open; /*!< Open I/O channel */
 555         fio_close_t close; /*!< Close I/O channel */
 556         fio_channel_destroy_t channel_destroy; /*!< Destroy I/O channel */
 557         fio_span_destroy_t span_destroy; /*!< Destroy span I/O */
 558         fio_get_alarms_t get_alarms; /*!< Get hardware alarms */
 559         fio_command_t command; /*!< Execute an I/O command on the channel */
 560         fio_wait_t wait; /*!< Wait for events on the channel */
 561         fio_read_t read; /*!< Read data from the channel */
 562         fio_write_t write; /*!< Write data to the channel */
 563         fio_span_poll_event_t poll_event; /*!< Poll for events on the whole span */
 564         fio_span_next_event_t next_event; /*!< Retrieve an event from the span */
 565         fio_api_t api; /*!< Execute a text command */
 566 };
 567 
 568 /*! \brief FreeTDM supported I/O codecs */
 569 typedef enum {
 570         FTDM_CODEC_ULAW = 0,
 571         FTDM_CODEC_ALAW = 8,
 572         FTDM_CODEC_SLIN = 10,
 573         FTDM_CODEC_NONE = (1 << 30)
 574 } ftdm_codec_t;
 575 
 576 /*! \brief FreeTDM supported indications.
 577  * This is used during incoming calls when you want to request the signaling stack
 578  * to notify about indications occurring locally */
 579 typedef enum {
 580         FTDM_CHANNEL_INDICATE_RING,
 581         FTDM_CHANNEL_INDICATE_PROCEED,
 582         FTDM_CHANNEL_INDICATE_PROGRESS,
 583         FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA,
 584         FTDM_CHANNEL_INDICATE_BUSY,
 585 } ftdm_channel_indication_t;
 586 
 587 /*! \brief FreeTDM supported hardware alarms. */
 588 typedef enum {
 589         FTDM_ALARM_NONE    = 0,
 590         FTDM_ALARM_RED     = (1 << 1),
 591         FTDM_ALARM_YELLOW  = (1 << 2),
 592         FTDM_ALARM_RAI     = (1 << 3),
 593         FTDM_ALARM_BLUE    = (1 << 4),
 594         FTDM_ALARM_AIS     = (1 << 5),
 595         FTDM_ALARM_GENERAL = (1 << 30)
 596 } ftdm_alarm_flag_t;
 597 
 598 /*! \brief Override the default queue handler */
 599 FT_DECLARE(ftdm_status_t) ftdm_global_set_queue_handler(ftdm_queue_handler_t *handler);
 600 
 601 /*! \brief Answer call */
 602 #define ftdm_channel_call_answer(ftdmchan) _ftdm_channel_call_answer(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
 603 
 604 /*! \brief Answer call recording the source code point where the it was called (see ftdm_channel_call_answer for an easy to use macro) */
 605 FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
 606 
 607 /*! \brief Place an outgoing call */
 608 #define ftdm_channel_call_place(ftdmchan) _ftdm_channel_call_place(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
 609 
 610 /*! \brief Place an outgoing call recording the source code point where it was called (see ftdm_channel_call_place for an easy to use macro) */
 611 FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
 612 
 613 /*! \brief Indicate a new condition in an incoming call */
 614 #define ftdm_channel_call_indicate(ftdmchan, indication) _ftdm_channel_call_indicate(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (indication))
 615 
 616 /*! \brief Indicate a new condition in an incoming call recording the source code point where it was called (see ftdm_channel_call_indicate for an easy to use macro) */
 617 FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication);
 618 
 619 /*! \brief Hangup the call without cause */
 620 #define ftdm_channel_call_hangup(ftdmchan) _ftdm_channel_call_hangup(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
 621 
 622 /*! \brief Hangup the call without cause recording the source code point where it was called (see ftdm_channel_call_hangup for an easy to use macro)*/
 623 FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
 624 
 625 /*! \brief Hangup the call with cause */
 626 #define ftdm_channel_call_hangup_with_cause(ftdmchan, cause) _ftdm_channel_call_hangup_with_cause(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (cause))
 627 
 628 /*! \brief Hangup the call with cause recording the source code point where it was called (see ftdm_channel_call_hangup_with_cause for an easy to use macro) */
 629 FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_call_cause_t);
 630 
 631 /*! \brief Put a call on hold (if supported by the signaling stack) */
 632 #define ftdm_channel_call_hold(ftdmchan) _ftdm_channel_call_hold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
 633 
 634 /*! \brief Put a call on hold recording the source code point where it was called (see ftdm_channel_call_hold for an easy to use macro) */
 635 FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
 636 
 637 /*! \brief Unhold a call */
 638 #define ftdm_channel_call_unhold(ftdmchan) _ftdm_channel_call_unhold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
 639 
 640 /*! \brief Unhold a call recording the source code point where it was called (see ftdm_channel_call_unhold for an easy to use macro) */
 641 FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
 642 
 643 /*! \brief Check if the call is answered already */
 644 FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_answered(const ftdm_channel_t *ftdmchan);
 645 
 646 /*! \brief Check if the call is busy */
 647 FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_busy(const ftdm_channel_t *ftdmchan);
 648 
 649 /*! \brief Check if the call is hangup */
 650 FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_hangup(const ftdm_channel_t *ftdmchan);
 651 
 652 /*! \brief Check if the call is done (final state for a call, just after hangup) */
 653 FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_done(const ftdm_channel_t *ftdmchan);
 654 
 655 /*! \brief Check if the call is in hold */
 656 FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_hold(const ftdm_channel_t *ftdmchan);
 657 
 658 /*! \brief Set channel signaling status (ie: put specific circuit down) only if supported by the signaling */
 659 FT_DECLARE(ftdm_status_t) ftdm_channel_set_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status);
 660 
 661 /*! \brief Get channel signaling status (ie: whether protocol layer is up or down) */
 662 FT_DECLARE(ftdm_status_t) ftdm_channel_get_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status);
 663 
 664 /*! \brief Set span signaling status (ie: put the whole span protocol layer down) only if supported by the signaling */
 665 FT_DECLARE(ftdm_status_t) ftdm_span_set_sig_status(ftdm_span_t *span, ftdm_signaling_status_t status);
 666 
 667 /*! \brief Get span signaling status (ie: whether protocol layer is up or down) */
 668 FT_DECLARE(ftdm_status_t) ftdm_span_get_sig_status(ftdm_span_t *span, ftdm_signaling_status_t *status);
 669 
 670 /*! 
 671  * \brief Set user private data in the channel
 672  *
 673  * \param ftdmchan The channel where the private data will be stored
 674  * \param pvt The private pointer to store
 675  *
 676  */
 677 FT_DECLARE(void) ftdm_channel_set_private(ftdm_channel_t *ftdmchan, void *pvt);
 678 
 679 /*! 
 680  * \brief Get user private data in the channel
 681  *
 682  * \param ftdmchan The channel to retrieve the private data
 683  * \retval The private data (if any or NULL if no data has been stored)
 684  *
 685  */
 686 FT_DECLARE(void *) ftdm_channel_get_private(const ftdm_channel_t *ftdmchan);
 687 
 688 /*! 
 689  * \brief Remove the given token from the channel
 690  *
 691  * \param ftdmchan The channel where the token is
 692  * \param token The token string. If NULL, all tokens in the channel are cleared
 693  *
 694  * \retval FTDM_SUCCESS success
 695  * \retval FTDM_FAIL failure
 696  */
 697 FT_DECLARE(ftdm_status_t) ftdm_channel_clear_token(ftdm_channel_t *ftdmchan, const char *token);
 698 
 699 /*! 
 700  * \brief Replace the given token with the new token
 701  *
 702  * \param ftdmchan The channel where the token is
 703  * \param old_token The token to replace
 704  * \param new_token The token to put in place
 705  */
 706 FT_DECLARE(void) ftdm_channel_replace_token(ftdm_channel_t *ftdmchan, const char *old_token, const char *new_token);
 707 
 708 /*! 
 709  * \brief Add a new token to the channel
 710  *
 711  * \param ftdmchan The channel where the token will be added
 712  * \param token The token string to add
 713  * \param end if 0, the token will be added at the beginning of the token list, to the end otherwise
 714  *
 715  * \retval FTDM_SUCCESS success
 716  * \retval FTDM_FAIL failure
 717  */
 718 FT_DECLARE(ftdm_status_t) ftdm_channel_add_token(ftdm_channel_t *ftdmchan, char *token, int end);
 719 
 720 /*! 
 721  * \brief Get the requested token
 722  *
 723  * \param ftdmchan The channel where the token is
 724  * \param tokenid The id of the token
 725  *
 726  * \retval The token character string
 727  * \retval NULL token not found
 728  */
 729 FT_DECLARE(const char *) ftdm_channel_get_token(const ftdm_channel_t *ftdmchan, uint32_t tokenid);
 730 
 731 /*! 
 732  * \brief Get the token count
 733  *
 734  * \param ftdmchan The channel to get the token count from
 735  *
 736  * \retval The token count
 737  */
 738 FT_DECLARE(uint32_t) ftdm_channel_get_token_count(const ftdm_channel_t *ftdmchan);
 739 
 740 /*! 
 741  * \brief Get the I/O read/write interval
 742  *
 743  * \param ftdmchan The channel to get the interval from
 744  *
 745  * \retval The interval in milliseconds
 746  */
 747 FT_DECLARE(uint32_t) ftdm_channel_get_io_interval(const ftdm_channel_t *ftdmchan);
 748 
 749 /*! 
 750  * \brief Get the I/O read/write packet length per interval
 751  *
 752  * \param ftdmchan The channel to get the packet length from
 753  *
 754  * \retval The packet length interval in bytes
 755  */
 756 FT_DECLARE(uint32_t) ftdm_channel_get_io_packet_len(const ftdm_channel_t *ftdmchan);
 757 
 758 /*! 
 759  * \brief Get the I/O read/write codec
 760  *
 761  * \param ftdmchan The channel to get the codec from
 762  *
 763  * \retval The codec type
 764  */
 765 FT_DECLARE(ftdm_codec_t) ftdm_channel_get_codec(const ftdm_channel_t *ftdmchan);
 766 
 767 /*! 
 768  * \brief Get the last error string for the channel
 769  *
 770  * \param ftdmchan The channel to get the error from
 771  *
 772  * \retval The error string (not thread-safe, the string is per channel, not per thread)
 773  */
 774 FT_DECLARE(const char *) ftdm_channel_get_last_error(const ftdm_channel_t *ftdmchan);
 775 
 776 /*! 
 777  * \brief Get the current alarm bitmask for the channel
 778  *
 779  * \param ftdmchan The channel to get the alarm bitmask from
 780  * \param alarmbits The alarm bitmask pointer to store the current alarms (you are responsible for allocation/deallocation)
 781  *
 782  * \retval FTDM_SUCCESS success
 783  * \retval FTDM_FAIL failure
 784  */
 785 FT_DECLARE(ftdm_status_t) ftdm_channel_get_alarms(ftdm_channel_t *ftdmchan, ftdm_alarm_flag_t *alarmbits);
 786 
 787 /*! 
 788  * \brief Get the channel type
 789  *
 790  * \param ftdmchan The channel to get the type from
 791  *
 792  * \retval channel type (FXO, FXS, B-channel, D-channel, etc)
 793  */
 794 FT_DECLARE(ftdm_chan_type_t) ftdm_channel_get_type(const ftdm_channel_t *ftdmchan);
 795 
 796 /*! 
 797  * \brief Dequeue DTMF from the given channel
 798  * \note To transmit DTMF use ftdm_channel_command with command FTDM_COMMAND_SEND_DTMF
 799  *
 800  * \param ftdmchan The channel to dequeue DTMF from
 801  * \param dtmf DTMF buffer to store the dtmf (you are responsible for its allocation and deallocation)
 802  * \param len The size of the provided DTMF buffer
 803  *
 804  * \retval The size of the dequeued DTMF (it might be zero if there is no DTMF in the queue)
 805  */
 806 FT_DECLARE(ftdm_size_t) ftdm_channel_dequeue_dtmf(ftdm_channel_t *ftdmchan, char *dtmf, ftdm_size_t len);
 807 
 808 /*! 
 809  * \brief Flush the DTMF queue
 810  *
 811  * \param ftdmchan The channel to flush the dtmf queue of
 812  */
 813 FT_DECLARE(void) ftdm_channel_flush_dtmf(ftdm_channel_t *ftdmchan);
 814 
 815 /*! 
 816  * \brief Wait for an event in the span
 817  *
 818  * \param span The span to wait events for
 819  * \param ms Milliseconds timeout
 820  *
 821  * \retval FTDM_SUCCESS success (at least one event available)
 822  * \retval FTDM_TIMEOUT Timed out waiting for events
 823  * \retval FTDM_FAIL failure
 824  */
 825 FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms);
 826 
 827 /*! 
 828  * \brief Find a span by its id
 829  *
 830  * \param id The span id 
 831  * \param span Pointer to store the span if found
 832  *
 833  * \retval FTDM_SUCCESS success (span is valid)
 834  * \retval FTDM_FAIL failure (span is not valid)
 835  */
 836 FT_DECLARE(ftdm_status_t) ftdm_span_find(uint32_t id, ftdm_span_t **span);
 837 
 838 /*! 
 839  * \brief Get the last error string for the given span
 840  *
 841  * \param span The span to get the last error from
 842  *
 843  * \retval character string for the last error
 844  */
 845 FT_DECLARE(const char *) ftdm_span_get_last_error(const ftdm_span_t *span);
 846 
 847 /*! 
 848  * \brief Create a new span (not needed if you are using freetdm.conf)
 849  *
 850  * \param iotype The I/O interface type this span will use. 
 851  *               This depends on the available I/O modules 
 852  *               ftmod_wanpipe = "wanpipe" (Sangoma)
 853  *               ftmod_zt = "zt" (DAHDI or Zaptel)
 854  *               ftmod_pika "pika" (this one is most likely broken)
 855  * \param name Name for the span
 856  * \param span Pointer to store the create span
 857  *
 858  * \retval FTDM_SUCCESS success (the span was created)
 859  * \retval FTDM_FAIL failure (span was not created)
 860  */
 861 FT_DECLARE(ftdm_status_t) ftdm_span_create(const char *iotype, const char *name, ftdm_span_t **span);
 862 
 863 /*! 
 864  * \brief Add a new channel to a span
 865  *
 866  * \param span Where to add the new channel
 867  * \param sockfd The socket device associated to the channel (ie: sangoma device, dahdi device etc)
 868  * \param type Channel type
 869  * \param chan Pointer to store the newly allocated channel
 870  *
 871  * \retval FTDM_SUCCESS success (the channel was created)
 872  * \retval FTDM_FAIL failure (span was not created)
 873  */
 874 FT_DECLARE(ftdm_status_t) ftdm_span_add_channel(ftdm_span_t *span, ftdm_socket_t sockfd, ftdm_chan_type_t type, ftdm_channel_t **chan);
 875 
 876 /*! \brief Add the channel to a hunt group */
 877 FT_DECLARE(ftdm_status_t) ftdm_channel_add_to_group(const char* name, ftdm_channel_t* ftdmchan);
 878 
 879 /*! \brief Remove the channel from a hunt group */
 880 FT_DECLARE(ftdm_status_t) ftdm_channel_remove_from_group(ftdm_group_t* group, ftdm_channel_t* ftdmchan);
 881 
 882 /*! \brief Find a hunt group by id */
 883 FT_DECLARE(ftdm_status_t) ftdm_group_find(uint32_t id, ftdm_group_t **group);
 884 
 885 /*! \brief Find a hunt group by name */
 886 FT_DECLARE(ftdm_status_t) ftdm_group_find_by_name(const char *name, ftdm_group_t **group);
 887 
 888 /*! \brief Create a group with the given name */
 889 FT_DECLARE(ftdm_status_t) ftdm_group_create(ftdm_group_t **group, const char *name);
 890 
 891 /*! \brief Get the number of channels in use on a span */
 892 FT_DECLARE(ftdm_status_t) ftdm_span_channel_use_count(ftdm_span_t *span, uint32_t *count);
 893 
 894 /*! \brief Get the number of channels in use on a group */
 895 FT_DECLARE(ftdm_status_t) ftdm_group_channel_use_count(ftdm_group_t *group, uint32_t *count);
 896 
 897 /*! \brief Get the id of a group */
 898 FT_DECLARE(uint32_t) ftdm_group_get_id(const ftdm_group_t *group);
 899 
 900 /*! 
 901  * \brief Open a channel specifying the span id and chan id (required before placing a call on the channel)
 902  *
 903  * \note You must call ftdm_channel_close() or ftdm_channel_call_hangup() to release the channel afterwards
 904  *      Only use ftdm_channel_close if there is no call (incoming or outgoing) in the channel
 905  *
 906  * \param span_id The span id the channel belongs to
 907  * \param chan_id Channel id of the channel you want to open
 908  * \param ftdmchan Pointer to store the channel once is open
 909  *
 910  * \retval FTDM_SUCCESS success (the channel was found and is available)
 911  * \retval FTDM_FAIL failure (channel was not found or not available)
 912  */
 913 FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id, ftdm_channel_t **ftdmchan);
 914 
 915 /*! 
 916  * \brief Hunts and opens a channel specifying the span id only
 917  *
 918  * \note You must call ftdm_channel_close() or ftdm_channel_call_hangup() to release the channel afterwards
 919  *      Only use ftdm_channel_close if there is no call (incoming or outgoing) in the channel
 920  *
 921  * \param span_id The span id to hunt for a channel
 922  * \param direction The hunting direction
 923  * \param caller_data The calling party information
 924  * \param ftdmchan The channel pointer to store the available channel
 925  *
 926  * \retval FTDM_SUCCESS success (a suitable channel was found available)
 927  * \retval FTDM_FAIL failure (no suitable channel was found available)
 928  */
 929 FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan);
 930 
 931 /*! 
 932  * \brief Hunts and opens a channel specifying group id
 933  *
 934  * \note You must call ftdm_channel_close() or ftdm_channel_call_hangup() to release the channel afterwards
 935  *      Only use ftdm_channel_close if there is no call (incoming or outgoing) in the channel
 936  *
 937  * \param group_id The group id to hunt for a channel
 938  * \param direction The hunting direction
 939  * \param caller_data The calling party information
 940  * \param ftdmchan The channel pointer to store the available channel
 941  *
 942  * \retval FTDM_SUCCESS success (a suitable channel was found available)
 943  * \retval FTDM_FAIL failure (no suitable channel was found available)
 944  */
 945 FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan);
 946 
 947 /*! 
 948  * \brief Close a previously open channel
 949  *
 950  * \note If you call ftdm_channel_call_hangup() you MUST NOT call this function, the signaling
 951  *       stack will close the channel.
 952  *
 953  * \param ftdmchan pointer to the channel to close
 954  *
 955  * \retval FTDM_SUCCESS success (a suitable channel was found available)
 956  * \retval FTDM_FAIL failure (no suitable channel was found available)
 957  */
 958 FT_DECLARE(ftdm_status_t) ftdm_channel_close(ftdm_channel_t **ftdmchan);
 959 
 960 /*! 
 961  * \brief Execute a command in a channel (same semantics as the ioctl() unix system call)
 962  *
 963  * \param ftdmchan The channel to execute the command
 964  * \param command The command to execute
 965  * \param arg The argument for the command
 966  *
 967  * \retval FTDM_SUCCESS success (a suitable channel was found available)
 968  * \retval FTDM_FAIL failure (no suitable channel was found available)
 969  */
 970 FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_command_t command, void *arg);
 971 
 972 /*! 
 973  * \brief Wait for I/O events in a channel
 974  *
 975  * \param ftdmchan The channel to wait I/O for
 976  * \param flags The wait I/O flags
 977  * \param timeout The timeout in milliseconds
 978  *
 979  * \retval FTDM_SUCCESS success (a suitable channel was found available)
 980  * \retval FTDM_FAIL failure (no suitable channel was found available)
 981  */
 982 FT_DECLARE(ftdm_status_t) ftdm_channel_wait(ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t timeout);
 983 
 984 /*! 
 985  * \brief Read data from a channel
 986  *
 987  * \param ftdmchan The channel to read data from
 988  * \param data The pointer to the buffer to store the read data
 989  * \param datalen The size in bytes of the provided buffer
 990  *
 991  * \retval FTDM_SUCCESS success (a suitable channel was found available)
 992  * \retval FTDM_FAIL failure (no suitable channel was found available)
 993  */
 994 FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen);
 995 
 996 /*! 
 997  * \brief Write data to a channel
 998  *
 999  * \note The difference between data and datasize is subtle but important.
1000  *
1001  *       datalen is a pointer to the size of the actual data that you want to write. This pointer
1002  *       will be updated with the number of bytes actually written.
1003  *       
1004  *       datasize on the other hand is the size of the entire buffer provided in data, whether 
1005  *       all of that buffer is in use or not is a different matter. The difference becomes
1006  *       important only if you are using FreeTDM doing transcoding, for example, providing
1007  *       a ulaw frame of 160 bytes but where the I/O device accepts input in signed linear,
1008  *       the data to write will be 320 bytes, therefore datasize is expected to be at least
1009  *       320 where datalen would be just 160.
1010  *
1011  * \param ftdmchan The channel to write data to
1012  * \param data The pointer to the buffer to write
1013  * \param datasize The maximum number of bytes in data that can be used (in case transcoding is necessary)
1014  * \param datalen The size of the actual data
1015  *
1016  * \retval FTDM_SUCCESS success (a suitable channel was found available)
1017  * \retval FTDM_FAIL failure (no suitable channel was found available)
1018  */
1019 FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t datasize, ftdm_size_t *datalen);
1020 
1021 /*! \brief Add a custom variable to the channel
1022  *  \note This variables may be used by signaling modules to override signaling parameters
1023  *  \todo Document which signaling variables are available
1024  * */
1025 FT_DECLARE(ftdm_status_t) ftdm_channel_add_var(ftdm_channel_t *ftdmchan, const char *var_name, const char *value);
1026 
1027 /*! \brief Get a custom variable from the channel. 
1028  *  \note The variable pointer returned is only valid while the channel is open and it'll be destroyed when the channel is closed. */
1029 FT_DECLARE(const char *) ftdm_channel_get_var(ftdm_channel_t *ftdmchan, const char *var_name);
1030 
1031 /*! \brief Get an iterator to iterate over the channel variables
1032  *  \param ftdmchan The channel structure containing the variables
1033  *  \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator.
1034  *  \note The iterator pointer returned is only valid while the channel is open and it'll be destroyed when the channel is closed. 
1035  *        This iterator is completely non-thread safe, if you are adding variables or removing variables while iterating 
1036  *        results are unpredictable
1037  */
1038 FT_DECLARE(ftdm_iterator_t *) ftdm_channel_get_var_iterator(const ftdm_channel_t *ftdmchan, ftdm_iterator_t *iter);
1039 
1040 /*! \brief Get iterator current value (depends on the iterator type)
1041  *  \note Channel iterators return a pointer to ftdm_channel_t
1042  *        Variable iterators return a pointer to the variable name (not the variable value)
1043  */
1044 FT_DECLARE(void *) ftdm_iterator_current(ftdm_iterator_t *iter);
1045 
1046 /*! \brief Get variable name and value for the current iterator position */
1047 FT_DECLARE(ftdm_status_t) ftdm_channel_get_current_var(ftdm_iterator_t *iter, const char **var_name, const char **var_val);
1048 
1049 /*! \brief Advance iterator */
1050 FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter);
1051 
1052 /*! \brief Free iterator 
1053  *  \note You must free an iterator after using it unless you plan to reuse it
1054  */
1055 FT_DECLARE(ftdm_status_t) ftdm_iterator_free(ftdm_iterator_t *iter);
1056 
1057 /*! \brief Get the span pointer associated to the channel */
1058 FT_DECLARE(ftdm_span_t *) ftdm_channel_get_span(const ftdm_channel_t *ftdmchan);
1059 
1060 /*! \brief Get the span pointer associated to the channel */
1061 FT_DECLARE(uint32_t) ftdm_channel_get_span_id(const ftdm_channel_t *ftdmchan);
1062 
1063 /*! \brief Get the physical span id associated to the channel */
1064 FT_DECLARE(uint32_t) ftdm_channel_get_ph_span_id(const ftdm_channel_t *ftdmchan);
1065 
1066 /*! \brief Get the span name associated to the channel */
1067 FT_DECLARE(const char *) ftdm_channel_get_span_name(const ftdm_channel_t *ftdmchan);
1068 
1069 /*! \brief Get the id associated to the channel */
1070 FT_DECLARE(uint32_t) ftdm_channel_get_id(const ftdm_channel_t *ftdmchan);
1071 
1072 /*! \brief Get the name associated to the channel */
1073 FT_DECLARE(const char *) ftdm_channel_get_name(const ftdm_channel_t *ftdmchan);
1074 
1075 /*! \brief Get the number associated to the channel */
1076 FT_DECLARE(const char *) ftdm_channel_get_number(const ftdm_channel_t *ftdmchan);
1077 
1078 /*! \brief Get the number physical id associated to the channel */
1079 FT_DECLARE(uint32_t) ftdm_channel_get_ph_id(const ftdm_channel_t *ftdmchan);
1080 
1081 /*! 
1082  * \brief Configure span with a signaling type (deprecated use ftdm_configure_span_signaling instead)
1083  *
1084  * \note This function does the same as ftdm_configure_span_signaling
1085  *
1086  * \param span The span to configure
1087  * \param type The signaling type ("boost", "isdn" and others, this depends on the available signaling modules)
1088  * \param sig_cb The callback that the signaling stack will use to notify about events
1089  * \param ... variable argument list with "var", value sequence, the variable and values are signaling type dependant
1090  *        the last argument must be FTDM_TAG_END
1091  *
1092  * \retval FTDM_SUCCESS success 
1093  * \retval FTDM_FAIL failure 
1094  */
1095 FT_DECLARE(ftdm_status_t) ftdm_configure_span(ftdm_span_t *span, const char *type, fio_signal_cb_t sig_cb, ...);
1096 #define FTDM_TAG_END NULL
1097 
1098 
1099 /*! 
1100  * \brief Configure span with a signaling type
1101  *
1102  * \param span The span to configure
1103  * \param type The signaling type ("boost", "isdn" and others, this depends on the available signaling modules)
1104  * \param sig_cb The callback that the signaling stack will use to notify about events
1105  * \param parameters The array if signaling-specific parameters (the last member of the array MUST have its var member set to NULL, ie: .var = NULL)
1106  *
1107  * \retval FTDM_SUCCESS success 
1108  * \retval FTDM_FAIL failure 
1109  */
1110 FT_DECLARE(ftdm_status_t) ftdm_configure_span_signaling(ftdm_span_t *span, const char *type, fio_signal_cb_t sig_cb, ftdm_conf_parameter_t *parameters);
1111 
1112 /*! 
1113  * \brief Start the span signaling (must call ftdm_configure_span_signaling first)
1114  *
1115  * \note Even before this function returns you may receive signaling events!
1116  *       Never block in the signaling callback since it might be called in a thread
1117  *       that handles more than 1 call and therefore you would be blocking all the
1118  *       calls handled by that thread!
1119  *
1120  * \param span The span to start
1121  *
1122  * \retval FTDM_SUCCESS success 
1123  * \retval FTDM_FAIL failure 
1124  */
1125 FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span);
1126 
1127 
1128 /*! 
1129  * \brief Stop the span signaling (must call ftdm_span_start first)
1130  * \note certain signalings (boost signaling) does not support granular span start/stop
1131  * so it is recommended to always configure all spans and then starting them all and finally
1132  * stop them all (or call ftdm_global_destroy which takes care of stopping and destroying the spans at once).
1133  *
1134  * \param span The span to stop
1135  *
1136  * \retval FTDM_SUCCESS success 
1137  * \retval FTDM_FAIL failure 
1138  */
1139 FT_DECLARE(ftdm_status_t) ftdm_span_stop(ftdm_span_t *span);
1140 
1141 /*! 
1142  * \brief Register a custom I/O interface with the FreeTDM core
1143  *
1144  * \param io_interface the Interface to register
1145  *
1146  * \retval FTDM_SUCCESS success 
1147  * \retval FTDM_FAIL failure 
1148  */
1149 FT_DECLARE(ftdm_status_t) ftdm_global_add_io_interface(ftdm_io_interface_t *io_interface);
1150 
1151 /*! \brief Find a span by name */
1152 FT_DECLARE(ftdm_status_t) ftdm_span_find_by_name(const char *name, ftdm_span_t **span);
1153 
1154 /*! \brief Get the span id */
1155 FT_DECLARE(uint32_t) ftdm_span_get_id(const ftdm_span_t *span);
1156 
1157 /*! \brief Get the span name */
1158 FT_DECLARE(const char *) ftdm_span_get_name(const ftdm_span_t *span);
1159 
1160 /*! \brief Get iterator for the span channels
1161  *  \param span The span containing the channels
1162  *  \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator.
1163  */
1164 FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter);
1165 
1166 /*! 
1167  * \brief Execute a text command. The text command output will be returned and must be free'd 
1168  *
1169  * \param cmd The command to execute
1170  *
1171  * \retval FTDM_SUCCESS success 
1172  * \retval FTDM_FAIL failure 
1173  */
1174 FT_DECLARE(char *) ftdm_api_execute(const char *cmd);
1175 
1176 /*! 
1177  * \brief Create a configuration node
1178  *
1179  * \param name The name of the configuration node
1180  * \param node The node pointer to store the new node
1181  * \param parent The parent node if any, or NULL if no parent
1182  *
1183  * \return FTDM_SUCCESS success
1184  * \return FTDM_FAIL failure
1185  */
1186 FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node_t **node, ftdm_conf_node_t *parent);
1187 
1188 /*! 
1189  * \brief Adds a new parameter to the specified configuration node
1190  *
1191  * \param node The configuration node to add the param-val pair to
1192  * \param param The parameter name
1193  * \param val The parameter value
1194  *
1195  * \return FTDM_SUCCESS success
1196  * \return FTDM_FAIL failure
1197  */
1198 FT_DECLARE(ftdm_status_t) ftdm_conf_node_add_param(ftdm_conf_node_t *node, const char *param, const char *val);
1199 
1200 /*! 
1201  * \brief Destroy the memory allocated for a configuration node (and all of its descendance)
1202  *
1203  * \param node The node to destroy
1204  *
1205  * \return FTDM_SUCCESS success
1206  * \return FTDM_FAIL failure
1207  */
1208 FT_DECLARE(ftdm_status_t) ftdm_conf_node_destroy(ftdm_conf_node_t *node);
1209 
1210 /*! 
1211  * \brief Create and configure channels in the given span
1212  *
1213  * \param span The span container
1214  * \param str The channel range null terminated string. "1-10", "24" etc
1215  * \param chan_config The basic channel configuration for each channel within the range
1216  * \param configured Pointer where the number of channels configured will be stored
1217  *
1218  * \return FTDM_SUCCESS success
1219  * \return FTDM_FAIL failure
1220  */
1221 FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const char *str, ftdm_channel_config_t *chan_config, unsigned *configured);
1222 
1223 /*! 
1224  * \brief Set the trunk type for a span
1225  *        This must be called before configuring any channels within the span
1226  *
1227  * \param span The span 
1228  * \param type The trunk type
1229  *
1230  */
1231 FT_DECLARE(void) ftdm_span_set_trunk_type(ftdm_span_t *span, ftdm_trunk_type_t type);
1232 
1233 /*! 
1234  * \brief Get the trunk type for a span
1235  *
1236  * \param span The span 
1237  *
1238  * \return The span trunk type
1239  */
1240 FT_DECLARE(ftdm_trunk_type_t) ftdm_span_get_trunk_type(const ftdm_span_t *span);
1241 
1242 /*! 
1243  * \brief Return the channel identified by the provided id
1244  *
1245  * \param span The span where the channel belongs
1246  * \param chanid The channel id within the span
1247  *
1248  * \return The channel pointer if found, NULL otherwise
1249  */
1250 FT_DECLARE(ftdm_channel_t *) ftdm_span_get_channel(const ftdm_span_t *span, uint32_t chanid);
1251 
1252 /*! \brief Return the channel count number for the given span */
1253 FT_DECLARE(uint32_t) ftdm_span_get_chan_count(const ftdm_span_t *span);
1254 
1255 /*! \brief Set the caller data for a channel. Be sure to call this before ftdm_channel_call_place() */
1256 FT_DECLARE(ftdm_status_t) ftdm_channel_set_caller_data(ftdm_channel_t *ftdmchan, ftdm_caller_data_t *caller_data);
1257 
1258 /*! \brief Get the caller data for a channel, typically you need this when receiving FTDM_SIGEVENT_START */
1259 FT_DECLARE(ftdm_caller_data_t *) ftdm_channel_get_caller_data(ftdm_channel_t *channel);
1260 
1261 /*! \brief For display debugging purposes you can display this string which describes the current channel internal state */
1262 FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *channel);
1263 
1264 /*! \brief For display debugging purposes you can display this string which describes the last channel internal state */
1265 FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *channel);
1266 
1267 /*! \brief For display debugging purposes you can display this string which describes the history of the channel 
1268  *  \param channel The channel to get the history from
1269  *  \return History string for the channel. You must free the string with ftdm_free
1270  */
1271 FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *channel);
1272 
1273 /*! \brief Initialize channel state for an outgoing call */
1274 FT_DECLARE(ftdm_status_t) ftdm_channel_init(ftdm_channel_t *ftdmchan);
1275 
1276 /*! \brief Initialize the library */
1277 FT_DECLARE(ftdm_status_t) ftdm_global_init(void);
1278 
1279 /*! \brief Create spans and channels reading the freetdm.conf file */
1280 FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void);
1281 
1282 /*! \brief Shutdown the library */
1283 FT_DECLARE(ftdm_status_t) ftdm_global_destroy(void);
1284 
1285 /*! \brief Set memory handler for the library */
1286 FT_DECLARE(ftdm_status_t) ftdm_global_set_memory_handler(ftdm_memory_handler_t *handler);
1287 
1288 /*! \brief Set the crash policy for the library */
1289 FT_DECLARE(void) ftdm_global_set_crash_policy(ftdm_crash_policy_t policy);
1290 
1291 /*! \brief Set the logger handler for the library */
1292 FT_DECLARE(void) ftdm_global_set_logger(ftdm_logger_t logger);
1293 
1294 /*! \brief Set the default logger level */
1295 FT_DECLARE(void) ftdm_global_set_default_logger(int level);
1296 
1297 /*! \brief Set the directory to look for modules */
1298 FT_DECLARE(void) ftdm_global_set_mod_directory(const char *path);
1299 
1300 /*! \brief Set the directory to look for configs */
1301 FT_DECLARE(void) ftdm_global_set_config_directory(const char *path);
1302 
1303 /*! \brief Check if the FTDM library is initialized and running */
1304 FT_DECLARE(ftdm_bool_t) ftdm_running(void);
1305 
1306 FT_DECLARE_DATA extern ftdm_logger_t ftdm_log;
1307 
1308 /*! \brief Basic transcoding function prototype */
1309 #define FIO_CODEC_ARGS (void *data, ftdm_size_t max, ftdm_size_t *datalen)
1310 #define FIO_CODEC_FUNCTION(name) FT_DECLARE_NONSTD(ftdm_status_t) name FIO_CODEC_ARGS
1311 typedef ftdm_status_t (*fio_codec_t) FIO_CODEC_ARGS ;
1312 
1313 /*! \brief Basic transcoding functions */
1314 FIO_CODEC_FUNCTION(fio_slin2ulaw);
1315 FIO_CODEC_FUNCTION(fio_ulaw2slin);
1316 FIO_CODEC_FUNCTION(fio_slin2alaw);
1317 FIO_CODEC_FUNCTION(fio_alaw2slin);
1318 FIO_CODEC_FUNCTION(fio_ulaw2alaw);
1319 FIO_CODEC_FUNCTION(fio_alaw2ulaw);
1320 
1321 #define FTDM_PRE __FILE__, __FUNCTION__, __LINE__
1322 #define FTDM_LOG_LEVEL_DEBUG 7
1323 #define FTDM_LOG_LEVEL_INFO 6
1324 #define FTDM_LOG_LEVEL_NOTICE 5
1325 #define FTDM_LOG_LEVEL_WARNING 4
1326 #define FTDM_LOG_LEVEL_ERROR 3
1327 #define FTDM_LOG_LEVEL_CRIT 2
1328 #define FTDM_LOG_LEVEL_ALERT 1
1329 #define FTDM_LOG_LEVEL_EMERG 0
1330 
1331 /*! \brief Log levels  */
1332 #define FTDM_LOG_DEBUG FTDM_PRE, FTDM_LOG_LEVEL_DEBUG
1333 #define FTDM_LOG_INFO FTDM_PRE, FTDM_LOG_LEVEL_INFO
1334 #define FTDM_LOG_NOTICE FTDM_PRE, FTDM_LOG_LEVEL_NOTICE
1335 #define FTDM_LOG_WARNING FTDM_PRE, FTDM_LOG_LEVEL_WARNING
1336 #define FTDM_LOG_ERROR FTDM_PRE, FTDM_LOG_LEVEL_ERROR
1337 #define FTDM_LOG_CRIT FTDM_PRE, FTDM_LOG_LEVEL_CRIT
1338 #define FTDM_LOG_ALERT FTDM_PRE, FTDM_LOG_LEVEL_ALERT
1339 #define FTDM_LOG_EMERG FTDM_PRE, FTDM_LOG_LEVEL_EMERG
1340 
1341 #ifdef __cplusplus
1342 } /* extern C */
1343 #endif
1344 
1345 #endif
1346 
1347 /* For Emacs:
1348  * Local Variables:
1349  * mode:c
1350  * indent-tabs-mode:t
1351  * tab-width:4
1352  * c-basic-offset:4
1353  * End:
1354  * For VIM:
1355  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
1356  */

/* [<][>][^][v][top][bottom][index][help] */