2002-06-01 01:06:46 +02:00
|
|
|
/*
|
2001-11-06 18:52:36 +01:00
|
|
|
* Copyright 2001 Mike McCormack
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-11-06 18:52:36 +01:00
|
|
|
*/
|
|
|
|
|
2001-11-06 20:01:05 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-11-06 18:52:36 +01:00
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-11-06 18:52:36 +01:00
|
|
|
#include <stdio.h>
|
2003-06-16 03:23:20 +02:00
|
|
|
#include <stdlib.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-11-06 18:52:36 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-11-06 18:52:36 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-11-06 18:52:36 +01:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "nb30.h"
|
2003-09-11 05:09:19 +02:00
|
|
|
#include "lm.h"
|
2003-06-16 03:23:20 +02:00
|
|
|
#include "iphlpapi.h"
|
2001-11-06 18:52:36 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(netbios);
|
2001-11-06 18:52:36 +01:00
|
|
|
|
|
|
|
HMODULE NETAPI32_hModule = 0;
|
|
|
|
|
2003-02-15 00:29:24 +01:00
|
|
|
static UCHAR NETBIOS_Enum(PNCB ncb)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
LANA_ENUM *lanas = (PLANA_ENUM) ncb->ncb_buffer;
|
2003-06-16 03:23:20 +02:00
|
|
|
DWORD apiReturn, size = 0;
|
|
|
|
PMIB_IFTABLE table;
|
|
|
|
UCHAR ret;
|
|
|
|
|
2003-02-15 00:29:24 +01:00
|
|
|
TRACE("NCBENUM\n");
|
2003-06-16 03:23:20 +02:00
|
|
|
|
|
|
|
apiReturn = GetIfTable(NULL, &size, FALSE);
|
|
|
|
if (apiReturn != NO_ERROR)
|
|
|
|
{
|
|
|
|
table = (PMIB_IFTABLE)malloc(size);
|
|
|
|
if (table)
|
|
|
|
{
|
|
|
|
apiReturn = GetIfTable(table, &size, FALSE);
|
|
|
|
if (apiReturn == NO_ERROR)
|
|
|
|
{
|
|
|
|
lanas->length = 0;
|
|
|
|
for (i = 0; i < table->dwNumEntries && lanas->length < MAX_LANA;
|
|
|
|
i++)
|
|
|
|
{
|
|
|
|
if (table->table[i].dwType != MIB_IF_TYPE_LOOPBACK)
|
|
|
|
{
|
|
|
|
lanas->lana[lanas->length] = table->table[i].dwIndex;
|
|
|
|
lanas->length++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = NRC_GOODRET;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = NRC_SYSTEM;
|
|
|
|
free(table);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = NRC_NORESOURCES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = NRC_SYSTEM;
|
|
|
|
return ret;
|
2001-11-06 18:52:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static UCHAR NETBIOS_Astat(PNCB ncb)
|
|
|
|
{
|
|
|
|
PADAPTER_STATUS astat = (PADAPTER_STATUS) ncb->ncb_buffer;
|
2003-06-16 03:23:20 +02:00
|
|
|
MIB_IFROW row;
|
|
|
|
|
2001-11-06 18:52:36 +01:00
|
|
|
TRACE("NCBASTAT (Adapter %d)\n", ncb->ncb_lana_num);
|
2003-06-16 03:23:20 +02:00
|
|
|
|
2001-11-06 18:52:36 +01:00
|
|
|
memset(astat, 0, sizeof astat);
|
2003-06-16 03:23:20 +02:00
|
|
|
|
|
|
|
row.dwIndex = ncb->ncb_lana_num;
|
|
|
|
if (GetIfEntry(&row) != NO_ERROR)
|
|
|
|
return NRC_INVADDRESS;
|
|
|
|
/* doubt anyone cares, but why not.. */
|
|
|
|
if (row.dwType == MIB_IF_TYPE_TOKENRING)
|
|
|
|
astat->adapter_type = 0xff;
|
|
|
|
else
|
|
|
|
astat->adapter_type = 0xfe; /* for Ethernet */
|
2001-11-06 18:52:36 +01:00
|
|
|
return NRC_GOODRET;
|
|
|
|
}
|
|
|
|
|
2002-11-05 00:53:41 +01:00
|
|
|
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
2001-11-06 18:52:36 +01:00
|
|
|
{
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
|
2001-11-06 18:52:36 +01:00
|
|
|
|
|
|
|
switch (fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2003-06-30 22:53:48 +02:00
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
2001-11-06 18:52:36 +01:00
|
|
|
NETAPI32_hModule = hinstDLL;
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-09-11 05:09:19 +02:00
|
|
|
UCHAR WINAPI Netbios(PNCB pncb)
|
2001-11-06 18:52:36 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
UCHAR ret = NRC_ILLCMD;
|
2001-11-06 18:52:36 +01:00
|
|
|
|
|
|
|
TRACE("ncb = %p\n",pncb);
|
|
|
|
|
|
|
|
if(!pncb)
|
|
|
|
return NRC_INVADDRESS;
|
|
|
|
|
|
|
|
switch(pncb->ncb_command&0x7f)
|
|
|
|
{
|
|
|
|
case NCBRESET:
|
|
|
|
FIXME("NCBRESET adapter %d\n",pncb->ncb_lana_num);
|
2003-06-16 03:23:20 +02:00
|
|
|
if(pncb->ncb_lana_num < MAX_LANA )
|
|
|
|
{
|
|
|
|
MIB_IFROW row;
|
|
|
|
|
|
|
|
row.dwIndex = pncb->ncb_lana_num;
|
|
|
|
if (GetIfEntry(&row) != NO_ERROR)
|
|
|
|
ret = NRC_GOODRET;
|
|
|
|
else
|
|
|
|
ret = NRC_ILLCMD; /* NetBIOS emulator not found */
|
|
|
|
}
|
2001-11-06 18:52:36 +01:00
|
|
|
else
|
|
|
|
ret = NRC_ILLCMD; /* NetBIOS emulator not found */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBADDNAME:
|
|
|
|
FIXME("NCBADDNAME\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBADDGRNAME:
|
|
|
|
FIXME("NCBADDGRNAME\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBDELNAME:
|
|
|
|
FIXME("NCBDELNAME\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBSEND:
|
|
|
|
FIXME("NCBSEND\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBRECV:
|
|
|
|
FIXME("NCBRECV\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBHANGUP:
|
|
|
|
FIXME("NCBHANGUP\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBCANCEL:
|
|
|
|
FIXME("NCBCANCEL\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBLISTEN:
|
|
|
|
FIXME("NCBLISTEN\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBASTAT:
|
|
|
|
ret = NETBIOS_Astat(pncb);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NCBENUM:
|
|
|
|
ret = NETBIOS_Enum(pncb);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("(%p): command code %02x\n", pncb, pncb->ncb_command);
|
|
|
|
|
|
|
|
ret = NRC_ILLCMD; /* NetBIOS emulator not found */
|
|
|
|
}
|
|
|
|
pncb->ncb_retcode = ret;
|
|
|
|
return ret;
|
|
|
|
}
|
2003-05-20 01:06:35 +02:00
|
|
|
|
|
|
|
NET_API_STATUS WINAPI NetServerEnum(
|
|
|
|
LPCWSTR servername,
|
|
|
|
DWORD level,
|
|
|
|
LPBYTE* bufptr,
|
|
|
|
DWORD prefmaxlen,
|
|
|
|
LPDWORD entriesread,
|
|
|
|
LPDWORD totalentries,
|
|
|
|
DWORD servertype,
|
|
|
|
LPCWSTR domain,
|
|
|
|
LPDWORD resume_handle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FIXME("Stub (%p, %ld %p %ld %p %p %ld %s %p)\n",servername, level, bufptr,
|
|
|
|
prefmaxlen, entriesread, totalentries, servertype, debugstr_w(domain), resume_handle);
|
|
|
|
|
|
|
|
return ERROR_NO_BROWSER_SERVERS_FOUND;
|
|
|
|
}
|
2003-09-11 05:09:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* NetStatisticsGet (NETAPI32.@)
|
|
|
|
*/
|
|
|
|
NET_API_STATUS WINAPI NetStatisticsGet(LPWSTR *server, LPWSTR *service,
|
|
|
|
DWORD level, DWORD options,
|
|
|
|
LPBYTE *bufptr)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %ld, %ld, %p)\n", server, service, level, options, bufptr);
|
|
|
|
return NERR_InternalError;
|
|
|
|
}
|