Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
9a5f54c
Accept poor fast-train training errors. This affords the DTE the opp…
redder86 Jun 4, 2022
cae078c
ITU-T V.250 6.3.1 defines the ATD command. It states: 'Any characters…
redder86 Jun 4, 2022
b4d2874
Prevent multiple CONNECT messages after +FRH=3 which could have been …
redder86 Jun 4, 2022
2949155
Send NO CARRIER message if hangup occurs during data transmit
redder86 Jun 4, 2022
3955808
Send NO CARRIER message if hangup occurs during data transmit (2)
redder86 Jun 4, 2022
f4790de
Correctly address the issue attempted to be fixed by the previous com…
redder86 Jun 4, 2022
cf204c8
This CONNECT message is superfluous. If there is some delay in the DT…
redder86 Jun 4, 2022
a701c59
These changes are a contribution from Robert Boisvert and the Alpine …
redder86 Jun 5, 2022
f5943c7
iaf is treated as a bitmap everywhere else in the code, not a boolean…
redder86 Jun 8, 2022
461bf79
The 3rd octet of the FIF does, indeed, indicate the length of the int…
redder86 Jun 9, 2022
056a9e6
Revert "These changes are a contribution from Robert Boisvert and the…
redder86 Jun 9, 2022
c410e11
Add t30_set_retransmit_capable API function to allow access to retran…
redder86 Jun 10, 2022
becb49f
If retransmit_capable is not enabled then spandsp's behavior followin…
redder86 Jun 10, 2022
2daa783
correction to the previous commit
redder86 Jun 10, 2022
0635d6b
If a terminal problem occurs as a receiver in Phase B such that we'll…
redder86 Jun 13, 2022
472ca5e
This adds HylaFAX+ SSL Fax client support.
redder86 Jul 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ AC_CHECK_LIB([tiff], [TIFFCreateCustomDirectory], [
AC_CHECK_HEADERS([jpeglib.h])
AC_CHECK_LIB([jpeg], [jpeg_start_compress], [JPEG_LIBS="-ljpeg"], AC_MSG_ERROR("Cannot build without libtiff (does your system require a libjpeg-devel or libjpeg-turbo-devel package?)"))

AC_CHECK_LIB([ssl], [TLS_client_method], [
AC_DEFINE([SPANDSP_SUPPORT_FLEXSSL], [1], [Support flexible OpenSSL methods])
SPANDSP_SUPPORT_FLEXSSL="#define SPANDSP_SUPPORT_FLEXSSL 1"
], [SPANDSP_SUPPORT_TIFF_FX="#undef SPANDSP_SUPPORT_FLEXSSL"], -lm)

LIBS="$LIBS $TIFF_LIBS $JPEG_LIBS"

TESTLIBS="$SIMLIBS $TESTLIBS"
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ libspandsp_la_SOURCES = ademco_contactid.c \
schedule.c \
sig_tone.c \
silence_gen.c \
sslfax.c \
super_tone_rx.c \
super_tone_tx.c \
swept_tone.c \
Expand Down Expand Up @@ -245,6 +246,7 @@ nobase_include_HEADERS = spandsp/ademco_contactid.h \
spandsp/stdbool.h \
spandsp/sig_tone.h \
spandsp/silence_gen.h \
spandsp/sslfax.h \
spandsp/super_tone_rx.h \
spandsp/super_tone_tx.h \
spandsp/swept_tone.h \
Expand Down Expand Up @@ -320,6 +322,7 @@ nobase_include_HEADERS = spandsp/ademco_contactid.h \
spandsp/private/schedule.h \
spandsp/private/sig_tone.h \
spandsp/private/silence_gen.h \
spandsp/private/sslfax.h \
spandsp/private/super_tone_rx.h \
spandsp/private/super_tone_tx.h \
spandsp/private/swept_tone.h \
Expand Down
4 changes: 1 addition & 3 deletions src/at_interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ SPAN_DECLARE(void) at_call_event(at_state_t *s, int event)
break;
case AT_CALL_EVENT_HANGUP:
span_log(&s->logging, SPAN_LOG_FLOW, "Hangup... at_rx_mode %d\n", s->at_rx_mode);
at_modem_control(s, AT_MODEM_CONTROL_ONHOOK, NULL);
if (s->dte_is_waiting)
{
if (s->ok_is_pending)
Expand All @@ -369,6 +368,7 @@ SPAN_DECLARE(void) at_call_event(at_state_t *s, int event)
if (s->at_rx_mode != AT_MODE_OFFHOOK_COMMAND && s->at_rx_mode != AT_MODE_ONHOOK_COMMAND)
at_put_response_code(s, AT_RESPONSE_CODE_NO_CARRIER);
s->rx_signal_present = false;
at_modem_control(s, AT_MODEM_CONTROL_ONHOOK, NULL);
at_modem_control(s, AT_MODEM_CONTROL_RNG, (void *) 0);
at_set_at_rx_mode(s, AT_MODE_ONHOOK_COMMAND);
break;
Expand Down Expand Up @@ -963,8 +963,6 @@ static const char *at_cmd_D(at_state_t *s, const char *t)
break;
case '+':
/* V.250 6.3.1.1 International access code */
/* TODO: */
break;
case ',':
/* V.250 6.3.1.2 Pause */
/* Pass these through to the application to handle. */
Expand Down
35 changes: 35 additions & 0 deletions src/fax.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,35 @@ SPAN_DECLARE(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len)
}
/*- End of function --------------------------------------------------------*/

static int fax_get_phase(void *user_data)
{
t30_state_t *s = user_data;
return s->phase;
}

static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc)
{
fax_state_t *s;
fax_modems_state_t *t;

s = (fax_state_t *) user_data;
t = &s->modems;

if (s->t30.sslfax.server && type != T30_MODEM_DONE)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Set fallback rx type %d%s\n", type, use_hdlc ? " (HDLC)" : "");
fax_modems_set_rx_handler(t, (span_rx_handler_t) &sslfax_rx, &s->t30.sslfax, (span_rx_fillin_handler_t) NULL, &s->t30.sslfax);
sslfax_setup(&s->t30.sslfax, &s->t30, t30_non_ecm_put, t30_non_ecm_get, t30_hdlc_accept, hdlc_underflow_handler, s->t30.sslfax.tx_use_hdlc, use_hdlc, fax_get_phase);
t->rx_bit_rate = bit_rate;
t->current_rx_type = type;
if (use_hdlc)
{
t30_hdlc_accept(&s->t30, NULL, SIG_STATUS_CARRIER_UP, true);
t30_hdlc_accept(&s->t30, NULL, SIG_STATUS_FRAMING_OK, true);
}
return;
}

span_log(&s->logging, SPAN_LOG_FLOW, "Set rx type %d\n", type);
if (t->current_rx_type == type)
return;
Expand Down Expand Up @@ -295,6 +317,19 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t

s = (fax_state_t *) user_data;
t = &s->modems;

if (s->t30.sslfax.server && type != T30_MODEM_DONE)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Set fallback tx type %d%s\n", type, use_hdlc ? " (HDLC)" : "");
fax_modems_set_tx_handler(t, (span_tx_handler_t) &sslfax_tx, &s->t30.sslfax);
fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &sslfax_tx, &s->t30.sslfax);
sslfax_setup(&s->t30.sslfax, &s->t30, t30_non_ecm_put, t30_non_ecm_get, t30_hdlc_accept, hdlc_underflow_handler, use_hdlc, s->t30.sslfax.rx_use_hdlc, fax_get_phase);
t->transmit = true;
t->tx_bit_rate = bit_rate;
t->current_tx_type = type;
return;
}

