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
control.h
Go to the documentation of this file.
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 CTRL_H
30 #define CTRL_H
31 
32 #include <map>
33 #include <vector>
34 #include <iostream>
35 #include <iomanip>
36 #include <fstream>
37 using namespace std;
38 #ifndef WINDOWS
39 #include <pthread.h>
40 #else
41 #define MSG_NOSIGNAL 0
42 #endif
43 #include "sslserver.h"
44 #define TLS_REQ 1
45 #define SOCKET_REQ 2
46 
47 void sig_int(int sig_num);
48 void do_nothing(int sig_num);
49 
50 #ifdef WINDOWS
51 unsigned _stdcall thread_fn(void *inp_arg);
52 unsigned _stdcall ssl_thread_fn(void *inp_arg);
53 BOOL CtrlHandler( DWORD fdwCtrlType );
54 #else
55 void *thread_fn(void *inp_arg);
56 void *ssl_thread_fn(void *inp_arg);
57 void daemonize();
58 #define PR_SET_NAME 15
59 #endif
60 unsigned int get_data_size(unsigned char *recvbuf);
61 int add_size(unsigned char *recvbuf,unsigned int size);
62 string get_input_plugin_name(char *buffer);
82 static int process_client_req(SOCKET clnt_sock,int plugin_init_state,GENERIC_PLUGIN *plugin_p,
83  int thread_no,generic_server *framework);
103 static int process_ssl_client_req(SOCKET clnt_sock,SSL *ssl,int plugin_init_state,GENERIC_PLUGIN *plugin_p,
104  int thread_no,generic_server *framework);
105 
117 static int terminate_client_session(SOCKET clnt_sock,generic_server *framework, GENERIC_PLUGIN *plugin_p,
118  int thread_no,unsigned char *senduf);
119 
131 static int terminate_ssl_client_session(SSL *ssl,generic_server *framework, GENERIC_PLUGIN *plugin_p,
132  int thread_no,unsigned char *senduf);
133 static int print_source_hostname(int clnt_sock,int req_type,generic_server *framework,int thread_no,
134  GENERIC_PLUGIN *plugin_p);
136 static int process_data(void);
137 static unsigned int init_sock_fds(fd_set *,SOCKET);
138 static int chk_command_sock(fd_set *,SOCKET);
147 static int launch_thread(GENERIC_PLUGIN *generic_plugin,unsigned int new_slot);
148 static int chk_all_clients(fd_set *socks);
149 static int read_socket(unsigned char *buffer,SOCKET sock,int size);
150 #endif
static int terminate_ssl_client_session(SSL *ssl, generic_server *framework, GENERIC_PLUGIN *plugin_p, int thread_no, unsigned char *senduf)
Definition: control.cpp:435
static int terminate_client_session(SOCKET clnt_sock, generic_server *framework, GENERIC_PLUGIN *plugin_p, int thread_no, unsigned char *senduf)
Definition: control.cpp:416
This is a singleton class and provides framework functionality.
This component provides functionality that are common across plug-ins. Framework would instantiate an...
static int process_client_req(SOCKET clnt_sock, int plugin_init_state, GENERIC_PLUGIN *plugin_p, int thread_no, generic_server *framework)
static int process_data(void)
Main loop to 'select()' sockets from multiple clients.
Definition: control.cpp:614
static int launch_thread(GENERIC_PLUGIN *generic_plugin, unsigned int new_slot)
Definition: control.cpp:689
static int process_ssl_client_req(SOCKET clnt_sock, SSL *ssl, int plugin_init_state, GENERIC_PLUGIN *plugin_p, int thread_no, generic_server *framework)
Utility class for TLS. Please refer excellent documentation at: http://www.openssl.org/docs/ssl/ssl.html.