ReactOS 0.4.16-dev-112-g52265ae
iinfo.c File Reference
#include "precomp.h"
#include <ipifcons.h>
Include dependency graph for iinfo.c:

Go to the source code of this file.

Macros

#define MAX_ADAPTER_DESCRIPTION_LENGTH   128
 

Functions

TDI_STATUS InfoTdiQueryGetInterfaceMIB (TDIEntityID ID, PIP_INTERFACE Interface, PNDIS_BUFFER Buffer, PUINT BufferSize)
 
TDI_STATUS InfoTdiQueryGetArptableMIB (TDIEntityID ID, PIP_INTERFACE Interface, PNDIS_BUFFER Buffer, PUINT BufferSize)
 
TDI_STATUS InfoTdiSetArptableMIB (PIP_INTERFACE IF, PVOID Buffer, UINT BufferSize)
 
VOID InsertTDIInterfaceEntity (PIP_INTERFACE Interface)
 
VOID RemoveTDIInterfaceEntity (PIP_INTERFACE Interface)
 

Macro Definition Documentation

◆ MAX_ADAPTER_DESCRIPTION_LENGTH

#define MAX_ADAPTER_DESCRIPTION_LENGTH   128

Definition at line 16 of file iinfo.c.

Function Documentation

◆ InfoTdiQueryGetArptableMIB()

TDI_STATUS InfoTdiQueryGetArptableMIB ( TDIEntityID  ID,
PIP_INTERFACE  Interface,
PNDIS_BUFFER  Buffer,
PUINT  BufferSize 
)

Definition at line 105 of file iinfo.c.

108 {
110 ULONG NumNeighbors = NBCopyNeighbors( Interface, NULL );
111 ULONG MemSize = NumNeighbors * sizeof(IPARP_ENTRY);
112 PIPARP_ENTRY ArpEntries;
113
114 if (MemSize != 0)
115 {
116 ArpEntries = ExAllocatePoolWithTag( NonPagedPool, MemSize, ARP_ENTRY_TAG );
117 if( !ArpEntries ) return STATUS_NO_MEMORY;
118
119 NBCopyNeighbors( Interface, ArpEntries );
120
121 Status = InfoCopyOut( (PVOID)ArpEntries, MemSize, Buffer, BufferSize );
122
123 ExFreePoolWithTag( ArpEntries, ARP_ENTRY_TAG );
124 }
125 else
126 {
128 }
129
130 return Status;
131}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define ARP_ENTRY_TAG
Definition: tags.h:40
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
TDI_STATUS InfoCopyOut(PCHAR DataOut, UINT SizeOut, PNDIS_BUFFER ClientBuf, PUINT ClientBufSize)
Definition: info.c:97
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
ULONG NBCopyNeighbors(PIP_INTERFACE Interface, PIPARP_ENTRY ArpTable)
Definition: neighbor.c:636
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
Definition: info.h:35
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by InfoTdiQueryInformationEx().

◆ InfoTdiQueryGetInterfaceMIB()

TDI_STATUS InfoTdiQueryGetInterfaceMIB ( TDIEntityID  ID,
PIP_INTERFACE  Interface,
PNDIS_BUFFER  Buffer,
PUINT  BufferSize 
)

Definition at line 18 of file iinfo.c.

