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
34 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(netbios
);
42 HMODULE NETAPI32_hModule
= 0;
44 static UCHAR
NETBIOS_Enum(PNCB ncb
)
47 LANA_ENUM
*lanas
= (PLANA_ENUM
) ncb
->ncb_buffer
;
48 DWORD apiReturn
, size
= 0;
54 apiReturn
= GetIfTable(NULL
, &size
, FALSE
);
55 if (apiReturn
!= NO_ERROR
)
57 table
= (PMIB_IFTABLE
)malloc(size
);
60 apiReturn
= GetIfTable(table
, &size
, FALSE
);
61 if (apiReturn
== NO_ERROR
)
64 for (i
= 0; i
< table
->dwNumEntries
&& lanas
->length
< MAX_LANA
;
67 if (table
->table
[i
].dwType
!= MIB_IF_TYPE_LOOPBACK
)
69 lanas
->lana
[lanas
->length
] = table
->table
[i
].dwIndex
;
80 ret
= NRC_NORESOURCES
;
88 static UCHAR
NETBIOS_Astat(PNCB ncb
)
90 PADAPTER_STATUS astat
= (PADAPTER_STATUS
) ncb
->ncb_buffer
;
93 TRACE("NCBASTAT (Adapter %d)\n", ncb
->ncb_lana_num
);
95 memset(astat
, 0, sizeof astat
);
97 row
.dwIndex
= ncb
->ncb_lana_num
;
98 if (GetIfEntry(&row
) != NO_ERROR
)
99 return NRC_INVADDRESS
;
100 /* doubt anyone cares, but why not.. */
101 if (row
.dwType
== MIB_IF_TYPE_TOKENRING
)
102 astat
->adapter_type
= 0xff;
104 astat
->adapter_type
= 0xfe; /* for Ethernet */
108 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
110 TRACE("%p,%lx,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
113 case DLL_PROCESS_ATTACH
:
114 DisableThreadLibraryCalls(hinstDLL
);
115 NETAPI32_hModule
= hinstDLL
;
117 case DLL_PROCESS_DETACH
:
124 UCHAR WINAPI
Netbios(PNCB pncb
)
126 UCHAR ret
= NRC_ILLCMD
;
128 TRACE("ncb = %p\n",pncb
);
131 return NRC_INVADDRESS
;
133 switch(pncb
->ncb_command
&0x7f)
136 FIXME("NCBRESET adapter %d\n",pncb
->ncb_lana_num
);
137 if(pncb
->ncb_lana_num
< MAX_LANA
)
141 row
.dwIndex
= pncb
->ncb_lana_num
;
142 if (GetIfEntry(&row
) != NO_ERROR
)
145 ret
= NRC_ILLCMD
; /* NetBIOS emulator not found */
148 ret
= NRC_ILLCMD
; /* NetBIOS emulator not found */
152 FIXME("NCBADDNAME\n");
156 FIXME("NCBADDGRNAME\n");
160 FIXME("NCBDELNAME\n");
172 FIXME("NCBHANGUP\n");
176 FIXME("NCBCANCEL\n");
180 FIXME("NCBLISTEN\n");
184 ret
= NETBIOS_Astat(pncb
);
188 ret
= NETBIOS_Enum(pncb
);
192 FIXME("(%p): command code %02x\n", pncb
, pncb
->ncb_command
);
194 ret
= NRC_ILLCMD
; /* NetBIOS emulator not found */
196 pncb
->ncb_retcode
= ret
;
200 NET_API_STATUS WINAPI
NetServerEnum(
206 LPDWORD totalentries
,
209 LPDWORD resume_handle
212 FIXME("Stub (%p, %ld %p %ld %p %p %ld %s %p)\n",servername
, level
, bufptr
,
213 prefmaxlen
, entriesread
, totalentries
, servertype
, debugstr_w(domain
), resume_handle
);
215 return ERROR_NO_BROWSER_SERVERS_FOUND
;
219 /************************************************************
220 * NetStatisticsGet (NETAPI32.@)
222 NET_API_STATUS WINAPI
NetStatisticsGet(LPWSTR
*server
, LPWSTR
*service
,
223 DWORD level
, DWORD options
,
226 TRACE("(%p, %p, %ld, %ld, %p)\n", server
, service
, level
, options
, bufptr
);
227 return NERR_InternalError
;