From dd1a6d3b0262028d0a59e6ecdaabc0b341609052 Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Wed, 7 Sep 2011 23:03:14 +0000 Subject: [PATCH] Cleaned up some winsock includes, changed EnumProtocolsW to use correct PROTOCOL_INFO structure. --- Makefile | 5 ++-- include/wsnwlink.h | 49 ++++++++++++++++++++++++++++++++++ src/winsock.c | 35 +++++++++++++++++++----- src/winstuff.h | 66 ---------------------------------------------- 4 files changed, 80 insertions(+), 75 deletions(-) create mode 100644 include/wsnwlink.h delete mode 100644 src/winstuff.h diff --git a/Makefile b/Makefile index 964185c..828a4ff 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,10 @@ IPXWRAPPER_DEPS := src/ipxwrapper.o src/winsock.o src/ipxwrapper_stubs.o src/log BIN_FILES := changes.txt license.txt readme.txt ipxwrapper.dll mswsock.dll wsock32.dll ipxconfig.exe SRC_FILES := changes.txt license.txt Makefile mkstubs.pl readme.txt src/config.h src/ipxconfig.cpp \ src/ipxwrapper.c src/ipxwrapper.def src/ipxwrapper.h src/ipxwrapper_stubs.txt src/log.c \ - src/mswsock.def src/mswsock_stubs.txt src/stubdll.c src/winsock.c src/winstuff.h src/wsock32.def \ + src/mswsock.def src/mswsock_stubs.txt src/stubdll.c src/winsock.c src/wsock32.def \ src/wsock32_stubs.txt src/directplay.c src/dpwsockx.def src/dpwsockx_stubs.txt src/common.c \ - src/common.h src/router.c src/router.h include/dplay.h include/dplaysp.h include/dplobby.h + src/common.h src/router.c src/router.h include/dplay.h include/dplaysp.h include/dplobby.h \ + include/wsnwlink.h all: ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe dpwsockx.dll diff --git a/include/wsnwlink.h b/include/wsnwlink.h new file mode 100644 index 0000000..5a5bb8b --- /dev/null +++ b/include/wsnwlink.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2003,2004 Roderick Colenbrander + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _WSNWLINK_ +#define _WSNWLINK_ + +#define IPX_PTYPE 0x4000 +#define IPX_FILTERPTYPE 0x4001 +#define IPX_DSTYPE 0x4002 +#define IPX_STOPFILTERPTYPE 0x4003 +#define IPX_EXTENDED_ADDRESS 0x4004 +#define IPX_RECVHDR 0x4005 +#define IPX_MAXSIZE 0x4006 +#define IPX_ADDRESS 0x4007 +#define IPX_GETNETINFO 0x4008 +#define IPX_GETNETINFO_NORIP 0x4009 +#define IPX_SPXGETCONNECTIONSTATUS 0x400b +#define IPX_ADDRESS_NOTIFY 0x400c +#define IPX_MAX_ADAPTER_NUM 0x400d +#define IPX_RERIPNETNUMBER 0x400e +#define IPX_RECEIVE_BROADCAST 0x400f +#define IPX_IMMEDIATESPXACK 0x4010 + +typedef struct _IPX_ADDRESS_DATA { + INT adapternum; + UCHAR netnum[4]; + UCHAR nodenum[6]; + BOOLEAN wan; + BOOLEAN status; + INT maxpkt; + ULONG linkspeed; +} IPX_ADDRESS_DATA, *PIPX_ADDRESS_DATA; + +#endif /* _WSNWLINK_ */ diff --git a/src/winsock.c b/src/winsock.c index 6eb330e..d799538 100644 --- a/src/winsock.c +++ b/src/winsock.c @@ -20,18 +20,28 @@ #include #include #include - -#include "winstuff.h" +#include #include "ipxwrapper.h" #include "common.h" #include "interface.h" #include "router.h" +typedef struct _PROTOCOL_INFOA { + DWORD dwServiceFlags ; + INT iAddressFamily ; + INT iMaxSockAddr ; + INT iMinSockAddr ; + INT iSocketType ; + INT iProtocol ; + DWORD dwMessageSize ; + LPSTR lpProtocol ; +} PROTOCOL_INFOA; + INT APIENTRY EnumProtocolsA(LPINT protocols, LPVOID buf, LPDWORD bsptr) { int bufsize = *bsptr, rval, i, want_ipx = 0; - PROTOCOL_INFO *pinfo = buf; + PROTOCOL_INFOA *pinfo = buf; rval = r_EnumProtocolsA(protocols, buf, bsptr); if(rval == -1) { @@ -57,7 +67,7 @@ INT APIENTRY EnumProtocolsA(LPINT protocols, LPVOID buf, LPDWORD bsptr) { } if(i == rval) { - *bsptr += sizeof(PROTOCOL_INFO); + *bsptr += sizeof(PROTOCOL_INFOA); rval++; } @@ -79,10 +89,21 @@ INT APIENTRY EnumProtocolsA(LPINT protocols, LPVOID buf, LPDWORD bsptr) { return rval; } +typedef struct _PROTOCOL_INFOW { + DWORD dwServiceFlags ; + 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 bufsize = *bsptr, rval, i, want_ipx = 0; - PROTOCOL_INFO *pinfo = buf; + PROTOCOL_INFOW *pinfo = buf; rval = r_EnumProtocolsW(protocols, buf, bsptr); if(rval == -1) { @@ -108,7 +129,7 @@ INT APIENTRY EnumProtocolsW(LPINT protocols, LPVOID buf, LPDWORD bsptr) { } if(i == rval) { - *bsptr += sizeof(PROTOCOL_INFO); + *bsptr += sizeof(PROTOCOL_INFOW); rval++; } @@ -124,7 +145,7 @@ INT APIENTRY EnumProtocolsW(LPINT protocols, LPVOID buf, LPDWORD bsptr) { pinfo[i].iSocketType = SOCK_DGRAM; pinfo[i].iProtocol = NSPROTO_IPX; pinfo[i].dwMessageSize = 576; - pinfo[i].lpProtocol = (char*)L"IPX"; + pinfo[i].lpProtocol = L"IPX"; } return rval; diff --git a/src/winstuff.h b/src/winstuff.h deleted file mode 100644 index 485f942..0000000 --- a/src/winstuff.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ipxwrapper - Winsock/win32 stuff - * Copyright (C) 2008 Daniel Collins - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * 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., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef WINSTUFF_H -#define WINSTUFF_H - -#define IPX_PTYPE 0x4000 -#define IPX_FILTERPTYPE 0x4001 -#define IPX_STOPFILTERPTYPE 0x4003 -#define IPX_MAXSIZE 0x4006 -#define IPX_ADDRESS 0x4007 -#define IPX_MAX_ADAPTER_NUM 0x400D - -typedef struct _PROTOCOL_INFOA { - DWORD dwServiceFlags ; - INT iAddressFamily ; - INT iMaxSockAddr ; - INT iMinSockAddr ; - INT iSocketType ; - INT iProtocol ; - DWORD dwMessageSize ; - LPSTR lpProtocol ; -} PROTOCOL_INFOA; - -typedef struct _PROTOCOL_INFOW { - DWORD dwServiceFlags ; - INT iAddressFamily ; - INT iMaxSockAddr ; - INT iMinSockAddr ; - INT iSocketType ; - INT iProtocol ; - DWORD dwMessageSize ; - LPWSTR lpProtocol ; -} PROTOCOL_INFOW; - -typedef struct _IPX_ADDRESS_DATA { - INT adapternum; - UCHAR netnum[4]; - UCHAR nodenum[6]; - BOOLEAN wan; - BOOLEAN status; - INT maxpkt; - ULONG linkspeed; -} IPX_ADDRESS_DATA; - -#ifdef UNICODE -typedef PROTOCOL_INFOW PROTOCOL_INFO; -#else -typedef PROTOCOL_INFOA PROTOCOL_INFO; -#endif - -#endif /* !WINSTUFF_H */