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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(vxd
);
33 #define INADDR_NONE ~0UL
36 typedef struct _nbtInfo
46 #define MAX_NBT_ENTRIES 7
48 typedef struct _nbtTable
51 nbtInfo table
[MAX_NBT_ENTRIES
];
59 /***********************************************************************
60 * DeviceIoControl (VNB.VXD.@)
62 BOOL WINAPI
VNBT_DeviceIoControl(DWORD dwIoControlCode
,
63 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
64 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
65 LPDWORD lpcbBytesReturned
,
66 LPOVERLAPPED lpOverlapped
)
70 switch (dwIoControlCode
)
73 if (lpcbBytesReturned
)
74 *lpcbBytesReturned
= sizeof(nbtTable
);
75 if (!lpvOutBuffer
|| cbOutBuffer
< sizeof(nbtTable
))
76 error
= ERROR_BUFFER_OVERFLOW
;
79 nbtTable
*info
= (nbtTable
*)lpvOutBuffer
;
82 memset(info
, 0, sizeof(nbtTable
));
84 error
= GetNetworkParams(NULL
, &size
);
85 if (ERROR_BUFFER_OVERFLOW
== error
)
87 PFIXED_INFO fixedInfo
= (PFIXED_INFO
)HeapAlloc( GetProcessHeap(), 0, size
);
89 error
= GetNetworkParams(fixedInfo
, &size
);
90 if (NO_ERROR
== error
)
92 info
->nodeType
= (WORD
)fixedInfo
->NodeType
;
93 info
->scopeLen
= min(strlen(fixedInfo
->ScopeId
) + 1,
94 sizeof(info
->scope
) - 2);
95 memcpy(info
->scope
+ 1, fixedInfo
->ScopeId
,
97 info
->scope
[info
->scopeLen
+ 1] = '\0';
99 /* convert into L2-encoded version */
102 for (ptr
= info
->scope
+ 1; *ptr
&&
103 ptr
- info
->scope
< sizeof(info
->scope
); )
105 for (lenPtr
= ptr
- 1, *lenPtr
= 0;
106 *ptr
&& *ptr
!= '.' &&
107 ptr
- info
->scope
< sizeof(info
->scope
);
113 /* could set DNS servers here too, but since
114 * ipconfig.exe and winipcfg.exe read these from the
115 * registry, there's no point */
118 HeapFree(GetProcessHeap(), 0, fixedInfo
);
121 error
= GetAdaptersInfo(NULL
, &size
);
122 if (ERROR_BUFFER_OVERFLOW
== error
)
124 PIP_ADAPTER_INFO adapterInfo
= HeapAlloc(GetProcessHeap(), 0, size
);
126 error
= GetAdaptersInfo(adapterInfo
, &size
);
127 if (NO_ERROR
== error
)
129 PIP_ADAPTER_INFO ptr
= adapterInfo
;
131 for (ptr
= adapterInfo
; ptr
&& info
->numEntries
<
132 MAX_NBT_ENTRIES
; ptr
= ptr
->Next
)
136 addr
= inet_addr(ptr
->IpAddressList
.IpAddress
.String
);
137 if (addr
!= 0 && addr
!= INADDR_NONE
)
138 info
->table
[info
->numEntries
].ip
= ntohl(addr
);
139 addr
= inet_addr(ptr
->PrimaryWinsServer
.IpAddress
.String
);
140 if (addr
!= 0 && addr
!= INADDR_NONE
)
141 info
->table
[info
->numEntries
].winsPrimary
= ntohl(addr
);
142 addr
= inet_addr(ptr
->SecondaryWinsServer
.IpAddress
.String
);
143 if (addr
!= 0 && addr
!= INADDR_NONE
)
144 info
->table
[info
->numEntries
].winsSecondary
= ntohl(addr
);
149 HeapFree(GetProcessHeap(), 0, adapterInfo
);
155 /* nbtstat.exe uses this, but the return seems to be a bunch of
156 * pointers, so it's not so easy to reverse engineer. Fall through
157 * to unimplemented...
160 FIXME( "Unimplemented control %ld for VxD device VNB\n",
162 error
= ERROR_NOT_SUPPORTED
;
167 return error
== NO_ERROR
;