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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
Miranda IM: the free IM client for Microsoft* Windows*
Copyright 2000-2006 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
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
of the License, 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.
*/
#define GetNetlibHandleType(h) (h?*(int*)h:NLH_INVALID)
#define NLH_INVALID 0
#define NLH_USER 'USER'
#define NLH_CONNECTION 'CONN'
#define NLH_BOUNDPORT 'BIND'
#define NLH_PACKETRECVER 'PCKT'
struct NetlibUser {
int handleType;
NETLIBUSER user;
NETLIBUSERSETTINGS settings;
char * szStickyHeaders;
};
struct NetlibNestedCriticalSection {
HANDLE hMutex;
DWORD dwOwningThreadId;
int lockCount;
};
struct NetlibHTTPProxyPacketQueue {
struct NetlibHTTPProxyPacketQueue *next;
PBYTE dataBuffer;
int dataBufferLen;
};
struct NetlibConnection {
int handleType;
SOCKET s;
int usingHttpGateway;
struct NetlibUser *nlu;
SOCKADDR_IN sinProxy;
NETLIBHTTPPROXYINFO nlhpi;
PBYTE dataBuffer;
int dataBufferLen;
DWORD dwLastGetSentTime;
CRITICAL_SECTION csHttpSequenceNums;
HANDLE hOkToCloseEvent;
LONG dontCloseNow;
struct NetlibNestedCriticalSection ncsSend,ncsRecv;
HINSTANCE hInstSecurityDll;
struct NetlibHTTPProxyPacketQueue * pHttpProxyPacketQueue;
int pollingTimeout;
};
struct NetlibBoundPort {
int handleType;
SOCKET s;
WORD wPort;
WORD wExPort;
struct NetlibUser *nlu;
NETLIBNEWCONNECTIONPROC_V2 pfnNewConnectionV2;
HANDLE hThread;
void *pExtra;
};
struct NetlibPacketRecver {
int handleType;
struct NetlibConnection *nlc;
NETLIBPACKETRECVER packetRecver;
};
//netlib.c
void NetlibFreeUserSettingsStruct(NETLIBUSERSETTINGS *settings);
int NetlibCloseHandle(WPARAM wParam,LPARAM lParam);
void NetlibInitializeNestedCS(struct NetlibNestedCriticalSection *nlncs);
void NetlibDeleteNestedCS(struct NetlibNestedCriticalSection *nlncs);
#define NLNCS_SEND 0
#define NLNCS_RECV 1
int NetlibEnterNestedCS(struct NetlibConnection *nlc,int which);
void NetlibLeaveNestedCS(struct NetlibNestedCriticalSection *nlncs);
int NetlibBase64Encode(WPARAM wParam,LPARAM lParam);
int NetlibBase64Decode(WPARAM wParam,LPARAM lParam);
int NetlibHttpUrlEncode(WPARAM wParam,LPARAM lParam);
//netlibbind.c
int NetlibFreeBoundPort(struct NetlibBoundPort *nlbp);
int NetlibBindPort(WPARAM wParam,LPARAM lParam);
int StringToPortsMask(const char *szPorts,BYTE *mask);
//netlibhttp.c
int NetlibHttpSendRequest(WPARAM wParam,LPARAM lParam);
int NetlibHttpRecvHeaders(WPARAM wParam,LPARAM lParam);
int NetlibHttpFreeRequestStruct(WPARAM wParam,LPARAM lParam);
int NetlibHttpTransaction(WPARAM wParam,LPARAM lParam);
void NetlibHttpSetLastErrorUsingHttpResult(int result);
//netlibhttpproxy.c
int NetlibInitHttpConnection(struct NetlibConnection *nlc,struct NetlibUser *nlu,NETLIBOPENCONNECTION *nloc);
int NetlibHttpGatewaySetInfo(WPARAM wParam,LPARAM lParam);
int NetlibHttpSetPollingTimeout(WPARAM wParam,LPARAM lParam);
int NetlibHttpGatewayRecv(struct NetlibConnection *nlc,char *buf,int len,int flags);
int NetlibHttpGatewayPost(struct NetlibConnection *nlc,const char *buf,int len,int flags);
int NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam);
//netliblog.c
void NetlibLogShowOptions(void);
void NetlibDumpData(struct NetlibConnection *nlc,PBYTE buf,int len,int sent,int flags);
void NetlibLogInit(void);
void NetlibLogShutdown(void);
//netlibopenconn.c
DWORD DnsLookup(struct NetlibUser *nlu,const char *szHost);
int WaitUntilReadable(SOCKET s,DWORD dwTimeout);
int NetlibOpenConnection(WPARAM wParam,LPARAM lParam);
//netlibopts.c
int NetlibOptInitialise(WPARAM wParam,LPARAM lParam);
void NetlibSaveUserSettingsStruct(const char *szSettingsModule,NETLIBUSERSETTINGS *settings);
//netlibpktrecver.c
int NetlibPacketRecverCreate(WPARAM wParam,LPARAM lParam);
int NetlibPacketRecverGetMore(WPARAM wParam,LPARAM lParam);
//netlibsock.c
int NetlibSend(WPARAM wParam,LPARAM lParam);
int NetlibRecv(WPARAM wParam,LPARAM lParam);
int NetlibSelect(WPARAM wParam,LPARAM lParam);
int NetlibSelectEx(WPARAM wParam,LPARAM lParam);
//netlibupnp.c
BOOL NetlibUPnPAddPortMapping(WORD intport, char *proto,
WORD *extport, DWORD *extip, BOOL search);
void NetlibUPnPDeletePortMapping(WORD extport, char* proto);
static __inline int NLSend(struct NetlibConnection *nlc,const char *buf,int len,int flags) {
NETLIBBUFFER nlb={(char*)buf,len,flags};
return NetlibSend((WPARAM)nlc,(LPARAM)&nlb);
}
static __inline int NLRecv(struct NetlibConnection *nlc,char *buf,int len,int flags) {
NETLIBBUFFER nlb={buf,len,flags};
return NetlibRecv((WPARAM)nlc,(LPARAM)&nlb);
}
|