mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
freetdm: multiple fixes for the core and analog
* Replace ftdm_channel_flag_t with defines. We reached the 32bit limit where does not seem reliable to keep using enum. * Flags member for ftdm_channel_t is now uint64_t * Added FTDM_CHANNEL_CALL_STARTED flag to indicate when the API user knows about a call * Refactored raw_data member for ftdm_sigmsg_t. If raw_data needs to be freed it must be requested explicitly through the autofree member * Added collected member to ftdm_sigmsg_t for FTDM_SIGEVENT_COLLECTED data instead of using raw_data * Created define FTDM_DIGITS_LIMIT for DNIS/ANI digits limit * Fix some stat checks and outdated code in ftmod_analog * Refactored ftdm_channel_get_history_str API to return the time offsets and time since last state change * Do not send FTDM_SIGEVENT_STOP and FTDM_SIGEVENT_RELEASED on calls that were never reported to the user
This commit is contained in:
@@ -281,16 +281,18 @@ typedef enum {
|
||||
#define CALLING_PARTY_CATEGORY_STRINGS "unknown", "operator", "ordinary", "priority", "data-call", "test-call", "payphone", "invalid"
|
||||
FTDM_STR2ENUM_P(ftdm_str2ftdm_calling_party_category, ftdm_calling_party_category2str, ftdm_calling_party_category_t)
|
||||
|
||||
/*! \brief Digit limit used in DNIS/ANI */
|
||||
#define FTDM_DIGITS_LIMIT 25
|
||||
|
||||
/*! \brief Number abstraction */
|
||||
typedef struct {
|
||||
char digits[25];
|
||||
char digits[FTDM_DIGITS_LIMIT];
|
||||
uint8_t type;
|
||||
uint8_t plan;
|
||||
} ftdm_number_t;
|
||||
|
||||
typedef void * ftdm_variable_container_t;
|
||||
|
||||
|
||||
/*! \brief Caller information */
|
||||
typedef struct ftdm_caller_data {
|
||||
char cid_date[8]; /*!< Caller ID date */
|
||||
@@ -299,10 +301,10 @@ typedef struct ftdm_caller_data {
|
||||
ftdm_number_t ani; /*!< ANI (Automatic Number Identification) */
|
||||
ftdm_number_t dnis; /*!< DNIS (Dialed Number Identification Service) */
|
||||
ftdm_number_t rdnis; /*!< RDNIS (Redirected Dialed Number Identification Service) */
|
||||
char aniII[25]; /*! ANI II */
|
||||
char aniII[FTDM_DIGITS_LIMIT]; /*! ANI II */
|
||||
uint8_t screen; /*!< Screening */
|
||||
uint8_t pres; /*!< Presentation*/
|
||||
char collected[25]; /*!< Collected digits so far */
|
||||
char collected[FTDM_DIGITS_LIMIT]; /*!< Collected digits so far */
|
||||
int hangup_cause; /*!< Hangup cause */
|
||||
char raw_data[1024]; /*!< Protocol specific raw caller data */
|
||||
uint32_t raw_data_len; /*!< Raw data length */
|
||||
@@ -426,19 +428,28 @@ typedef struct {
|
||||
uint8_t level; /* 1 for phy layer, 2 for q921/mtp2, 3 for q931/mtp3 */
|
||||
} ftdm_event_trace_t;
|
||||
|
||||
typedef struct {
|
||||
/* Digits collected */
|
||||
char digits[FTDM_DIGITS_LIMIT];
|
||||
} ftdm_event_collected_t;
|
||||
|
||||
/*! \brief Generic signaling message */
|
||||
struct ftdm_sigmsg {
|
||||
ftdm_signal_event_t event_id; /*!< The type of message */
|
||||
ftdm_channel_t *channel; /*!< Related channel */
|
||||
uint32_t chan_id; /*!< easy access to chan id */
|
||||
uint32_t span_id; /*!< easy access to span_id */
|
||||
void *raw_data; /*!< Message specific data if any */
|
||||
uint32_t raw_data_len; /*!< Data len in case is needed */
|
||||
uint32_t call_id; /*!< unique call id for this call */
|
||||
union {
|
||||
ftdm_event_sigstatus_t sigstatus; /*!< valid if event_id is FTDM_SIGEVENT_SIGSTATUS_CHANGED */
|
||||
ftdm_event_trace_t logevent; /*!< valid if event_id is FTDM_SIGEVENT_TRACE or FTDM_SIGEVENT_TRACE_RAW */
|
||||
ftdm_event_collected_t collected; /*!< valif if event_id is FTDM_SIGEVENT_COLLECTED_DIGIT */
|
||||
} ev_data;
|
||||
struct {
|
||||
uint8_t autofree; /*!< Whether the freetdm core will free it after message delivery */
|
||||
uint32_t len; /*!< Data len */
|
||||
void *data; /*!< Signaling module specific data */
|
||||
} raw;
|
||||
};
|
||||
|
||||
/*! \brief Crash policy
|
||||
|
@@ -411,7 +411,7 @@ struct ftdm_channel {
|
||||
uint32_t extra_id;
|
||||
ftdm_chan_type_t type;
|
||||
ftdm_socket_t sockfd;
|
||||
uint32_t flags;
|
||||
uint64_t flags;
|
||||
uint32_t pflags;
|
||||
uint32_t sflags;
|
||||
ftdm_alarm_flag_t alarm_flags;
|
||||
|
@@ -237,52 +237,41 @@ typedef enum {
|
||||
"HANGUP", "HANGUP_COMPLETE", "IN_LOOP", "RESET", "INVALID"
|
||||
FTDM_STR2ENUM_P(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channel_state_t)
|
||||
|
||||
typedef enum {
|
||||
FTDM_CHANNEL_CONFIGURED = (1 << 0),
|
||||
FTDM_CHANNEL_READY = (1 << 1),
|
||||
FTDM_CHANNEL_OPEN = (1 << 2),
|
||||
FTDM_CHANNEL_DTMF_DETECT = (1 << 3),
|
||||
FTDM_CHANNEL_SUPRESS_DTMF = (1 << 4),
|
||||
FTDM_CHANNEL_TRANSCODE = (1 << 5),
|
||||
FTDM_CHANNEL_BUFFER = (1 << 6),
|
||||
FTDM_CHANNEL_EVENT = (1 << 7),
|
||||
FTDM_CHANNEL_INTHREAD = (1 << 8),
|
||||
FTDM_CHANNEL_WINK = (1 << 9),
|
||||
FTDM_CHANNEL_FLASH = (1 << 10),
|
||||
FTDM_CHANNEL_STATE_CHANGE = (1 << 11),
|
||||
FTDM_CHANNEL_HOLD = (1 << 12),
|
||||
FTDM_CHANNEL_INUSE = (1 << 13),
|
||||
FTDM_CHANNEL_OFFHOOK = (1 << 14),
|
||||
FTDM_CHANNEL_RINGING = (1 << 15),
|
||||
FTDM_CHANNEL_PROGRESS_DETECT = (1 << 16),
|
||||
FTDM_CHANNEL_CALLERID_DETECT = (1 << 17),
|
||||
FTDM_CHANNEL_OUTBOUND = (1 << 18),
|
||||
FTDM_CHANNEL_SUSPENDED = (1 << 19),
|
||||
FTDM_CHANNEL_3WAY = (1 << 20),
|
||||
FTDM_CHANNEL_PROGRESS = (1 << 21),
|
||||
FTDM_CHANNEL_MEDIA = (1 << 22),
|
||||
FTDM_CHANNEL_ANSWERED = (1 << 23),
|
||||
FTDM_CHANNEL_MUTE = (1 << 24),
|
||||
FTDM_CHANNEL_USE_RX_GAIN = (1 << 25),
|
||||
FTDM_CHANNEL_USE_TX_GAIN = (1 << 26),
|
||||
FTDM_CHANNEL_IN_ALARM = (1 << 27),
|
||||
FTDM_CHANNEL_SIG_UP = (1 << 28),
|
||||
FTDM_CHANNEL_USER_HANGUP = (1 << 29),
|
||||
FTDM_CHANNEL_RX_DISABLED = (1 << 30),
|
||||
FTDM_CHANNEL_TX_DISABLED = (1 << 31),
|
||||
/* ok, when we reach 32, we need to move to uint64_t all the flag stuff */
|
||||
} ftdm_channel_flag_t;
|
||||
#if defined(__cplusplus) && defined(WIN32)
|
||||
// fix C2676
|
||||
__inline__ ftdm_channel_flag_t operator|=(ftdm_channel_flag_t a, int32_t b) {
|
||||
a = (ftdm_channel_flag_t)(a | b);
|
||||
return a;
|
||||
}
|
||||
__inline__ ftdm_channel_flag_t operator&=(ftdm_channel_flag_t a, int32_t b) {
|
||||
a = (ftdm_channel_flag_t)(a & b);
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
/*!< Channel flags. This used to be an enum but we reached the 32bit limit for enums */
|
||||
#define FTDM_CHANNEL_CONFIGURED (1UL << 0)
|
||||
#define FTDM_CHANNEL_READY (1UL << 1)
|
||||
#define FTDM_CHANNEL_OPEN (1UL << 2)
|
||||
#define FTDM_CHANNEL_DTMF_DETECT (1UL << 3)
|
||||
#define FTDM_CHANNEL_SUPRESS_DTMF (1UL << 4)
|
||||
#define FTDM_CHANNEL_TRANSCODE (1UL << 5)
|
||||
#define FTDM_CHANNEL_BUFFER (1UL << 6)
|
||||
#define FTDM_CHANNEL_EVENT (1UL << 7)
|
||||
#define FTDM_CHANNEL_INTHREAD (1UL << 8)
|
||||
#define FTDM_CHANNEL_WINK (1UL << 9)
|
||||
#define FTDM_CHANNEL_FLASH (1UL << 10)
|
||||
#define FTDM_CHANNEL_STATE_CHANGE (1UL << 11)
|
||||
#define FTDM_CHANNEL_HOLD (1UL << 12)
|
||||
#define FTDM_CHANNEL_INUSE (1UL << 13)
|
||||
#define FTDM_CHANNEL_OFFHOOK (1UL << 14)
|
||||
#define FTDM_CHANNEL_RINGING (1UL << 15)
|
||||
#define FTDM_CHANNEL_PROGRESS_DETECT (1UL << 16)
|
||||
#define FTDM_CHANNEL_CALLERID_DETECT (1UL << 17)
|
||||
#define FTDM_CHANNEL_OUTBOUND (1UL << 18)
|
||||
#define FTDM_CHANNEL_SUSPENDED (1UL << 19)
|
||||
#define FTDM_CHANNEL_3WAY (1UL << 20)
|
||||
#define FTDM_CHANNEL_PROGRESS (1UL << 21)
|
||||
#define FTDM_CHANNEL_MEDIA (1UL << 22)
|
||||
#define FTDM_CHANNEL_ANSWERED (1UL << 23)
|
||||
#define FTDM_CHANNEL_MUTE (1UL << 24)
|
||||
#define FTDM_CHANNEL_USE_RX_GAIN (1UL << 25)
|
||||
#define FTDM_CHANNEL_USE_TX_GAIN (1UL << 26)
|
||||
#define FTDM_CHANNEL_IN_ALARM (1UL << 27)
|
||||
#define FTDM_CHANNEL_SIG_UP (1UL << 28)
|
||||
#define FTDM_CHANNEL_USER_HANGUP (1UL << 29)
|
||||
#define FTDM_CHANNEL_RX_DISABLED (1UL << 30)
|
||||
#define FTDM_CHANNEL_TX_DISABLED (1UL << 31)
|
||||
/*!< The user knows about a call in this channel */
|
||||
#define FTDM_CHANNEL_CALL_STARTED (1UL << 32)
|
||||
|
||||
typedef enum {
|
||||
ZSM_NONE,
|
||||
|
Reference in New Issue
Block a user