2 * Copyright 2001 Mike McCormack
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(netbios);
40 HMODULE NETAPI32_hModule = 0;
42 static UCHAR NETBIOS_Enum(PNCB ncb)
45 LANA_ENUM *lanas = (PLANA_ENUM) ncb->ncb_buffer;
46 DWORD apiReturn, size = 0;
52 apiReturn = GetIfTable(NULL, &size, FALSE);
53 if (apiReturn != NO_ERROR)
55 table = (PMIB_IFTABLE)malloc(size);
58 apiReturn = GetIfTable(table, &size, FALSE);
59 if (apiReturn == NO_ERROR)
62 for (i = 0; i < table->dwNumEntries && lanas->length < MAX_LANA;
65 if (table->table[i].dwType != MIB_IF_TYPE_LOOPBACK)
67 lanas->lana[lanas->length] = table->table[i].dwIndex;
78 ret = NRC_NORESOURCES;
86 static UCHAR NETBIOS_Astat(PNCB ncb)
88 PADAPTER_STATUS astat = (PADAPTER_STATUS) ncb->ncb_buffer;
91 TRACE("NCBASTAT (Adapter %d)\n", ncb->ncb_lana_num);
93 memset(astat, 0, sizeof astat);
95 row.dwIndex = ncb->ncb_lana_num;
96 if (GetIfEntry(&row) != NO_ERROR)
97 return NRC_INVADDRESS;
98 /* doubt anyone cares, but why not.. */
99 if (row.dwType == MIB_IF_TYPE_TOKENRING)
100 astat->adapter_type = 0xff;
102 astat->adapter_type = 0xfe; /* for Ethernet */
106 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
108 TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
111 case DLL_PROCESS_ATTACH:
112 DisableThreadLibraryCalls(hinstDLL);
113 NETAPI32_hModule = hinstDLL;
115 case DLL_PROCESS_DETACH:
122 BOOL WINAPI Netbios(PNCB pncb)
124 UCHAR ret = NRC_ILLCMD;
126 TRACE("ncb = %p\n",pncb);
129 return NRC_INVADDRESS;
131 switch(pncb->ncb_command&0x7f)
134 FIXME("NCBRESET adapter %d\n",pncb->ncb_lana_num);
135 if(pncb->ncb_lana_num < MAX_LANA )
139 row.dwIndex = pncb->ncb_lana_num;
140 if (GetIfEntry(&row) != NO_ERROR)
143 ret = NRC_ILLCMD; /* NetBIOS emulator not found */
146 ret = NRC_ILLCMD; /* NetBIOS emulator not found */
150 FIXME("NCBADDNAME\n");
154 FIXME("NCBADDGRNAME\n");
158 FIXME("NCBDELNAME\n");
170 FIXME("NCBHANGUP\n");
174 FIXME("NCBCANCEL\n");
178 FIXME("NCBLISTEN\n");
182 ret = NETBIOS_Astat(pncb);
186 ret = NETBIOS_Enum(pncb);
190 FIXME("(%p): command code %02x\n", pncb, pncb->ncb_command);
192 ret = NRC_ILLCMD; /* NetBIOS emulator not found */
194 pncb->ncb_retcode = ret;
198 NET_API_STATUS WINAPI NetServerEnum(
204 LPDWORD totalentries,
207 LPDWORD resume_handle
210 FIXME("Stub (%p, %ld %p %ld %p %p %ld %s %p)\n",servername, level, bufptr,
211 prefmaxlen, entriesread, totalentries, servertype, debugstr_w(domain), resume_handle);
213 return ERROR_NO_BROWSER_SERVERS_FOUND;