21 {
23 IFEntry* OutData;
24 PLAN_ADAPTER IF;
25 PCHAR IFDescr;
26 ULONG Size;
27 NDIS_STATUS NdisStatus;
28
29 if (!Interface)
31
33
35 ("Getting IFEntry MIB (IF %08x LA %08x) (%04x:%d)\n",
36 Interface, IF, ID.tei_entity, ID.tei_instance));
37
39
40 if( !OutData ) return TDI_NO_RESOURCES; /* Out of memory */
41
43
44 OutData->if_index = Interface->Index;
45 /* viz: tcpip keeps those indices */
46 OutData->if_type = Interface ==
48 OutData->if_mtu = Interface->MTU;
50 ("Getting interface speed\n"));
51 OutData->if_physaddrlen = Interface->AddressLength;
53 /* NDIS_HARDWARE_STATUS -> ROUTER_CONNECTION_STATE */
55
56 IFDescr = (PCHAR)&OutData->if_descr[0];
57
58 if( IF ) {
61 ("IF Speed = %d * 100bps\n", OutData->if_speed));
62 memcpy(OutData->if_physaddr, Interface->Address, Interface->AddressLength);
63 TI_DbgPrint(DEBUG_INFO, ("Got HWAddr\n"));
64
65 memcpy(&OutData->if_inoctets, &Interface->Stats, sizeof(SEND_RECV_STATS));
66
67 NdisStatus = NDISCall(IF,
70 &OutData->if_outerrors,
71 sizeof(ULONG));
72 if (NdisStatus != NDIS_STATUS_SUCCESS)
73 OutData->if_outerrors = 0;
74
75 TI_DbgPrint(DEBUG_INFO, ("OutErrors = %d\n", OutData->if_outerrors));
76
77 NdisStatus = NDISCall(IF,
80 &OutData->if_inerrors,
81 sizeof(ULONG));
82 if (NdisStatus != NDIS_STATUS_SUCCESS)
83 OutData->if_inerrors = 0;
84
85 TI_DbgPrint(DEBUG_INFO, ("InErrors = %d\n", OutData->if_inerrors));
86 }
87
89
90 TI_DbgPrint(DEBUG_INFO, ("Copied in name %s\n", IFDescr));
91 OutData->if_descrlen = strlen(IFDescr);
92 Size = FIELD_OFFSET(IFEntry, if_descr[OutData->if_descrlen + 1]);
93
94 TI_DbgPrint(DEBUG_INFO, ("Finished IFEntry MIB (%04x:%d) size %d\n",
95 ID.tei_entity, ID.tei_instance, Size));
96
99
100 TI_DbgPrint(DEBUG_INFO,("Returning %x\n", Status));
101
102 return Status;
103}
bool GetInterfaceName(const WCHAR *InterfaceString, WCHAR *buf, size_t size)
Definition: CFontExt.cpp:46
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define DEBUG_INFO
Definition: debug.h:33
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define OUT_DATA_TAG
Definition: tags.h:39
#define MAX_ADAPTER_DESCRIPTION_LENGTH
Definition: iinfo.c:16
#define MIB_IF_TYPE_ETHERNET
Definition: ipifcons.h:223
#define MIB_IF_TYPE_LOOPBACK
Definition: ipifcons.h:227
#define MIB_IF_ADMIN_STATUS_UP
Definition: ipifcons.h:232
struct LAN_ADAPTER * PLAN_ADAPTER
NDIS_STATUS NDISCall(PLAN_ADAPTER Adapter, NDIS_REQUEST_TYPE Type, NDIS_OID OID, PVOID Buffer, UINT Length)
Send a request to NDIS.
Definition: lan.c:29
PIP_INTERFACE Loopback
Definition: loopback.c:13
#define PCHAR
Definition: match.c:90
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int * PUINT
Definition: ndis.h:50
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
@ NdisRequestQueryInformation
Definition: ndis.h:790
NTSTATUS GetInterfaceSpeed(PIP_INTERFACE Interface, PUINT Speed)
Definition: interface.c:62
VOID GetInterfaceConnectionStatus(PIP_INTERFACE Interface, PULONG OperStatus)
Definition: interface.c:254
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
int NDIS_STATUS
Definition: ntddndis.h:475
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
#define ID
Definition: ruserpass.c:36
ULONG if_operstatus
Definition: tcpioctl.h:115
UCHAR if_descr[1]
Definition: tcpioctl.h:130
ULONG if_inerrors
Definition: tcpioctl.h:121
ULONG if_index
Definition: tcpioctl.h:108
ULONG if_descrlen
Definition: tcpioctl.h:129
ULONG if_physaddrlen
Definition: tcpioctl.h:112
ULONG if_inoctets
Definition: tcpioctl.h:117
ULONG if_type
Definition: tcpioctl.h:109
ULONG if_speed
Definition: tcpioctl.h:111
ULONG if_mtu
Definition: tcpioctl.h:110
ULONG if_outerrors
Definition: tcpioctl.h:127
UCHAR if_physaddr[MAX_PHYSADDR_SIZE]
Definition: tcpioctl.h:113
ULONG if_adminstatus
Definition: tcpioctl.h:114
PVOID Context
Definition: lan.h:64
LONG TDI_STATUS
Definition: tdi.h:36
#define TDI_NO_RESOURCES
Definition: tdistat.h:31
#define TDI_INVALID_PARAMETER
Definition: tdistat.h:52
#define TDI_INVALID_REQUEST
Definition: tdistat.h:63
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by InfoTdiQueryInformationEx().

