Added simple dword OID query to lan.

Correct oper status, admin status and type settings in iinfo.
Small fixes in lan.c for adapter name.

svn path=/trunk/; revision=14173
This commit is contained in:
Art Yerkes 2005-03-18 03:26:12 +00:00
parent 59c145b801
commit 604f4f13c1
6 changed files with 65 additions and 5 deletions

View file

@ -209,3 +209,28 @@ PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address)
return NULL;
}
NTSTATUS GetInterfaceConnectionStatus
( PIP_INTERFACE Interface, PDWORD Result ) {
NTSTATUS Status = TcpipLanGetDwordOid
( Interface, OID_GEN_HARDWARE_STATUS, Result );
if( NT_SUCCESS(Status) ) switch( *Result ) {
case NdisHardwareStatusReady:
*Result = MIB_IF_OPER_STATUS_OPERATIONAL;
break;
case NdisHardwareStatusInitializing:
*Result = MIB_IF_OPER_STATUS_CONNECTING;
break;
case NdisHardwareStatusReset:
*Result = MIB_IF_OPER_STATUS_DISCONNECTED;
break;
case NdisHardwareStatusNotReady:
*Result = MIB_IF_OPER_STATUS_DISCONNECTED;
break;
case NdisHardwareStatusClosing:
default:
*Result = MIB_IF_OPER_STATUS_NON_OPERATIONAL;
break;
}
return Status;
}

View file

@ -165,6 +165,28 @@ VOID FreeAdapter(
}
NTSTATUS TcpipLanGetDwordOid
( PIP_INTERFACE Interface,
NDIS_OID Oid,
PDWORD Result ) {
/* Get maximum frame size */
if( Interface->Context ) {
return NDISCall((PLAN_ADAPTER)Interface->Context,
NdisRequestQueryInformation,
Oid,
Result,
sizeof(DWORD));
} else switch( Oid ) { /* Loopback Case */
case OID_GEN_HARDWARE_STATUS:
*Result = NdisHardwareStatusReady;
return STATUS_SUCCESS;
default:
return STATUS_INVALID_PARAMETER;
}
}
VOID STDCALL ProtocolOpenAdapterComplete(
NDIS_HANDLE BindingContext,
NDIS_STATUS Status,
@ -916,11 +938,10 @@ VOID BindAdapter(
TI_DbgPrint(MID_TRACE,("BCAST(IF) %s\n", A2S(&IF->Broadcast)));
if(NT_SUCCESS(Status)) {
RtlZeroMemory( &IF->Name, sizeof(IF->Name) );
Status = ReadStringFromRegistry( RegHandle, L"DeviceDesc",
&IF->Name );
RtlZeroMemory( &IF->Name, sizeof( IF->Name ) );
/* I think that not getting a devicedesc is not a fatal error */
if( !NT_SUCCESS(Status) ) {
if( IF->Name.Buffer ) exFreePool( IF->Name.Buffer );
@ -929,6 +950,8 @@ VOID BindAdapter(
Status = STATUS_SUCCESS;
}
TI_DbgPrint(MID_TRACE,("Adapter Name: %wZ\n", &IF->Name));
if(!NT_SUCCESS(Status))
{
TI_DbgPrint(MIN_TRACE, ("Unable to open protocol-specific registry key: 0x%x\n", Status));

View file

@ -13,6 +13,8 @@ UINT CountInterfaceAddresses( PIP_INTERFACE Interface );
NTSTATUS GetInterfaceSpeed( PIP_INTERFACE Interface, PUINT Speed );
NTSTATUS GetInterfaceName( PIP_INTERFACE Interface, PCHAR NameBuffer,
UINT NameMaxLen );
NTSTATUS GetInterfaceConnectionStatus( PIP_INTERFACE Interface,
PDWORD OperStatus );
PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address);
#endif//_TCPIP_INTERFACE_H

View file

@ -98,6 +98,9 @@ VOID LANUnregisterProtocol(
VOID LANStartup();
VOID LANShutdown();
NTSTATUS TcpipLanGetDwordOid( PIP_INTERFACE Interface, NDIS_OID Oid,
PDWORD Result );
NDIS_STATUS NDISCall(
PLAN_ADAPTER Adapter,
NDIS_REQUEST_TYPE Type,

View file

@ -35,5 +35,6 @@
#include <oskittcp.h>
#include <interface.h>
#include <ports.h>
#include <ipifcons.h>
#define NTOS_MODE_USER
#include <ntos.h>

View file

@ -35,13 +35,19 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID *ID,
OutData->Index = ID->tei_instance + 1;
/* viz: tcpip keeps those indices */
OutData->Type = Interface == Loopback ? IFENT_SOFTWARE_LOOPBACK : 0;
OutData->Type = Interface ==
Loopback ? MIB_IF_TYPE_LOOPBACK : MIB_IF_TYPE_ETHERNET;
OutData->Mtu = Interface->MTU;
TI_DbgPrint(MAX_TRACE,
("Getting interface speed\n"));
OutData->PhysAddrLen = Interface->AddressLength;
OutData->AdminStatus = 1; /* XXX Up -- How do I know? */
OutData->OperStatus = 1; /* XXX Up -- How do I know? */
OutData->AdminStatus = MIB_IF_ADMIN_STATUS_UP;
/* NDIS_HARDWARE_STATUS -> ROUTER_CONNECTION_STATE */
Status = GetInterfaceConnectionStatus( Interface, &OutData->OperStatus );
/* Not sure what to do here, but not ready seems a safe bet on failure */
if( !NT_SUCCESS(Status) )
OutData->OperStatus = NdisHardwareStatusNotReady;
IFDescr = (PCHAR)&OutData[1];