-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipother_module.cc
79 lines (66 loc) · 1.83 KB
/
ipother_module.cc
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
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <iostream>
#include "Minet.h"
int main(int argc, char *argv[])
{
MinetHandle mux;
MinetHandle sock;
MinetInit(MINET_IP_OTHER_MODULE);
mux=MinetIsModuleInConfig(MINET_IP_MUX) ? MinetConnect(MINET_IP_MUX) : MINET_NOHANDLE;
sock=MinetIsModuleInConfig(MINET_SOCK_MODULE) ? MinetAccept(MINET_SOCK_MODULE) : MINET_NOHANDLE;
if (mux==MINET_NOHANDLE && MinetIsModuleInConfig(MINET_IP_MUX)) {
MinetSendToMonitor(MinetMonitoringEvent("Can't connect to ip_mux"));
return -1;
}
if (sock==MINET_NOHANDLE && MinetIsModuleInConfig(MINET_SOCK_MODULE)) {
MinetSendToMonitor(MinetMonitoringEvent("Can't accept from sock_module"));
return -1;
}
cerr << "ipother_module handling non-UDP, non-TCP, non-ICMP traffic......."<<endl;
MinetSendToMonitor(MinetMonitoringEvent("ipother_module handling non-UDP, non-TCP, non-ICMP traffic........"));
MinetEvent event;
while (MinetGetNextEvent(event)==0) {
if (event.eventtype!=MinetEvent::Dataflow
|| event.direction!=MinetEvent::IN) {
MinetSendToMonitor(MinetMonitoringEvent("Unknown event ignored."));
} else {
if (event.handle==mux) {
Packet p;
MinetReceive(mux,p);
}
if (event.handle==sock) {
SockRequestResponse req;
MinetReceive(sock,req);
switch (req.type) {
case STATUS:
// ignored, no response needed
break;
case CONNECT:
case ACCEPT:
case WRITE:
case FORWARD:
case CLOSE:
default:
{
SockRequestResponse repl;
// repl.type=SockRequestResponse::STATUS;
repl.type=STATUS;
repl.error=EWHAT;
MinetSend(sock,repl);
}
}
}
}
}
return 0;
}