mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Merged EnumProtocolsA and EnumProtocolsW into a single function.
This commit is contained in:
parent
dd1a6d3b02
commit
3c9d1870c8
@ -27,7 +27,7 @@
|
|||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "router.h"
|
#include "router.h"
|
||||||
|
|
||||||
typedef struct _PROTOCOL_INFOA {
|
typedef struct _PROTOCOL_INFO {
|
||||||
DWORD dwServiceFlags ;
|
DWORD dwServiceFlags ;
|
||||||
INT iAddressFamily ;
|
INT iAddressFamily ;
|
||||||
INT iMaxSockAddr ;
|
INT iMaxSockAddr ;
|
||||||
@ -35,16 +35,15 @@ typedef struct _PROTOCOL_INFOA {
|
|||||||
INT iSocketType ;
|
INT iSocketType ;
|
||||||
INT iProtocol ;
|
INT iProtocol ;
|
||||||
DWORD dwMessageSize ;
|
DWORD dwMessageSize ;
|
||||||
LPSTR lpProtocol ;
|
void *lpProtocol ;
|
||||||
} PROTOCOL_INFOA;
|
} PROTOCOL_INFO;
|
||||||
|
|
||||||
INT APIENTRY EnumProtocolsA(LPINT protocols, LPVOID buf, LPDWORD bsptr) {
|
static int do_EnumProtocols(LPINT protocols, LPVOID buf, LPDWORD bsptr, BOOL unicode) {
|
||||||
int bufsize = *bsptr, rval, i, want_ipx = 0;
|
int bufsize = *bsptr, rval, i, want_ipx = 0;
|
||||||
|
|
||||||
PROTOCOL_INFOA *pinfo = buf;
|
PROTOCOL_INFO *pinfo = buf;
|
||||||
|
|
||||||
rval = r_EnumProtocolsA(protocols, buf, bsptr);
|
if((rval = unicode ? r_EnumProtocolsW(protocols, buf, bsptr) : r_EnumProtocolsA(protocols, buf, bsptr)) == -1) {
|
||||||
if(rval == -1) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ INT APIENTRY EnumProtocolsA(LPINT protocols, LPVOID buf, LPDWORD bsptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(i == rval) {
|
if(i == rval) {
|
||||||
*bsptr += sizeof(PROTOCOL_INFOA);
|
*bsptr += sizeof(PROTOCOL_INFO);
|
||||||
rval++;
|
rval++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,72 +82,18 @@ INT APIENTRY EnumProtocolsA(LPINT protocols, LPVOID buf, LPDWORD bsptr) {
|
|||||||
pinfo[i].iSocketType = SOCK_DGRAM;
|
pinfo[i].iSocketType = SOCK_DGRAM;
|
||||||
pinfo[i].iProtocol = NSPROTO_IPX;
|
pinfo[i].iProtocol = NSPROTO_IPX;
|
||||||
pinfo[i].dwMessageSize = 576;
|
pinfo[i].dwMessageSize = 576;
|
||||||
pinfo[i].lpProtocol = "IPX";
|
pinfo[i].lpProtocol = unicode ? (char*)L"IPX" : "IPX";
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _PROTOCOL_INFOW {
|
INT APIENTRY EnumProtocolsA(LPINT protocols, LPVOID buf, LPDWORD bsptr) {
|
||||||
DWORD dwServiceFlags ;
|
return do_EnumProtocols(protocols, buf, bsptr, FALSE);
|
||||||
INT iAddressFamily ;
|
}
|
||||||
INT iMaxSockAddr ;
|
|
||||||
INT iMinSockAddr ;
|
|
||||||
INT iSocketType ;
|
|
||||||
INT iProtocol ;
|
|
||||||
DWORD dwMessageSize ;
|
|
||||||
LPWSTR lpProtocol ;
|
|
||||||
} PROTOCOL_INFOW;
|
|
||||||
|
|
||||||
INT APIENTRY EnumProtocolsW(LPINT protocols, LPVOID buf, LPDWORD bsptr) {
|
INT APIENTRY EnumProtocolsW(LPINT protocols, LPVOID buf, LPDWORD bsptr) {
|
||||||
int bufsize = *bsptr, rval, i, want_ipx = 0;
|
return do_EnumProtocols(protocols, buf, bsptr, TRUE);
|
||||||
|
|
||||||
PROTOCOL_INFOW *pinfo = buf;
|
|
||||||
|
|
||||||
rval = r_EnumProtocolsW(protocols, buf, bsptr);
|
|
||||||
if(rval == -1) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!protocols) {
|
|
||||||
want_ipx = 1;
|
|
||||||
}else{
|
|
||||||
for(i = 0; protocols[i]; i++) {
|
|
||||||
if(protocols[i] == NSPROTO_IPX) {
|
|
||||||
want_ipx = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(want_ipx) {
|
|
||||||
for(i = 0; i < rval; i++) {
|
|
||||||
if(pinfo[i].iProtocol == NSPROTO_IPX) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == rval) {
|
|
||||||
*bsptr += sizeof(PROTOCOL_INFOW);
|
|
||||||
rval++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*bsptr > bufsize) {
|
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pinfo[i].dwServiceFlags = 5641;
|
|
||||||
pinfo[i].iAddressFamily = AF_IPX;
|
|
||||||
pinfo[i].iMaxSockAddr = 16;
|
|
||||||
pinfo[i].iMinSockAddr = 14;
|
|
||||||
pinfo[i].iSocketType = SOCK_DGRAM;
|
|
||||||
pinfo[i].iProtocol = NSPROTO_IPX;
|
|
||||||
pinfo[i].dwMessageSize = 576;
|
|
||||||
pinfo[i].lpProtocol = L"IPX";
|
|
||||||
}
|
|
||||||
|
|
||||||
return rval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKET WSAAPI socket(int af, int type, int protocol) {
|
SOCKET WSAAPI socket(int af, int type, int protocol) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user