mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 13:28:31 +00:00
Numerous little changes to spandsp that haven't been pushed to Freeswitch for a
while. The only big changes are a majorly rewritten V.42 and V.42bis which are now basically functional.
This commit is contained in:
1 parent
6f62f39139
commit
d30e82e226
68 files changed
+2513
-2114
No files matched your search
@@ -69,6 +69,12 @@ SPAN_DECLARE(const char *) signal_status_to_str(int status)
|
|||||||
return "Poor signal quality";
|
return "Poor signal quality";
|
||||||
case SIG_STATUS_MODEM_RETRAIN_OCCURRED:
|
case SIG_STATUS_MODEM_RETRAIN_OCCURRED:
|
||||||
return "Modem retrain occurred";
|
return "Modem retrain occurred";
|
||||||
|
case SIG_STATUS_LINK_CONNECTED:
|
||||||
|
return "Link connected";
|
||||||
|
case SIG_STATUS_LINK_DISCONNECTED:
|
||||||
|
return "Link disconnected";
|
||||||
|
case SIG_STATUS_LINK_ERROR:
|
||||||
|
return "Link error";
|
||||||
}
|
}
|
||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
/* This is a simple set of direct digital synthesis (DDS) functions to generate sine
|
/* This is a simple set of direct digital synthesis (DDS) functions to generate sine
|
||||||
waves. This version uses a 128 entry sin/cos table to cover one quadrant. */
|
waves. This version uses a 128 entry sin/cos table to cover one quadrant. */
|
||||||
|
|
||||||
static const int16_t sine_table[DDS_STEPS] =
|
static const int16_t sine_table[DDS_STEPS + 1] =
|
||||||
{
|
{
|
||||||
201,
|
201,
|
||||||
603,
|
603,
|
||||||
@@ -186,6 +186,7 @@ static const int16_t sine_table[DDS_STEPS] =
|
|||||||
32753,
|
32753,
|
||||||
32762,
|
32762,
|
||||||
32767,
|
32767,
|
||||||
|
32767
|
||||||
};
|
};
|
||||||
|
|
||||||
SPAN_DECLARE(int32_t) dds_phase_rate(float frequency)
|
SPAN_DECLARE(int32_t) dds_phase_rate(float frequency)
|
||||||
@@ -220,7 +221,7 @@ SPAN_DECLARE(int16_t) dds_lookup(uint32_t phase)
|
|||||||
phase >>= DDS_SHIFT;
|
phase >>= DDS_SHIFT;
|
||||||
step = phase & (DDS_STEPS - 1);
|
step = phase & (DDS_STEPS - 1);
|
||||||
if ((phase & DDS_STEPS))
|
if ((phase & DDS_STEPS))
|
||||||
step = (DDS_STEPS - 1) - step;
|
step = DDS_STEPS - step;
|
||||||
amp = sine_table[step];
|
amp = sine_table[step];
|
||||||
if ((phase & (2*DDS_STEPS)))
|
if ((phase & (2*DDS_STEPS)))
|
||||||
amp = -amp;
|
amp = -amp;
|
||||||
@@ -254,7 +255,7 @@ SPAN_DECLARE(int16_t) dds_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t s
|
|||||||
{
|
{
|
||||||
int16_t amp;
|
int16_t amp;
|
||||||
|
|
||||||
amp = (int16_t) (((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15);
|
amp = (int16_t) (((int32_t) dds_lookup(*phase_acc + phase)*scale) >> 15);
|
||||||
*phase_acc += phase_rate;
|
*phase_acc += phase_rate;
|
||||||
return amp;
|
return amp;
|
||||||
}
|
}
|
||||||
@@ -280,8 +281,8 @@ SPAN_DECLARE(complexi_t) dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rat
|
|||||||
{
|
{
|
||||||
complexi_t amp;
|
complexi_t amp;
|
||||||
|
|
||||||
amp = complex_seti(((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*(int32_t) scale) >> 15,
|
amp = complex_seti(((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*scale) >> 15,
|
||||||
((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15);
|
((int32_t) dds_lookup(*phase_acc + phase)*scale) >> 15);
|
||||||
*phase_acc += phase_rate;
|
*phase_acc += phase_rate;
|
||||||
return amp;
|
return amp;
|
||||||
}
|
}
|
||||||
@@ -307,8 +308,8 @@ SPAN_DECLARE(complexi16_t) dds_complexi16_mod(uint32_t *phase_acc, int32_t phase
|
|||||||
{
|
{
|
||||||
complexi16_t amp;
|
complexi16_t amp;
|
||||||
|
|
||||||
amp = complex_seti16((int16_t) (((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*(int32_t) scale) >> 15),
|
amp = complex_seti16((int16_t) (((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*scale) >> 15),
|
||||||
(int16_t) (((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15));
|
(int16_t) (((int32_t) dds_lookup(*phase_acc + phase)*scale) >> 15));
|
||||||
*phase_acc += phase_rate;
|
*phase_acc += phase_rate;
|
||||||
return amp;
|
return amp;
|
||||||
}
|
}
|
||||||
@@ -334,8 +335,8 @@ SPAN_DECLARE(complexi32_t) dds_complexi32_mod(uint32_t *phase_acc, int32_t phase
|
|||||||
{
|
{
|
||||||
complexi32_t amp;
|
complexi32_t amp;
|
||||||
|
|
||||||
amp = complex_seti32(((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*(int32_t) scale) >> 15,
|
amp = complex_seti32(((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*scale) >> 15,
|
||||||
((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15);
|
((int32_t) dds_lookup(*phase_acc + phase)*scale) >> 15);
|
||||||
*phase_acc += phase_rate;
|
*phase_acc += phase_rate;
|
||||||
return amp;
|
return amp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ SPAN_DECLARE(void) fsk_tx_set_get_bit(fsk_tx_state_t *s, get_bit_func_t get_bit,
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) fsk_tx_set_modem_status_handler(fsk_tx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) fsk_tx_set_modem_status_handler(fsk_tx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
@@ -248,7 +248,7 @@ SPAN_DECLARE(void) fsk_rx_set_put_bit(fsk_rx_state_t *s, put_bit_func_t put_bit,
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) fsk_rx_set_modem_status_handler(fsk_rx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) fsk_rx_set_modem_status_handler(fsk_rx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -91,15 +91,16 @@ void gsm0610_preprocess(gsm0610_state_t *s, const int16_t amp[GSM0610_FRAME_LEN]
|
|||||||
/* 4.2.1 Downscaling of the input signal */
|
/* 4.2.1 Downscaling of the input signal */
|
||||||
SO = (amp[k] >> 1) & ~3;
|
SO = (amp[k] >> 1) & ~3;
|
||||||
|
|
||||||
assert(SO >= -0x4000); // downscaled by
|
/* This is supposed to have been downscaled by previous routine. */
|
||||||
assert(SO <= 0x3FFC); // previous routine.
|
assert(SO >= -0x4000);
|
||||||
|
assert(SO <= 0x3FFC);
|
||||||
|
|
||||||
/* 4.2.2 Offset compensation */
|
/* 4.2.2 Offset compensation */
|
||||||
|
|
||||||
/* This part implements a high-pass filter and requires extended
|
/* This part implements a high-pass filter and requires extended
|
||||||
arithmetic precision for the recursive part of this filter.
|
arithmetic precision for the recursive part of this filter.
|
||||||
The input of this procedure is the array so[0...159] and the
|
The input of this procedure is the array so[0...159] and the
|
||||||
output the array sof[ 0...159 ].
|
output the array sof[0...159].
|
||||||
*/
|
*/
|
||||||
/* Compute the non-recursive part */
|
/* Compute the non-recursive part */
|
||||||
s1 = SO - z1;
|
s1 = SO - z1;
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ SPAN_DECLARE(void) hdlc_rx_set_frame_handler(hdlc_rx_state_t *s, hdlc_frame_hand
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) hdlc_rx_set_status_handler(hdlc_rx_state_t *s, modem_rx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) hdlc_rx_set_status_handler(hdlc_rx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -146,12 +146,12 @@ static int image_resize_row(image_translate_state_t *s, uint8_t buf[], size_t le
|
|||||||
int input_length;
|
int input_length;
|
||||||
double c1;
|
double c1;
|
||||||
double c2;
|
double c2;
|
||||||
double int_part;
|
|
||||||
int x;
|
int x;
|
||||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||||
int frac_row;
|
int frac_row;
|
||||||
int frac_col;
|
int frac_col;
|
||||||
#else
|
#else
|
||||||
|
double int_part;
|
||||||
double frac_row;
|
double frac_row;
|
||||||
double frac_col;
|
double frac_col;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ static __inline__ int32_t pow_ii(int32_t x, int32_t n)
|
|||||||
if (n == 0 || x == 1)
|
if (n == 0 || x == 1)
|
||||||
return 1;
|
return 1;
|
||||||
if (x != -1)
|
if (x != -1)
|
||||||
return (x == 0) ? 1/x : 0;
|
return (x != 0) ? 1/x : 0;
|
||||||
n = -n;
|
n = -n;
|
||||||
}
|
}
|
||||||
u = n;
|
u = n;
|
||||||
|
|||||||
@@ -165,10 +165,8 @@ SPAN_DECLARE(int) plc_fillin(plc_state_t *s, int16_t amp[], int len)
|
|||||||
float old_weight;
|
float old_weight;
|
||||||
float new_weight;
|
float new_weight;
|
||||||
float gain;
|
float gain;
|
||||||
//int16_t *orig_amp;
|
|
||||||
int orig_len;
|
int orig_len;
|
||||||
|
|
||||||
//orig_amp = amp;
|
|
||||||
orig_len = len;
|
orig_len = len;
|
||||||
if (s->missing_samples == 0)
|
if (s->missing_samples == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ SPAN_DECLARE(float) power_meter_current_dbm0(power_meter_t *s)
|
|||||||
if (s->reading <= 0)
|
if (s->reading <= 0)
|
||||||
return -96.329f + DBM0_MAX_POWER;
|
return -96.329f + DBM0_MAX_POWER;
|
||||||
/* This is based on A-law, but u-law is only 0.03dB different, so don't worry. */
|
/* This is based on A-law, but u-law is only 0.03dB different, so don't worry. */
|
||||||
return log10f((float) s->reading/(32767.0f*32767.0f))*10.0f + DBM0_MAX_POWER;
|
return 10.0f*log10f((float) s->reading/(32767.0f*32767.0f) + 1.0e-10f) + DBM0_MAX_POWER;
|
||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ SPAN_DECLARE(float) power_meter_current_dbov(power_meter_t *s)
|
|||||||
{
|
{
|
||||||
if (s->reading <= 0)
|
if (s->reading <= 0)
|
||||||
return -96.329f;
|
return -96.329f;
|
||||||
return log10f((float) s->reading/(32767.0f*32767.0f))*10.0f;
|
return 10.0f*log10f((float) s->reading/(32767.0f*32767.0f) + 1.0e-10f);
|
||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ SPAN_DECLARE(int) silence_gen_generated(silence_gen_state_t *s)
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) silence_gen_status_handler(silence_gen_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) silence_gen_status_handler(silence_gen_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -49,8 +49,18 @@ static __inline__ int32_t arctan2(float y, float x)
|
|||||||
float abs_y;
|
float abs_y;
|
||||||
float angle;
|
float angle;
|
||||||
|
|
||||||
if (x == 0.0f || y == 0.0f)
|
if (y == 0.0f)
|
||||||
return 0;
|
{
|
||||||
|
if (x < 0.0f)
|
||||||
|
return 0x80000000;
|
||||||
|
return 0x00000000;
|
||||||
|
}
|
||||||
|
if (x == 0.0f)
|
||||||
|
{
|
||||||
|
if (y < 0.0f)
|
||||||
|
return 0xc0000000;
|
||||||
|
return 0x40000000;
|
||||||
|
}
|
||||||
|
|
||||||
abs_y = fabsf(y);
|
abs_y = fabsf(y);
|
||||||
|
|
||||||
@@ -77,8 +87,18 @@ static __inline__ float arctan2f(float y, float x)
|
|||||||
float fx;
|
float fx;
|
||||||
float fy;
|
float fy;
|
||||||
|
|
||||||
if (x == 0.0f || y == 0.0f)
|
if (y == 0.0f)
|
||||||
return 0;
|
{
|
||||||
|
if (x < 0.0f)
|
||||||
|
return 3.1415926f;
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
if (x == 0.0f)
|
||||||
|
{
|
||||||
|
if (y < 0.0f)
|
||||||
|
return 3.1415926f*1.5f;
|
||||||
|
return 3.1415926f*0.5f;
|
||||||
|
}
|
||||||
fx = fabsf(x);
|
fx = fabsf(x);
|
||||||
fy = fabsf(y);
|
fy = fabsf(y);
|
||||||
/* Deal with the octants */
|
/* Deal with the octants */
|
||||||
|
|||||||
@@ -80,7 +80,13 @@ enum
|
|||||||
/*! \brief Notification that a modem has detected signal quality degradation. */
|
/*! \brief Notification that a modem has detected signal quality degradation. */
|
||||||
SIG_STATUS_POOR_SIGNAL_QUALITY = -12,
|
SIG_STATUS_POOR_SIGNAL_QUALITY = -12,
|
||||||
/*! \brief Notification that a modem retrain has occurred. */
|
/*! \brief Notification that a modem retrain has occurred. */
|
||||||
SIG_STATUS_MODEM_RETRAIN_OCCURRED = -13
|
SIG_STATUS_MODEM_RETRAIN_OCCURRED = -13,
|
||||||
|
/*! \brief The link protocol (e.g. V.42) has connected. */
|
||||||
|
SIG_STATUS_LINK_CONNECTED = -14,
|
||||||
|
/*! \brief The link protocol (e.g. V.42) has disconnected. */
|
||||||
|
SIG_STATUS_LINK_DISCONNECTED = -15,
|
||||||
|
/*! \brief An error has occurred in the link protocol (e.g. V.42). */
|
||||||
|
SIG_STATUS_LINK_ERROR = -16
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Message put function for data pumps */
|
/*! Message put function for data pumps */
|
||||||
@@ -101,11 +107,8 @@ typedef void (*put_bit_func_t)(void *user_data, int bit);
|
|||||||
/*! Bit get function for data pumps */
|
/*! Bit get function for data pumps */
|
||||||
typedef int (*get_bit_func_t)(void *user_data);
|
typedef int (*get_bit_func_t)(void *user_data);
|
||||||
|
|
||||||
/*! Completion callback function for tx data pumps */
|
/*! Status change callback function for data pumps */
|
||||||
typedef void (*modem_tx_status_func_t)(void *user_data, int status);
|
typedef void (*modem_status_func_t)(void *user_data, int status);
|
||||||
|
|
||||||
/*! Completion callback function for rx data pumps */
|
|
||||||
typedef void (*modem_rx_status_func_t)(void *user_data, int status);
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ SPAN_DECLARE(uint32_t) bit_reverse_4bytes(uint32_t data);
|
|||||||
SPAN_DECLARE(uint64_t) bit_reverse_8bytes(uint64_t data);
|
SPAN_DECLARE(uint64_t) bit_reverse_8bytes(uint64_t data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! \brief Bit reverse each bytes in a buffer.
|
/*! \brief Bit reverse each byte in a buffer.
|
||||||
\param to The buffer to place the reversed data in.
|
\param to The buffer to place the reversed data in.
|
||||||
\param from The buffer containing the data to be reversed.
|
\param from The buffer containing the data to be reversed.
|
||||||
\param len The length of the data in the buffer. */
|
\param len The length of the data in the buffer. */
|
||||||
|
|||||||
@@ -477,6 +477,12 @@ static __inline__ complexi32_t complex_conji32(const complexi32_t *x)
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
|
static __inline__ int32_t poweri16(const complexi16_t *x)
|
||||||
|
{
|
||||||
|
return (int32_t) x->re*x->re + (int32_t) x->im*x->im;
|
||||||
|
}
|
||||||
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
static __inline__ float powerf(const complexf_t *x)
|
static __inline__ float powerf(const complexf_t *x)
|
||||||
{
|
{
|
||||||
return x->re*x->re + x->im*x->im;
|
return x->re*x->re + x->im*x->im;
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ SPAN_DECLARE(void) fsk_tx_set_get_bit(fsk_tx_state_t *s, get_bit_func_t get_bit,
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) fsk_tx_set_modem_status_handler(fsk_tx_state_t *s, modem_tx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) fsk_tx_set_modem_status_handler(fsk_tx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Generate a block of FSK modem audio samples.
|
/*! Generate a block of FSK modem audio samples.
|
||||||
\brief Generate a block of FSK modem audio samples.
|
\brief Generate a block of FSK modem audio samples.
|
||||||
@@ -243,7 +243,7 @@ SPAN_DECLARE(void) fsk_rx_set_put_bit(fsk_rx_state_t *s, put_bit_func_t put_bit,
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) fsk_rx_set_modem_status_handler(fsk_rx_state_t *s, modem_rx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) fsk_rx_set_modem_status_handler(fsk_rx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ SPAN_DECLARE(void) hdlc_rx_set_frame_handler(hdlc_rx_state_t *s, hdlc_frame_hand
|
|||||||
\param handler The callback routine used to report status changes.
|
\param handler The callback routine used to report status changes.
|
||||||
\param user_data An opaque parameter for the callback routine.
|
\param user_data An opaque parameter for the callback routine.
|
||||||
*/
|
*/
|
||||||
SPAN_DECLARE(void) hdlc_rx_set_status_handler(hdlc_rx_state_t *s, modem_rx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) hdlc_rx_set_status_handler(hdlc_rx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Release an HDLC receiver context.
|
/*! Release an HDLC receiver context.
|
||||||
\brief Release an HDLC receiver context.
|
\brief Release an HDLC receiver context.
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct fsk_tx_state_s
|
|||||||
void *get_bit_user_data;
|
void *get_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_tx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ struct fsk_rx_state_s
|
|||||||
void *put_bit_user_data;
|
void *put_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_tx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ struct hdlc_rx_state_s
|
|||||||
/*! \brief An opaque parameter passed to the frame callback routine. */
|
/*! \brief An opaque parameter passed to the frame callback routine. */
|
||||||
void *frame_user_data;
|
void *frame_user_data;
|
||||||
/*! \brief The callback routine called to report status changes. */
|
/*! \brief The callback routine called to report status changes. */
|
||||||
modem_rx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief An opaque parameter passed to the status callback routine. */
|
/*! \brief An opaque parameter passed to the status callback routine. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
/*! \brief TRUE if bad frames are to be reported. */
|
/*! \brief TRUE if bad frames are to be reported. */
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
struct silence_gen_state_s
|
struct silence_gen_state_s
|
||||||
{
|
{
|
||||||
/*! \brief The callback function used to report status changes. */
|
/*! \brief The callback function used to report status changes. */
|
||||||
modem_tx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ struct v17_rx_state_s
|
|||||||
void *put_bit_user_data;
|
void *put_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_rx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ struct v17_tx_state_s
|
|||||||
void *get_bit_user_data;
|
void *get_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_tx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ struct v22bis_state_s
|
|||||||
/*! \brief A user specified opaque pointer passed to the put_bit callback routine. */
|
/*! \brief A user specified opaque pointer passed to the put_bit callback routine. */
|
||||||
void *put_bit_user_data;
|
void *put_bit_user_data;
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_rx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ struct v27ter_rx_state_s
|
|||||||
void *put_bit_user_data;
|
void *put_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_rx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct v27ter_tx_state_s
|
|||||||
void *get_bit_user_data;
|
void *get_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_tx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ struct v29_rx_state_s
|
|||||||
void *put_bit_user_data;
|
void *put_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_rx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct v29_tx_state_s
|
|||||||
void *get_bit_user_data;
|
void *get_bit_user_data;
|
||||||
|
|
||||||
/*! \brief The callback function used to report modem status changes. */
|
/*! \brief The callback function used to report modem status changes. */
|
||||||
modem_tx_status_func_t status_handler;
|
modem_status_func_t status_handler;
|
||||||
/*! \brief A user specified opaque pointer passed to the status function. */
|
/*! \brief A user specified opaque pointer passed to the status function. */
|
||||||
void *status_user_data;
|
void *status_user_data;
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ struct v29_tx_state_s
|
|||||||
int rrc_filter_step;
|
int rrc_filter_step;
|
||||||
|
|
||||||
/*! \brief The register for the data scrambler. */
|
/*! \brief The register for the data scrambler. */
|
||||||
unsigned int scramble_reg;
|
uint32_t scramble_reg;
|
||||||
/*! \brief The register for the training scrambler. */
|
/*! \brief The register for the training scrambler. */
|
||||||
uint8_t training_scramble_reg;
|
uint8_t training_scramble_reg;
|
||||||
/*! \brief TRUE if transmitting the training sequence, or shutting down transmission.
|
/*! \brief TRUE if transmitting the training sequence, or shutting down transmission.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Written by Steve Underwood <steveu@coppice.org>
|
* Written by Steve Underwood <steveu@coppice.org>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003 Steve Underwood
|
* Copyright (C) 2003, 2011 Steve Underwood
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -26,75 +26,94 @@
|
|||||||
#if !defined(_SPANDSP_PRIVATE_V42_H_)
|
#if !defined(_SPANDSP_PRIVATE_V42_H_)
|
||||||
#define _SPANDSP_PRIVATE_V42_H_
|
#define _SPANDSP_PRIVATE_V42_H_
|
||||||
|
|
||||||
|
/*! Max retries (9.2.2) */
|
||||||
|
#define V42_DEFAULT_N_400 5
|
||||||
|
/*! Default for max octets in an information field (9.2.3) */
|
||||||
|
#define V42_DEFAULT_N_401 128
|
||||||
|
/*! Maximum supported value for max octets in an information field */
|
||||||
|
#define V42_MAX_N_401 128
|
||||||
|
/*! Default window size (k) (9.2.4) */
|
||||||
|
#define V42_DEFAULT_WINDOW_SIZE_K 15
|
||||||
|
/*! Maximum supported window size (k) */
|
||||||
|
#define V42_MAX_WINDOW_SIZE_K 15
|
||||||
|
|
||||||
|
/*! The number of info frames to allocate */
|
||||||
|
#define V42_INFO_FRAMES (V42_MAX_WINDOW_SIZE_K + 1)
|
||||||
|
/*! The number of control frames to allocate */
|
||||||
|
#define V42_CTRL_FRAMES 8
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* V.42 LAP.M parameters */
|
||||||
|
uint8_t v42_tx_window_size_k;
|
||||||
|
uint8_t v42_rx_window_size_k;
|
||||||
|
uint16_t v42_tx_n401;
|
||||||
|
uint16_t v42_rx_n401;
|
||||||
|
|
||||||
|
/* V.42bis compressor parameters */
|
||||||
|
uint8_t comp;
|
||||||
|
int comp_dict_size;
|
||||||
|
int comp_max_string;
|
||||||
|
} v42_config_parameters_t;
|
||||||
|
|
||||||
|
typedef struct frame_s
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
uint8_t buf[4 + V42_MAX_N_401];
|
||||||
|
} v42_frame_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
LAP-M descriptor. This defines the working state for a single instance of LAP-M.
|
LAP-M descriptor. This defines the working state for a single instance of LAP-M.
|
||||||
*/
|
*/
|
||||||
struct lapm_state_s
|
typedef struct
|
||||||
{
|
{
|
||||||
int handle;
|
get_msg_func_t iframe_get;
|
||||||
|
void *iframe_get_user_data;
|
||||||
|
|
||||||
|
put_msg_func_t iframe_put;
|
||||||
|
void *iframe_put_user_data;
|
||||||
|
|
||||||
|
modem_status_func_t status_handler;
|
||||||
|
void *status_user_data;
|
||||||
|
|
||||||
hdlc_rx_state_t hdlc_rx;
|
hdlc_rx_state_t hdlc_rx;
|
||||||
hdlc_tx_state_t hdlc_tx;
|
hdlc_tx_state_t hdlc_tx;
|
||||||
|
|
||||||
v42_frame_handler_t iframe_receive;
|
|
||||||
void *iframe_receive_user_data;
|
|
||||||
|
|
||||||
v42_status_func_t status_callback;
|
/*! Negotiated values for the window and maximum info sizes */
|
||||||
void *status_callback_user_data;
|
uint8_t tx_window_size_k;
|
||||||
|
uint8_t rx_window_size_k;
|
||||||
|
uint16_t tx_n401;
|
||||||
|
uint16_t rx_n401;
|
||||||
|
|
||||||
|
uint8_t cmd_addr;
|
||||||
|
uint8_t rsp_addr;
|
||||||
|
uint8_t vs;
|
||||||
|
uint8_t va;
|
||||||
|
uint8_t vr;
|
||||||
int state;
|
int state;
|
||||||
int tx_waiting;
|
int configuring;
|
||||||
int debug;
|
int local_busy;
|
||||||
/*! TRUE if originator. FALSE if answerer */
|
int far_busy;
|
||||||
int we_are_originator;
|
int rejected;
|
||||||
/*! Remote network type (unknown, answerer. originator) */
|
int retry_count;
|
||||||
int peer_is_originator;
|
|
||||||
/*! Next N(S) for transmission */
|
|
||||||
int next_tx_frame;
|
|
||||||
/*! The last of our frames which the peer acknowledged */
|
|
||||||
int last_frame_peer_acknowledged;
|
|
||||||
/*! Next N(R) for reception */
|
|
||||||
int next_expected_frame;
|
|
||||||
/*! The last of the peer's frames which we acknowledged */
|
|
||||||
int last_frame_we_acknowledged;
|
|
||||||
/*! TRUE if we sent an I or S frame with the F-bit set */
|
|
||||||
int solicit_f_bit;
|
|
||||||
/*! Retransmission count */
|
|
||||||
int retransmissions;
|
|
||||||
/*! TRUE if peer is busy */
|
|
||||||
int busy;
|
|
||||||
|
|
||||||
/*! Acknowledgement timer */
|
/* The control frame buffer, and its pointers */
|
||||||
int t401_timer;
|
int ctrl_put;
|
||||||
/*! Reply delay timer - optional */
|
int ctrl_get;
|
||||||
int t402_timer;
|
v42_frame_t ctrl_buf[V42_CTRL_FRAMES];
|
||||||
/*! Inactivity timer - optional */
|
|
||||||
int t403_timer;
|
|
||||||
/*! Maximum number of octets in an information field */
|
|
||||||
int n401;
|
|
||||||
/*! Window size */
|
|
||||||
int window_size_k;
|
|
||||||
|
|
||||||
lapm_frame_queue_t *txqueue;
|
|
||||||
lapm_frame_queue_t *tx_next;
|
|
||||||
lapm_frame_queue_t *tx_last;
|
|
||||||
queue_state_t *tx_queue;
|
|
||||||
|
|
||||||
span_sched_state_t sched;
|
|
||||||
/*! \brief Error and flow logging control */
|
|
||||||
logging_state_t logging;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/* The info frame buffer, and its pointers */
|
||||||
V.42 descriptor. This defines the working state for a single instance of V.42.
|
int info_put;
|
||||||
*/
|
int info_get;
|
||||||
struct v42_state_s
|
int info_acked;
|
||||||
|
v42_frame_t info_buf[V42_INFO_FRAMES];
|
||||||
|
|
||||||
|
void (*packer_process)(v42_state_t *m, int bits);
|
||||||
|
} lapm_state_t;
|
||||||
|
|
||||||
|
/*! V.42 support negotiation parameters */
|
||||||
|
typedef struct
|
||||||
{
|
{
|
||||||
/*! TRUE if we are the calling party, otherwise FALSE */
|
|
||||||
int calling_party;
|
|
||||||
/*! TRUE if we should detect whether the far end is V.42 capable. FALSE if we go
|
|
||||||
directly to protocol establishment */
|
|
||||||
int detect;
|
|
||||||
|
|
||||||
/*! Stage in negotiating V.42 support */
|
/*! Stage in negotiating V.42 support */
|
||||||
int rx_negotiation_step;
|
int rx_negotiation_step;
|
||||||
int rxbits;
|
int rxbits;
|
||||||
@@ -104,11 +123,30 @@ struct v42_state_s
|
|||||||
int txbits;
|
int txbits;
|
||||||
int txstream;
|
int txstream;
|
||||||
int txadps;
|
int txadps;
|
||||||
/*! The LAP.M context */
|
} v42_negotiation_t;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
V.42 descriptor. This defines the working state for a single
|
||||||
|
instance of a V.42 error corrector.
|
||||||
|
*/
|
||||||
|
struct v42_state_s
|
||||||
|
{
|
||||||
|
/*! TRUE if we are the calling party, otherwise FALSE. */
|
||||||
|
int calling_party;
|
||||||
|
/*! TRUE if we should detect whether the far end is V.42 capable. FALSE if we go
|
||||||
|
directly to protocol establishment. */
|
||||||
|
int detect;
|
||||||
|
|
||||||
|
/*! The bit rate, used to time events */
|
||||||
|
int tx_bit_rate;
|
||||||
|
|
||||||
|
v42_config_parameters_t config;
|
||||||
|
v42_negotiation_t neg;
|
||||||
lapm_state_t lapm;
|
lapm_state_t lapm;
|
||||||
|
|
||||||
/*! V.42 support detection timer */
|
int bit_timer;
|
||||||
int t400_timer;
|
void (*bit_timer_func)(v42_state_t *m);
|
||||||
|
|
||||||
/*! \brief Error and flow logging control */
|
/*! \brief Error and flow logging control */
|
||||||
logging_state_t logging;
|
logging_state_t logging;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,100 +28,85 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
V.42bis dictionary node.
|
V.42bis dictionary node.
|
||||||
|
Note that 0 is not a valid node to point to (0 is always a control code), so 0 is used
|
||||||
|
as a "no such value" marker in this structure.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/*! \brief The prior code for each defined code. */
|
/*! \brief The value of the octet represented by the current dictionary node */
|
||||||
uint16_t parent_code;
|
|
||||||
/*! \brief The number of leaf nodes this node has */
|
|
||||||
int16_t leaves;
|
|
||||||
/*! \brief This leaf octet for each defined code. */
|
|
||||||
uint8_t node_octet;
|
uint8_t node_octet;
|
||||||
/*! \brief Bit map of the children which exist */
|
/*! \brief The parent of this node */
|
||||||
uint32_t children[8];
|
uint16_t parent;
|
||||||
|
/*! \brief The first child of this node */
|
||||||
|
uint16_t child;
|
||||||
|
/*! \brief The next node at the same depth */
|
||||||
|
uint16_t next;
|
||||||
} v42bis_dict_node_t;
|
} v42bis_dict_node_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
V.42bis compression. This defines the working state for a single instance
|
V.42bis compression or decompression. This defines the working state for a single instance
|
||||||
of V.42bis compression.
|
of V.42bis compression or decompression.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
/*! \brief Compression enabled. */
|
||||||
|
int v42bis_parm_p0;
|
||||||
/*! \brief Compression mode. */
|
/*! \brief Compression mode. */
|
||||||
int compression_mode;
|
int compression_mode;
|
||||||
/*! \brief Callback function to handle received frames. */
|
/*! \brief Callback function to handle output data. */
|
||||||
v42bis_frame_handler_t handler;
|
put_msg_func_t handler;
|
||||||
/*! \brief An opaque pointer passed in calls to frame_handler. */
|
/*! \brief An opaque pointer passed in calls to the data handler. */
|
||||||
void *user_data;
|
void *user_data;
|
||||||
/*! \brief The maximum frame length allowed */
|
/*! \brief The maximum amount to be passed to the data handler. */
|
||||||
int max_len;
|
int max_output_len;
|
||||||
|
|
||||||
uint32_t string_code;
|
/*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */
|
||||||
uint32_t latest_code;
|
int transparent;
|
||||||
|
/*! \brief Next empty dictionary entry */
|
||||||
|
uint16_t v42bis_parm_c1;
|
||||||
|
/*! \brief Current codeword size */
|
||||||
|
uint16_t v42bis_parm_c2;
|
||||||
|
/*! \brief Threshold for codeword size change */
|
||||||
|
uint16_t v42bis_parm_c3;
|
||||||
|
/*! \brief The current update point in the dictionary */
|
||||||
|
uint16_t update_at;
|
||||||
|
/*! \brief The last entry matched in the dictionary */
|
||||||
|
uint16_t last_matched;
|
||||||
|
/*! \brief The last entry added to the dictionary */
|
||||||
|
uint16_t last_added;
|
||||||
|
/*! \brief Total number of codewords in the dictionary */
|
||||||
|
int v42bis_parm_n2;
|
||||||
|
/*! \brief Maximum permitted string length */
|
||||||
|
int v42bis_parm_n7;
|
||||||
|
/*! \brief The dictionary */
|
||||||
|
v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS];
|
||||||
|
|
||||||
|
/*! \brief The octet string in progress */
|
||||||
|
uint8_t string[V42BIS_MAX_STRING_SIZE];
|
||||||
|
/*! \brief The current length of the octet string in progress */
|
||||||
int string_length;
|
int string_length;
|
||||||
uint32_t output_bit_buffer;
|
/*! \brief The amount of the octet string in progress which has already
|
||||||
int output_bit_count;
|
been flushed out of the buffer */
|
||||||
|
int flushed_length;
|
||||||
|
|
||||||
|
/*! \brief Compression performance metric */
|
||||||
|
uint16_t compression_performance;
|
||||||
|
|
||||||
|
/*! \brief Outgoing bit buffer (compression), or incoming bit buffer (decompression) */
|
||||||
|
uint32_t bit_buffer;
|
||||||
|
/*! \brief Outgoing bit count (compression), or incoming bit count (decompression) */
|
||||||
|
int bit_count;
|
||||||
|
|
||||||
|
/*! \brief The output composition buffer */
|
||||||
|
uint8_t output_buf[V42BIS_MAX_OUTPUT_LENGTH];
|
||||||
|
/*! \brief The length of the contents of the output composition buffer */
|
||||||
int output_octet_count;
|
int output_octet_count;
|
||||||
uint8_t output_buf[1024];
|
|
||||||
v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS];
|
|
||||||
/*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */
|
|
||||||
int transparent;
|
|
||||||
int change_transparency;
|
|
||||||
/*! \brief IIR filter state, used in assessing compressibility. */
|
|
||||||
int compressibility_filter;
|
|
||||||
int compressibility_persistence;
|
|
||||||
|
|
||||||
/*! \brief Next empty dictionary entry */
|
|
||||||
uint32_t v42bis_parm_c1;
|
|
||||||
/*! \brief Current codeword size */
|
|
||||||
int v42bis_parm_c2;
|
|
||||||
/*! \brief Threshold for codeword size change */
|
|
||||||
uint32_t v42bis_parm_c3;
|
|
||||||
|
|
||||||
/*! \brief Mark that this is the first octet/code to be processed */
|
/*! \brief The current value of the escape code */
|
||||||
int first;
|
|
||||||
uint8_t escape_code;
|
|
||||||
} v42bis_compress_state_t;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
V.42bis decompression. This defines the working state for a single instance
|
|
||||||
of V.42bis decompression.
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
/*! \brief Callback function to handle decompressed data. */
|
|
||||||
v42bis_data_handler_t handler;
|
|
||||||
/*! \brief An opaque pointer passed in calls to data_handler. */
|
|
||||||
void *user_data;
|
|
||||||
/*! \brief The maximum decompressed data block length allowed */
|
|
||||||
int max_len;
|
|
||||||
|
|
||||||
uint32_t old_code;
|
|
||||||
uint32_t last_old_code;
|
|
||||||
uint32_t input_bit_buffer;
|
|
||||||
int input_bit_count;
|
|
||||||
int octet;
|
|
||||||
int last_length;
|
|
||||||
int output_octet_count;
|
|
||||||
uint8_t output_buf[1024];
|
|
||||||
v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS];
|
|
||||||
/*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */
|
|
||||||
int transparent;
|
|
||||||
|
|
||||||
int last_extra_octet;
|
|
||||||
|
|
||||||
/*! \brief Next empty dictionary entry */
|
|
||||||
uint32_t v42bis_parm_c1;
|
|
||||||
/*! \brief Current codeword size */
|
|
||||||
int v42bis_parm_c2;
|
|
||||||
/*! \brief Threshold for codeword size change */
|
|
||||||
uint32_t v42bis_parm_c3;
|
|
||||||
|
|
||||||
/*! \brief Mark that this is the first octet/code to be processed */
|
|
||||||
int first;
|
|
||||||
uint8_t escape_code;
|
uint8_t escape_code;
|
||||||
|
/*! \brief TRUE if we just hit an escape code, and are waiting for the following octet */
|
||||||
int escaped;
|
int escaped;
|
||||||
} v42bis_decompress_state_t;
|
} v42bis_comp_state_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
V.42bis compression/decompression descriptor. This defines the working state for a
|
V.42bis compression/decompression descriptor. This defines the working state for a
|
||||||
@@ -129,20 +114,13 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
struct v42bis_state_s
|
struct v42bis_state_s
|
||||||
{
|
{
|
||||||
/*! \brief V.42bis data compression directions. */
|
|
||||||
int v42bis_parm_p0;
|
|
||||||
|
|
||||||
/*! \brief Compression state. */
|
/*! \brief Compression state. */
|
||||||
v42bis_compress_state_t compress;
|
v42bis_comp_state_t compress;
|
||||||
/*! \brief Decompression state. */
|
/*! \brief Decompression state. */
|
||||||
v42bis_decompress_state_t decompress;
|
v42bis_comp_state_t decompress;
|
||||||
|
|
||||||
/*! \brief Maximum codeword size (bits) */
|
/*! \brief Error and flow logging control */
|
||||||
int v42bis_parm_n1;
|
logging_state_t logging;
|
||||||
/*! \brief Total number of codewords */
|
|
||||||
uint32_t v42bis_parm_n2;
|
|
||||||
/*! \brief Maximum string length */
|
|
||||||
int v42bis_parm_n7;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ SPAN_DECLARE(int) silence_gen_generated(silence_gen_state_t *s);
|
|||||||
\param s The silence generator context.
|
\param s The silence generator context.
|
||||||
\param handler The callback routine used to report status changes.
|
\param handler The callback routine used to report status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) silence_gen_status_handler(silence_gen_state_t *s, modem_tx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) silence_gen_status_handler(silence_gen_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Initialise a timed silence generator context.
|
/*! Initialise a timed silence generator context.
|
||||||
\brief Initialise a timed silence generator context.
|
\brief Initialise a timed silence generator context.
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ enum
|
|||||||
T30_ERR_RX_GOTDCS, /*! DCS received while waiting for DTC */
|
T30_ERR_RX_GOTDCS, /*! DCS received while waiting for DTC */
|
||||||
T30_ERR_RX_INVALCMD, /*! Unexpected command after page received */
|
T30_ERR_RX_INVALCMD, /*! Unexpected command after page received */
|
||||||
T30_ERR_RX_NOCARRIER, /*! Carrier lost during fax receive */
|
T30_ERR_RX_NOCARRIER, /*! Carrier lost during fax receive */
|
||||||
T30_ERR_RX_NOEOL, /*! Timed out while waiting for EOL (end Of line) */
|
T30_ERR_RX_NOEOL, /*! Timed out while waiting for EOL (end of line) */
|
||||||
T30_ERR_RX_NOFAX, /*! Timed out while waiting for first line */
|
T30_ERR_RX_NOFAX, /*! Timed out while waiting for first line */
|
||||||
T30_ERR_RX_T2EXPDCN, /*! Timer T2 expired while waiting for DCN */
|
T30_ERR_RX_T2EXPDCN, /*! Timer T2 expired while waiting for DCN */
|
||||||
T30_ERR_RX_T2EXPD, /*! Timer T2 expired while waiting for phase D */
|
T30_ERR_RX_T2EXPD, /*! Timer T2 expired while waiting for phase D */
|
||||||
|
|||||||
@@ -77,6 +77,27 @@ typedef int (span_tx_handler_t)(void *s, int16_t amp[], int max_len);
|
|||||||
#define TRUE (!FALSE)
|
#define TRUE (!FALSE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Fixed point constant macros */
|
||||||
|
#define FP_Q_9_7(x) ((int16_t) (128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_8_8(x) ((int16_t) (256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_7_9(x) ((int16_t) (512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_6_10(x) ((int16_t) (1024.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_5_11(x) ((int16_t) (2048.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_4_12(x) ((int16_t) (4096.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_3_13(x) ((int16_t) (8192.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_2_14(x) ((int16_t) (16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_1_15(x) ((int16_t) (32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
|
||||||
|
#define FP_Q_9_23(x) ((int32_t) (65536.0*128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_8_24(x) ((int32_t) (65536.0*256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_7_25(x) ((int32_t) (65536.0*512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_6_26(x) ((int32_t) (65536.0*1024.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_5_27(x) ((int32_t) (65536.0*2048.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_4_28(x) ((int32_t) (65536.0*4096.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_3_29(x) ((int32_t) (65536.0*8192.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_2_30(x) ((int32_t) (65536.0*16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
#define FP_Q_1_31(x) ((int32_t) (65536.0*32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
/* C++ doesn't seem to have sane rounding functions/macros yet */
|
/* C++ doesn't seem to have sane rounding functions/macros yet */
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ SPAN_DECLARE(void) v17_rx_set_put_bit(v17_rx_state_t *s, put_bit_func_t put_bit,
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) v17_rx_set_modem_status_handler(v17_rx_state_t *s, modem_rx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) v17_rx_set_modem_status_handler(v17_rx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Process a block of received V.17 modem audio samples.
|
/*! Process a block of received V.17 modem audio samples.
|
||||||
\brief Process a block of received V.17 modem audio samples.
|
\brief Process a block of received V.17 modem audio samples.
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ SPAN_DECLARE(void) v17_tx_set_get_bit(v17_tx_state_t *s, get_bit_func_t get_bit,
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) v17_tx_set_modem_status_handler(v17_tx_state_t *s, modem_tx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) v17_tx_set_modem_status_handler(v17_tx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Generate a block of V.17 modem audio samples.
|
/*! Generate a block of V.17 modem audio samples.
|
||||||
\brief Generate a block of V.17 modem audio samples.
|
\brief Generate a block of V.17 modem audio samples.
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ SPAN_DECLARE(void) v22bis_set_put_bit(v22bis_state_t *s, put_bit_func_t put_bit,
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) v22bis_set_modem_status_handler(v22bis_state_t *s, modem_rx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) v22bis_set_modem_status_handler(v22bis_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ SPAN_DECLARE(void) v27ter_rx_set_put_bit(v27ter_rx_state_t *s, put_bit_func_t pu
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) v27ter_rx_set_modem_status_handler(v27ter_rx_state_t *s, modem_rx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) v27ter_rx_set_modem_status_handler(v27ter_rx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Process a block of received V.27ter modem audio samples.
|
/*! Process a block of received V.27ter modem audio samples.
|
||||||
\brief Process a block of received V.27ter modem audio samples.
|
\brief Process a block of received V.27ter modem audio samples.
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ SPAN_DECLARE(void) v27ter_tx_set_get_bit(v27ter_tx_state_t *s, get_bit_func_t ge
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) v27ter_tx_set_modem_status_handler(v27ter_tx_state_t *s, modem_tx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) v27ter_tx_set_modem_status_handler(v27ter_tx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Generate a block of V.27ter modem audio samples.
|
/*! Generate a block of V.27ter modem audio samples.
|
||||||
\brief Generate a block of V.27ter modem audio samples.
|
\brief Generate a block of V.27ter modem audio samples.
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ SPAN_DECLARE(void) v29_rx_set_put_bit(v29_rx_state_t *s, put_bit_func_t put_bit,
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) v29_rx_set_modem_status_handler(v29_rx_state_t *s, modem_rx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) v29_rx_set_modem_status_handler(v29_rx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Process a block of received V.29 modem audio samples.
|
/*! Process a block of received V.29 modem audio samples.
|
||||||
\brief Process a block of received V.29 modem audio samples.
|
\brief Process a block of received V.29 modem audio samples.
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ SPAN_DECLARE(void) v29_tx_set_get_bit(v29_tx_state_t *s, get_bit_func_t get_bit,
|
|||||||
\param s The modem context.
|
\param s The modem context.
|
||||||
\param handler The callback routine used to report modem status changes.
|
\param handler The callback routine used to report modem status changes.
|
||||||
\param user_data An opaque pointer. */
|
\param user_data An opaque pointer. */
|
||||||
SPAN_DECLARE(void) v29_tx_set_modem_status_handler(v29_tx_state_t *s, modem_tx_status_func_t handler, void *user_data);
|
SPAN_DECLARE(void) v29_tx_set_modem_status_handler(v29_tx_state_t *s, modem_status_func_t handler, void *user_data);
|
||||||
|
|
||||||
/*! Generate a block of V.29 modem audio samples.
|
/*! Generate a block of V.29 modem audio samples.
|
||||||
\brief Generate a block of V.29 modem audio samples.
|
\brief Generate a block of V.29 modem audio samples.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Written by Steve Underwood <steveu@coppice.org>
|
* Written by Steve Underwood <steveu@coppice.org>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003 Steve Underwood
|
* Copyright (C) 2003, 2011 Steve Underwood
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -36,45 +36,8 @@ far modem supports V.42 is also defined.
|
|||||||
#if !defined(_SPANDSP_V42_H_)
|
#if !defined(_SPANDSP_V42_H_)
|
||||||
#define _SPANDSP_V42_H_
|
#define _SPANDSP_V42_H_
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
LAPM_DETECT = 0,
|
|
||||||
LAPM_ESTABLISH = 1,
|
|
||||||
LAPM_DATA = 2,
|
|
||||||
LAPM_RELEASE = 3,
|
|
||||||
LAPM_SIGNAL = 4,
|
|
||||||
LAPM_SETPARM = 5,
|
|
||||||
LAPM_TEST = 6,
|
|
||||||
LAPM_UNSUPPORTED = 7
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void (*v42_status_func_t)(void *user_data, int status);
|
|
||||||
typedef void (*v42_frame_handler_t)(void *user_data, const uint8_t *pkt, int len);
|
|
||||||
|
|
||||||
typedef struct lapm_frame_queue_s
|
|
||||||
{
|
|
||||||
struct lapm_frame_queue_s *next;
|
|
||||||
int len;
|
|
||||||
uint8_t frame[];
|
|
||||||
} lapm_frame_queue_t;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
LAP-M descriptor. This defines the working state for a single instance of LAP-M.
|
|
||||||
*/
|
|
||||||
typedef struct lapm_state_s lapm_state_t;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
V.42 descriptor. This defines the working state for a single instance of V.42.
|
|
||||||
*/
|
|
||||||
typedef struct v42_state_s v42_state_t;
|
typedef struct v42_state_s v42_state_t;
|
||||||
|
|
||||||
/*! Log the raw HDLC frames */
|
|
||||||
#define LAPM_DEBUG_LAPM_RAW (1 << 0)
|
|
||||||
/*! Log the interpreted frames */
|
|
||||||
#define LAPM_DEBUG_LAPM_DUMP (1 << 1)
|
|
||||||
/*! Log state machine changes */
|
|
||||||
#define LAPM_DEBUG_LAPM_STATE (1 << 2)
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@@ -82,58 +45,46 @@ extern "C"
|
|||||||
|
|
||||||
SPAN_DECLARE(const char *) lapm_status_to_str(int status);
|
SPAN_DECLARE(const char *) lapm_status_to_str(int status);
|
||||||
|
|
||||||
/*! Dump LAP.M frames in a raw and/or decoded forms
|
SPAN_DECLARE_NONSTD(void) lapm_receive(void *user_data, const uint8_t *frame, int len, int ok);
|
||||||
\param frame The frame itself
|
|
||||||
\param len The length of the frame, in octets
|
|
||||||
\param showraw TRUE if the raw octets should be dumped
|
|
||||||
\param txrx TRUE if tx, FALSE if rx. Used to highlight the packet's direction.
|
|
||||||
*/
|
|
||||||
SPAN_DECLARE(void) lapm_dump(lapm_state_t *s, const uint8_t *frame, int len, int showraw, int txrx);
|
|
||||||
|
|
||||||
/*! Accept an HDLC packet
|
SPAN_DECLARE(void) v42_start(v42_state_t *s);
|
||||||
*/
|
|
||||||
SPAN_DECLARE_NONSTD(void) lapm_receive(void *user_data, const uint8_t *buf, int len, int ok);
|
|
||||||
|
|
||||||
/*! Transmit a LAP.M frame
|
SPAN_DECLARE(void) v42_stop(v42_state_t *s);
|
||||||
*/
|
|
||||||
SPAN_DECLARE(int) lapm_tx(lapm_state_t *s, const void *buf, int len);
|
|
||||||
|
|
||||||
/*! Transmit a LAP.M information frame
|
/*! Set the busy status of the local end of a V.42 context.
|
||||||
|
\param s The V.42 context.
|
||||||
|
\param busy The new local end busy status.
|
||||||
|
\return The previous local end busy status.
|
||||||
*/
|
*/
|
||||||
SPAN_DECLARE(int) lapm_tx_iframe(lapm_state_t *s, const void *buf, int len, int cr);
|
SPAN_DECLARE(int) v42_set_local_busy_status(v42_state_t *s, int busy);
|
||||||
|
|
||||||
/*! Send a break over a LAP.M connection
|
/*! Get the busy status of the far end of a V.42 context.
|
||||||
|
\param s The V.42 context.
|
||||||
|
\return The far end busy status.
|
||||||
*/
|
*/
|
||||||
SPAN_DECLARE(int) lapm_break(lapm_state_t *s, int enable);
|
SPAN_DECLARE(int) v42_get_far_busy_status(v42_state_t *s);
|
||||||
|
|
||||||
/*! Initiate an orderly release of a LAP.M connection
|
|
||||||
*/
|
|
||||||
SPAN_DECLARE(int) lapm_release(lapm_state_t *s);
|
|
||||||
|
|
||||||
/*! Enable or disable loopback of a LAP.M connection
|
|
||||||
*/
|
|
||||||
SPAN_DECLARE(int) lapm_loopback(lapm_state_t *s, int enable);
|
|
||||||
|
|
||||||
/*! Assign or remove a callback routine used to deal with V.42 status changes.
|
|
||||||
*/
|
|
||||||
SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, v42_status_func_t callback, void *user_data);
|
|
||||||
|
|
||||||
/*! Process a newly received bit for a V.42 context.
|
|
||||||
*/
|
|
||||||
SPAN_DECLARE(void) v42_rx_bit(void *user_data, int bit);
|
SPAN_DECLARE(void) v42_rx_bit(void *user_data, int bit);
|
||||||
|
|
||||||
/*! Get the next transmit bit for a V.42 context.
|
|
||||||
*/
|
|
||||||
SPAN_DECLARE(int) v42_tx_bit(void *user_data);
|
SPAN_DECLARE(int) v42_tx_bit(void *user_data);
|
||||||
|
|
||||||
|
SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, modem_status_func_t callback, void *user_data);
|
||||||
|
|
||||||
/*! Initialise a V.42 context.
|
/*! Initialise a V.42 context.
|
||||||
\param s The V.42 context.
|
\param s The V.42 context.
|
||||||
\param calling_party TRUE if caller mode, else answerer mode.
|
\param calling_party TRUE if caller mode, else answerer mode.
|
||||||
\param frame_handler A callback function to handle received frames of data.
|
\param detect TRUE to perform the V.42 detection, else go straight into LAP.M
|
||||||
\param user_data An opaque pointer passed to the frame handler routine.
|
\param iframe_get A callback function to handle received frames of data.
|
||||||
|
\param iframe_put A callback function to get frames of data for transmission.
|
||||||
|
\param user_data An opaque pointer passed to the frame handler routines.
|
||||||
\return ???
|
\return ???
|
||||||
*/
|
*/
|
||||||
SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, int calling_party, int detect, v42_frame_handler_t frame_handler, void *user_data);
|
SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s,
|
||||||
|
int calling_party,
|
||||||
|
int detect,
|
||||||
|
get_msg_func_t iframe_get,
|
||||||
|
put_msg_func_t iframe_put,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
/*! Restart a V.42 context.
|
/*! Restart a V.42 context.
|
||||||
\param s The V.42 context.
|
\param s The V.42 context.
|
||||||
@@ -143,12 +94,12 @@ SPAN_DECLARE(void) v42_restart(v42_state_t *s);
|
|||||||
/*! Release a V.42 context.
|
/*! Release a V.42 context.
|
||||||
\param s The V.42 context.
|
\param s The V.42 context.
|
||||||
\return 0 if OK */
|
\return 0 if OK */
|
||||||
SPAN_DECLARE(int) v42_release(v42_state_t *s);
|
SPAN_DECLARE(void) v42_release(v42_state_t *s);
|
||||||
|
|
||||||
/*! Free a V.42 context.
|
/*! Free a V.42 context.
|
||||||
\param s The V.42 context.
|
\param s The V.42 context.
|
||||||
\return 0 if OK */
|
\return 0 if OK */
|
||||||
SPAN_DECLARE(int) v42_free(v42_state_t *s);
|
SPAN_DECLARE(void) v42_free(v42_state_t *s);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Written by Steve Underwood <steveu@coppice.org>
|
* Written by Steve Underwood <steveu@coppice.org>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 Steve Underwood
|
* Copyright (C) 2005, 2011 Steve Underwood
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -39,7 +39,7 @@ conjunction with the error correction scheme defined in V.42.
|
|||||||
#define V42BIS_MIN_DICTIONARY_SIZE 512
|
#define V42BIS_MIN_DICTIONARY_SIZE 512
|
||||||
#define V42BIS_MAX_BITS 12
|
#define V42BIS_MAX_BITS 12
|
||||||
#define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */
|
#define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */
|
||||||
#define V42BIS_TABLE_SIZE 5021 /* This should be a prime >(2^V42BIS_MAX_BITS) */
|
#define V42BIS_MAX_OUTPUT_LENGTH 1024
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -56,9 +56,6 @@ enum
|
|||||||
V42BIS_COMPRESSION_MODE_NEVER
|
V42BIS_COMPRESSION_MODE_NEVER
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*v42bis_frame_handler_t)(void *user_data, const uint8_t *pkt, int len);
|
|
||||||
typedef void (*v42bis_data_handler_t)(void *user_data, const uint8_t *buf, int len);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
V.42bis compression/decompression descriptor. This defines the working state for a
|
V.42bis compression/decompression descriptor. This defines the working state for a
|
||||||
single instance of V.42bis compress/decompression.
|
single instance of V.42bis compress/decompression.
|
||||||
@@ -75,7 +72,7 @@ extern "C"
|
|||||||
\param buf The data to be compressed.
|
\param buf The data to be compressed.
|
||||||
\param len The length of the data buffer.
|
\param len The length of the data buffer.
|
||||||
\return 0 */
|
\return 0 */
|
||||||
SPAN_DECLARE(int) v42bis_compress(v42bis_state_t *s, const uint8_t *buf, int len);
|
SPAN_DECLARE(int) v42bis_compress(v42bis_state_t *s, const uint8_t buf[], int len);
|
||||||
|
|
||||||
/*! Flush out any data remaining in a compression buffer.
|
/*! Flush out any data remaining in a compression buffer.
|
||||||
\param s The V.42bis context.
|
\param s The V.42bis context.
|
||||||
@@ -87,7 +84,7 @@ SPAN_DECLARE(int) v42bis_compress_flush(v42bis_state_t *s);
|
|||||||
\param buf The data to be decompressed.
|
\param buf The data to be decompressed.
|
||||||
\param len The length of the data buffer.
|
\param len The length of the data buffer.
|
||||||
\return 0 */
|
\return 0 */
|
||||||
SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *s, const uint8_t *buf, int len);
|
SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *s, const uint8_t buf[], int len);
|
||||||
|
|
||||||
/*! Flush out any data remaining in the decompression buffer.
|
/*! Flush out any data remaining in the decompression buffer.
|
||||||
\param s The V.42bis context.
|
\param s The V.42bis context.
|
||||||
@@ -107,23 +104,23 @@ SPAN_DECLARE(void) v42bis_compression_control(v42bis_state_t *s, int mode);
|
|||||||
\param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec.
|
\param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec.
|
||||||
\param negotiated_p1 The negotiated P1 parameter, from the V.42bis spec.
|
\param negotiated_p1 The negotiated P1 parameter, from the V.42bis spec.
|
||||||
\param negotiated_p2 The negotiated P2 parameter, from the V.42bis spec.
|
\param negotiated_p2 The negotiated P2 parameter, from the V.42bis spec.
|
||||||
\param frame_handler Frame callback handler.
|
\param encode_handler Encode callback handler.
|
||||||
\param frame_user_data An opaque pointer passed to the frame callback handler.
|
\param encode_user_data An opaque pointer passed to the encode callback handler.
|
||||||
\param max_frame_len The maximum length that should be passed to the frame handler.
|
\param max_encode_len The maximum length that should be passed to the encode handler.
|
||||||
\param data_handler data callback handler.
|
\param decode_handler Decode callback handler.
|
||||||
\param data_user_data An opaque pointer passed to the data callback handler.
|
\param decode_user_data An opaque pointer passed to the decode callback handler.
|
||||||
\param max_data_len The maximum length that should be passed to the data handler.
|
\param max_decode_len The maximum length that should be passed to the decode handler.
|
||||||
\return The V.42bis context. */
|
\return The V.42bis context. */
|
||||||
SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s,
|
SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s,
|
||||||
int negotiated_p0,
|
int negotiated_p0,
|
||||||
int negotiated_p1,
|
int negotiated_p1,
|
||||||
int negotiated_p2,
|
int negotiated_p2,
|
||||||
v42bis_frame_handler_t frame_handler,
|
put_msg_func_t encode_handler,
|
||||||
void *frame_user_data,
|
void *encode_user_data,
|
||||||
int max_frame_len,
|
int max_encode_len,
|
||||||
v42bis_data_handler_t data_handler,
|
put_msg_func_t decode_handler,
|
||||||
void *data_user_data,
|
void *decode_user_data,
|
||||||
int max_data_len);
|
int max_decode_len);
|
||||||
|
|
||||||
/*! Release a V.42bis context.
|
/*! Release a V.42bis context.
|
||||||
\param s The V.42bis context.
|
\param s The V.42bis context.
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ static const int year_lengths[2] =
|
|||||||
|
|
||||||
static int increment_overflow(int *number, int delta)
|
static int increment_overflow(int *number, int delta)
|
||||||
{
|
{
|
||||||
int number0;
|
int last_number;
|
||||||
|
|
||||||
number0 = *number;
|
last_number = *number;
|
||||||
*number += delta;
|
*number += delta;
|
||||||
return (*number < number0) != (delta < 0);
|
return (*number < last_number) != (delta < 0);
|
||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -164,6 +164,10 @@ static struct tm *time_sub(const time_t * const timep, const long int offset, co
|
|||||||
int y;
|
int y;
|
||||||
int hit;
|
int hit;
|
||||||
int i;
|
int i;
|
||||||
|
int newy;
|
||||||
|
time_t tdelta;
|
||||||
|
int idelta;
|
||||||
|
int leapdays;
|
||||||
|
|
||||||
corr = 0;
|
corr = 0;
|
||||||
hit = 0;
|
hit = 0;
|
||||||
@@ -198,11 +202,6 @@ static struct tm *time_sub(const time_t * const timep, const long int offset, co
|
|||||||
rem = *timep - tdays*SECS_PER_DAY;
|
rem = *timep - tdays*SECS_PER_DAY;
|
||||||
while (tdays < 0 || tdays >= year_lengths[isleap(y)])
|
while (tdays < 0 || tdays >= year_lengths[isleap(y)])
|
||||||
{
|
{
|
||||||
int newy;
|
|
||||||
time_t tdelta;
|
|
||||||
int idelta;
|
|
||||||
int leapdays;
|
|
||||||
|
|
||||||
tdelta = tdays / DAYS_PER_LEAP_YEAR;
|
tdelta = tdays / DAYS_PER_LEAP_YEAR;
|
||||||
idelta = tdelta;
|
idelta = tdelta;
|
||||||
if (tdelta - idelta >= 1 || idelta - tdelta >= 1)
|
if (tdelta - idelta >= 1 || idelta - tdelta >= 1)
|
||||||
|
|||||||
@@ -1248,7 +1248,7 @@ SPAN_DECLARE(void) v17_rx_set_put_bit(v17_rx_state_t *s, put_bit_func_t put_bit,
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) v17_rx_set_modem_status_handler(v17_rx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) v17_rx_set_modem_status_handler(v17_rx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ SPAN_DECLARE(void) v17_tx_set_get_bit(v17_tx_state_t *s, get_bit_func_t get_bit,
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) v17_tx_set_modem_status_handler(v17_tx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) v17_tx_set_modem_status_handler(v17_tx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ SPAN_DECLARE(void) v22bis_set_put_bit(v22bis_state_t *s, put_bit_func_t put_bit,
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) v22bis_set_modem_status_handler(v22bis_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) v22bis_set_modem_status_handler(v22bis_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -1019,7 +1019,7 @@ SPAN_DECLARE(void) v27ter_rx_set_put_bit(v27ter_rx_state_t *s, put_bit_func_t pu
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) v27ter_rx_set_modem_status_handler(v27ter_rx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) v27ter_rx_set_modem_status_handler(v27ter_rx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ SPAN_DECLARE(void) v27ter_tx_set_get_bit(v27ter_tx_state_t *s, get_bit_func_t ge
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) v27ter_tx_set_modem_status_handler(v27ter_tx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) v27ter_tx_set_modem_status_handler(v27ter_tx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -1052,7 +1052,7 @@ SPAN_DECLARE(void) v29_rx_set_put_bit(v29_rx_state_t *s, put_bit_func_t put_bit,
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) v29_rx_set_modem_status_handler(v29_rx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) v29_rx_set_modem_status_handler(v29_rx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ SPAN_DECLARE(void) v29_tx_set_get_bit(v29_tx_state_t *s, get_bit_func_t get_bit,
|
|||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(void) v29_tx_set_modem_status_handler(v29_tx_state_t *s, modem_tx_status_func_t handler, void *user_data)
|
SPAN_DECLARE(void) v29_tx_set_modem_status_handler(v29_tx_state_t *s, modem_status_func_t handler, void *user_data)
|
||||||
{
|
{
|
||||||
s->status_handler = handler;
|
s->status_handler = handler;
|
||||||
s->status_user_data = user_data;
|
s->status_user_data = user_data;
|
||||||
|
|||||||
+1209
-1071
File diff suppressed because it is too large.
Load diff
+558
-516
File diff suppressed because it is too large.
Load diff
@@ -23,11 +23,11 @@ LIBS += $(TESTLIBS)
|
|||||||
|
|
||||||
noinst_DATA = sound_c1_8k.wav sound_c3_8k.wav
|
noinst_DATA = sound_c1_8k.wav sound_c3_8k.wav
|
||||||
|
|
||||||
EXTRA_DIST = regression_tests.sh \
|
EXTRA_DIST = fax_tests.sh \
|
||||||
|
regression_tests.sh \
|
||||||
tsb85_extra_tests.sh \
|
tsb85_extra_tests.sh \
|
||||||
v42bis_tests.sh \
|
|
||||||
fax_tests.sh \
|
|
||||||
tsb85_tests.sh \
|
tsb85_tests.sh \
|
||||||
|
v42bis_tests.sh \
|
||||||
msvc/adsi_tests.vcproj \
|
msvc/adsi_tests.vcproj \
|
||||||
msvc/complex_tests.vcproj \
|
msvc/complex_tests.vcproj \
|
||||||
msvc/complex_vector_float_tests.vcproj \
|
msvc/complex_vector_float_tests.vcproj \
|
||||||
@@ -102,15 +102,15 @@ noinst_PROGRAMS = adsi_tests \
|
|||||||
super_tone_rx_tests \
|
super_tone_rx_tests \
|
||||||
super_tone_tx_tests \
|
super_tone_tx_tests \
|
||||||
swept_tone_tests \
|
swept_tone_tests \
|
||||||
t4_tests \
|
|
||||||
t31_tests \
|
t31_tests \
|
||||||
t38_decode \
|
|
||||||
t38_core_tests \
|
t38_core_tests \
|
||||||
|
t38_decode \
|
||||||
t38_gateway_tests \
|
t38_gateway_tests \
|
||||||
t38_gateway_to_terminal_tests \
|
t38_gateway_to_terminal_tests \
|
||||||
t38_non_ecm_buffer_tests \
|
t38_non_ecm_buffer_tests \
|
||||||
t38_terminal_tests \
|
t38_terminal_tests \
|
||||||
t38_terminal_to_gateway_tests \
|
t38_terminal_to_gateway_tests \
|
||||||
|
t4_tests \
|
||||||
time_scale_tests \
|
time_scale_tests \
|
||||||
timezone_tests \
|
timezone_tests \
|
||||||
tone_detect_tests \
|
tone_detect_tests \
|
||||||
@@ -126,8 +126,6 @@ noinst_PROGRAMS = adsi_tests \
|
|||||||
v8_tests \
|
v8_tests \
|
||||||
vector_float_tests \
|
vector_float_tests \
|
||||||
vector_int_tests \
|
vector_int_tests \
|
||||||
testadsi \
|
|
||||||
testfax \
|
|
||||||
tsb85_tests
|
tsb85_tests
|
||||||
|
|
||||||
noinst_HEADERS = echo_monitor.h \
|
noinst_HEADERS = echo_monitor.h \
|
||||||
@@ -364,12 +362,6 @@ vector_float_tests_LDADD = $(LIBDIR) -lspandsp
|
|||||||
vector_int_tests_SOURCES = vector_int_tests.c
|
vector_int_tests_SOURCES = vector_int_tests.c
|
||||||
vector_int_tests_LDADD = $(LIBDIR) -lspandsp
|
vector_int_tests_LDADD = $(LIBDIR) -lspandsp
|
||||||
|
|
||||||
testadsi_SOURCES = testadsi.c
|
|
||||||
testadsi_LDADD = $(LIBDIR) -lspandsp
|
|
||||||
|
|
||||||
testfax_SOURCES = testfax.c
|
|
||||||
testfax_LDADD = $(LIBDIR) -lspandsp
|
|
||||||
|
|
||||||
# We need to create the CSS files for echo cancellation tests.
|
# We need to create the CSS files for echo cancellation tests.
|
||||||
|
|
||||||
sound_c1_8k.wav sound_c3_8k.wav: make_g168_css$(EXEEXT)
|
sound_c1_8k.wav sound_c3_8k.wav: make_g168_css$(EXEEXT)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (int) (intptr_t) user_data;
|
i = (int) (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase B:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase B", i);
|
||||||
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
||||||
log_rx_parameters(s, tag);
|
log_rx_parameters(s, tag);
|
||||||
return T30_ERR_OK;
|
return T30_ERR_OK;
|
||||||
@@ -93,7 +93,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (int) (intptr_t) user_data;
|
i = (int) (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase D:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase D", i);
|
||||||
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
||||||
log_transfer_statistics(s, tag);
|
log_transfer_statistics(s, tag);
|
||||||
log_tx_parameters(s, tag);
|
log_tx_parameters(s, tag);
|
||||||
@@ -136,7 +136,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (intptr_t) user_data;
|
i = (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase E:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase E", i);
|
||||||
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
|
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
|
||||||
log_transfer_statistics(s, tag);
|
log_transfer_statistics(s, tag);
|
||||||
log_tx_parameters(s, tag);
|
log_tx_parameters(s, tag);
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
encoded_fd = -1;
|
||||||
|
inhandle = NULL;
|
||||||
|
oki_enc_state = NULL;
|
||||||
if (encoded_file_name)
|
if (encoded_file_name)
|
||||||
{
|
{
|
||||||
if ((encoded_fd = open(encoded_file_name, O_RDONLY)) < 0)
|
if ((encoded_fd = open(encoded_file_name, O_RDONLY)) < 0)
|
||||||
|
|||||||
@@ -34,14 +34,17 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_PCAP_H)
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
|
#endif
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/udp.h>
|
#include <netinet/udp.h>
|
||||||
#if defined(__HPUX) || defined(__CYGWIN) || defined(__FreeBSD__)
|
#if defined(__HPUX) || defined(__CYGWIN__) || defined(__FreeBSD__)
|
||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
#endif
|
#endif
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#ifndef __CYGWIN
|
#if !defined(__CYGWIN__)
|
||||||
#include <netinet/ip6.h>
|
#include <netinet/ip6.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -55,7 +58,7 @@
|
|||||||
#include "spandsp.h"
|
#include "spandsp.h"
|
||||||
#include "pcap_parse.h"
|
#include "pcap_parse.h"
|
||||||
|
|
||||||
#if defined(__HPUX) || defined(__DARWIN) || defined(__CYGWIN) || defined(__FreeBSD__)
|
#if defined(__HPUX) || defined(__DARWIN) || defined(__CYGWIN__) || defined(__FreeBSD__)
|
||||||
|
|
||||||
struct iphdr
|
struct iphdr
|
||||||
{
|
{
|
||||||
@@ -90,15 +93,22 @@ typedef struct _ether_hdr
|
|||||||
{
|
{
|
||||||
char ether_dst[6];
|
char ether_dst[6];
|
||||||
char ether_src[6];
|
char ether_src[6];
|
||||||
u_int16_t ether_type; /* we only need the type, so we can determine, if the next header is IPv4 or IPv6 */
|
u_int16_t ether_type;
|
||||||
} ether_hdr;
|
} ether_hdr;
|
||||||
|
|
||||||
|
typedef struct _null_hdr
|
||||||
|
{
|
||||||
|
uint32_t pf_type;
|
||||||
|
} null_hdr;
|
||||||
|
|
||||||
|
#if !defined(__CYGWIN__)
|
||||||
typedef struct _ipv6_hdr
|
typedef struct _ipv6_hdr
|
||||||
{
|
{
|
||||||
char dontcare[6];
|
char dontcare[6];
|
||||||
u_int8_t nxt_header; /* we only need the next header, so we can determine, if the next header is UDP or not */
|
u_int8_t nxt_header; /* we only need the next header, so we can determine, if the next header is UDP or not */
|
||||||
char dontcare2[33];
|
char dontcare2[33];
|
||||||
} ipv6_hdr;
|
} ipv6_hdr;
|
||||||
|
#endif
|
||||||
|
|
||||||
char errbuf[PCAP_ERRBUF_SIZE];
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
@@ -119,9 +129,14 @@ int pcap_scan_pkts(const char *file,
|
|||||||
int total_pkts;
|
int total_pkts;
|
||||||
uint32_t pktlen;
|
uint32_t pktlen;
|
||||||
ether_hdr *ethhdr;
|
ether_hdr *ethhdr;
|
||||||
|
null_hdr *nullhdr;
|
||||||
struct iphdr *iphdr;
|
struct iphdr *iphdr;
|
||||||
|
#if !defined(__CYGWIN__)
|
||||||
ipv6_hdr *ip6hdr;
|
ipv6_hdr *ip6hdr;
|
||||||
|
#endif
|
||||||
struct udphdr *udphdr;
|
struct udphdr *udphdr;
|
||||||
|
int datalink;
|
||||||
|
int packet_type;
|
||||||
|
|
||||||
total_pkts = 0;
|
total_pkts = 0;
|
||||||
if ((pcap = pcap_open_offline(file, errbuf)) == NULL)
|
if ((pcap = pcap_open_offline(file, errbuf)) == NULL)
|
||||||
@@ -129,6 +144,15 @@ int pcap_scan_pkts(const char *file,
|
|||||||
fprintf(stderr, "Can't open PCAP file '%s'\n", file);
|
fprintf(stderr, "Can't open PCAP file '%s'\n", file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
datalink = pcap_datalink(pcap);
|
||||||
|
/* DLT_EN10MB seems to apply to all forms of ethernet, not just the 10MB kind. */
|
||||||
|
if (datalink != DLT_EN10MB && datalink != DLT_NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unsupported data link type %d\n", datalink);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Datalink type %d\n", datalink);
|
||||||
pkthdr = NULL;
|
pkthdr = NULL;
|
||||||
pktdata = NULL;
|
pktdata = NULL;
|
||||||
#if defined(HAVE_PCAP_NEXT_EX)
|
#if defined(HAVE_PCAP_NEXT_EX)
|
||||||
@@ -143,14 +167,43 @@ int pcap_scan_pkts(const char *file,
|
|||||||
while ((pktdata = (uint8_t *) pcap_next(pcap, pkthdr)) != NULL)
|
while ((pktdata = (uint8_t *) pcap_next(pcap, pkthdr)) != NULL)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
ethhdr = (ether_hdr *) pktdata;
|
if (datalink == DLT_EN10MB)
|
||||||
if (ntohs(ethhdr->ether_type) != 0x0800 /* IPv4 */
|
{
|
||||||
&&
|
ethhdr = (ether_hdr *) pktdata;
|
||||||
ntohs(ethhdr->ether_type) != 0x86dd) /* IPv6 */
|
packet_type = ntohs(ethhdr->ether_type);
|
||||||
|
#if !defined(__CYGWIN__)
|
||||||
|
if (packet_type != 0x0800 /* IPv4 */
|
||||||
|
&&
|
||||||
|
packet_type != 0x86DD) /* IPv6 */
|
||||||
|
#else
|
||||||
|
if (packet_type != 0x0800) /* IPv4 */
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
iphdr = (struct iphdr *) ((uint8_t *) ethhdr + sizeof(*ethhdr));
|
||||||
|
}
|
||||||
|
else if (datalink == DLT_NULL)
|
||||||
|
{
|
||||||
|
nullhdr = (null_hdr *) pktdata;
|
||||||
|
if (nullhdr->pf_type != PF_INET && nullhdr->pf_type != PF_INET6)
|
||||||
|
continue;
|
||||||
|
iphdr = (struct iphdr *) ((uint8_t *) nullhdr + sizeof(*nullhdr));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
iphdr = (struct iphdr *) ((uint8_t *) ethhdr + sizeof(*ethhdr));
|
#if 0
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
printf("--- %d -", pkthdr->caplen);
|
||||||
|
for (i = 0; i < pkthdr->caplen; i++)
|
||||||
|
printf(" %02x", pktdata[i]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if !defined(__CYGWIN__)
|
||||||
if (iphdr && iphdr->version == 6)
|
if (iphdr && iphdr->version == 6)
|
||||||
{
|
{
|
||||||
/* ipv6 */
|
/* ipv6 */
|
||||||
@@ -161,11 +214,12 @@ int pcap_scan_pkts(const char *file,
|
|||||||
udphdr = (struct udphdr *) ((uint8_t *) ip6hdr + sizeof(*ip6hdr));
|
udphdr = (struct udphdr *) ((uint8_t *) ip6hdr + sizeof(*ip6hdr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* ipv4 */
|
/* ipv4 */
|
||||||
if (iphdr->protocol != IPPROTO_UDP)
|
if (iphdr->protocol != IPPROTO_UDP)
|
||||||
continue;
|
continue;
|
||||||
#if defined(__DARWIN) || defined(__CYGWIN) || defined(__FreeBSD__)
|
#if defined(__DARWIN) || defined(__CYGWIN__) || defined(__FreeBSD__)
|
||||||
udphdr = (struct udphdr *) ((uint8_t *) iphdr + (iphdr->ihl << 2) + 4);
|
udphdr = (struct udphdr *) ((uint8_t *) iphdr + (iphdr->ihl << 2) + 4);
|
||||||
pktlen = (uint32_t) ntohs(udphdr->uh_ulen);
|
pktlen = (uint32_t) ntohs(udphdr->uh_ulen);
|
||||||
#elif defined ( __HPUX)
|
#elif defined ( __HPUX)
|
||||||
@@ -176,24 +230,39 @@ int pcap_scan_pkts(const char *file,
|
|||||||
pktlen = (uint32_t) ntohs(udphdr->len);
|
pktlen = (uint32_t) ntohs(udphdr->len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
timing_update_handler(user_data, &pkthdr->ts);
|
timing_update_handler(user_data, &pkthdr->ts);
|
||||||
|
|
||||||
if (src_addr && ntohl(iphdr->saddr) != src_addr)
|
if (src_addr && ntohl(iphdr->saddr) != src_addr)
|
||||||
continue;
|
continue;
|
||||||
|
#if defined(__DARWIN) || defined(__CYGWIN__) || defined(__FreeBSD__)
|
||||||
|
if (src_port && ntohs(udphdr->uh_sport) != src_port)
|
||||||
|
#else
|
||||||
if (src_port && ntohs(udphdr->source) != src_port)
|
if (src_port && ntohs(udphdr->source) != src_port)
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
if (dest_addr && ntohl(iphdr->daddr) != dest_addr)
|
if (dest_addr && ntohl(iphdr->daddr) != dest_addr)
|
||||||
continue;
|
continue;
|
||||||
|
#if defined(__DARWIN) || defined(__CYGWIN__) || defined(__FreeBSD__)
|
||||||
|
if (dest_port && ntohs(udphdr->uh_dport) != dest_port)
|
||||||
|
#else
|
||||||
if (dest_port && ntohs(udphdr->dest) != dest_port)
|
if (dest_port && ntohs(udphdr->dest) != dest_port)
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (pkthdr->len != pkthdr->caplen)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Truncated packet - total len = %d, captured len = %d\n", pkthdr->len, pkthdr->caplen);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
body = (const uint8_t *) udphdr;
|
body = (const uint8_t *) udphdr;
|
||||||
body += sizeof(udphdr);
|
body += sizeof(struct udphdr);
|
||||||
body_len = pktlen - sizeof(udphdr);
|
body_len = pktlen - sizeof(struct udphdr);
|
||||||
packet_handler(user_data, body, body_len);
|
packet_handler(user_data, body, body_len);
|
||||||
|
|
||||||
total_pkts++;
|
total_pkts++;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "In pcap %s, npkts %d\n", file, total_pkts);
|
fprintf(stderr, "In pcap %s there were %d accepted packets\n", file, total_pkts);
|
||||||
pcap_close(pcap);
|
pcap_close(pcap);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -846,25 +846,23 @@ echo v29_tests completed OK
|
|||||||
#fi
|
#fi
|
||||||
#echo v32bis_tests completed OK
|
#echo v32bis_tests completed OK
|
||||||
|
|
||||||
#./v42_tests >$STDOUT_DEST 2>$STDERR_DEST
|
./v42_tests >$STDOUT_DEST 2>$STDERR_DEST
|
||||||
#RETVAL=$?
|
RETVAL=$?
|
||||||
#if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
#then
|
then
|
||||||
# echo v42_tests failed!
|
echo v42_tests failed!
|
||||||
# exit $RETVAL
|
exit $RETVAL
|
||||||
#fi
|
fi
|
||||||
#echo v42_tests completed OK
|
echo v42_tests completed OK
|
||||||
echo v42_tests not enabled
|
|
||||||
|
|
||||||
#./v42bis_tests.sh >/dev/null
|
./v42bis_tests.sh >/dev/null
|
||||||
#RETVAL=$?
|
RETVAL=$?
|
||||||
#if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
#then
|
then
|
||||||
# echo v42bis_tests failed!
|
echo v42bis_tests failed!
|
||||||
# exit $RETVAL
|
exit $RETVAL
|
||||||
#fi
|
fi
|
||||||
#echo v42bis_tests completed OK
|
echo v42bis_tests completed OK
|
||||||
echo v42bis_tests not enabled
|
|
||||||
|
|
||||||
./v8_tests >$STDOUT_DEST 2>$STDERR_DEST
|
./v8_tests >$STDOUT_DEST 2>$STDERR_DEST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (int) (intptr_t) user_data;
|
i = (int) (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase B:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase B", i);
|
||||||
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
||||||
log_rx_parameters(s, tag);
|
log_rx_parameters(s, tag);
|
||||||
return T30_ERR_OK;
|
return T30_ERR_OK;
|
||||||
@@ -293,7 +293,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (int) (intptr_t) user_data;
|
i = (int) (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase D:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase D", i);
|
||||||
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
||||||
log_transfer_statistics(s, tag);
|
log_transfer_statistics(s, tag);
|
||||||
log_tx_parameters(s, tag);
|
log_tx_parameters(s, tag);
|
||||||
@@ -308,7 +308,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (intptr_t) user_data;
|
i = (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase E:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase E", i);
|
||||||
printf("Phase E handler on channel %c\n", i);
|
printf("Phase E handler on channel %c\n", i);
|
||||||
log_transfer_statistics(s, tag);
|
log_transfer_statistics(s, tag);
|
||||||
log_tx_parameters(s, tag);
|
log_tx_parameters(s, tag);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SpanDSP - a series of DSP components for telephony
|
* SpanDSP - a series of DSP components for telephony
|
||||||
*
|
*
|
||||||
* pcap-parse.c
|
* t38_decode.c
|
||||||
*
|
*
|
||||||
* Written by Steve Underwood <steveu@coppice.org>
|
* Written by Steve Underwood <steveu@coppice.org>
|
||||||
*
|
*
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
#define OUTPUT_FILE_NAME "t38pcap.tif"
|
#define OUTPUT_FILE_NAME "t38pcap.tif"
|
||||||
|
|
||||||
t38_terminal_state_t *t38_state;
|
t38_terminal_state_t *t38_state;
|
||||||
|
struct timeval now;
|
||||||
|
|
||||||
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
|
||||||
{
|
{
|
||||||
@@ -110,29 +111,35 @@ static int timing_update(void *user_data, struct timeval *ts)
|
|||||||
t38_core_state_t *t38_core;
|
t38_core_state_t *t38_core;
|
||||||
logging_state_t *logging;
|
logging_state_t *logging;
|
||||||
int samples;
|
int samples;
|
||||||
|
int partial;
|
||||||
static int64_t current = 0;
|
static int64_t current = 0;
|
||||||
int64_t when;
|
int64_t when;
|
||||||
int64_t diff;
|
int64_t diff;
|
||||||
|
|
||||||
|
memcpy(&now, ts, sizeof(now));
|
||||||
|
|
||||||
when = ts->tv_sec*1000000LL + ts->tv_usec;
|
when = ts->tv_sec*1000000LL + ts->tv_usec;
|
||||||
if (current == 0)
|
if (current == 0)
|
||||||
current = when;
|
current = when;
|
||||||
|
|
||||||
diff = when - current;
|
diff = when - current;
|
||||||
samples = diff/125LL;
|
samples = diff/125LL;
|
||||||
if (samples > 0)
|
while (samples > 0)
|
||||||
{
|
{
|
||||||
|
partial = (samples > 160) ? 160 : samples;
|
||||||
|
//fprintf(stderr, "Update time by %d samples\n", partial);
|
||||||
logging = t38_terminal_get_logging_state(t38_state);
|
logging = t38_terminal_get_logging_state(t38_state);
|
||||||
span_log_bump_samples(logging, samples);
|
span_log_bump_samples(logging, partial);
|
||||||
t38_core = t38_terminal_get_t38_core_state(t38_state);
|
t38_core = t38_terminal_get_t38_core_state(t38_state);
|
||||||
logging = t38_core_get_logging_state(t38_core);
|
logging = t38_core_get_logging_state(t38_core);
|
||||||
span_log_bump_samples(logging, samples);
|
span_log_bump_samples(logging, partial);
|
||||||
t30 = t38_terminal_get_t30_state(t38_state);
|
t30 = t38_terminal_get_t30_state(t38_state);
|
||||||
logging = t30_get_logging_state(t30);
|
logging = t30_get_logging_state(t30);
|
||||||
span_log_bump_samples(logging, samples);
|
span_log_bump_samples(logging, partial);
|
||||||
|
|
||||||
t38_terminal_send_timeout(t38_state, samples);
|
t38_terminal_send_timeout(t38_state, partial);
|
||||||
current = when;
|
current = when;
|
||||||
|
samples -= partial;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -188,6 +195,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
use_ecm = FALSE;
|
use_ecm = FALSE;
|
||||||
t38_version = 1;
|
t38_version = 1;
|
||||||
|
options = 0;
|
||||||
input_file_name = INPUT_FILE_NAME;
|
input_file_name = INPUT_FILE_NAME;
|
||||||
fill_removal = FALSE;
|
fill_removal = FALSE;
|
||||||
use_tep = FALSE;
|
use_tep = FALSE;
|
||||||
@@ -196,7 +204,7 @@ int main(int argc, char *argv[])
|
|||||||
src_port = 0;
|
src_port = 0;
|
||||||
dest_addr = 0;
|
dest_addr = 0;
|
||||||
dest_port = 0;
|
dest_port = 0;
|
||||||
while ((opt = getopt(argc, argv, "D:d:eFi:m:S:s:tv:")) != -1)
|
while ((opt = getopt(argc, argv, "D:d:eFi:m:oS:s:tv:")) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
@@ -218,6 +226,9 @@ int main(int argc, char *argv[])
|
|||||||
case 'm':
|
case 'm':
|
||||||
supported_modems = atoi(optarg);
|
supported_modems = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
options = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
src_addr = atoi(optarg);
|
src_addr = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
@@ -272,6 +283,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, timing_update, process_packet, NULL))
|
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, timing_update, process_packet, NULL))
|
||||||
exit(2);
|
exit(2);
|
||||||
|
/* Push the time along, to flush out any remaining activity from the application. */
|
||||||
|
now.tv_sec += 60;
|
||||||
|
timing_update(NULL, &now);
|
||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
/*- End of file ------------------------------------------------------------*/
|
/*- End of file ------------------------------------------------------------*/
|
||||||
@@ -595,7 +595,7 @@ int main(int argc, char *argv[])
|
|||||||
logging = t38_core_get_logging_state(t38_core);
|
logging = t38_core_get_logging_state(t38_core);
|
||||||
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
|
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
|
||||||
logging = &t38_state_a->audio.modems.v17_rx.logging;
|
logging = &t38_state_a->audio.modems.v17_rx.logging;
|
||||||
span_log_bump_samples(logging, t30_len_a);
|
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
|
||||||
|
|
||||||
logging = t38_terminal_get_logging_state(t38_state_b);
|
logging = t38_terminal_get_logging_state(t38_state_b);
|
||||||
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
|
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
|
||||||
|
|||||||
@@ -1,86 +1,86 @@
|
|||||||
/*
|
/*
|
||||||
* SpanDSP - a series of DSP components for telephony
|
* SpanDSP - a series of DSP components for telephony
|
||||||
*
|
*
|
||||||
* timezone_tests.c - Timezone handling for time interpretation
|
* timezone_tests.c - Timezone handling for time interpretation
|
||||||
*
|
*
|
||||||
* Written by Steve Underwood <steveu@coppice.org>
|
* Written by Steve Underwood <steveu@coppice.org>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Steve Underwood
|
* Copyright (C) 2010 Steve Underwood
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License version 2.1,
|
* it under the terms of the GNU Lesser General Public License version 2.1,
|
||||||
* as published by the Free Software Foundation.
|
* as published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this program; if not, write to the Free Software
|
* License along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \page timezone_tests_page Timezone handling tests
|
/*! \page timezone_tests_page Timezone handling tests
|
||||||
\section timezone_tests_page_sec_1 What does it do?
|
\section timezone_tests_page_sec_1 What does it do?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(HAVE_CONFIG_H)
|
#if defined(HAVE_CONFIG_H)
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
#include "spandsp.h"
|
#include "spandsp.h"
|
||||||
|
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
#define TRUE (!FALSE)
|
#define TRUE (!FALSE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct tm tms;
|
struct tm tms;
|
||||||
struct tm *tmp = &tms;
|
struct tm *tmp = &tms;
|
||||||
time_t ltime;
|
time_t ltime;
|
||||||
tz_t *tz;
|
tz_t *tz;
|
||||||
|
|
||||||
/* Get the current time */
|
/* Get the current time */
|
||||||
ltime = time(NULL);
|
ltime = time(NULL);
|
||||||
|
|
||||||
/* Compute the local current time now for several localities, based on Posix tz strings */
|
/* Compute the local current time now for several localities, based on Posix tz strings */
|
||||||
|
|
||||||
tz = tz_init(NULL, "GMT0GMT0,M10.5.0,M3.5.0");
|
tz = tz_init(NULL, "GMT0GMT0,M10.5.0,M3.5.0");
|
||||||
tz_localtime(tz, tmp, ltime);
|
tz_localtime(tz, tmp, ltime);
|
||||||
printf("Local time is %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
printf("Local time is %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||||
printf("Time zone is %s\n", tz_tzname(tz, tmp->tm_isdst));
|
printf("Time zone is %s\n", tz_tzname(tz, tmp->tm_isdst));
|
||||||
|
|
||||||
tz_init(tz, "CST-8CST-8,M10.5.0,M3.5.0");
|
tz_init(tz, "CST-8CST-8,M10.5.0,M3.5.0");
|
||||||
tz_localtime(tz, tmp, ltime);
|
tz_localtime(tz, tmp, ltime);
|
||||||
printf("Local time is %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
printf("Local time is %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||||
printf("Time zone is %s\n", tz_tzname(tz, tmp->tm_isdst));
|
printf("Time zone is %s\n", tz_tzname(tz, tmp->tm_isdst));
|
||||||
|
|
||||||
tz_init(tz, "AEST-10AEDT-11,M10.5.0,M3.5.0");
|
tz_init(tz, "AEST-10AEDT-11,M10.5.0,M3.5.0");
|
||||||
tz_localtime(tz, tmp, ltime);
|
tz_localtime(tz, tmp, ltime);
|
||||||
printf("Local time is %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
printf("Local time is %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
||||||
printf("Time zone is %s\n", tz_tzname(tz, tmp->tm_isdst));
|
printf("Time zone is %s\n", tz_tzname(tz, tmp->tm_isdst));
|
||||||
|
|
||||||
tz_free(tz);
|
tz_free(tz);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
/*- End of file ------------------------------------------------------------*/
|
/*- End of file ------------------------------------------------------------*/
|
||||||
@@ -217,7 +217,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (intptr_t) user_data;
|
i = (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase D:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase D", i);
|
||||||
|
|
||||||
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
|
||||||
log_transfer_statistics(s, tag);
|
log_transfer_statistics(s, tag);
|
||||||
@@ -260,7 +260,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
char tag[20];
|
char tag[20];
|
||||||
|
|
||||||
i = (intptr_t) user_data;
|
i = (intptr_t) user_data;
|
||||||
snprintf(tag, sizeof(tag), "%c: Phase E:", i);
|
snprintf(tag, sizeof(tag), "%c: Phase E", i);
|
||||||
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
|
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
|
||||||
log_transfer_statistics(s, tag);
|
log_transfer_statistics(s, tag);
|
||||||
log_tx_parameters(s, tag);
|
log_tx_parameters(s, tag);
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ display of modem status is maintained.
|
|||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#if defined(HAVE_FENV_H)
|
#if defined(HAVE_FENV_H)
|
||||||
|
#define __USE_GNU
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ display of modem status is maintained.
|
|||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#if defined(HAVE_FENV_H)
|
#if defined(HAVE_FENV_H)
|
||||||
|
#define __USE_GNU
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ display of modem status is maintained.
|
|||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#if defined(HAVE_FENV_H)
|
#if defined(HAVE_FENV_H)
|
||||||
|
#define __USE_GNU
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Written by Steve Underwood <steveu@coppice.org>
|
* Written by Steve Underwood <steveu@coppice.org>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004 Steve Underwood
|
* Copyright (C) 2004, 2011 Steve Underwood
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -32,10 +32,11 @@ then exchanged between them.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(HAVE_CONFIG_H)
|
#if defined(HAVE_CONFIG_H)
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -48,6 +49,7 @@ then exchanged between them.
|
|||||||
|
|
||||||
v42_state_t caller;
|
v42_state_t caller;
|
||||||
v42_state_t answerer;
|
v42_state_t answerer;
|
||||||
|
int variable_length;
|
||||||
|
|
||||||
int rx_next[3] = {0};
|
int rx_next[3] = {0};
|
||||||
int tx_next[3] = {0};
|
int tx_next[3] = {0};
|
||||||
@@ -55,66 +57,120 @@ int tx_next[3] = {0};
|
|||||||
static void v42_status(void *user_data, int status)
|
static void v42_status(void *user_data, int status)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
x = (intptr_t) user_data;
|
|
||||||
printf("%d: Status is '%s' (%d)\n", x, lapm_status_to_str(status), status);
|
|
||||||
//if (status == LAPM_DATA)
|
|
||||||
// lapm_tx_iframe((x == 1) ? &caller.lapm : &answerer.lapm, "ABCDEFGHIJ", 10, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void v42_frames(void *user_data, const uint8_t *msg, int len)
|
x = (intptr_t) user_data;
|
||||||
|
if (status < 0)
|
||||||
|
printf("%d: Status is '%s' (%d)\n", x, signal_status_to_str(status), status);
|
||||||
|
else
|
||||||
|
printf("%d: Status is '%s' (%d)\n", x, lapm_status_to_str(status), status);
|
||||||
|
}
|
||||||
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
|
static int v42_get_frames(void *user_data, uint8_t *msg, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
int k;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
if (len < 0)
|
||||||
|
{
|
||||||
|
v42_status(user_data, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
x = (intptr_t) user_data;
|
||||||
|
if (variable_length)
|
||||||
|
{
|
||||||
|
j = make_mask32(len);
|
||||||
|
do
|
||||||
|
k = j & rand();
|
||||||
|
while (k > len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
k = len;
|
||||||
|
}
|
||||||
|
for (i = 0; i < k; i++)
|
||||||
|
msg[i] = tx_next[x]++;
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void v42_put_frames(void *user_data, const uint8_t *msg, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
|
if (len < 0)
|
||||||
|
{
|
||||||
|
v42_status(user_data, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
x = (intptr_t) user_data;
|
x = (intptr_t) user_data;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
if (msg[i] != (rx_next[x] & 0xFF))
|
if (msg[i] != (rx_next[x] & 0xFF))
|
||||||
|
{
|
||||||
printf("%d: Mismatch 0x%02X 0x%02X\n", x, msg[i], rx_next[x] & 0xFF);
|
printf("%d: Mismatch 0x%02X 0x%02X\n", x, msg[i], rx_next[x] & 0xFF);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
rx_next[x]++;
|
rx_next[x]++;
|
||||||
}
|
}
|
||||||
printf("%d: Got frame len %d\n", x, len);
|
printf("%d: Got frame len %d\n", x, len);
|
||||||
}
|
}
|
||||||
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int bit;
|
int bit;
|
||||||
uint8_t buf[1024];
|
int insert_caller_bit_errors;
|
||||||
|
int insert_answerer_bit_errors;
|
||||||
|
int opt;
|
||||||
|
|
||||||
v42_init(&caller, TRUE, TRUE, v42_frames, (void *) 1);
|
insert_caller_bit_errors = FALSE;
|
||||||
v42_init(&answerer, FALSE, TRUE, v42_frames, (void *) 2);
|
insert_answerer_bit_errors = FALSE;
|
||||||
|
variable_length = FALSE;
|
||||||
|
while ((opt = getopt(argc, argv, "bv")) != -1)
|
||||||
|
{
|
||||||
|
switch (opt)
|
||||||
|
{
|
||||||
|
case 'b':
|
||||||
|
insert_caller_bit_errors = 11000;
|
||||||
|
insert_answerer_bit_errors = 10000;
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
variable_length = TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//usage();
|
||||||
|
exit(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
v42_init(&caller, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) 1);
|
||||||
|
v42_init(&answerer, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) 2);
|
||||||
v42_set_status_callback(&caller, v42_status, (void *) 1);
|
v42_set_status_callback(&caller, v42_status, (void *) 1);
|
||||||
v42_set_status_callback(&answerer, v42_status, (void *) 2);
|
v42_set_status_callback(&answerer, v42_status, (void *) 2);
|
||||||
span_log_set_level(&caller.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_DEBUG);
|
v42_restart(&caller);
|
||||||
|
v42_restart(&answerer);
|
||||||
|
|
||||||
|
span_log_set_level(&caller.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_DEBUG);
|
||||||
span_log_set_tag(&caller.logging, "caller");
|
span_log_set_tag(&caller.logging, "caller");
|
||||||
span_log_set_level(&caller.lapm.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_DEBUG);
|
span_log_set_level(&answerer.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_DEBUG);
|
||||||
span_log_set_tag(&caller.lapm.logging, "caller");
|
|
||||||
span_log_set_level(&caller.lapm.sched.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_DEBUG);
|
|
||||||
span_log_set_tag(&caller.lapm.sched.logging, "caller");
|
|
||||||
span_log_set_level(&answerer.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_DEBUG);
|
|
||||||
span_log_set_tag(&answerer.logging, "answerer");
|
span_log_set_tag(&answerer.logging, "answerer");
|
||||||
span_log_set_level(&answerer.lapm.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_DEBUG);
|
|
||||||
span_log_set_tag(&answerer.lapm.logging, "answerer");
|
for (i = 0; i < 1000000; i++)
|
||||||
span_log_set_level(&answerer.lapm.sched.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_DEBUG);
|
|
||||||
span_log_set_tag(&answerer.lapm.sched.logging, "answerer");
|
|
||||||
for (i = 0; i < 100000; i++)
|
|
||||||
{
|
{
|
||||||
bit = v42_tx_bit(&caller);
|
bit = v42_tx_bit(&caller);
|
||||||
|
if (insert_caller_bit_errors && i%insert_caller_bit_errors == 0)
|
||||||
|
bit ^= 1;
|
||||||
v42_rx_bit(&answerer, bit);
|
v42_rx_bit(&answerer, bit);
|
||||||
bit = v42_tx_bit(&answerer);
|
bit = v42_tx_bit(&answerer);
|
||||||
//if (i%10000 == 0)
|
if (insert_answerer_bit_errors && i%insert_answerer_bit_errors == 0)
|
||||||
// bit ^= 1;
|
bit ^= 1;
|
||||||
v42_rx_bit(&caller, bit);
|
v42_rx_bit(&caller, bit);
|
||||||
span_schedule_update(&caller.lapm.sched, 4);
|
|
||||||
span_schedule_update(&answerer.lapm.sched, 4);
|
|
||||||
buf[0] = tx_next[1];
|
|
||||||
if (lapm_tx(&caller.lapm, buf, 1) == 1)
|
|
||||||
tx_next[1]++;
|
|
||||||
buf[0] = tx_next[2];
|
|
||||||
if (lapm_tx(&answerer.lapm, buf, 1) == 1)
|
|
||||||
tx_next[2]++;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ of this file should exactly match the original file.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(HAVE_CONFIG_H)
|
#if defined(HAVE_CONFIG_H)
|
||||||
#include <config.h>
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -46,12 +46,14 @@ of this file should exactly match the original file.
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||||
|
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||||
|
//#endif
|
||||||
|
|
||||||
#include "spandsp.h"
|
#include "spandsp.h"
|
||||||
|
|
||||||
#include "spandsp/private/v42bis.h"
|
|
||||||
|
|
||||||
#define COMPRESSED_FILE_NAME "v42bis_tests.v42bis"
|
#define COMPRESSED_FILE_NAME "v42bis_tests.v42bis"
|
||||||
#define OUTPUT_FILE_NAME "v42bis_tests.out"
|
#define DECOMPRESSED_FILE_NAME "v42bis_tests.out"
|
||||||
|
|
||||||
int in_octets_to_date = 0;
|
int in_octets_to_date = 0;
|
||||||
int out_octets_to_date = 0;
|
int out_octets_to_date = 0;
|
||||||
@@ -85,36 +87,96 @@ int main(int argc, char *argv[])
|
|||||||
int out_fd;
|
int out_fd;
|
||||||
int do_compression;
|
int do_compression;
|
||||||
int do_decompression;
|
int do_decompression;
|
||||||
|
int stutter_compression;
|
||||||
|
int stutter_time;
|
||||||
|
int seg;
|
||||||
|
int opt;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
const char *argv0;
|
||||||
|
const char *original_file;
|
||||||
|
const char *compressed_file;
|
||||||
|
const char *decompressed_file;
|
||||||
|
|
||||||
do_compression = TRUE;
|
argv0 = argv[0];
|
||||||
do_decompression = TRUE;
|
do_compression = FALSE;
|
||||||
if (argc < 2)
|
do_decompression = FALSE;
|
||||||
|
stutter_compression = FALSE;
|
||||||
|
while ((opt = getopt(argc, argv, "cds")) != -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
|
switch (opt)
|
||||||
|
{
|
||||||
|
case 'c':
|
||||||
|
do_compression = TRUE;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
do_decompression = TRUE;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
stutter_compression = TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//usage();
|
||||||
|
exit(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
if (argc < 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: %s [-c] [-d] [-s] <in-file> [<out-file>]\n", argv0);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (do_compression)
|
if (do_compression)
|
||||||
{
|
{
|
||||||
if ((in_fd = open(argv[1], O_RDONLY)) < 0)
|
original_file = argv[0];
|
||||||
|
compressed_file = COMPRESSED_FILE_NAME;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
original_file = NULL;
|
||||||
|
compressed_file = argv[0];
|
||||||
|
}
|
||||||
|
decompressed_file = (argc > 1) ? argv[1] : DECOMPRESSED_FILE_NAME;
|
||||||
|
if (do_compression)
|
||||||
|
{
|
||||||
|
stutter_time = rand() & 0x3FF;
|
||||||
|
if ((in_fd = open(argv[0], O_RDONLY)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error opening file '%s'.\n", argv[1]);
|
fprintf(stderr, "Error opening file '%s'.\n", original_file);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if ((v42bis_fd = open(COMPRESSED_FILE_NAME, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
|
if ((v42bis_fd = open(compressed_file, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error opening file '%s'.\n", COMPRESSED_FILE_NAME);
|
fprintf(stderr, "Error opening file '%s'.\n", compressed_file);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
v42bis_init(&state_a, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, NULL, 512);
|
v42bis_init(&state_a, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, NULL, 512);
|
||||||
v42bis_compression_control(&state_a, V42BIS_COMPRESSION_MODE_ALWAYS);
|
span_log_set_level(&state_a.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
|
||||||
|
span_log_set_tag(&state_a.logging, "XXX");
|
||||||
|
//v42bis_compression_control(&state_a, V42BIS_COMPRESSION_MODE_ALWAYS);
|
||||||
in_octets_to_date = 0;
|
in_octets_to_date = 0;
|
||||||
out_octets_to_date = 0;
|
out_octets_to_date = 0;
|
||||||
while ((len = read(in_fd, buf, 1024)) > 0)
|
while ((len = read(in_fd, buf, 1024)) > 0)
|
||||||
{
|
{
|
||||||
if (v42bis_compress(&state_a, buf, len))
|
seg = 0;
|
||||||
|
if (stutter_compression)
|
||||||
|
{
|
||||||
|
while ((len - seg) >= stutter_time)
|
||||||
|
{
|
||||||
|
if (v42bis_compress(&state_a, buf + seg, stutter_time))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Bad return code from compression\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
v42bis_compress_flush(&state_a);
|
||||||
|
seg += stutter_time;
|
||||||
|
stutter_time = rand() & 0x3FF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (v42bis_compress(&state_a, buf + seg, len - seg))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Bad return code from compression\n");
|
fprintf(stderr, "Bad return code from compression\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
@@ -130,19 +192,21 @@ int main(int argc, char *argv[])
|
|||||||
if (do_decompression)
|
if (do_decompression)
|
||||||
{
|
{
|
||||||
/* Now open the files for the decompression. */
|
/* Now open the files for the decompression. */
|
||||||
if ((v42bis_fd = open(COMPRESSED_FILE_NAME, O_RDONLY)) < 0)
|
if ((v42bis_fd = open(compressed_file, O_RDONLY)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error opening file '%s'.\n", COMPRESSED_FILE_NAME);
|
fprintf(stderr, "Error opening file '%s'.\n", compressed_file);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if ((out_fd = open(OUTPUT_FILE_NAME, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
|
if ((out_fd = open(decompressed_file, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error opening file '%s'.\n", OUTPUT_FILE_NAME);
|
fprintf(stderr, "Error opening file '%s'.\n", decompressed_file);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
v42bis_init(&state_b, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, (void *) (intptr_t) out_fd, 512);
|
v42bis_init(&state_b, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, (void *) (intptr_t) out_fd, 512);
|
||||||
|
span_log_set_level(&state_b.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
|
||||||
|
span_log_set_tag(&state_b.logging, "XXX");
|
||||||
in_octets_to_date = 0;
|
in_octets_to_date = 0;
|
||||||
out_octets_to_date = 0;
|
out_octets_to_date = 0;
|
||||||
while ((len = read(v42bis_fd, buf, 1024)) > 0)
|
while ((len = read(v42bis_fd, buf, 1024)) > 0)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
BASE=../test-data/itu/v56ter
|
BASE=../test-data/itu/v56ter
|
||||||
|
|
||||||
./v42bis_tests ${BASE}/1.TST
|
./v42bis_tests -c -d ${BASE}/1.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -29,7 +29,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/1X04.TST
|
./v42bis_tests -c -d ${BASE}/1X04.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -41,7 +41,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/1X30.TST
|
./v42bis_tests -c -d ${BASE}/1X30.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -53,7 +53,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/2.TST
|
./v42bis_tests -c -d ${BASE}/2.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -65,8 +65,9 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/2X10.TST
|
./v42bis_tests -c -d ${BASE}/2X10.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
@@ -77,7 +78,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/3.TST
|
./v42bis_tests -c -d ${BASE}/3.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -89,7 +90,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/3X06.TST
|
./v42bis_tests -c -d ${BASE}/3X06.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -101,7 +102,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/4.TST
|
./v42bis_tests -c -d ${BASE}/4.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -113,7 +114,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/4X04.TST
|
./v42bis_tests -c -d ${BASE}/4X04.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -125,7 +126,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/5.TST
|
./v42bis_tests -c -d ${BASE}/5.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
@@ -137,7 +138,7 @@ if [ $RETVAL != 0 ]
|
|||||||
then
|
then
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
fi
|
fi
|
||||||
./v42bis_tests ${BASE}/5X16.TST
|
./v42bis_tests -c -d ${BASE}/5X16.TST
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL != 0 ]
|
if [ $RETVAL != 0 ]
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ else
|
|||||||
cd gsm0610
|
cd gsm0610
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $1x = --no-exe-runx ]
|
if [ $1x == --no-exe-runx ]
|
||||||
then
|
then
|
||||||
# Run the .exe files, which should be here
|
# Run the .exe files, which should be here
|
||||||
./FR_A.EXE
|
./FR_A.EXE
|
||||||
@@ -77,7 +77,7 @@ rm -rf READ_FRA.TXT
|
|||||||
rm -rf ACTION
|
rm -rf ACTION
|
||||||
rm -rf unpacked
|
rm -rf unpacked
|
||||||
|
|
||||||
if [ $1x = --no-exex ]
|
if [ $1x == --no-exex ]
|
||||||
then
|
then
|
||||||
# We need to prepare the .exe files to be run separately
|
# We need to prepare the .exe files to be run separately
|
||||||
rm -rf *.INP
|
rm -rf *.INP
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
version='1.0'>
|
version='1.0'>
|
||||||
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/xhtml/chunk.xsl"/>
|
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/xhtml/chunk.xsl"/>
|
||||||
<xsl:param name="html.stylesheet">css.css</xsl:param>
|
<xsl:param name="html.stylesheet">css.css</xsl:param>
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
Reference in new issue
Block a user