iphlpapi: Implement GetIfEntry() on top of nsi.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e93053c344
commit
d044171b72
|
@ -745,47 +745,6 @@ DWORD getInterfaceStatusByName(const char *name, INTERNAL_IF_OPER_STATUS *status
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry)
|
|
||||||
{
|
|
||||||
BYTE addr[MAX_INTERFACE_PHYSADDR];
|
|
||||||
DWORD ret, len = sizeof(addr), type;
|
|
||||||
|
|
||||||
if (!name)
|
|
||||||
return ERROR_INVALID_PARAMETER;
|
|
||||||
if (!entry)
|
|
||||||
return ERROR_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
if (getInterfacePhysicalByName(name, &len, addr, &type) == NO_ERROR) {
|
|
||||||
WCHAR *assigner;
|
|
||||||
const char *walker;
|
|
||||||
|
|
||||||
memset(entry, 0, sizeof(MIB_IFROW));
|
|
||||||
for (assigner = entry->wszName, walker = name; *walker;
|
|
||||||
walker++, assigner++)
|
|
||||||
*assigner = *walker;
|
|
||||||
*assigner = 0;
|
|
||||||
getInterfaceIndexByName(name, &entry->dwIndex);
|
|
||||||
entry->dwPhysAddrLen = len;
|
|
||||||
memcpy(entry->bPhysAddr, addr, len);
|
|
||||||
memset(entry->bPhysAddr + len, 0, sizeof(entry->bPhysAddr) - len);
|
|
||||||
entry->dwType = type;
|
|
||||||
/* FIXME: how to calculate real speed? */
|
|
||||||
getInterfaceMtuByName(name, &entry->dwMtu);
|
|
||||||
/* lie, there's no "administratively down" here */
|
|
||||||
entry->dwAdminStatus = MIB_IF_ADMIN_STATUS_UP;
|
|
||||||
getInterfaceStatusByName(name, &entry->dwOperStatus);
|
|
||||||
/* punt on dwLastChange? */
|
|
||||||
entry->dwDescrLen = min(strlen(name), MAX_INTERFACE_DESCRIPTION - 1);
|
|
||||||
memcpy(entry->bDescr, name, entry->dwDescrLen);
|
|
||||||
entry->bDescr[entry->dwDescrLen] = '\0';
|
|
||||||
entry->dwDescrLen++;
|
|
||||||
ret = NO_ERROR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ret = ERROR_INVALID_DATA;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DWORD getIPAddrRowByName(PMIB_IPADDRROW ipAddrRow, const char *ifName,
|
static DWORD getIPAddrRowByName(PMIB_IPADDRROW ipAddrRow, const char *ifName,
|
||||||
const struct sockaddr *sa)
|
const struct sockaddr *sa)
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,13 +87,6 @@ DWORD getInterfaceIndexByName(const char *name, IF_INDEX *index) DECLSPEC_HIDDEN
|
||||||
DWORD getInterfacePhysicalByIndex(IF_INDEX index, PDWORD len, PBYTE addr,
|
DWORD getInterfacePhysicalByIndex(IF_INDEX index, PDWORD len, PBYTE addr,
|
||||||
PDWORD type) DECLSPEC_HIDDEN;
|
PDWORD type) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* Fills in the MIB_IFROW by name. Doesn't fill in interface statistics,
|
|
||||||
* see ipstats.h for that.
|
|
||||||
* Returns ERROR_INVALID_PARAMETER if name is NULL, ERROR_INVALID_DATA
|
|
||||||
* if name isn't valid, and NO_ERROR otherwise.
|
|
||||||
*/
|
|
||||||
DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry) DECLSPEC_HIDDEN;
|
|
||||||
|
|
||||||
DWORD getNumIPAddresses(void) DECLSPEC_HIDDEN;
|
DWORD getNumIPAddresses(void) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* Gets the configured IP addresses for the system, and sets *ppIpAddrTable to
|
/* Gets the configured IP addresses for the system, and sets *ppIpAddrTable to
|
||||||
|
|
|
@ -1821,26 +1821,25 @@ static void if_row_fill( MIB_IFROW *row, struct nsi_ndis_ifinfo_rw *rw, struct n
|
||||||
* Success: NO_ERROR
|
* Success: NO_ERROR
|
||||||
* Failure: error code from winerror.h
|
* Failure: error code from winerror.h
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
|
DWORD WINAPI GetIfEntry( MIB_IFROW *row )
|
||||||
{
|
{
|
||||||
DWORD ret;
|
struct nsi_ndis_ifinfo_rw rw;
|
||||||
char nameBuf[MAX_ADAPTER_NAME];
|
struct nsi_ndis_ifinfo_dynamic dyn;
|
||||||
char *name;
|
struct nsi_ndis_ifinfo_static stat;
|
||||||
|
NET_LUID luid;
|
||||||
|
DWORD err;
|
||||||
|
|
||||||
TRACE("pIfRow %p\n", pIfRow);
|
TRACE( "row %p\n", row );
|
||||||
if (!pIfRow)
|
if (!row) return ERROR_INVALID_PARAMETER;
|
||||||
return ERROR_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
name = getInterfaceNameByIndex(pIfRow->dwIndex, nameBuf);
|
err = ConvertInterfaceIndexToLuid( row->dwIndex, &luid );
|
||||||
if (name) {
|
if (err) return err;
|
||||||
ret = getInterfaceEntryByName(name, pIfRow);
|
|
||||||
if (ret == NO_ERROR)
|
err = NsiGetAllParameters( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE,
|
||||||
ret = getInterfaceStatsByName(name, pIfRow);
|
&luid, sizeof(luid), &rw, sizeof(rw),
|
||||||
}
|
&dyn, sizeof(dyn), &stat, sizeof(stat) );
|
||||||
else
|
if (!err) if_row_fill( row, &rw, &dyn, &stat );
|
||||||
ret = ERROR_INVALID_DATA;
|
return err;
|
||||||
TRACE("returning %d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ifrow_cmp( const void *a, const void *b )
|
static int ifrow_cmp( const void *a, const void *b )
|
||||||
|
|
Loading…
Reference in New Issue