span_log(&s->logging, SPAN_LOG_FLOW, "Set tx type %d\n", type);
if (t->current_tx_type == type)
return;
Expand Down
1 change: 1 addition & 0 deletions src/spandsp.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
#include <spandsp/v42bis.h>
#include <spandsp/v18.h>
#include <spandsp/timezone.h>
#include <spandsp/sslfax.h>
#include <spandsp/t4_rx.h>
#include <spandsp/t4_tx.h>
#include <spandsp/image_translate.h>
Expand Down
1 change: 1 addition & 0 deletions src/spandsp/expose.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#include <spandsp/private/data_modems.h>
#include <spandsp/private/fax_modems.h>
#include <spandsp/private/timezone.h>
#include <spandsp/private/sslfax.h>
#include <spandsp/private/image_translate.h>
#include <spandsp/private/t4_t6_decode.h>
#include <spandsp/private/t4_t6_encode.h>
Expand Down
123 changes: 123 additions & 0 deletions src/spandsp/private/sslfax.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* The code in this file was derived from sources taken from (1) HylaFAX+ on
* 13 June 2022. That source states that it was derived from (2) GitHub user,
* "mrwicks", on 9 Oct 2018. That source, itself, was derived from work by
* "Amlendra" published at Aticleworld on 21 May 2017 (3). That work, then,
* references programs (4) Copyright (c) 2000 Sean Walton and Macmillan
* Publishers (The "Linux Socket Programming" book) and are licensed under
* the GPL.
*
* 1. https://hylafax.sourceforge.net
* 2. https://github.com/mrwicks/miscellaneous/tree/master/tls_1.2_example
* 3. https://aticleworld.com/ssl-server-client-using-openssl-in-c/
* 4. http://www.cs.utah.edu/~swalton/listings/sockets/programs/
*
* It is, therefore, presumed that this work is either under the* public
* domain or is licensed under the GPL. A copy of the GPL is as follows...
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
//#ifndef __sslfax_H
//#define __sslfax_H
//
//#include <errno.h>
//#include <unistd.h>
//#include <string.h>
//#include <arpa/inet.h>
//#include <sys/socket.h>
//#include <sys/types.h>
//#include <netinet/in.h>
//#include <resolv.h>
//#include <stdio.h>
//#include <netdb.h>
//#include <openssl/ssl.h>
//#include <openssl/err.h>
//
//#include "Str.h"
//
//struct SSLFaxProcess {
// SSL_CTX *ctx;
// SSL *ssl;
// int server;
// int client;
// fxStr emsg; // error message
//};
//
//struct SSLFax {
//public:
// int getAddressFamily(fxStr& address);
// SSLFaxProcess null();
// SSLFaxProcess startServer(fxStr info, fxStr pemFile);
// SSLFaxProcess startClient(fxStr info, fxStr passcode, const u_char* bitrev, long ms);
// void acceptClient(SSLFaxProcess& sfp, fxStr passcode, int modemFd, long ms);
// bool acceptClient1(SSLFaxProcess& sfp, long ms, bool sustain = false);
// void acceptClient2(SSLFaxProcess& sfp, fxStr passcode, int modemFd, long ms, bool sustain = false);
// void cleanup(SSLFaxProcess& sfp, bool sustain = false);
// int pending(SSLFaxProcess& sfp);
// int read(SSLFaxProcess& sfp, void *buf, size_t count, int modemFd, long ms, bool sustain = false, bool carryon = false);
// int write(SSLFaxProcess& sfp, const u_char *buf, u_int count, const u_char* bitrev, int modemFd, long ms, bool eod, bool sustain = false);
//};
//
//#endif

