mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 14:44:17 +00:00
spring cleaning
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4795 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
a021945cef
commit
3a54126261
143 files changed
+22413
-31567
No files matched your search
@@ -50,137 +50,110 @@ extern "C" {
|
||||
#ifndef __inline__
|
||||
#define __inline__ __inline
|
||||
#endif
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
/*! \brief Find the bit position of the highest set bit in a word
|
||||
\param bits The word to be searched
|
||||
\return The bit number of the highest set bit, or -1 if the word is zero. */
|
||||
static __inline__ int top_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
static __inline__ int top_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n"
|
||||
" bsrl %%eax,%%edx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n" " bsrl %%eax,%%edx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*//*! \brief Find the bit position of the lowest set bit in a word
|
||||
\param bits The word to be searched
|
||||
\return The bit number of the lowest set bit, or -1 if the word is zero. */
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
/*! \brief Find the bit position of the lowest set bit in a word
|
||||
\param bits The word to be searched
|
||||
\return The bit number of the lowest set bit, or -1 if the word is zero. */
|
||||
static __inline__ int bottom_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n"
|
||||
" bsfl %%eax,%%edx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n" " bsfl %%eax,%%edx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#elif defined(__x86_64__)
|
||||
static __inline__ int top_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
static __inline__ int top_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n"
|
||||
" bsrq %%rax,%%rdx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsrq %%rax,%%rdx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
static __inline__ int bottom_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n"
|
||||
" bsfq %%rax,%%rdx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsfq %%rax,%%rdx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#else
|
||||
static __inline__ int top_bit(unsigned int bits)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 0;
|
||||
if (bits & 0xFFFF0000)
|
||||
{
|
||||
bits &= 0xFFFF0000;
|
||||
i += 16;
|
||||
}
|
||||
if (bits & 0xFF00FF00)
|
||||
{
|
||||
bits &= 0xFF00FF00;
|
||||
i += 8;
|
||||
}
|
||||
if (bits & 0xF0F0F0F0)
|
||||
{
|
||||
bits &= 0xF0F0F0F0;
|
||||
i += 4;
|
||||
}
|
||||
if (bits & 0xCCCCCCCC)
|
||||
{
|
||||
bits &= 0xCCCCCCCC;
|
||||
i += 2;
|
||||
}
|
||||
if (bits & 0xAAAAAAAA)
|
||||
{
|
||||
bits &= 0xAAAAAAAA;
|
||||
i += 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
static __inline__ int top_bit(unsigned int bits) {
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 0;
|
||||
if (bits & 0xFFFF0000) {
|
||||
bits &= 0xFFFF0000;
|
||||
i += 16;
|
||||
}
|
||||
if (bits & 0xFF00FF00) {
|
||||
bits &= 0xFF00FF00;
|
||||
i += 8;
|
||||
}
|
||||
if (bits & 0xF0F0F0F0) {
|
||||
bits &= 0xF0F0F0F0;
|
||||
i += 4;
|
||||
}
|
||||
if (bits & 0xCCCCCCCC) {
|
||||
bits &= 0xCCCCCCCC;
|
||||
i += 2;
|
||||
}
|
||||
if (bits & 0xAAAAAAAA) {
|
||||
bits &= 0xAAAAAAAA;
|
||||
i += 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static __inline__ int bottom_bit(unsigned int bits)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 32;
|
||||
if (bits & 0x0000FFFF)
|
||||
{
|
||||
bits &= 0x0000FFFF;
|
||||
i -= 16;
|
||||
}
|
||||
if (bits & 0x00FF00FF)
|
||||
{
|
||||
bits &= 0x00FF00FF;
|
||||
i -= 8;
|
||||
}
|
||||
if (bits & 0x0F0F0F0F)
|
||||
{
|
||||
bits &= 0x0F0F0F0F;
|
||||
i -= 4;
|
||||
}
|
||||
if (bits & 0x33333333)
|
||||
{
|
||||
bits &= 0x33333333;
|
||||
i -= 2;
|
||||
}
|
||||
if (bits & 0x55555555)
|
||||
{
|
||||
bits &= 0x55555555;
|
||||
i -= 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 32;
|
||||
if (bits & 0x0000FFFF) {
|
||||
bits &= 0x0000FFFF;
|
||||
i -= 16;
|
||||
}
|
||||
if (bits & 0x00FF00FF) {
|
||||
bits &= 0x00FF00FF;
|
||||
i -= 8;
|
||||
}
|
||||
if (bits & 0x0F0F0F0F) {
|
||||
bits &= 0x0F0F0F0F;
|
||||
i -= 4;
|
||||
}
|
||||
if (bits & 0x33333333) {
|
||||
bits &= 0x33333333;
|
||||
i -= 2;
|
||||
}
|
||||
if (bits & 0x55555555) {
|
||||
bits &= 0x55555555;
|
||||
i -= 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#endif
|
||||
|
||||
@@ -194,7 +167,7 @@ static __inline__ int bottom_bit(unsigned int bits)
|
||||
* segment, but a little inline assembly can fix that on an i386, x86_64 and
|
||||
* many other modern processors.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Mu-law is basically as follows:
|
||||
*
|
||||
@@ -222,66 +195,61 @@ static __inline__ int bottom_bit(unsigned int bits)
|
||||
*/
|
||||
|
||||
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD */
|
||||
#define ULAW_BIAS 0x84 /* Bias for linear code. */
|
||||
#define ULAW_BIAS 0x84 /* Bias for linear code. */
|
||||
|
||||
/*! \brief Encode a linear sample to u-law
|
||||
\param linear The sample to encode.
|
||||
\return The u-law value.
|
||||
*/
|
||||
static __inline__ uint8_t linear_to_ulaw(int linear)
|
||||
{
|
||||
uint8_t u_val;
|
||||
int mask;
|
||||
int seg;
|
||||
static __inline__ uint8_t linear_to_ulaw(int linear) {
|
||||
uint8_t u_val;
|
||||
int mask;
|
||||
int seg;
|
||||
|
||||
/* Get the sign and the magnitude of the value. */
|
||||
if (linear < 0)
|
||||
{
|
||||
linear = ULAW_BIAS - linear;
|
||||
mask = 0x7F;
|
||||
}
|
||||
else
|
||||
{
|
||||
linear = ULAW_BIAS + linear;
|
||||
mask = 0xFF;
|
||||
}
|
||||
/* Get the sign and the magnitude of the value. */
|
||||
if (linear < 0) {
|
||||
linear = ULAW_BIAS - linear;
|
||||
mask = 0x7F;
|
||||
} else {
|
||||
linear = ULAW_BIAS + linear;
|
||||
mask = 0xFF;
|
||||
}
|
||||
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
|
||||
/*
|
||||
* Combine the sign, segment, quantization bits,
|
||||
* and complement the code word.
|
||||
*/
|
||||
if (seg >= 8)
|
||||
u_val = (uint8_t) (0x7F ^ mask);
|
||||
else
|
||||
u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
|
||||
/*
|
||||
* Combine the sign, segment, quantization bits,
|
||||
* and complement the code word.
|
||||
*/
|
||||
if (seg >= 8)
|
||||
u_val = (uint8_t) (0x7F ^ mask);
|
||||
else
|
||||
u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
|
||||
#ifdef ULAW_ZEROTRAP
|
||||
/* Optional ITU trap */
|
||||
if (u_val == 0)
|
||||
u_val = 0x02;
|
||||
/* Optional ITU trap */
|
||||
if (u_val == 0)
|
||||
u_val = 0x02;
|
||||
#endif
|
||||
return u_val;
|
||||
}
|
||||
return u_val;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*! \brief Decode an u-law sample to a linear value.
|
||||
\param ulaw The u-law sample to decode.
|
||||
\return The linear value.
|
||||
*/
|
||||
static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
|
||||
{
|
||||
int t;
|
||||
|
||||
/* Complement to obtain normal u-law value. */
|
||||
ulaw = ~ulaw;
|
||||
/*
|
||||
* Extract and bias the quantization bits. Then
|
||||
* shift up by the segment number and subtract out the bias.
|
||||
*/
|
||||
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
|
||||
return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
|
||||
}
|
||||
static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) {
|
||||
int t;
|
||||
|
||||
/* Complement to obtain normal u-law value. */
|
||||
ulaw = ~ulaw;
|
||||
/*
|
||||
* Extract and bias the quantization bits. Then
|
||||
* shift up by the segment number and subtract out the bias.
|
||||
*/
|
||||
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
|
||||
return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
@@ -308,71 +276,64 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
|
||||
\param linear The sample to encode.
|
||||
\return The A-law value.
|
||||
*/
|
||||
static __inline__ uint8_t linear_to_alaw(int linear)
|
||||
{
|
||||
int mask;
|
||||
int seg;
|
||||
|
||||
if (linear >= 0)
|
||||
{
|
||||
/* Sign (bit 7) bit = 1 */
|
||||
mask = ALAW_AMI_MASK | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Sign (bit 7) bit = 0 */
|
||||
mask = ALAW_AMI_MASK;
|
||||
linear = -linear - 8;
|
||||
}
|
||||
static __inline__ uint8_t linear_to_alaw(int linear) {
|
||||
int mask;
|
||||
int seg;
|
||||
|
||||
/* Convert the scaled magnitude to segment number. */
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
if (seg >= 8)
|
||||
{
|
||||
if (linear >= 0)
|
||||
{
|
||||
/* Out of range. Return maximum value. */
|
||||
return (uint8_t) (0x7F ^ mask);
|
||||
}
|
||||
/* We must be just a tiny step below zero */
|
||||
return (uint8_t) (0x00 ^ mask);
|
||||
}
|
||||
/* Combine the sign, segment, and quantization bits. */
|
||||
return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
|
||||
}
|
||||
if (linear >= 0) {
|
||||
/* Sign (bit 7) bit = 1 */
|
||||
mask = ALAW_AMI_MASK | 0x80;
|
||||
} else {
|
||||
/* Sign (bit 7) bit = 0 */
|
||||
mask = ALAW_AMI_MASK;
|
||||
linear = -linear - 8;
|
||||
}
|
||||
|
||||
/* Convert the scaled magnitude to segment number. */
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
if (seg >= 8) {
|
||||
if (linear >= 0) {
|
||||
/* Out of range. Return maximum value. */
|
||||
return (uint8_t) (0x7F ^ mask);
|
||||
}
|
||||
/* We must be just a tiny step below zero */
|
||||
return (uint8_t) (0x00 ^ mask);
|
||||
}
|
||||
/* Combine the sign, segment, and quantization bits. */
|
||||
return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*! \brief Decode an A-law sample to a linear value.
|
||||
\param alaw The A-law sample to decode.
|
||||
\return The linear value.
|
||||
*/
|
||||
static __inline__ int16_t alaw_to_linear(uint8_t alaw)
|
||||
{
|
||||
int i;
|
||||
int seg;
|
||||
static __inline__ int16_t alaw_to_linear(uint8_t alaw) {
|
||||
int i;
|
||||
int seg;
|
||||
|
||||
alaw ^= ALAW_AMI_MASK;
|
||||
i = ((alaw & 0x0F) << 4);
|
||||
seg = (((int) alaw & 0x70) >> 4);
|
||||
if (seg)
|
||||
i = (i + 0x108) << (seg - 1);
|
||||
else
|
||||
i += 8;
|
||||
return (int16_t) ((alaw & 0x80) ? i : -i);
|
||||
}
|
||||
alaw ^= ALAW_AMI_MASK;
|
||||
i = ((alaw & 0x0F) << 4);
|
||||
seg = (((int) alaw & 0x70) >> 4);
|
||||
if (seg)
|
||||
i = (i + 0x108) << (seg - 1);
|
||||
else
|
||||
i += 8;
|
||||
return (int16_t) ((alaw & 0x80) ? i : -i);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*! \brief Transcode from A-law to u-law, using the procedure defined in G.711.
|
||||
\param alaw The A-law sample to transcode.
|
||||
\return The best matching u-law value.
|
||||
*/
|
||||
uint8_t alaw_to_ulaw(uint8_t alaw);
|
||||
uint8_t alaw_to_ulaw(uint8_t alaw);
|
||||
|
||||
/*! \brief Transcode from u-law to A-law, using the procedure defined in G.711.
|
||||
\param alaw The u-law sample to transcode.
|
||||
\return The best matching A-law value.
|
||||
*/
|
||||
uint8_t ulaw_to_alaw(uint8_t ulaw);
|
||||
uint8_t ulaw_to_alaw(uint8_t ulaw);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -34,7 +34,7 @@ typedef unsigned __int32 u_int32_t;
|
||||
#ifdef WANPIPE_TDM_API
|
||||
#include <wanpipe_tdm_api.h> //for TDMV API
|
||||
#endif
|
||||
#include <sang_status_defines.h>//return codes
|
||||
#include <sang_status_defines.h> //return codes
|
||||
#include <sang_api.h> //for IOCTL codes
|
||||
#include <sdla_te1_pmc.h> //RBS definitions
|
||||
#include <sdla_te1.h> //TE1 macros
|
||||
@@ -94,7 +94,7 @@ sng_fd_t sangoma_create_socket_by_name(char *device, char *card);
|
||||
/* Open Span/Chan devices
|
||||
* open_tdmapi_span_chan: open device based on span chan values
|
||||
* sangoma_open_tdmapi_span: open first available device on span
|
||||
*/
|
||||
*/
|
||||
|
||||
sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan);
|
||||
sng_fd_t sangoma_open_tdmapi_span(int span);
|
||||
@@ -104,67 +104,65 @@ sng_fd_t sangoma_open_tdmapi_span(int span);
|
||||
/* Device Rx/Tx functions
|
||||
* writemsg_tdm: tx header + data from separate buffers
|
||||
* readmsg_tdm: rx header + data to separate buffers
|
||||
*/
|
||||
int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen,
|
||||
void *databuf, unsigned short datalen, int flag);
|
||||
int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen,
|
||||
void *databuf, int datalen, int flag);
|
||||
*/
|
||||
int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag);
|
||||
int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag);
|
||||
|
||||
#define sangoma_readmsg_socket sangoma_readmsg_tdm
|
||||
#define sangoma_sendmsg_socket sangoma_writemsg_tdm
|
||||
|
||||
#ifdef WANPIPE_TDM_API
|
||||
|
||||
void sangoma_socket_close(sng_fd_t *sp);
|
||||
void sangoma_socket_close(sng_fd_t * sp);
|
||||
int sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags);
|
||||
|
||||
/* Get Full TDM API configuration per chan */
|
||||
int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Get/Set TDM Codec per chan */
|
||||
int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec);
|
||||
int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int codec);
|
||||
int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Get/Set USR Tx/Rx Period in milliseconds */
|
||||
int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int period);
|
||||
int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int period);
|
||||
int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Get user MTU/MRU values in bytes */
|
||||
int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Not supported yet */
|
||||
int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int power);
|
||||
int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int power);
|
||||
int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Flush buffers from current channel */
|
||||
int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int poll_in_sec);
|
||||
int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int poll_in_sec);
|
||||
int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, unsigned char rbs);
|
||||
int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, unsigned char rbs);
|
||||
|
||||
int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* DTMF Detection on Octasic chip */
|
||||
int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* DTMF Detection on A200 (SLIC) chip */
|
||||
int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* On/Off hook events on A200 (Analog) card */
|
||||
int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
#ifndef LIBSANGOMA_GET_HWCODING
|
||||
#define LIBSANGOMA_GET_HWCODING 1
|
||||
#endif
|
||||
int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
#endif /* WANPIPE_TDM_API */
|
||||
#endif /* WANPIPE_TDM_API */
|
||||
|
||||
#endif
|
||||
@@ -23,20 +23,21 @@
|
||||
static __inline int gettimeofday(struct timeval *tp, void *nothing)
|
||||
{
|
||||
#ifdef WITHOUT_MM_LIB
|
||||
SYSTEMTIME st;
|
||||
time_t tt;
|
||||
struct tm tmtm;
|
||||
/* mktime converts local to UTC */
|
||||
GetLocalTime (&st);
|
||||
tmtm.tm_sec = st.wSecond;
|
||||
tmtm.tm_min = st.wMinute;
|
||||
tmtm.tm_hour = st.wHour;
|
||||
tmtm.tm_mday = st.wDay;
|
||||
tmtm.tm_mon = st.wMonth - 1;
|
||||
tmtm.tm_year = st.wYear - 1900; tmtm.tm_isdst = -1;
|
||||
tt = mktime (&tmtm);
|
||||
tp->tv_sec = tt;
|
||||
tp->tv_usec = st.wMilliseconds * 1000;
|
||||
SYSTEMTIME st;
|
||||
time_t tt;
|
||||
struct tm tmtm;
|
||||
/* mktime converts local to UTC */
|
||||
GetLocalTime(&st);
|
||||
tmtm.tm_sec = st.wSecond;
|
||||
tmtm.tm_min = st.wMinute;
|
||||
tmtm.tm_hour = st.wHour;
|
||||
tmtm.tm_mday = st.wDay;
|
||||
tmtm.tm_mon = st.wMonth - 1;
|
||||
tmtm.tm_year = st.wYear - 1900;
|
||||
tmtm.tm_isdst = -1;
|
||||
tt = mktime(&tmtm);
|
||||
tp->tv_sec = tt;
|
||||
tp->tv_usec = st.wMilliseconds * 1000;
|
||||
#else
|
||||
/**
|
||||
** The earlier time calculations using GetLocalTime
|
||||
@@ -44,18 +45,18 @@ static __inline int gettimeofday(struct timeval *tp, void *nothing)
|
||||
** of multimedia apis offer a better time resolution
|
||||
** of 1ms.Need to link against winmm.lib for this
|
||||
**/
|
||||
unsigned long Ticks = 0;
|
||||
unsigned long Sec =0;
|
||||
unsigned long Usec = 0;
|
||||
Ticks = timeGetTime();
|
||||
unsigned long Ticks = 0;
|
||||
unsigned long Sec = 0;
|
||||
unsigned long Usec = 0;
|
||||
Ticks = timeGetTime();
|
||||
|
||||
Sec = Ticks/1000;
|
||||
Usec = (Ticks - (Sec*1000))*1000;
|
||||
tp->tv_sec = Sec;
|
||||
tp->tv_usec = Usec;
|
||||
Sec = Ticks / 1000;
|
||||
Usec = (Ticks - (Sec * 1000)) * 1000;
|
||||
tp->tv_sec = Sec;
|
||||
tp->tv_usec = Usec;
|
||||
#endif /* WITHOUT_MM_LIB */
|
||||
(void)nothing;
|
||||
return 0;
|
||||
(void) nothing;
|
||||
return 0;
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* HAVE_GETTIMEOFDAY */
|
||||
@@ -84,37 +85,37 @@ static struct sangoma_pri_event_list SANGOMA_PRI_EVENT_LIST[] = {
|
||||
|
||||
|
||||
char *sangoma_pri_event_str(sangoma_pri_event_t event_id)
|
||||
{
|
||||
{
|
||||
return SANGOMA_PRI_EVENT_LIST[event_id].name;
|
||||
}
|
||||
|
||||
static int __pri_sangoma_read(struct pri *pri, void *buf, int buflen)
|
||||
{
|
||||
unsigned char tmpbuf[sizeof(wp_tdm_api_rx_hdr_t)];
|
||||
|
||||
|
||||
|
||||
/* NOTE: This code will be different for A104
|
||||
* A104 receives data + 2byte CRC + 1 byte flag
|
||||
* A101/2 receives data only */
|
||||
|
||||
int res = sangoma_readmsg_socket((sng_fd_t)(pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
|
||||
buf, buflen,
|
||||
0);
|
||||
if (res > 0){
|
||||
* A101/2 receives data only */
|
||||
|
||||
int res = sangoma_readmsg_socket((sng_fd_t) (pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
|
||||
buf, buflen,
|
||||
0);
|
||||
if (res > 0) {
|
||||
#ifdef WANPIPE_LEGACY_A104
|
||||
/* Prior 2.3.4 release A104 API passed up
|
||||
* 3 extra bytes: 2 CRC + 1 FLAG,
|
||||
* PRI is expecting only 2 CRC bytes, thus we
|
||||
* must remove 1 flag byte */
|
||||
* 3 extra bytes: 2 CRC + 1 FLAG,
|
||||
* PRI is expecting only 2 CRC bytes, thus we
|
||||
* must remove 1 flag byte */
|
||||
res--;
|
||||
#else
|
||||
/* Add 2 byte CRC and set it to ZERO */
|
||||
memset(&((unsigned char*)buf)[res],0,2);
|
||||
res+=2;
|
||||
/* Add 2 byte CRC and set it to ZERO */
|
||||
memset(&((unsigned char *) buf)[res], 0, 2);
|
||||
res += 2;
|
||||
#endif
|
||||
}else{
|
||||
res=0;
|
||||
} else {
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -126,25 +127,23 @@ static int __pri_sangoma_write(struct pri *pri, void *buf, int buflen)
|
||||
int res;
|
||||
|
||||
|
||||
memset(&tmpbuf[0],0,sizeof(wp_tdm_api_rx_hdr_t));
|
||||
memset(&tmpbuf[0], 0, sizeof(wp_tdm_api_rx_hdr_t));
|
||||
|
||||
if (buflen < 1){
|
||||
if (buflen < 1) {
|
||||
/* HDLC Frame must be greater than 2byte CRC */
|
||||
fprintf(stderr,"%s: Got short frame %i\n",__FUNCTION__,buflen);
|
||||
fprintf(stderr, "%s: Got short frame %i\n", __FUNCTION__, buflen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: This might cause problems with other libraries
|
||||
* We must remove 2 bytes from buflen because
|
||||
* libpri sends 2 fake CRC bytes */
|
||||
res=sangoma_sendmsg_socket((sng_fd_t)(pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
|
||||
buf, (unsigned short)buflen-2,
|
||||
0);
|
||||
if (res > 0){
|
||||
res=buflen;
|
||||
res = sangoma_sendmsg_socket((sng_fd_t) (pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t), buf, (unsigned short) buflen - 2, 0);
|
||||
if (res > 0) {
|
||||
res = buflen;
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -155,10 +154,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
|
||||
|
||||
memset(spri, 0, sizeof(struct sangoma_pri));
|
||||
|
||||
if((dfd = sangoma_open_tdmapi_span_chan(span, dchan)) < 0) {
|
||||
if ((dfd = sangoma_open_tdmapi_span_chan(span, dchan)) < 0) {
|
||||
fprintf(stderr, "Unable to open DCHAN %d for span %d (%s)\n", dchan, span, strerror(errno));
|
||||
} else {
|
||||
if ((spri->pri = pri_new_cb((int)dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))){
|
||||
if ((spri->pri = pri_new_cb((int) dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))) {
|
||||
spri->span = span;
|
||||
pri_set_debug(spri->pri, debug);
|
||||
ret = 0;
|
||||
@@ -173,10 +172,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
|
||||
int sangoma_one_loop(struct sangoma_pri *spri)
|
||||
{
|
||||
fd_set rfds, efds;
|
||||
struct timeval now = {0,0}, *next;
|
||||
struct timeval now = { 0, 0 }, *next;
|
||||
pri_event *event;
|
||||
int sel;
|
||||
|
||||
int sel;
|
||||
|
||||
if (spri->on_loop) {
|
||||
spri->on_loop(spri);
|
||||
}
|
||||
@@ -223,10 +222,11 @@ int sangoma_one_loop(struct sangoma_pri *spri)
|
||||
if (event) {
|
||||
event_handler handler;
|
||||
/* 0 is catchall event handler */
|
||||
if ((handler = spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
if ((handler =
|
||||
spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
handler(spri, event->e, event);
|
||||
} else {
|
||||
fprintf(stderr,"No event handler found for event %d.\n", event->e);
|
||||
fprintf(stderr, "No event handler found for event %d.\n", event->e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,23 +237,22 @@ int sangoma_run_pri(struct sangoma_pri *spri)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
for (;;){
|
||||
ret=sangoma_one_loop(spri);
|
||||
if (ret < 0){
|
||||
for (;;) {
|
||||
ret = sangoma_one_loop(spri);
|
||||
if (ret < 0) {
|
||||
|
||||
#ifndef WIN32 //This needs to be adressed fror WIN32 still
|
||||
if (errno == EINTR){
|
||||
#ifndef WIN32 //This needs to be adressed fror WIN32 still
|
||||
if (errno == EINTR) {
|
||||
/* Igonore an interrupted system call */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
printf("Error = %i\n",ret);
|
||||
#endif
|
||||
printf("Error = %i\n", ret);
|
||||
perror("Sangoma Run Pri: ");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ typedef enum {
|
||||
|
||||
typedef enum {
|
||||
SANGOMA_PRI_SWITCH_UNKNOWN = PRI_SWITCH_UNKNOWN,
|
||||
SANGOMA_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,
|
||||
SANGOMA_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,
|
||||
SANGOMA_PRI_SWITCH_DMS100 = PRI_SWITCH_DMS100,
|
||||
SANGOMA_PRI_SWITCH_LUCENT5E = PRI_SWITCH_LUCENT5E,
|
||||
SANGOMA_PRI_SWITCH_ATT4ESS = PRI_SWITCH_ATT4ESS,
|
||||
@@ -67,8 +67,8 @@ typedef enum {
|
||||
} sangoma_pri_flag_t;
|
||||
|
||||
struct sangoma_pri;
|
||||
typedef int (*event_handler)(struct sangoma_pri *, sangoma_pri_event_t, pri_event *);
|
||||
typedef int (*loop_handler)(struct sangoma_pri *);
|
||||
typedef int (*event_handler) (struct sangoma_pri *, sangoma_pri_event_t, pri_event *);
|
||||
typedef int (*loop_handler) (struct sangoma_pri *);
|
||||
#define MAX_EVENT 18
|
||||
|
||||
struct sangoma_pri {
|
||||
@@ -77,7 +77,7 @@ struct sangoma_pri {
|
||||
int dchan;
|
||||
unsigned int flags;
|
||||
void *private_info;
|
||||
event_handler eventmap[MAX_EVENT+1];
|
||||
event_handler eventmap[MAX_EVENT + 1];
|
||||
loop_handler on_loop;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,228 +11,159 @@
|
||||
#ifndef _WIN_API_COMMON_H
|
||||
#define _WIN_API_COMMON_H
|
||||
|
||||
static
|
||||
int
|
||||
tdmv_api_ioctl(
|
||||
HANDLE fd,
|
||||
wanpipe_tdm_api_cmd_t *tdm_api_cmd
|
||||
)
|
||||
static
|
||||
int tdmv_api_ioctl(HANDLE fd, wanpipe_tdm_api_cmd_t * tdm_api_cmd)
|
||||
{
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
|
||||
wan_udp.wan_udphdr_request_reply = 0x01;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
|
||||
wan_udp.wan_udphdr_command = WAN_TDMV_API_IOCTL;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wanpipe_tdm_api_cmd_t);
|
||||
wan_udp.wan_udphdr_command = WAN_TDMV_API_IOCTL;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wanpipe_tdm_api_cmd_t);
|
||||
|
||||
//copy data from caller's buffer to driver's buffer
|
||||
memcpy( wan_udp.wan_udphdr_data,
|
||||
(void*)tdm_api_cmd,
|
||||
sizeof(wanpipe_tdm_api_cmd_t));
|
||||
memcpy(wan_udp.wan_udphdr_data, (void *) tdm_api_cmd, sizeof(wanpipe_tdm_api_cmd_t));
|
||||
|
||||
if(DeviceIoControl(
|
||||
fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) & wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//actual ioctl failed
|
||||
err = 1;
|
||||
prn(1, "Error: tdmv_api_ioctl(): DeviceIoControl failed!!\n");
|
||||
return err;
|
||||
}else{
|
||||
} else {
|
||||
err = 0;
|
||||
}
|
||||
|
||||
if(wan_udp.wan_udphdr_return_code != WAN_CMD_OK){
|
||||
if (wan_udp.wan_udphdr_return_code != WAN_CMD_OK) {
|
||||
//ioctl ok, but command failed
|
||||
prn(1, "Error: tdmv_api_ioctl(): command failed! Return code: 0x%X.\n",
|
||||
wan_udp.wan_udphdr_return_code);
|
||||
prn(1, "Error: tdmv_api_ioctl(): command failed! Return code: 0x%X.\n", wan_udp.wan_udphdr_return_code);
|
||||
return 2;
|
||||
}
|
||||
|
||||
//copy data from driver's buffer to caller's buffer
|
||||
memcpy( (void*)tdm_api_cmd,
|
||||
wan_udp.wan_udphdr_data,
|
||||
sizeof(wanpipe_tdm_api_cmd_t));
|
||||
memcpy((void *) tdm_api_cmd, wan_udp.wan_udphdr_data, sizeof(wanpipe_tdm_api_cmd_t));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
wanpipe_api_ioctl(
|
||||
HANDLE fd,
|
||||
wan_cmd_api_t *api_cmd
|
||||
)
|
||||
static
|
||||
int wanpipe_api_ioctl(HANDLE fd, wan_cmd_api_t * api_cmd)
|
||||
{
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
|
||||
wan_udp.wan_udphdr_request_reply = 0x01;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
|
||||
wan_udp.wan_udphdr_command = SIOC_WANPIPE_API;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wan_cmd_api_t);
|
||||
wan_udp.wan_udphdr_command = SIOC_WANPIPE_API;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wan_cmd_api_t);
|
||||
|
||||
//copy data from caller's buffer to driver's buffer
|
||||
memcpy( wan_udp.wan_udphdr_data,
|
||||
(void*)api_cmd,
|
||||
sizeof(wan_cmd_api_t));
|
||||
memcpy(wan_udp.wan_udphdr_data, (void *) api_cmd, sizeof(wan_cmd_api_t));
|
||||
|
||||
if(DeviceIoControl(
|
||||
fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) & wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
err = 1;
|
||||
prn(1, "Error: wanpipe_api_ioctl(): DeviceIoControl failed!!\n");
|
||||
return err;
|
||||
}else{
|
||||
} else {
|
||||
err = 0;
|
||||
}
|
||||
|
||||
if(wan_udp.wan_udphdr_return_code != WAN_CMD_OK){
|
||||
prn(1, "Error: wanpipe_api_ioctl(): command failed! Return code: 0x%X.\n",
|
||||
wan_udp.wan_udphdr_return_code);
|
||||
if (wan_udp.wan_udphdr_return_code != WAN_CMD_OK) {
|
||||
prn(1, "Error: wanpipe_api_ioctl(): command failed! Return code: 0x%X.\n", wan_udp.wan_udphdr_return_code);
|
||||
return 2;
|
||||
}
|
||||
|
||||
//copy data from driver's buffer to caller's buffer
|
||||
memcpy( (void*)api_cmd,
|
||||
wan_udp.wan_udphdr_data,
|
||||
sizeof(wan_cmd_api_t));
|
||||
memcpy((void *) api_cmd, wan_udp.wan_udphdr_data, sizeof(wan_cmd_api_t));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Blocking read command. If used after DoApiPollCommand(),
|
||||
// it will return immediatly, without blocking.
|
||||
static
|
||||
USHORT
|
||||
DoReadCommand(
|
||||
HANDLE drv,
|
||||
RX_DATA_STRUCT * pRx
|
||||
)
|
||||
static USHORT DoReadCommand(HANDLE drv, RX_DATA_STRUCT * pRx)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if (DeviceIoControl(
|
||||
drv,
|
||||
IoctlReadCommand,
|
||||
(LPVOID)NULL,
|
||||
0L,
|
||||
(LPVOID)pRx,
|
||||
sizeof(RX_DATA_STRUCT),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlReadCommand,
|
||||
(LPVOID) NULL,
|
||||
0L, (LPVOID) pRx, sizeof(RX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoReadCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Blocking write command. If used after DoApiPollCommand(),
|
||||
// it will return immediatly, without blocking.
|
||||
static
|
||||
UCHAR
|
||||
DoWriteCommand(
|
||||
HANDLE drv,
|
||||
TX_DATA_STRUCT * pTx
|
||||
)
|
||||
static UCHAR DoWriteCommand(HANDLE drv, TX_DATA_STRUCT * pTx)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if(DeviceIoControl(
|
||||
drv,
|
||||
IoctlWriteCommand,
|
||||
(LPVOID)pTx,
|
||||
(ULONG)sizeof(TX_DATA_STRUCT),
|
||||
(LPVOID)pTx,
|
||||
sizeof(TX_DATA_STRUCT),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlWriteCommand,
|
||||
(LPVOID) pTx,
|
||||
(ULONG) sizeof(TX_DATA_STRUCT),
|
||||
(LPVOID) pTx, sizeof(TX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoWriteCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Blocking API Poll command.
|
||||
static
|
||||
USHORT
|
||||
DoApiPollCommand(
|
||||
HANDLE drv,
|
||||
API_POLL_STRUCT *api_poll_ptr
|
||||
)
|
||||
static USHORT DoApiPollCommand(HANDLE drv, API_POLL_STRUCT * api_poll_ptr)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if (DeviceIoControl(
|
||||
drv,
|
||||
IoctlApiPoll,
|
||||
(LPVOID)NULL,
|
||||
0L,
|
||||
(LPVOID)api_poll_ptr,
|
||||
sizeof(API_POLL_STRUCT),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlApiPoll,
|
||||
(LPVOID) NULL,
|
||||
0L,
|
||||
(LPVOID) api_poll_ptr,
|
||||
sizeof(API_POLL_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoApiPollCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
DoManagementCommand(
|
||||
HANDLE drv,
|
||||
wan_udp_hdr_t* wan_udp
|
||||
)
|
||||
int DoManagementCommand(HANDLE drv, wan_udp_hdr_t * wan_udp)
|
||||
{
|
||||
DWORD ln;
|
||||
static unsigned char id = 0;
|
||||
static unsigned char id = 0;
|
||||
|
||||
wan_udp->wan_udphdr_request_reply = 0x01;
|
||||
wan_udp->wan_udphdr_id = id++;
|
||||
wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
|
||||
if(DeviceIoControl(
|
||||
drv,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID)wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID)wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoManagementCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -16,38 +16,35 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum e_sigboost_event_id_values
|
||||
{
|
||||
SIGBOOST_EVENT_CALL_START = 0x80, /*128*/
|
||||
SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129*/
|
||||
SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130*/
|
||||
SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131*/
|
||||
SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132*/
|
||||
SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133*/
|
||||
SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134*/
|
||||
SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135*/
|
||||
SIGBOOST_EVENT_HEARTBEAT = 0x88, /*136*/
|
||||
enum e_sigboost_event_id_values {
|
||||
SIGBOOST_EVENT_CALL_START = 0x80, /*128 */
|
||||
SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129 */
|
||||
SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130 */
|
||||
SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131 */
|
||||
SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132 */
|
||||
SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133 */
|
||||
SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134 */
|
||||
SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135 */
|
||||
SIGBOOST_EVENT_HEARTBEAT = 0x88, /*136 */
|
||||
};
|
||||
|
||||
enum e_sigboost_release_cause_values
|
||||
{
|
||||
SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0x00,
|
||||
SIGBOOST_RELEASE_CAUSE_NORMAL = 0x90,
|
||||
SIGBOOST_RELEASE_CAUSE_BUSY = 0x91,
|
||||
SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92,
|
||||
SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93,
|
||||
SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94
|
||||
enum e_sigboost_release_cause_values {
|
||||
SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0x00,
|
||||
SIGBOOST_RELEASE_CAUSE_NORMAL = 0x90,
|
||||
SIGBOOST_RELEASE_CAUSE_BUSY = 0x91,
|
||||
SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92,
|
||||
SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93,
|
||||
SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94
|
||||
};
|
||||
|
||||
enum e_sigboost_call_setup_ack_nack_cause_values
|
||||
{
|
||||
SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10,
|
||||
SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11,
|
||||
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 0x12,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_BIG = 0x13,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_BIG = 0x14,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_SMALL = 0x15,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_SMALL = 0x16,
|
||||
enum e_sigboost_call_setup_ack_nack_cause_values {
|
||||
SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10,
|
||||
SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11,
|
||||
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 0x12,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_BIG = 0x13,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_BIG = 0x14,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_SMALL = 0x15,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_SMALL = 0x16,
|
||||
};
|
||||
|
||||
#define MAX_DIALED_DIGITS 31
|
||||
@@ -61,21 +58,20 @@ enum e_sigboost_call_setup_ack_nack_cause_values
|
||||
/* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
uint32_t event_id;
|
||||
uint32_t seqno;
|
||||
uint32_t call_setup_id;
|
||||
uint32_t trunk_group;
|
||||
uint32_t span;
|
||||
uint32_t chan;
|
||||
uint32_t called_number_digits_count;
|
||||
int8_t called_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t calling_number_digits_count; /* it's an array */
|
||||
int8_t calling_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t release_cause;
|
||||
struct timeval tv;
|
||||
uint32_t calling_number_presentation;
|
||||
typedef struct {
|
||||
uint32_t event_id;
|
||||
uint32_t seqno;
|
||||
uint32_t call_setup_id;
|
||||
uint32_t trunk_group;
|
||||
uint32_t span;
|
||||
uint32_t chan;
|
||||
uint32_t called_number_digits_count;
|
||||
int8_t called_number_digits[MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t calling_number_digits_count; /* it's an array */
|
||||
int8_t calling_number_digits[MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t release_cause;
|
||||
struct timeval tv;
|
||||
uint32_t calling_number_presentation;
|
||||
} t_sigboost;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
@@ -52,23 +52,25 @@ static struct ss7boost_client_map ss7boost_client_table[] = {
|
||||
{SIGBOOST_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
|
||||
{SIGBOOST_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
|
||||
{SIGBOOST_EVENT_HEARTBEAT, "HEARTBEAT"},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, char *local_ip, int local_port, char *ip,
|
||||
int port)
|
||||
{
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
|
||||
if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (switch_sockaddr_info_get(&mcon->remote_addr, ip, SWITCH_UNSPEC, port, 0, mcon->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (switch_socket_create(&mcon->socket, AF_INET, SOCK_DGRAM, 0, mcon->pool) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_socket_bind(mcon->socket, mcon->local_addr) != SWITCH_STATUS_SUCCESS) {
|
||||
goto fail;
|
||||
@@ -77,18 +79,20 @@ static switch_status_t create_udp_socket(ss7boost_client_connection_t *mcon, cha
|
||||
goto fail;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip,
|
||||
local_port, ip, port);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip,
|
||||
local_port, ip, port);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t *mcon)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon)
|
||||
{
|
||||
switch_socket_close(mcon->socket);
|
||||
mcon->socket = NULL;
|
||||
@@ -97,12 +101,10 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t *mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip,
|
||||
int port,
|
||||
switch_memory_pool_t *pool)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip, int port, switch_memory_pool_t *pool)
|
||||
{
|
||||
memset(mcon, 0, sizeof(*mcon));
|
||||
mcon->pool = pool;
|
||||
@@ -111,32 +113,30 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_
|
||||
switch_mutex_init(&mcon->mutex, SWITCH_MUTEX_NESTED, mcon->pool);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
memset(mcon, 0, sizeof(*mcon));
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t *mcon, ss7boost_client_event_t **event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t ** event)
|
||||
{
|
||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||
switch_size_t bytes = 0;
|
||||
|
||||
bytes = sizeof(mcon->event);
|
||||
|
||||
if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *)&mcon->event, &bytes) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *) &mcon->event, &bytes) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
if (bytes == sizeof(mcon->event) ||
|
||||
bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
||||
if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event) - sizeof(uint32_t))) {
|
||||
if (rxseq != mcon->event.seqno) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n",
|
||||
rxseq,mcon->event.seqno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n", rxseq, mcon->event.seqno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
}
|
||||
rxseq++;
|
||||
|
||||
@@ -147,7 +147,8 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t *mcon, ss7boost_client_event_t *event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t * event)
|
||||
{
|
||||
int err;
|
||||
switch_size_t len;
|
||||
@@ -158,23 +159,19 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
}
|
||||
|
||||
if (event->span < 0 || event->chan < 0 || event->span > 7 || event->chan > 30) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Span=%i Chan=%i\n",
|
||||
event->span,event->chan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Span=%i Chan=%i\n", event->span, event->chan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
//TODO set the tv with win func
|
||||
#else
|
||||
gettimeofday(&event->tv,NULL);
|
||||
#else
|
||||
gettimeofday(&event->tv, NULL);
|
||||
#endif
|
||||
|
||||
switch_mutex_lock(mcon->mutex);
|
||||
event->seqno=txseq++;
|
||||
event->seqno = txseq++;
|
||||
len = sizeof(*event);
|
||||
if (switch_socket_sendto(mcon->socket, mcon->remote_addr, 0, (void *) event, &len) != SWITCH_STATUS_SUCCESS) {
|
||||
err = -1;
|
||||
@@ -182,7 +179,8 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
switch_mutex_unlock(mcon->mutex);
|
||||
|
||||
if (len != sizeof(ss7boost_client_event_t)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno, strerror(errno));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno,
|
||||
strerror(errno));
|
||||
err = -1;
|
||||
}
|
||||
|
||||
@@ -204,42 +202,39 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
"\n",
|
||||
ss7boost_client_event_id_name(event->event_id),
|
||||
event->event_id,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->span + 1,
|
||||
event->chan + 1,
|
||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
|
||||
event->release_cause,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->event_id,
|
||||
event->call_setup_id,
|
||||
event->seqno
|
||||
);
|
||||
event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
|
||||
|
||||
|
||||
return err ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t *event, char *calling, char *called, int setup_id)
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
|
||||
int setup_id)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = SIGBOOST_EVENT_CALL_START;
|
||||
|
||||
if (calling) {
|
||||
strncpy((char*)event->calling_number_digits, calling, sizeof(event->calling_number_digits)-1);
|
||||
strncpy((char *) event->calling_number_digits, calling, sizeof(event->calling_number_digits) - 1);
|
||||
event->calling_number_digits_count = strlen(calling);
|
||||
}
|
||||
|
||||
if (called) {
|
||||
strncpy((char*)event->called_number_digits, called, sizeof(event->called_number_digits)-1);
|
||||
strncpy((char *) event->called_number_digits, called, sizeof(event->called_number_digits) - 1);
|
||||
event->called_number_digits_count = strlen(called);
|
||||
}
|
||||
|
||||
|
||||
event->call_setup_id = setup_id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t *event, ss7boost_client_event_id_t event_id, int chan, int span)
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
|
||||
int chan, int span)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = event_id;
|
||||
@@ -252,7 +247,7 @@ SWITCH_DECLARE(char *) ss7boost_client_event_id_name(uint32_t event_id)
|
||||
int x;
|
||||
char *ret = NULL;
|
||||
|
||||
for (x = 0 ; x < sizeof(ss7boost_client_table)/sizeof(struct ss7boost_client_map); x++) {
|
||||
for (x = 0; x < sizeof(ss7boost_client_table) / sizeof(struct ss7boost_client_map); x++) {
|
||||
if (ss7boost_client_table[x].event_id == event_id) {
|
||||
ret = ss7boost_client_table[x].name;
|
||||
break;
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
(dest)->flags |= ((src)->flags & (flagz)); \
|
||||
} while (0)
|
||||
|
||||
typedef t_sigboost ss7boost_client_event_t;
|
||||
typedef t_sigboost ss7boost_client_event_t;
|
||||
typedef uint32_t ss7boost_client_event_id_t;
|
||||
|
||||
struct ss7boost_client_connection {
|
||||
@@ -80,7 +80,7 @@ struct ss7boost_client_connection {
|
||||
ss7boost_client_event_t event;
|
||||
unsigned int flags;
|
||||
switch_mutex_t *mutex;
|
||||
switch_memory_pool_t * pool;
|
||||
switch_memory_pool_t *pool;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -89,19 +89,19 @@ typedef enum {
|
||||
|
||||
typedef struct ss7boost_client_connection ss7boost_client_connection_t;
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t *mcon);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t *mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip,
|
||||
int port,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t *mcon, ss7boost_client_event_t **event);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t *mcon, ss7boost_client_event_t *event);
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t *event, ss7boost_client_event_id_t event_id, int chan, int span);
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t *event, char *calling, char *called, int setup_id);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip, int port, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t ** event);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t * event);
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
|
||||
int chan, int span);
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
|
||||
int setup_id);
|
||||
SWITCH_DECLARE(char *) ss7boost_client_event_id_name(uint32_t event_id);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user