◆ InfoTdiSetArptableMIB()

TDI_STATUS InfoTdiSetArptableMIB ( PIP_INTERFACE  IF,
PVOID  Buffer,
UINT  BufferSize 
)

Definition at line 133 of file iinfo.c.

134{
135 PIPARP_ENTRY ArpEntry = Buffer;
138
139 if (!Buffer || BufferSize < sizeof(IPARP_ENTRY))
141
142 AddrInitIPv4(&Address, ArpEntry->LogAddr);
143
144 if ((NCE = NBLocateNeighbor(&Address, IF)))
145 NBRemoveNeighbor(NCE);
146
147 if (NBAddNeighbor(IF,
148 &Address,
149 ArpEntry->PhysAddr,
150 ArpEntry->AddrSize,
152 0))
153 return TDI_SUCCESS;
154 else
156}
#define AddrInitIPv4(IPAddress, RawAddress)
Definition: address.h:16
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(PIP_ADDRESS Address, PIP_INTERFACE Interface)
Definition: neighbor.c:417
PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(PIP_INTERFACE Interface, PIP_ADDRESS Address, PVOID LinkAddress, UINT LinkAddressLength, UCHAR Type, UINT EventTimer)
Definition: neighbor.c:273
#define NUD_PERMANENT
Definition: neighbor.h:42
VOID NBRemoveNeighbor(PNEIGHBOR_CACHE_ENTRY NCE)
Definition: neighbor.c:590
static WCHAR Address[46]
Definition: ping.c:68
ULONG LogAddr
Definition: info.h:39
UCHAR PhysAddr[8]
Definition: info.h:38
ULONG AddrSize
Definition: info.h:37
Definition: ip.h:23
Definition: neighbor.h:28
#define TDI_SUCCESS
Definition: tdistat.h:30

Referenced by InfoTdiSetInformationEx().

◆ InsertTDIInterfaceEntity()

VOID InsertTDIInterfaceEntity ( PIP_INTERFACE  Interface)

Definition at line 158 of file iinfo.c.

158 {
160
163
164 /* FIXME: This is probably wrong */
166}
VOID AddEntity(ULONG EntityType, PVOID Context, ULONG Flags)
Definition: info.c:15
#define IF_ENTITY
Definition: tdiinfo.h:47
#define CL_NL_IP
Definition: tdiinfo.h:54
#define AT_ENTITY
Definition: tdiinfo.h:41
#define AT_NULL
Definition: tdiinfo.h:50
#define AT_ARP
Definition: tdiinfo.h:49
#define CL_NL_ENTITY
Definition: tdiinfo.h:42
#define IF_MIB
Definition: tdiinfo.h:61

Referenced by IPCreateInterface().

◆ RemoveTDIInterfaceEntity()

VOID RemoveTDIInterfaceEntity ( PIP_INTERFACE  Interface)

Definition at line 168 of file iinfo.c.

168 {
169 /* This removes all of them */
171}
VOID RemoveEntityByContext(PVOID Context)
Definition: info.c:46

Referenced by IPDestroyInterface().