2 * VNBT VxD implementation
4 * Copyright 2003 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(vxd
);
30 typedef struct _nbtInfo
40 #define MAX_NBT_ENTRIES 7
42 typedef struct _nbtTable
45 nbtInfo table
[MAX_NBT_ENTRIES
];
53 /***********************************************************************
54 * DeviceIoControl (VNB.VXD.@)
56 BOOL WINAPI
VNBT_DeviceIoControl(DWORD dwIoControlCode
,
57 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
58 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
59 LPDWORD lpcbBytesReturned
,
60 LPOVERLAPPED lpOverlapped
)
64 switch (dwIoControlCode
)
67 if (lpcbBytesReturned
)
68 *lpcbBytesReturned
= sizeof(nbtTable
);
69 if (!lpvOutBuffer
|| cbOutBuffer
< sizeof(nbtTable
))
70 error
= ERROR_BUFFER_OVERFLOW
;
73 nbtTable
*info
= (nbtTable
*)lpvOutBuffer
;
76 memset(info
, 0, sizeof(nbtTable
));
78 error
= GetNetworkParams(NULL
, &size
);
79 if (ERROR_BUFFER_OVERFLOW
== error
)
81 PFIXED_INFO fixedInfo
= HeapAlloc( GetProcessHeap(), 0, size
);
83 error
= GetNetworkParams(fixedInfo
, &size
);
84 if (NO_ERROR
== error
)
86 info
->nodeType
= (WORD
)fixedInfo
->NodeType
;
87 info
->scopeLen
= min(strlen(fixedInfo
->ScopeId
) + 1,
88 sizeof(info
->scope
) - 2);
89 memcpy(info
->scope
+ 1, fixedInfo
->ScopeId
,
91 info
->scope
[info
->scopeLen
+ 1] = '\0';
93 /* convert into L2-encoded version */
96 for (ptr
= info
->scope
+ 1; *ptr
&&
97 ptr
- info
->scope
< sizeof(info
->scope
); )
99 for (lenPtr
= ptr
- 1, *lenPtr
= 0;
100 *ptr
&& *ptr
!= '.' &&
101 ptr
- info
->scope
< sizeof(info
->scope
);
107 /* could set DNS servers here too, but since
108 * ipconfig.exe and winipcfg.exe read these from the
109 * registry, there's no point */
111 HeapFree(GetProcessHeap(), 0, fixedInfo
);
114 error
= GetAdaptersInfo(NULL
, &size
);
115 if (ERROR_BUFFER_OVERFLOW
== error
)
117 PIP_ADAPTER_INFO adapterInfo
= HeapAlloc(GetProcessHeap(), 0, size
);
119 error
= GetAdaptersInfo(adapterInfo
, &size
);
120 if (NO_ERROR
== error
)
122 PIP_ADAPTER_INFO ptr
;
124 for (ptr
= adapterInfo
; ptr
&& info
->numEntries
<
125 MAX_NBT_ENTRIES
; ptr
= ptr
->Next
)
129 addr
= inet_addr(ptr
->IpAddressList
.IpAddress
.String
);
130 if (addr
!= 0 && addr
!= INADDR_NONE
)
131 info
->table
[info
->numEntries
].ip
= ntohl(addr
);
132 addr
= inet_addr(ptr
->PrimaryWinsServer
.IpAddress
.String
);
133 if (addr
!= 0 && addr
!= INADDR_NONE
)
134 info
->table
[info
->numEntries
].winsPrimary
= ntohl(addr
);
135 addr
= inet_addr(ptr
->SecondaryWinsServer
.IpAddress
.String
);
136 if (addr
!= 0 && addr
!= INADDR_NONE
)
137 info
->table
[info
->numEntries
].winsSecondary
= ntohl(addr
);
141 HeapFree(GetProcessHeap(), 0, adapterInfo
);
147 /* nbtstat.exe uses this, but the return seems to be a bunch of
148 * pointers, so it's not so easy to reverse engineer. Fall through
149 * to unimplemented...
152 FIXME( "Unimplemented control %d for VxD device VNB\n",
154 error
= ERROR_NOT_SUPPORTED
;
159 return error
== NO_ERROR
;