diff --git a/dlls/netapi32/netapi32.c b/dlls/netapi32/netapi32.c index 21c2a9b6148..8a379b4d79e 100644 --- a/dlls/netapi32/netapi32.c +++ b/dlls/netapi32/netapi32.c @@ -99,22 +99,15 @@ int get_hw_address(int sd, struct ifreq *ifr, unsigned char *address) # endif /* SIOCGENADDR */ # endif /* SIOCGIFHWADDR */ -static UCHAR NETBIOS_Enum(PNCB ncb) +int enum_hw(void) { + int ret = 0; #ifdef HAVE_NET_IF_H int sd; struct ifreq ifr, *ifrp; struct ifconf ifc; unsigned char buf[1024]; int i, ofs; -#endif - LANA_ENUM *lanas = (PLANA_ENUM) ncb->ncb_buffer; - - TRACE("NCBENUM\n"); - - lanas->length = 0; - -#ifdef HAVE_NET_IF_H /* BSD 4.4 defines the size of an ifreq to be * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len * However, under earlier systems, sa_len isn't present, so @@ -156,13 +149,49 @@ static UCHAR NETBIOS_Enum(PNCB ncb) a[0],a[1],a[2],a[3],a[4],a[5]); NETBIOS_Adapter[i].valid = TRUE; - lanas->lana[lanas->length] = i; - lanas->length++; + + ret++; } ofs += ifreq_size(ifr); } close(sd); + TRACE("found %d adapters\n",ret); #endif /* HAVE_NET_IF_H */ + return ret; +} + +void wprint_mac(WCHAR* buffer, int index) +{ + int i; + unsigned char val; + for (i = 0; i<6; i++) + { + val = NETBIOS_Adapter[index].address[i]; + if ((val >>4) >9) + buffer[2*i] = (WCHAR)((val >>4) + 'A' - 10); + else + buffer[2*i] = (WCHAR)((val >>4) + '0'); + if ((val & 0xf ) >9) + buffer[2*i+1] = (WCHAR)((val & 0xf) + 'A' - 10); + else + buffer[2*i+1] = (WCHAR)((val & 0xf) + '0'); + } + buffer[12]=(WCHAR)0; + +} +static UCHAR NETBIOS_Enum(PNCB ncb) +{ + int i; + LANA_ENUM *lanas = (PLANA_ENUM) ncb->ncb_buffer; + + TRACE("NCBENUM\n"); + + lanas->length = 0; + for (i = 0; i < enum_hw(); i++) + { + lanas->lana[lanas->length] = i; + lanas->length++; + } return NRC_GOODRET; } @@ -266,4 +295,3 @@ BOOL WINAPI Netbios(PNCB pncb) pncb->ncb_retcode = ret; return ret; } - diff --git a/dlls/netapi32/netapi32.spec b/dlls/netapi32/netapi32.spec index d83f3425bda..a8ed5bd507e 100644 --- a/dlls/netapi32/netapi32.spec +++ b/dlls/netapi32/netapi32.spec @@ -198,7 +198,7 @@ @ stub NetWkstaSetInfo @ stub NetWkstaTransportAdd @ stub NetWkstaTransportDel -@ stub NetWkstaTransportEnum +@ stdcall NetWkstaTransportEnum (wstr long ptr long ptr ptr ptr) NetWkstaTransportEnum @ stub NetWkstaUserEnum @ stdcall NetWkstaUserGetInfo(wstr long ptr) NetWkstaUserGetInfo @ stub NetWkstaUserSetInfo diff --git a/dlls/netapi32/wksta.c b/dlls/netapi32/wksta.c index a7193d2c4e6..320296675e1 100644 --- a/dlls/netapi32/wksta.c +++ b/dlls/netapi32/wksta.c @@ -59,6 +59,76 @@ BOOL NETAPI_IsLocalComputer(LPCWSTR ServerName) } } +int enum_hw(void); +void wprint_mac(WCHAR* buffer, int index); + +NET_API_STATUS WINAPI +NetWkstaTransportEnum(LPCWSTR ServerName, DWORD level, LPBYTE* pbuf, + DWORD prefmaxlen, LPDWORD read_entries, + LPDWORD total_entries, LPDWORD hresume) +{ + FIXME(":%s, 0x%08lx, %p, 0x%08lx, %p, %p, %p\n", debugstr_w(ServerName), + level, pbuf, prefmaxlen, read_entries, total_entries,hresume); + if (!NETAPI_IsLocalComputer(ServerName)) + { + FIXME(":not implemented for non-local computers\n"); + return ERROR_INVALID_LEVEL; + } + else + { + if (hresume && *hresume) + { + FIXME(":resume handle not implemented\n"); + return ERROR_INVALID_LEVEL; + } + + switch (level) + { + case 0: /* transport info */ + { + PWKSTA_TRANSPORT_INFO_0 ti; + int i,size_needed,n_adapt = enum_hw(); + + size_needed = n_adapt * (sizeof(WKSTA_TRANSPORT_INFO_0) + * 13 * sizeof (WCHAR)); + if (prefmaxlen == MAX_PREFERRED_LENGTH) + NetApiBufferAllocate( size_needed, (LPVOID *) pbuf); + else + { + if (size_needed > prefmaxlen) + return ERROR_MORE_DATA; + NetApiBufferAllocate(prefmaxlen, + (LPVOID *) pbuf); + } + for (i = 0; i wkti0_quality_of_service=0; + ti->wkti0_number_of_vcs=0; + ti->wkti0_transport_name=NULL; + ti->wkti0_transport_address= (LPWSTR) + ((PBYTE )*pbuf + n_adapt* sizeof(WKSTA_TRANSPORT_INFO_0) + + i * 13 * sizeof (WCHAR)); + ti->wkti0_wan_ish=TRUE; /*TCPIP/NETBIOS Protocoll*/ + wprint_mac(ti->wkti0_transport_address,i); + TRACE("%d of %d:ti at %p transport_address at %p %s\n",i,n_adapt, + ti, ti->wkti0_transport_address, debugstr_w(ti->wkti0_transport_address)); + } + if(read_entries)*read_entries = n_adapt; + if(total_entries)*total_entries = n_adapt; + if(hresume) *hresume= 0; + break; + } + default: + ERR("Invalid level %ld is specified\n", level); + return ERROR_INVALID_LEVEL; + } + return NERR_Success; + } +} + + /************************************************************ * NetWkstaUserGetInfo (NETAPI32.@) */ diff --git a/include/lmwksta.h b/include/lmwksta.h index 19c52d8810d..8eba78af300 100644 --- a/include/lmwksta.h +++ b/include/lmwksta.h @@ -28,6 +28,14 @@ extern "C" { /* NetBIOS */ UCHAR WINAPI Netbios(PNCB pncb); +typedef struct _WKSTA_TRANSPORT_INFO_0 { + DWORD wkti0_quality_of_service; + DWORD wkti0_number_of_vcs; + LPWSTR wkti0_transport_name; + LPWSTR wkti0_transport_address; + BOOL wkti0_wan_ish; +} WKSTA_TRANSPORT_INFO_0, *PWKSTA_TRANSPORT_INFO_0, *LPWKSTA_TRANSPORT_INFO_0; + typedef struct _WKSTA_USER_INFO_0 { LPWSTR wkui0_username; } WKSTA_USER_INFO_0, *PWKSTA_USER_INFO_0, *LPWKSTA_USER_INFO_0;