summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/delphi/m_netlib.inc348
-rw-r--r--include/m_netlib.h136
2 files changed, 55 insertions, 429 deletions
diff --git a/include/delphi/m_netlib.inc b/include/delphi/m_netlib.inc
index 3bfe107306..ab60822163 100644
--- a/include/delphi/m_netlib.inc
+++ b/include/delphi/m_netlib.inc
@@ -219,24 +219,6 @@ type
validateSSL :int;
end;
- TNetlibNewConnectionProc = procedure(hNewConnection:THANDLE; dwRemoveIP:dword); cdecl;
- TNetlibNewConnectionProc_V2 = procedure(hNewConnection:THANDLE; dwRemoveIP:dword; pExtra:pointer); cdecl;
-
- PNETLIBBIND = ^TNETLIBBIND;
- TNETLIBBIND = record
- cbSize:int;
- // new code should use V2
- pfnNewConnection:TNETLIBNEWCONNECTIONPROC;
- // or pfnNewConnectionV2:NETLIBNEWCONNECTIONPROC_V2;
- //function to call when there's a new connection. Params are: the
- //new connection, IP of remote machine (host byte order)
- dwInternalIP:dword; //set on return, host byte order
- wPort :word; //set on return, host byte order
- pExtra :^pointer; //argument is sent to callback, added during 0.3.4+
- dwExternalIP:dword; //set on return, host byte order
- wExPort :word; //set on return, host byte order
- end;
-
type
PNETLIBHTTPPROXYINFO = ^TNETLIBHTTPPROXYINFO;
TNETLIBHTTPPROXYINFO = record
@@ -249,49 +231,6 @@ type
combinePackets : int; // MIRANDA_VER >= 0x0900
end;
-type
- PNETLIBBUFFER = ^TNETLIBBUFFER;
- TNETLIBBUFFER = record
- buf : PAnsiChar;
- len : int;
- flags: int; // see MSG_* constants above
- end;
-
- PNETLIBSELECT = ^TNETLIBSELECT;
- TNETLIBSELECT = record
- cbSize : int;
- dwTimeout : dword; // in milliseconds, INFINITE is acceptable
- hReadConns : array [0..FD_SETSIZE] of THANDLE;
- hWriteConns : array [0..FD_SETSIZE] of THANDLE;
- hExceptConns: array [0..FD_SETSIZE] of THANDLE;
- end;
-
- PNETLIBSELECTEX = ^TNETLIBSELECTEX;
- TNETLIBSELECTEX = record
- cbSize : int;
- dwTimeout : dword; // in milliseconds, INFINITE is acceptable
- hReadConns : array [0..FD_SETSIZE] of THANDLE;
- hWriteConns : array [0..FD_SETSIZE] of THANDLE;
- hExceptConns: array [0..FD_SETSIZE] of THANDLE;
- // Added in v0.3.3+
- hReadStatus : array [0..FD_SETSIZE] of bool; // out, [in, expected to be FALSE]
- hWriteStatus : array [0..FD_SETSIZE] of bool; // out, [in, expected to be FALSE]
- hExceptStatus: array [0..FD_SETSIZE] of bool; // out, [in, expected to be FALSE]
- end;
-
- PNETLIBPACKETRECVER = ^TNETLIBPACKETRECVER;
- TNETLIBPACKETRECVER = record
- cbSize : int;
- dwTimeout : dword; // infinite is allowed -- initialise before use
- bytesUsed : int; // this many bytes are removed from the start of the
- // buffer, set to 0 on return -- initialise before use
- bytesAvailable: int; // equal the returnd value by service, unless the
- // return value is 0 (connection closed)
- bufferSize : int; // same as the parameter given to
- // MS_NETLIB_CREATEPACKETRECVER: wParam
- buffer : PByte; // contains the read data
- end;
-
{
Affects: Initialises the netlib for a set of connections, see notes
Returns: Returns a handle for future netlib calls, NULL on failure.
@@ -323,8 +262,7 @@ function Netlib_RegisterUser(pInfo:PNETLIBUSER) : THANDLE; stdcall; external App
Errors : ERROR_INVALID_PARAMETER
}
-const
- MS_NETLIB_GETUSERSETTINGS:PAnsiChar = 'Netlib/GetUserSettings';
+function Netlib_GetUserSettings(nlu:THANDLE; nlus:PNETLIBUSERSETTINGS) : int; stdcall; external AppDll;
{
Affects: Closes a handle, see notes
@@ -337,136 +275,6 @@ const
function Netlib_CloseHandle(pHandle:THANDLE) : int; stdcall; external AppDll;
{
- wParam : HANDLE
- lParam : Pointer to a initialised TNETLIBBIND
- Affects: Open a port and wait for connections on it -- see notes
- Returns: Returns a handle on success, NULL(0) on failure
- Notes : this function does the equivalent of socket(), bind(), getsockname(),
- listen(), accept() -- internally this function creates a new thread
- which waits around in accept() for new connections.
- When one is received, TNETLIBBIND.pfnNewConnection is called,
- from the context of the NEW thread and then it
- returns to waiting for connections.
- -
- Close the returned handle to end the thread and close the port.
- -
- Errors : ERROR_INVALID_PARAMETER, any returned by socket(), bind(), listen()
- getsockname()
- }
-
-const
- MS_NETLIB_BINDPORT:PAnsiChar = 'Netlib/BindPort';
-
- {
- wParam : HANDLE
- lParam : Pointer to an initalised TNETLIBOPENCONNECTION structure
- Affects: Opens a connection -- see notes
- Returns: Returns a Handle to a new connection on success, NULL(0) on failure
- Notes : internally this service is the equivalent of socket(), gethostbyname(),
- connect()
- -
- If NLOCF_HTTP is set and HANDLE is configured for HTTP(S) proxy
- then this function will connect() to that proxy server ONLY,
- without performing any initialisation conversation.
- -
- If HANDLE is configured for an HTTP proxy and does not support
- HTTP gateways and you try to open a connection without NLOCF_HTTP
- then this service will first attempt to open an HTTPS connection,
- if that fails, it will try a direct connection, if *that* fails
- then it will return failure with the error
- from connect() during the connection attempt
- Errors : ERROR_INVALID_PARAMETER, any returned by socket(), gethostbyname(),
- connect(), MS_NETLIB_SEND, MS_NETLIB_RECV, select()
- -
- ERROR_TIMEOUT (during proxy communication)
- ERROR_BAD_FORMAT (very invalid proxy reply)
- ERROR_ACCESS_DENIED (by proxy)
- ERROR_CONNECTION_UNAVAIL (socks proxy can't connect to identd)
- ERROR_INVALID_ACCESS (proxy refused identd auth)
- ERROR_INVALID_DATA (proxy returned invalid code)
- ERROR_INVALID_ID_AUTHORITY (proxy requires use of auth method that's not supported)
- ERROR_GEN_FAILURE (socks5/https general failure)
- ERROR_CALL_NOT_IMPLEMENTED (socks5 command not supported)
- ERROR_INVALID_ADDRESS (socks5 address type not supported)
- -
- HTTP: anything from TNETLIBUSER.pfnHttpGatewayInit, TNETLIBUSER.pfnHttpGatewayBegin,
- MS_NETLIB_SENDHTTPREQUEST or MS_NETLIB_RECVHTTPHEADERS
- }
- MS_NETLIB_OPENCONNECTION:PAnsiChar = 'Netlib/OpenConnection';
-
- {
- wParam : HANDLE
- lParam : Pointer to an initialised NETLIBHTTPPROXYINFO structure
- Affects: Sets the required information for an HTTP proxy connection -- see notes
- Returns: [non zero] on success, NULL(0) on failure
- Notes : This service is designed to be called from
- within TNETLIBUSER.pfnHttpGatewayInit (see notes in C header under
- MS_NETLIB_REGISTERUSER)
- Errors : ERROR_INVALID_PARAMETER
- }
- MS_NETLIB_SETHTTPPROXYINFO:PAnsiChar = 'Netlib/SetHttpProxyInfo';
-
- {
- wParam : HANDLE
- lParam : 0
- Affects: Get's the SOCKET associated with a handle -- see notes
- Returns: the SOCKET on success, INVALID_SOCKET on failure
- Notes : The Netlib handle passed to this service should only be passed
- if they were returned with MS_NETLIB_OPENCONNECTION or MS_NETLIB_BINDPORT
- -
- Be careful how you use this socket because you might be connected via an
- HTTP proxy, in which case calling send/recv() will break things
- -
- Errors : ERROR_INVALID_PARAMETER
- }
- MS_NETLIB_GETSOCKET:PAnsiChar = 'Netlib/GetSocket';
-
-{
- Converts string representation of IP and port into numerical SOCKADDR_INET
- IPv4 could supplied in formats address:port or address
- IPv6 could supplied in formats [address]:port or [address]
- wParam=(WPARAM)(char*) string to convert
- lParam=(LPARAM)(SOCKADDR_INET*) numeric IP address structure
- Returns 0 on success
-}
- MS_NETLIB_STRINGTOADDRESS:PAnsiChar = 'Netlib/StringToAddress';
-
-{
- Converts numerical representation of IP in SOCKADDR_INET into string representation with IP and port
- IPv4 will be supplied in formats address:port or address
- IPv6 will be supplied in formats [address]:port or [address]
- wParam=(WPARAM)(int) 0 - lParam - (SOCKADDR_INET*); 1 - lParam - (unsigned) in host byte order
- lParam=(LPARAM)(SOCKADDR_INET*) or (unsigned) numeric IP address structure
- Returns pointer to the string or NULL if not successful
-}
- MS_NETLIB_ADDRESSTOSTRING:PAnsiChar = 'Netlib/AddressToString';
-
-type
- TNETLIBCONNINFO = record
- cbSize :int;
- szIpPort:array [0..63] of AnsiChar;
- dwIpv4 :uint;
- wPort :word;
- end;
-
-const
-{
- Get connection Information
- IPv4 will be supplied in formats address:port or address
- IPv6 will be supplied in formats [address]:port or [address]
- wParam=(WPARAM)(HANDLE)hConnection
- lParam=(LPARAM)(NETLIBCONNINFO*) pointer to the connection information structure to fill
- Returns 0 if successful
-}
- MS_NETLIB_GETCONNECTIONINFO:PAnsiChar = 'Netlib/GetConnectionInfo';
-
-type
- TNETLIBIPLIST = record
- cbNum:uint;
- szIp :array[0..0,0..63] of AnsiChar;
- end;
-
- {
Affect : Free the memory used by a TNETLIBHTTPREQUEST structure, see notes
Returns: [non zero] on success, NULL(0) on failure
Notes : This service should only be used with memory pointers returned
@@ -562,72 +370,6 @@ function Netlib_Send(hConn:THANDLE; pBuf:Pointer; len,flags:int) : int; stdcall;
function Netlib_Recv(hConn:THANDLE; pBuf:Pointer; len,flags:int) : int; stdcall; external AppDll;
{
- wParam : 0
- lParam : Pointer to an initialised TNETLIBSELECT structure
- Affect : Determine the status of one or more connections, see notes
- Returns: The numbe of ready connections, SOCKET_ERROR on failure
- Notes : All handles passed to this service must have been returned
- either by MS_NETLIB_OPENCONNECTION or MS_NETLIB_BINDPORT,
- the last handle in each list must be followed by either NULL
- or INVALID_HANDLE_VALUE.
- Errors : ERROR_INVALID_HANDLE, ERROR_INVALID_DATA, anything from select()
- }
-const
- MS_NETLIB_SELECT :PAnsiChar = 'Netlib/Select';
- MS_NETLIB_SELECTEX:PAnsiChar = 'Netlib/SelectEx'; // added in v0.3.3
-
-{
- Shutdown connection
- wParam=(WPARAM)(HANDLE)hConnection
- lParam=(LPARAM)0
- Returns 0
-}
- MS_NETLIB_SHUTDOWN:PAnsiChar = 'Netlib/Shutdown';
-
- {
- wParam : HANDLE
- lParam : maxPacketSize
- Affect : Create a packet receiver, see notes
- Returns: A handle on success, NULL(0) on failure
- Notes : The packet receiver implements the common situation where
- you have a variable length of packets coming thru over a connection
- and you want them split up in order to handle them.
- -
- The major limiation is, that the buffer is created in memory,
- so you can't have arbitrarily large packets
- Errors : ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY
- }
- MS_NETLIB_CREATEPACKETRECVER:PAnsiChar = 'Netlib/CreatePacketRecver';
-
- {
- wParam : Handle returned by MS_NETLIB_CREATEPACKETRECVER
- lParam : Pointer to an initialised TNETLIBPACKETRECVER
- Returns: The total number of bytes available in the buffer, NULL(0)
- if the connection was closed or SOCKET_ERROR.
- -
- If TNETLIBPACKETRECVER.bytesUsed is set to zero and the
- buffer is already full up to the maxPacketSize, it is assumed
- that a too large packet has been received, All data in
- the buffer is discarded and receiving has started anew.
- -
- This will probably cause alignment problem so if you think
- that tis iss likely to happen, then you should deal with it
- yourself.
- -
- Closing the packet receiver will not close the associated
- connection but will discard any bytes still in the buffer,
- so if you intend to carry on reading from that connection,
- make sure you have processed the buffer first.
- -
- This service is equivalent of memmove() to remove
- the first bytesUsed from the buffer, select(), if dwTimeOut
- is not INFINITE, then MS_NETLIB_RECV
- Errors : ERROR_INVALID_PARAMETER, ERROR_TIMEOUT, anything from select(),
- MS_NETLIB_RECV
- }
- MS_NETLIB_GETMOREPACKETS:PAnsiChar = 'Netlib/GetMorePackets';
-
- {
Affect : Add a message to the log (if it's running) see notes
Returns: non zeror on success, NULL(0) on failure
Notes : Don't include \r\n or #13#10 it's not needed,
@@ -641,92 +383,4 @@ const
function Netlib_Log(nlu:THANDLE; str:PAnsiChar) : int; stdcall; external AppDll;
function Netlib_LogW(nlu:THANDLE; str:PWideChar) : int; stdcall; external AppDll;
-{
- Makes connection SSL
- wParam=(WPARAM)(HANDLE)hConn
- lParam=0
- Returns 0 on failure 1 on success
-}
-
-const
- MS_NETLIB_STARTSSL:PAnsiChar = 'Netlib/StartSsl';
-
-type
- TNETLIBSSL = record
- cbSize:int;
- host :PAnsiChar; // Expected host name
- flags :int; // Reserved
- end;
-
-const
-/////////////////////////////////////////////////////////////////////////////////////////
-// Security providers (0.6+)
-
- NNR_UNICODE = 1;
-// Inits a required security provider. Right now only NTLM is supported
-// Returns HANDLE = NULL on error or non-null value on success
-// Known providers: Basic, NTLM, Negotiate, Kerberos, GSSAPI - (Kerberos SASL)
- MS_NETLIB_INITSECURITYPROVIDER:PAnsiChar = 'Netlib/InitSecurityProvider';
-
-type
- TNETLIBNTLMINIT2 = record
- cbSize :size_t;
- szProviderName:TChar;
- szPrincipal :TChar;
- flags :uint;
- end;
-
-const
- MS_NETLIB_INITSECURITYPROVIDER2:PAnsiChar = 'Netlib/InitSecurityProvider2';
-
-// Destroys a security provider's handle, provided by Netlib_InitSecurityProvider.
-// Right now only NTLM is supported
- MS_NETLIB_DESTROYSECURITYPROVIDER:PAnsiChar = 'Netlib/DestroySecurityProvider';
-
-// Returns the NTLM response string. The result value should be freed using mir_free
- MS_NETLIB_NTLMCREATERESPONSE:PAnsiChar = 'Netlib/NtlmCreateResponse';
-
-type
- TNETLIBNTLMREQUEST = record
- szChallenge:PAnsiChar;
- userName :PAnsiChar;
- password :PAnsiChar;
-// complete :int; // not present in last versions
- end;
-
-type
- TNETLIBNTLMREQUEST2 = record
- cbSize :size_t;
- szChallenge:PAnsiChar;
- szUserName :TChar;
- szPassword :TChar;
- complete :uint;
- flags :uint;
- end;
-
-const
- MS_NETLIB_NTLMCREATERESPONSE2 = 'Netlib/NtlmCreateResponse2';
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Netlib hooks (0.8+)
-
-// WARNING: these hooks are being called in the context of the calling thread, without switching
-// to the first thread, like all another events do. The hook procedure should be ready for the
-// multithreaded mode
-//
-// Parameters:
-// wParam: NETLIBNOTIFY* - points to the data being sent/received
-// lParam: NETLIBUSER* - points to the protocol definition
-
-type
- TNETLIBNOTIFY = record
- nlb :PNETLIBBUFFER; // pointer to the request buffer
- result:int; // amount of bytes really sent/received
- end;
-
-const
- ME_NETLIB_FASTRECV :PAnsiChar = 'Netlib/OnRecv'; // being called on every receive
- ME_NETLIB_FASTSEND :PAnsiChar = 'Netlib/OnSend'; // being called on every send
- ME_NETLIB_FASTDUMP :PAnsiChar = 'Netlib/OnDump'; // being called on every dump
-
{$ENDIF}
diff --git a/include/m_netlib.h b/include/m_netlib.h
index 1ab848528c..eb343ce4a1 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -170,16 +170,6 @@ When you call MS_NETLIB_SEND or MS_NETLIB_RECV from any of these functions, you
should use the MSG_DUMPPROXY flag so that the logging is neat.
*/
-/////////////////////////////////////////////////////////////////////////////////////////
-// Gets the user-configured settings for a netlib user
-// wParam = (WPARAM)(HANDLE)hUser
-// lParam = (LPARAM)(NETLIBUSERSETTINGS*)&nlus
-// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
-// The pointers referred to in the returned struct will remain valid until
-// the hUser handle is closed, or until the user changes the settings in the
-// options page, so it's best not to rely on them for too long.
-// Errors: ERROR_INVALID_PARAMETER
-
#define PROXYTYPE_SOCKS4 1
#define PROXYTYPE_SOCKS5 2
#define PROXYTYPE_HTTP 3
@@ -206,11 +196,20 @@ struct NETLIBUSERSETTINGS
int validateSSL;
};
-#define MS_NETLIB_GETUSERSETTINGS "Netlib/GetUserSettings"
+/////////////////////////////////////////////////////////////////////////////////////////
+// Gets the user-configured settings for a netlib user
+//
+// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
+// The pointers referred to in the returned struct will remain valid until
+// the hUser handle is closed, or until the user changes the settings in the
+// options page, so it's best not to rely on them for too long.
+// Errors: ERROR_INVALID_PARAMETER
+
+EXTERN_C MIR_APP_DLL(int) Netlib_GetUserSettings(HNETLIBUSER nlu, NETLIBUSERSETTINGS *result);
+/////////////////////////////////////////////////////////////////////////////////////////
// Changes the user-configurable settings for a netlib user
-// wParam = (WPARAM)(HANDLE)hUser
-// lParam = (LPARAM)(NETLIBUSERSETTINGS*)&nlus
+//
// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
// This function is only really useful for people that specify NUF_NOOPTIONS
// and want to create their own options.
@@ -218,9 +217,11 @@ struct NETLIBUSERSETTINGS
// zero) that settings is still set for use in the options dialog.
// Errors: ERROR_INVALID_PARAMETER
-#define MS_NETLIB_SETUSERSETTINGS "Netlib/SetUserSettings"
+EXTERN_C MIR_APP_DLL(int) Netlib_SetUserSettings(HNETLIBUSER nlu, const NETLIBUSERSETTINGS *result);
+/////////////////////////////////////////////////////////////////////////////////////////
// Closes a netlib handle
+//
// Returns nonzero on success, 0 on failure (!! this is different to most of the rest of Miranda, but consistent with netlib)
// This function should be called on all handles returned by netlib functions
// once you are done with them. If it's called on a socket-type handle, the
@@ -231,8 +232,7 @@ EXTERN_C MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE h);
/////////////////////////////////////////////////////////////////////////////////////////
// Open a port and wait for connections on it
-// wParam = (WPARAM)(HANDLE)hUser
-// lParam = (LPARAM)(NETLIBBIND*)&nlb
+//
// Returns a HANDLE on success, NULL on failure
// hUser should have been returned by MS_NETLIB_REGISTERUSER
// This function does the equivalent of socket(), bind(), getsockname(),
@@ -261,7 +261,7 @@ EXTERN_C MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE h);
/* pExtra was added during 0.3.4+, prior its just two args, since we use the cdecl convention
it shouldnt matter */
-typedef void (*NETLIBNEWCONNECTIONPROC_V2)(HANDLE hNewConnection, DWORD dwRemoteIP, void * pExtra);
+typedef void (*NETLIBNEWCONNECTIONPROC_V2)(HANDLE hNewConnection, DWORD dwRemoteIP, void *pExtra);
typedef void (*NETLIBNEWCONNECTIONPROC)(HANDLE hNewConnection, DWORD dwRemoteIP);
struct NETLIBBIND
@@ -271,21 +271,21 @@ struct NETLIBBIND
NETLIBNEWCONNECTIONPROC pfnNewConnection;
NETLIBNEWCONNECTIONPROC_V2 pfnNewConnectionV2;
};
- // function to call when there's a new connection. Params are: the
- // new connection, IP of remote machine (host byte order)
+
+ // function to call when there's a new connection. Params are: the
+ // new connection, IP of remote machine (host byte order)
DWORD dwInternalIP; // set on return, host byte order
- WORD wPort; // set on return, host byte order
- void * pExtra; // argument is sent to callback, added during 0.3.4+
+ WORD wPort; // set on return, host byte order
+ void *pExtra; // argument is sent to callback
DWORD dwExternalIP; // set on return, host byte order
- WORD wExPort; // set on return, host byte order
+ WORD wExPort; // set on return, host byte order
};
-#define MS_NETLIB_BINDPORT "Netlib/BindPort"
+EXTERN_C MIR_APP_DLL(HANDLE) Netlib_BindPort(HNETLIBUSER nlu, NETLIBBIND *nlb);
/////////////////////////////////////////////////////////////////////////////////////////
// Open a connection
-// wParam = (WPARAM)(HANDLE)hUser
-// lParam = (LPARAM)(NETLIBOPENCONNECTION*)&nloc
+//
// Returns a HANDLE to the new connection on success, NULL on failure
// hUser must have been returned by MS_NETLIB_REGISTERUSER
// Internally this function is the equivalent of socket(), gethostbyname(),
@@ -320,12 +320,6 @@ struct NETLIBBIND
#define NLOCF_SSL 0x0010 // this connection is SSL
#define NLOCF_HTTPGATEWAY 0x0020 // this connection is HTTP Gateway
-/* Added during 0.4.0+ development!! (2004/11/29) prior to this, connect() blocks til a connection is made or
-a hard timeout is reached, this can be anywhere between 30-60 seconds, and it stops Miranda from unloading whilst
-this is attempted, clearing sucking - so now you can set a timeout of any value, there is still a hard limit which is
-always reached by Windows, If a timeout occurs, or Miranda is exiting then you will get ERROR_TIMEOUT as soon as possible.
-*/
-
struct NETLIBOPENCONNECTION
{
int cbSize;
@@ -338,7 +332,7 @@ struct NETLIBOPENCONNECTION
int (*waitcallback) (unsigned int * timeout);
};
-#define MS_NETLIB_OPENCONNECTION "Netlib/OpenConnection"
+EXTERN_C MIR_APP_DLL(HANDLE) Netlib_OpenConnection(HNETLIBUSER nlu, const NETLIBOPENCONNECTION *nloc);
/////////////////////////////////////////////////////////////////////////////////////////
// Sets the required information for an HTTP proxy connection
@@ -387,32 +381,14 @@ struct NETLIBHTTPPROXYINFO
EXTERN_C MIR_APP_DLL(HNETLIBUSER) Netlib_GetConnNlu(HANDLE hConn);
/////////////////////////////////////////////////////////////////////////////////////////
-// Converts string representation of IP and port into numerical SOCKADDR_INET
-// IPv4 could supplied in formats address:port or address
-// IPv6 could supplied in formats [address]:port or [address]
-// wParam = (WPARAM)(char*) string to convert
-// lParam = (LPARAM)(SOCKADDR_INET*) numeric IP address structure
-// Returns 0 on success
-
-#define MS_NETLIB_STRINGTOADDRESS "Netlib/StringToAddress"
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Converts numerical representation of IP in SOCKADDR_INET into string representation with IP and port
// IPv4 will be supplied in formats address:port or address
// IPv6 will be supplied in formats [address]:port or [address]
-// wParam = (WPARAM)(int)0 - lParam - (sockaddr_gen*); 1 - lParam - (unsigned) in host byte order
-// lParam = (LPARAM)(sockaddr_gen*) or (unsigned) numeric IP address structure
// Returns pointer to the string or NULL if not successful
-#define MS_NETLIB_ADDRESSTOSTRING "Netlib/AddressToString"
-
-struct NETLIBCONNINFO
-{
- int cbSize;
- char szIpPort[64];
- unsigned dwIpv4;
- WORD wPort;
-};
+struct sockaddr_in;
+EXTERN_C MIR_APP_DLL(char*) Netlib_AddressToString(sockaddr_in *addr);
+EXTERN_C MIR_APP_DLL(bool) Netlib_StringToAddress(const char *str, sockaddr_in *addr);
/////////////////////////////////////////////////////////////////////////////////////////
// Get connection Information
@@ -422,26 +398,33 @@ struct NETLIBCONNINFO
// lParam = (LPARAM)(NETLIBCONNINFO*) pointer to the connection information structure to fill
// Returns 0 if successful
-#define MS_NETLIB_GETCONNECTIONINFO "Netlib/GetConnectionInfo"
-
-struct NETLIBIPLIST
+struct NETLIBCONNINFO
{
- unsigned cbNum;
- char szIp[1][64];
+ int cbSize;
+ char szIpPort[64];
+ unsigned dwIpv4;
+ WORD wPort;
};
+#define MS_NETLIB_GETCONNECTIONINFO "Netlib/GetConnectionInfo"
+
/////////////////////////////////////////////////////////////////////////////////////////
// Get connection Information
// wParam = (WPARAM)IP filter 1 - return global only IPv6 address, 0 all IPs
// Returns (INT_PTR)(NETLIBIPLIST*) numeric IP address address array
// the last element of the array is all 0s, 0 if not successful
+struct NETLIBIPLIST
+{
+ unsigned cbNum;
+ char szIp[1][64];
+};
+
#define MS_NETLIB_GETMYIP "Netlib/GetMyIP"
/////////////////////////////////////////////////////////////////////////////////////////
// Send an HTTP request over a connection
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = (LPARAM)(NETLIBHTTPREQUEST*)&nlhr
+//
// Returns number of bytes sent on success, SOCKET_ERROR on failure
// hConnection must have been returned by MS_NETLIB_OPENCONNECTION
// Note that if you use NLHRF_SMARTAUTHHEADER and NTLM authentication is in use
@@ -495,7 +478,7 @@ struct NETLIBHTTPREQUEST
int timeout;
};
-#define MS_NETLIB_SENDHTTPREQUEST "Netlib/SendHttpRequest"
+EXTERN_C MIR_APP_DLL(int) Netlib_SendHttpRequest(HANDLE hConnection, NETLIBHTTPREQUEST *pRec);
/////////////////////////////////////////////////////////////////////////////////////////
// Receives HTTP headers
@@ -675,21 +658,12 @@ struct NETLIBSELECTEX
/////////////////////////////////////////////////////////////////////////////////////////
// Shutdown connection
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = 0
-// Returns 0
-
-#define MS_NETLIB_SHUTDOWN "Netlib/Shutdown"
-__forceinline void Netlib_Shutdown(HANDLE h)
-{
- CallService(MS_NETLIB_SHUTDOWN, (WPARAM)h, 0);
-}
+EXTERN_C MIR_APP_DLL(void) Netlib_Shutdown(HANDLE h);
/////////////////////////////////////////////////////////////////////////////////////////
// Create a packet receiver
-// wParam = (WPARAM)(HANDLE)hConnection
-// lParam = (LPARAM)(int)maxPacketSize
+//
// Returns a HANDLE on success, NULL on failure
// The packet receiver implements the common situation where you have variable
// length packets coming in over a connection and you want to split them up
@@ -698,12 +672,11 @@ __forceinline void Netlib_Shutdown(HANDLE h)
// have arbitrarily large packets.
// Errors: ERROR_INVALID_PARAMETER, ERROR_OUTOFMEMORY
-#define MS_NETLIB_CREATEPACKETRECVER "Netlib/CreatePacketRecver"
+EXTERN_C MIR_APP_DLL(HANDLE) Netlib_CreatePacketReceiver(HANDLE hConnection, int iMaxSize);
/////////////////////////////////////////////////////////////////////////////////////////
// Get the next set of packets from a packet receiver
-// wParam = (WPARAM)(HANDLE)hPacketRecver
-// lParam = (LPARAM)(NETLIBPACKETRECVER*)&nlpr
+//
// Returns the total number of bytes available in the buffer, 0 if the
// connection was closed, SOCKET_ERROR on error.
// hPacketRecver must have been returned by MS_NETLIB_CREATEPACKETRECVER
@@ -722,15 +695,14 @@ __forceinline void Netlib_Shutdown(HANDLE h)
struct NETLIBPACKETRECVER
{
- int cbSize;
- DWORD dwTimeout; // fill before calling. In milliseconds. INFINITE is valid
- int bytesUsed; // fill before calling. This many bytes are removed from the start of the buffer. Set to 0 on return
- int bytesAvailable; // equal to the return value, unless the return value is 0
- int bufferSize; // same as parameter to MS_NETLIB_CREATEPACKETRECVER
- BYTE *buffer; // contains the recved data
+ DWORD dwTimeout; // fill before calling. In milliseconds. INFINITE is valid
+ int bytesUsed; // fill before calling. This many bytes are removed from the start of the buffer. Set to 0 on return
+ int bytesAvailable; // equal to the return value, unless the return value is 0
+ int bufferSize; // same as parameter to MS_NETLIB_CREATEPACKETRECVER
+ BYTE *buffer; // contains the recved data
};
-#define MS_NETLIB_GETMOREPACKETS "Netlib/GetMorePackets"
+EXTERN_C MIR_APP_DLL(int) Netlib_GetMorePackets(HANDLE hReceiver, NETLIBPACKETRECVER *nlprParam);
/////////////////////////////////////////////////////////////////////////////////////////
// Sets a gateway polling timeout interval