"Fossies" - the Fresh Open Source Software Archive

Member "hylafax-7.0.2/faxd/sslfax.h" (5 Dec 2019, 2609 Bytes) of package /linux/misc/hylafax-7.0.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sslfax.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * The code in this file was derived from sources taken from (1) GitHub user,
    3  * "mrwicks", on 9 Oct 2018.  That source, itself, was derived from work by
    4  * "Amlendra" published at Aticleworld on 21 May 2017 (2).  That work, then,
    5  * references programs (3) Copyright (c) 2000 Sean Walton and Macmillan
    6  * Publishers (The "Linux Socket Programming" book) and are licensed under
    7  * the GPL.
    8  *
    9  * 1. https://github.com/mrwicks/miscellaneous/tree/master/tls_1.2_example
   10  * 2. https://aticleworld.com/ssl-server-client-using-openssl-in-c/
   11  * 3. http://www.cs.utah.edu/~swalton/listings/sockets/programs/
   12  *
   13  * It is, therefore, presumed that this work is either under the* public
   14  * domain or is licensed under the GPL.  A copy of the GPL is as follows...
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  */
   28 #ifndef __sslfax_H
   29 #define __sslfax_H
   30 
   31 #include <errno.h>
   32 #include <unistd.h>
   33 #include <malloc.h>
   34 #include <string.h>
   35 #include <arpa/inet.h>
   36 #include <sys/socket.h>
   37 #include <sys/types.h>
   38 #include <netinet/in.h>
   39 #include <resolv.h>
   40 #include <stdio.h>
   41 #include <netdb.h>
   42 #include <openssl/ssl.h>
   43 #include <openssl/err.h>
   44 
   45 #include "Str.h"
   46 
   47 struct SSLFaxProcess {
   48     SSL_CTX *ctx;
   49     SSL *ssl;
   50     int server;
   51     int client;
   52     fxStr emsg;     // error message
   53 };
   54 
   55 struct SSLFax {
   56 public:
   57     int getAddressFamily(fxStr& address);
   58     SSLFaxProcess null();
   59     SSLFaxProcess startServer(fxStr info, fxStr pemFile);
   60     SSLFaxProcess startClient(fxStr info, fxStr passcode, const u_char* bitrev, long ms);
   61     void acceptClient(SSLFaxProcess& sfp, fxStr passcode, int modemFd, long ms);
   62     void cleanup(SSLFaxProcess& sfp);
   63     int pending(SSLFaxProcess& sfp);
   64     int read(SSLFaxProcess& sfp, void *buf, size_t count, int modemFd, long ms);
   65     int write(SSLFaxProcess& sfp, const u_char *buf, u_int count, const u_char* bitrev, int modemFd, long ms, bool eod);
   66 };
   67 
   68 #endif