ReactOS  0.4.14-dev-554-g2f8d847
iinfo.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS TCP/IP protocol driver
4  * FILE: tcpip/iinfo.c
5  * PURPOSE: Per-interface information.
6  * PROGRAMMERS: Art Yerkes
7  * REVISIONS:
8  * CSH 01/08-2000 Created
9  */
10 
11 #include "precomp.h"
12 
13 #include <ipifcons.h>
14 
15 /* See iptypes.h */
16 #define MAX_ADAPTER_DESCRIPTION_LENGTH 128
17 
21  PUINT BufferSize) {
23  IFEntry* OutData;
24  PLAN_ADAPTER IF;
25  PCHAR IFDescr;
26  ULONG Size;
27  NDIS_STATUS NdisStatus;
28 
29  if (!Interface)
30  return TDI_INVALID_PARAMETER;
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 
97  Status = InfoCopyOut( (PCHAR)OutData, Size, Buffer, BufferSize );
98  ExFreePoolWithTag( OutData, OUT_DATA_TAG );
99 
100  TI_DbgPrint(DEBUG_INFO,("Returning %x\n", Status));
101 
102  return Status;
103 }
104 
108  PUINT BufferSize) {
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 }
132 
134 {
135  PIPARP_ENTRY ArpEntry = Buffer;
138 
139  if (!Buffer || BufferSize < sizeof(IPARP_ENTRY))
140  return TDI_INVALID_PARAMETER;
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
155  return TDI_INVALID_PARAMETER;
156 }
157 
160 
162  (Interface != Loopback) ? AT_ARP : AT_NULL);
163 
164  /* FIXME: This is probably wrong */
166 }
167 
169  /* This removes all of them */
171 }
signed char * PCHAR
Definition: retypes.h:7
PVOID Context
Definition: lan.h:64
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define AT_ENTITY
Definition: tdiinfo.h:41
ULONG if_descrlen
Definition: tcpioctl.h:126
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
#define TDI_SUCCESS
Definition: tdistat.h:30
ULONG if_inoctets
Definition: tcpioctl.h:114
struct IPARP_ENTRY IPARP_ENTRY
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: neighbor.h:28
MDL * PNDIS_BUFFER
Definition: ndis.h:343
LONG NTSTATUS
Definition: precomp.h:26
ULONG if_physaddrlen
Definition: tcpioctl.h:109
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
LONG TDI_STATUS
Definition: tdi.h:36
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(PIP_ADDRESS Address, PIP_INTERFACE Interface)
Definition: neighbor.c:417
ULONG if_index
Definition: tcpioctl.h:105
ULONG if_operstatus
Definition: tcpioctl.h:112
ULONG if_outerrors
Definition: tcpioctl.h:124
#define NUD_PERMANENT
Definition: neighbor.h:42
bool GetInterfaceName(const WCHAR *InterfaceString, WCHAR *buf, size_t size)
Definition: CFontExt.cpp:34
TDI_STATUS InfoTdiQueryGetArptableMIB(TDIEntityID ID, PIP_INTERFACE Interface, PNDIS_BUFFER Buffer, PUINT BufferSize)
Definition: iinfo.c:105
#define CL_NL_IP
Definition: tdiinfo.h:54
#define MIB_IF_TYPE_LOOPBACK
Definition: ipifcons.h:227
PIP_INTERFACE Loopback
Definition: loopback.c:13
#define AT_NULL
Definition: tdiinfo.h:50
int NDIS_STATUS
Definition: ntddndis.h:471
Definition: ip.h:23
UCHAR PhysAddr[8]
Definition: info.h:38
#define AT_ARP
Definition: tdiinfo.h:49
ULONG if_type
Definition: tcpioctl.h:106
TDI_STATUS InfoCopyOut(PCHAR DataOut, UINT SizeOut, PNDIS_BUFFER ClientBuf, PUINT ClientBufSize)
Definition: info.c:97
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
ULONG if_mtu
Definition: tcpioctl.h:107
ULONG if_speed
Definition: tcpioctl.h:108
#define MIB_IF_ADMIN_STATUS_UP
Definition: ipifcons.h:232
#define PCHAR
Definition: match.c:90
TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID, PIP_INTERFACE Interface, PNDIS_BUFFER Buffer, PUINT BufferSize)
Definition: iinfo.c:18
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
VOID NBRemoveNeighbor(PNEIGHBOR_CACHE_ENTRY NCE)
Definition: neighbor.c:590
struct LAN_ADAPTER * PLAN_ADAPTER
#define AddrInitIPv4(IPAddress, RawAddress)
Definition: address.h:16
#define MIB_IF_TYPE_ETHERNET
Definition: ipifcons.h:223
#define BufferSize
Definition: classpnp.h:419
NTSTATUS GetInterfaceSpeed(PIP_INTERFACE Interface, PUINT Speed)
Definition: interface.c:62
ULONG if_inerrors
Definition: tcpioctl.h:118
#define IF_ENTITY
Definition: tdiinfo.h:47
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define CL_NL_ENTITY
Definition: tdiinfo.h:42
VOID RemoveTDIInterfaceEntity(PIP_INTERFACE Interface)
Definition: iinfo.c:168
#define TDI_INVALID_PARAMETER
Definition: tdistat.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ID
Definition: ruserpass.c:36
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define ARP_ENTRY_TAG
Definition: tags.h:40
PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(PIP_INTERFACE Interface, PIP_ADDRESS Address, PVOID LinkAddress, UINT LinkAddressLength, UCHAR Type, UINT EventTimer)
Definition: neighbor.c:273
ULONG LogAddr
Definition: info.h:39
Status
Definition: gdiplustypes.h:24
ULONG if_adminstatus
Definition: tcpioctl.h:111
TDI_STATUS InfoTdiSetArptableMIB(PIP_INTERFACE IF, PVOID Buffer, UINT BufferSize)
Definition: iinfo.c:133
Definition: info.h:35
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int UINT
Definition: ndis.h:50
ULONG NBCopyNeighbors(PIP_INTERFACE Interface, PIPARP_ENTRY ArpTable)
Definition: neighbor.c:636
VOID GetInterfaceConnectionStatus(PIP_INTERFACE Interface, PULONG OperStatus)
Definition: interface.c:254
#define TDI_NO_RESOURCES
Definition: tdistat.h:31
#define MAX_ADAPTER_DESCRIPTION_LENGTH
Definition: iinfo.c:16
VOID InsertTDIInterfaceEntity(PIP_INTERFACE Interface)
Definition: iinfo.c:158
VOID AddEntity(ULONG EntityType, PVOID Context, ULONG Flags)
Definition: info.c:15
ULONG AddrSize
Definition: info.h:37
unsigned int ULONG
Definition: retypes.h:1
#define IF_MIB
Definition: tdiinfo.h:61
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID RemoveEntityByContext(PVOID Context)
Definition: info.c:46
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define OUT_DATA_TAG
Definition: tags.h:39
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
UCHAR if_physaddr[MAX_PHYSADDR_SIZE]
Definition: tcpioctl.h:110
#define DEBUG_INFO
Definition: debug.h:33
#define TDI_INVALID_REQUEST
Definition: tdistat.h:63
UCHAR if_descr[1]
Definition: tcpioctl.h:127
unsigned int * PUINT
Definition: ndis.h:50