-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.c
121 lines (100 loc) · 2.91 KB
/
plugin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
multivpn - Multiprotocol VPN tool
Copyright (C) 2004 Gorka Gorrotxategi - zgor; Jose Ignacio Sanchez Martin - Topo[LB]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
---------
plugin.c: Plugin handler
*/
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "tcp_plugin.h"
#include "globals.h"
// Active Plugin Functions Pointers
static int (*active_plugin_start)(void);
static int (*active_plugin_build)(void);
static int (*active_plugin_check_parameters)(t_global_v);
static int (*active_plugin_getTunTap)(void);
static int (*active_plugin_fillFDSET)(fd_set*);
static int (*active_plugin_checkFDISSET)(fd_set*);
// Active Plugin Main Thread
static pthread_t active_plugin_thread;
int plugin_checkConfig(t_global_v variables)
{
debug("User selected plugin is: %s",global_v.plugin_name);
if (!strncmp(global_v.plugin_name,"tcp",strlen("tcp")))
{
debug(1,"PLUGIN: tcp plugin selected");
global_v.plugin=TCP_PLUGIN;
active_plugin_start=tcp_plugin_getStart();
active_plugin_build=tcp_plugin_getBuild();
active_plugin_check_parameters=tcp_plugin_getCheckParameters();
active_plugin_fillFDSET=tcp_plugin_getFillFDSET();
active_plugin_checkFDISSET=tcp_plugin_getCheckFDISSET();
active_plugin_getTunTap=tcp_plugin_getTunTap();
return (active_plugin_check_parameters(variables));
}
else
{
debug_error("Plugin: %s not in this source code",global_v.plugin_name);
return(-1);
}
}
int plugin_build()
{
if (pipe(global_v.pipe_from_plugin) || pipe(global_v.pipe_to_plugin) )
{
perror("Plugin: Failed Building Pipes ");
return -1;
}
debug(1,"PLUGIN: Building Active");
if ( active_plugin_build() )
return -1;
return 0;
}
int plugin_start()
{
if (active_plugin_start)
{
// Starting Active Plugin Main Thread
debug(2,"creating plugin thread now");
pthread_create( &active_plugin_thread, NULL, active_plugin_start, NULL);
return 0;
}
else
{
debug_error("Active Plugin Start Call not set!");
return (-1);
}
}
int plugin_getTunTap()
{
}
void plugin_stop()
{
debug(1,"stopping plugin");
}
int plugin_fillFDSET(fd_set *set)
{
debug(3,"Plugin filling fdset for blocking");
active_plugin_fillFDSET(set);
return 0;
}
int plugin_checkFDISSET(fd_set *set)
{
int s;
debug(3,"Plugin Checking read sockets");
return 0;
}