/*! \file */

#if !defined(_SPANDSP_PRIVATE_SSLFAX_H_)
#define _SPANDSP_PRIVATE_SSLFAX_H_

#include <openssl/ssl.h>
#include <openssl/err.h>

/*!
SSL Fax connection descriptor. This defines the state of a single
instance of an SSL Fax connection.
*/
struct sslfax_state_s
{
/*! \brief The remote SSL Fax URL, if known, else NULL. */
char* url;
SSL_CTX *ctx;
SSL *ssl;
int server;
int client;
int rcp_count;
int ecm_ones;
int ecm_bitpos;
uint8_t ecm_byte;
bool doread;
int signal;
bool do_underflow;
bool cleanup;

get_byte_func_t get_phase;

/*! \brief A user specified opaque pointer passed to the put, get, and hdlc routines. */
void *msg_user_data;
/*! \brief The callback function used to get bytes to be transmitted. */
get_msg_func_t get_msg;
/*! \brief The callback function used to put bytes received. */
put_msg_func_t put_msg;
/*! \brief The callback function used to accept HDLC frames. */
hdlc_frame_handler_t hdlc_accept;
/*! \brief The callback function used for HDLC underflow indication. */
hdlc_underflow_handler_t hdlc_tx_underflow;
/*! \brief Whether or not the data represents HDLC or not. */
bool tx_use_hdlc;
bool rx_use_hdlc;

/*! \brief Error and flow logging control */
logging_state_t logging;
};

#endif
/*- End of file ------------------------------------------------------------*/
4 changes: 4 additions & 0 deletions src/spandsp/private/t30.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#if !defined(_SPANDSP_PRIVATE_T30_H_)
#define _SPANDSP_PRIVATE_T30_H_

#include "spandsp/private/sslfax.h"

