GENERIC_SERVER  0.0.0.9
A light-weight, cross-platform, pluggable, extensible and secure framework for deploying C++ plug-ins.
 All Classes Files Functions Variables Typedefs Pages
util.h
1 /*
2  Copyright 2013 Broadcom Corporation
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
29 #ifndef UTIL_H
30 #define UTIL_H
31 #ifdef WINDOWS
32 #include <ws2tcpip.h>
33 #include <conio.h>
34 #include <process.h>
35 #else
36 #include <sys/socket.h>
37 #include <arpa/inet.h>
38 #include <resolv.h>
39 #include <unistd.h>
40 #include <netinet/in.h>
41 #include <sys/socket.h>
42 #include <signal.h>
43 #include <fcntl.h>
44 #endif
45 #include <openssl/ssl.h>
46 #include <openssl/err.h>
47 #include <openssl/rand.h>
48 #include <stdio.h>
49 
50 #include <iostream>
51 #include <fstream>
52 #include <algorithm>
53 #include <vector>
54 #include <string>
55 #include <sstream>
56 #include <map>
57 #include <utility>
58 using namespace std;
59 
61 {
62 #ifdef WINDOWS
63  HANDLE mutex;
64 #else
65  pthread_mutex_t mutex;
66 #endif
67 };
68 #ifdef WINDOWS
69 int sock_init(void);
70 static HANDLE *mutex_buf;
71 #else
72 static pthread_mutex_t *mutex_buf;
73 #endif
74 #ifndef WINDOWS
75 #define SOCKET int
76 #define SOCKET_ERROR -1
77 #endif
78 #define PLUGIN_SIGNATURE 0xDEDDAECF
79 #define MSG_HDR_SIZE 8
80 #define MAX_SZ 10000
81 void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l,const char *file, int line);
82 void dyn_destroy_function(struct CRYPTO_dynlock_value *l,const char *file, int line);
83 struct CRYPTO_dynlock_value *dyn_create_function(const char *file, int line);
84 void locking_function(int mode, int n, const char *file, int line);
85 unsigned long id_function(void);
86 int ssl_read_socket(unsigned char *line,SOCKET &sock,SSL **ssl_client);
87 int read_socket(unsigned char *buffer,SOCKET sock);
88 int ssl_connect(unsigned char *ip_address, unsigned int port_number,SOCKET &sock,SSL **ssl_client,SSL_CTX **ctx);
89 int sock_connect(unsigned char *ip_address, unsigned int port_number,SOCKET &sock);
93 int ssl_init(SSL_CTX **ctx);
94 int ssl_read(SSL *ssl,char *buf,int size);
95 int setnonblocking(int sock);
96 int setblocking(int sock);
105 int create_message(string plugin_name,string message,char *buff);
106 #endif
Struct to store OS agnostic mutex. Required for Openssl locking functions.
Definition: sslserver.cpp:33