Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygeniinfo.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS TCP/IP protocol driver 00004 * FILE: tcpip/iinfo.c 00005 * PURPOSE: Per-interface information. 00006 * PROGRAMMERS: Art Yerkes 00007 * REVISIONS: 00008 * CSH 01/08-2000 Created 00009 */ 00010 00011 #include "precomp.h" 00012 00013 TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID, 00014 PIP_INTERFACE Interface, 00015 PNDIS_BUFFER Buffer, 00016 PUINT BufferSize) { 00017 TDI_STATUS Status = TDI_INVALID_REQUEST; 00018 PIFENTRY OutData; 00019 PLAN_ADAPTER IF; 00020 PCHAR IFDescr; 00021 ULONG Size; 00022 UINT DescrLenMax = MAX_IFDESCR_LEN - 1; 00023 NDIS_STATUS NdisStatus; 00024 00025 if (!Interface) 00026 return TDI_INVALID_PARAMETER; 00027 00028 IF = (PLAN_ADAPTER)Interface->Context; 00029 00030 TI_DbgPrint(DEBUG_INFO, 00031 ("Getting IFEntry MIB (IF %08x LA %08x) (%04x:%d)\n", 00032 Interface, IF, ID.tei_entity, ID.tei_instance)); 00033 00034 OutData = 00035 (PIFENTRY)ExAllocatePool( NonPagedPool, 00036 sizeof(IFENTRY) + MAX_IFDESCR_LEN ); 00037 00038 if( !OutData ) return TDI_NO_RESOURCES; /* Out of memory */ 00039 00040 RtlZeroMemory( OutData, sizeof(IFENTRY) + MAX_IFDESCR_LEN ); 00041 00042 OutData->Index = Interface->Index; 00043 /* viz: tcpip keeps those indices */ 00044 OutData->Type = Interface == 00045 Loopback ? MIB_IF_TYPE_LOOPBACK : MIB_IF_TYPE_ETHERNET; 00046 OutData->Mtu = Interface->MTU; 00047 TI_DbgPrint(DEBUG_INFO, 00048 ("Getting interface speed\n")); 00049 OutData->PhysAddrLen = Interface->AddressLength; 00050 OutData->AdminStatus = MIB_IF_ADMIN_STATUS_UP; 00051 /* NDIS_HARDWARE_STATUS -> ROUTER_CONNECTION_STATE */ 00052 Status = GetInterfaceConnectionStatus( Interface, &OutData->OperStatus ); 00053 00054 /* Not sure what to do here, but not ready seems a safe bet on failure */ 00055 if( !NT_SUCCESS(Status) ) 00056 OutData->OperStatus = NdisHardwareStatusNotReady; 00057 00058 IFDescr = (PCHAR)&OutData[1]; 00059 00060 if( IF ) { 00061 GetInterfaceSpeed( Interface, (PUINT)&OutData->Speed ); 00062 TI_DbgPrint(DEBUG_INFO, 00063 ("IF Speed = %d * 100bps\n", OutData->Speed)); 00064 memcpy(OutData->PhysAddr,Interface->Address,Interface->AddressLength); 00065 TI_DbgPrint(DEBUG_INFO, ("Got HWAddr\n")); 00066 00067 memcpy(&OutData->InOctets, &Interface->Stats, sizeof(SEND_RECV_STATS)); 00068 00069 NdisStatus = NDISCall(IF, 00070 NdisRequestQueryInformation, 00071 OID_GEN_XMIT_ERROR, 00072 &OutData->OutErrors, 00073 sizeof(ULONG)); 00074 if (NdisStatus != NDIS_STATUS_SUCCESS) 00075 OutData->OutErrors = 0; 00076 00077 TI_DbgPrint(DEBUG_INFO, ("OutErrors = %d\n", OutData->OutErrors)); 00078 00079 NdisStatus = NDISCall(IF, 00080 NdisRequestQueryInformation, 00081 OID_GEN_RCV_ERROR, 00082 &OutData->InErrors, 00083 sizeof(ULONG)); 00084 if (NdisStatus != NDIS_STATUS_SUCCESS) 00085 OutData->InErrors = 0; 00086 00087 TI_DbgPrint(DEBUG_INFO, ("InErrors = %d\n", OutData->InErrors)); 00088 } 00089 00090 GetInterfaceName( Interface, IFDescr, MAX_IFDESCR_LEN - 1 ); 00091 DescrLenMax = strlen( IFDescr ) + 1; 00092 00093 TI_DbgPrint(DEBUG_INFO, ("Copied in name %s\n", IFDescr)); 00094 OutData->DescrLen = DescrLenMax; 00095 IFDescr += DescrLenMax; 00096 Size = IFDescr - (PCHAR)OutData + 1; 00097 00098 TI_DbgPrint(DEBUG_INFO, ("Finished IFEntry MIB (%04x:%d) size %d\n", 00099 ID.tei_entity, ID.tei_instance, Size)); 00100 00101 Status = InfoCopyOut( (PCHAR)OutData, Size, Buffer, BufferSize ); 00102 ExFreePool( OutData ); 00103 00104 TI_DbgPrint(DEBUG_INFO,("Returning %x\n", Status)); 00105 00106 return Status; 00107 } 00108 00109 TDI_STATUS InfoTdiQueryGetArptableMIB(TDIEntityID ID, 00110 PIP_INTERFACE Interface, 00111 PNDIS_BUFFER Buffer, 00112 PUINT BufferSize) { 00113 NTSTATUS Status; 00114 ULONG NumNeighbors = NBCopyNeighbors( Interface, NULL ); 00115 ULONG MemSize = NumNeighbors * sizeof(IPARP_ENTRY); 00116 PIPARP_ENTRY ArpEntries; 00117 00118 if (MemSize != 0) 00119 { 00120 ArpEntries = ExAllocatePool( NonPagedPool, MemSize ); 00121 if( !ArpEntries ) return STATUS_NO_MEMORY; 00122 00123 NBCopyNeighbors( Interface, ArpEntries ); 00124 00125 Status = InfoCopyOut( (PVOID)ArpEntries, MemSize, Buffer, BufferSize ); 00126 00127 ExFreePool( ArpEntries ); 00128 } 00129 else 00130 { 00131 Status = InfoCopyOut(NULL, 0, NULL, BufferSize); 00132 } 00133 00134 return Status; 00135 } 00136 00137 TDI_STATUS InfoTdiSetArptableMIB(PIP_INTERFACE IF, PVOID Buffer, UINT BufferSize) 00138 { 00139 PIPARP_ENTRY ArpEntry = Buffer; 00140 IP_ADDRESS Address; 00141 PNEIGHBOR_CACHE_ENTRY NCE; 00142 00143 if (!Buffer || BufferSize < sizeof(IPARP_ENTRY)) 00144 return TDI_INVALID_PARAMETER; 00145 00146 AddrInitIPv4(&Address, ArpEntry->LogAddr); 00147 00148 if ((NCE = NBLocateNeighbor(&Address))) 00149 NBRemoveNeighbor(NCE); 00150 00151 if (NBAddNeighbor(IF, 00152 &Address, 00153 ArpEntry->PhysAddr, 00154 ArpEntry->AddrSize, 00155 NUD_PERMANENT, 00156 0)) 00157 return TDI_SUCCESS; 00158 else 00159 return TDI_INVALID_PARAMETER; 00160 } 00161 00162 VOID InsertTDIInterfaceEntity( PIP_INTERFACE Interface ) { 00163 AddEntity(IF_ENTITY, Interface, IF_MIB); 00164 00165 AddEntity(AT_ENTITY, Interface, 00166 (Interface != Loopback) ? AT_ARP : AT_NULL); 00167 00168 /* FIXME: This is probably wrong */ 00169 AddEntity(CL_NL_ENTITY, Interface, CL_NL_IP); 00170 } 00171 00172 VOID RemoveTDIInterfaceEntity( PIP_INTERFACE Interface ) { 00173 /* This removes all of them */ 00174 RemoveEntityByContext(Interface); 00175 } 00176 Generated on Sat May 26 2012 04:26:41 for ReactOS by
1.7.6.1
|