/*!
T.30 FAX channel descriptor. This defines the state of a single working
instance of a T.30 FAX channel.
Expand All @@ -51,6 +53,8 @@ struct t30_state_s

/*! \brief Internet aware FAX mode bit mask. */
int iaf;
/*! \brief SSL Fax context. */
sslfax_state_t sslfax;
/*! \brief A bit mask of the currently supported modem types. */
int supported_modems;
/*! \brief A bit mask of the currently supported image compression modes for use
Expand Down
71 changes: 71 additions & 0 deletions src/spandsp/sslfax.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* The code in this file was derived from sources taken from (1) HylaFAX+ on
* 13 June 2022. That source states that it was derived from (2) GitHub user,
* "mrwicks", on 9 Oct 2018. That source, itself, was derived from work by
* "Amlendra" published at Aticleworld on 21 May 2017 (3). That work, then,
* references programs (4) Copyright (c) 2000 Sean Walton and Macmillan
* Publishers (The "Linux Socket Programming" book) and are licensed under
* the GPL.
*
* 1. https://hylafax.sourceforge.net
* 2. https://github.com/mrwicks/miscellaneous/tree/master/tls_1.2_example
* 3. https://aticleworld.com/ssl-server-client-using-openssl-in-c/
* 4. http://www.cs.utah.edu/~swalton/listings/sockets/programs/
*
* It is, therefore, presumed that this work is either under the* public
* domain or is licensed under the GPL. A copy of the GPL is as follows...
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*! \file */

#if !defined(_SPANDSP_SSLFAX_H_)
#define _SPANDSP_SSLFAX_H_

#include <openssl/ssl.h>
#include <openssl/err.h>

#include "spandsp/telephony.h"
#include "spandsp/async.h"
#include "spandsp/hdlc.h"

typedef struct sslfax_state_s sslfax_state_t;

#if defined(__cplusplus)
extern "C"
{
#endif

SPAN_DECLARE(sslfax_state_t *) sslfax_init(sslfax_state_t *s);

SPAN_DECLARE(bool) sslfax_start_client(sslfax_state_t *s);

SPAN_DECLARE(void) sslfax_cleanup(sslfax_state_t *s, bool sustain);

SPAN_DECLARE(int) sslfax_tx(sslfax_state_t *s, int16_t amp[], int len);

SPAN_DECLARE(int) sslfax_rx(sslfax_state_t *s, const int16_t amp[], int len);

SPAN_DECLARE(void) sslfax_setup(sslfax_state_t *s, void *msg_user_data, put_msg_func_t put_msg, get_msg_func_t get_msg, hdlc_frame_handler_t hdlc_accept, hdlc_underflow_handler_t hdlc_tx_underflow, bool tx_use_hdlc, bool rx_use_hdlc, get_byte_func_t get_phase);

SPAN_DECLARE(int) sslfax_write(sslfax_state_t *s, const u_char *buf, u_int count, int modemFd, long ms, bool filter, bool sustain);

SPAN_DECLARE(int) sslfax_read(sslfax_state_t *s, void *buf, size_t count, int modemFd, long ms, bool sustain, bool carryon);

#if defined(__cplusplus)
}
#endif


#endif
/*- End of file ------------------------------------------------------------*/
2 changes: 2 additions & 0 deletions src/spandsp/t30.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#if !defined(_SPANDSP_T30_H_)
#define _SPANDSP_T30_H_

#include "spandsp/sslfax.h"

/*! \page t30_page T.30 FAX protocol handling

\section t30_page_sec_1 What does it do?
Expand Down
10 changes: 8 additions & 2 deletions src/spandsp/t30_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ SPAN_DECLARE(void) t30_set_tx_file(t30_state_t *s, const char *file, int start_p
/*! Set Internet aware FAX (IAF) mode.
\brief Set Internet aware FAX (IAF) mode.
\param s The T.30 context.
\param iaf True for IAF, or false for non-IAF. */
SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, bool iaf);
\param iaf Bitmap for IAF values. */
SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, int iaf);

/*! Specify if error correction mode (ECM) is allowed by a T.30 context.
\brief Select ECM capability.
Expand All @@ -464,6 +464,12 @@ SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, bool iaf);
\return 0 if OK, else -1. */
SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, bool enabled);

/*! Specify if page retransmission is allowed by a T.30 context.
\brief Select page regtransmission capable.
\param s The T.30 context.
\param enabled True for retransmit capable, or false for not retransmit capable. */
SPAN_DECLARE(void) t30_set_retransmit_capable(t30_state_t *s, bool enabled);

/*! Specify the output encoding for TIFF files created during FAX reception.
\brief Specify the output encoding for TIFF files created during FAX reception.
\param s The T.30 context.
Expand Down
Loading