Commit d044171b authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

iphlpapi: Implement GetIfEntry() on top of nsi.

parent e93053c3
......@@ -745,47 +745,6 @@ DWORD getInterfaceStatusByName(const char *name, INTERNAL_IF_OPER_STATUS *status
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,
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,
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;
/* 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
* Failure: error code from winerror.h
*/
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
DWORD WINAPI GetIfEntry( MIB_IFROW *row )
{
DWORD ret;
char nameBuf[MAX_ADAPTER_NAME];
char *name;
struct nsi_ndis_ifinfo_rw rw;
struct nsi_ndis_ifinfo_dynamic dyn;
struct nsi_ndis_ifinfo_static stat;
NET_LUID luid;
DWORD err;
TRACE("pIfRow %p\n", pIfRow);
if (!pIfRow)
return ERROR_INVALID_PARAMETER;
TRACE( "row %p\n", row );
if (!row) return ERROR_INVALID_PARAMETER;
name = getInterfaceNameByIndex(pIfRow->dwIndex, nameBuf);
if (name) {
ret = getInterfaceEntryByName(name, pIfRow);
if (ret == NO_ERROR)
ret = getInterfaceStatsByName(name, pIfRow);
}
else
ret = ERROR_INVALID_DATA;
TRACE("returning %d\n", ret);
return ret;
err = ConvertInterfaceIndexToLuid( row->dwIndex, &luid );
if (err) return err;
err = NsiGetAllParameters( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE,
&luid, sizeof(luid), &rw, sizeof(rw),
&dyn, sizeof(dyn), &stat, sizeof(stat) );
if (!err) if_row_fill( row, &rw, &dyn, &stat );
return err;
}
static int ifrow_cmp( const void *a, const void *b )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment