21
21
#include " OspeDll.h"
22
22
#include " FilterManager.h"
23
23
#include < sstream>
24
-
24
+ # include " Utils.h "
25
25
26
26
// #define DBG_BLOCKPKT // para debuggear packets bloqueados
27
27
#define DBG_SENDPACKETDATA // para debuggear data de los packets
@@ -41,10 +41,10 @@ void SetInfo(SOCKET socket, Functions functionId, int length, PacketInfo* info)
41
41
socklen_t addr_len = sizeof (struct sockaddr_storage );
42
42
43
43
if (getsockname (socket, (struct sockaddr *)&addrLocal, &addr_len) == SOCKET_ERROR)
44
- errorLog (strm (2 , " getsockname: " , itos (WSAGetLastError ())));
44
+ Utils:: errorLog (Utils:: strm (2 , " getsockname: " , Utils::IntToString (WSAGetLastError ())));
45
45
46
46
if (getpeername (socket, (struct sockaddr *)&addrRemote, &addr_len) == SOCKET_ERROR)
47
- errorLog (strm (2 , " getpeername: " , itos (WSAGetLastError ())));
47
+ Utils:: errorLog (Utils:: strm (2 , " getpeername: " , Utils::IntToString (WSAGetLastError ())));
48
48
49
49
// deal with both IPv4 and IPv6:
50
50
if (addrLocal.ss_family == AF_INET)
@@ -59,7 +59,7 @@ void SetInfo(SOCKET socket, Functions functionId, int length, PacketInfo* info)
59
59
else
60
60
{ // AF_INET6
61
61
// Falta implementar
62
- errorLog (" CRASH ALERT: IPv6 SOCKET NOT IMPLEMENTED" );
62
+ Utils:: errorLog (" CRASH ALERT: IPv6 SOCKET NOT IMPLEMENTED" );
63
63
// struct sockaddr_in6 *sock_addr = (struct sockaddr_in6 *)&addrFrom;
64
64
// info->portFrom = ntohs(sock_addr->sin6_port);
65
65
// inet_ntop(AF_INET6, &sock_addr->sin6_addr, ipstr, sizeof ipstr);
@@ -83,14 +83,24 @@ void ProcessPacket(Functions functionId, char* &buffer, int &length, SOCKET sock
83
83
if (!client.IsOk ())
84
84
{
85
85
#ifdef DBG_SENDPACKETDATA
86
- errorLog (" Fail to open MMF!!" , 1 );
86
+ Utils:: errorLog (" Fail to open MMF!!" , 1 );
87
87
#endif
88
88
return ;
89
89
}
90
90
91
91
// Set needed packet info (ip, port, Function, Size)
92
92
PacketInfo info;
93
- SetInfo (socket, functionId, (int )length, &info);
93
+ if (socket != NULL )
94
+ SetInfo (socket, functionId, (int )length, &info);
95
+ else {
96
+ info.functionId = functionId;
97
+ info.localIp = 0 ;
98
+ info.localPort = 0 ;
99
+ info.remoteIp = 0 ;
100
+ info.remotePort = 0 ;
101
+ info.size = length;
102
+ info.socketId = 0 ;
103
+ }
94
104
95
105
// Set data
96
106
@@ -99,7 +109,7 @@ void ProcessPacket(Functions functionId, char* &buffer, int &length, SOCKET sock
99
109
std::stringstream sinfo;
100
110
sinfo << " GOT Info - FunctionID=" << info.functionId << " LocalIp=" << info.localIp << " LocalPort=" << info.localPort << " RemoteIp="
101
111
<< info.remoteIp << " RemotePort=" << info.remotePort << " Size=" << info.size ;
102
- errorLog ((char *)sinfo.str ().c_str (), 2 );
112
+ Utils:: errorLog ((char *)sinfo.str ().c_str (), 2 );
103
113
#endif
104
114
105
115
char * pBuff = (char *) malloc (sizeof (info) + length);
@@ -137,6 +147,12 @@ void ProcessPacket(Functions functionId, char* &buffer, int &length, SOCKET sock
137
147
free (pBuff);
138
148
}
139
149
150
+ void ProcessPacket (Functions functionId, char *& buffer, int & length)
151
+ {
152
+ bool blocked = false ;
153
+ ProcessPacket (functionId, buffer, length, NULL , blocked);
154
+ }
155
+
140
156
void InjectPacket ()
141
157
{
142
158
SOCKET s = (((UINT8)readData[2 ] << 8 ) | (UINT8)readData[1 ]);
@@ -184,7 +200,7 @@ DWORD WINAPI Command_Reader(LPVOID context)
184
200
UnLoadDllEx ();
185
201
break ;
186
202
default :
187
- errorLog (" UNKNOWN SERVER CODE!" );
203
+ Utils:: errorLog (" UNKNOWN SERVER CODE!" );
188
204
}
189
205
190
206
}
0 commit comments