2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
5 * PURPOSE: Per-interface information.
6 * PROGRAMMERS: Art Yerkes
8 * CSH 01/08-2000 Created
13 TDI_STATUS
InfoTdiQueryGetInterfaceMIB(TDIEntityID
*ID
,
14 PIP_INTERFACE Interface
,
17 TDI_STATUS Status
= TDI_INVALID_REQUEST
;
19 PLAN_ADAPTER IF
= (PLAN_ADAPTER
)Interface
->Context
;
22 UINT DescrLenMax
= MAX_IFDESCR_LEN
- 1;
23 NDIS_STATUS NdisStatus
;
25 TI_DbgPrint(DEBUG_INFO
,
26 ("Getting IFEntry MIB (IF %08x LA %08x) (%04x:%d)\n",
27 Interface
, IF
, ID
->tei_entity
, ID
->tei_instance
));
30 (PIFENTRY
)exAllocatePool( NonPagedPool
,
31 sizeof(IFENTRY
) + MAX_IFDESCR_LEN
);
33 if( !OutData
) return TDI_NO_RESOURCES
; /* Out of memory */
35 RtlZeroMemory( OutData
, sizeof(IFENTRY
) + MAX_IFDESCR_LEN
);
37 OutData
->Index
= Interface
->Index
;
38 /* viz: tcpip keeps those indices */
39 OutData
->Type
= Interface
==
40 Loopback
? MIB_IF_TYPE_LOOPBACK
: MIB_IF_TYPE_ETHERNET
;
41 OutData
->Mtu
= Interface
->MTU
;
42 TI_DbgPrint(DEBUG_INFO
,
43 ("Getting interface speed\n"));
44 OutData
->PhysAddrLen
= Interface
->AddressLength
;
45 OutData
->AdminStatus
= MIB_IF_ADMIN_STATUS_UP
;
46 /* NDIS_HARDWARE_STATUS -> ROUTER_CONNECTION_STATE */
47 Status
= GetInterfaceConnectionStatus( Interface
, &OutData
->OperStatus
);
49 /* Not sure what to do here, but not ready seems a safe bet on failure */
50 if( !NT_SUCCESS(Status
) )
51 OutData
->OperStatus
= NdisHardwareStatusNotReady
;
53 IFDescr
= (PCHAR
)&OutData
[1];
56 GetInterfaceSpeed( Interface
, (PUINT
)&OutData
->Speed
);
57 TI_DbgPrint(DEBUG_INFO
,
58 ("IF Speed = %d * 100bps\n", OutData
->Speed
));
59 memcpy(OutData
->PhysAddr
,Interface
->Address
,Interface
->AddressLength
);
60 TI_DbgPrint(DEBUG_INFO
, ("Got HWAddr\n"));
62 memcpy(&OutData
->InOctets
, &Interface
->Stats
, sizeof(SEND_RECV_STATS
));
64 NdisStatus
= NDISCall(IF
,
65 NdisRequestQueryInformation
,
69 if (NdisStatus
!= NDIS_STATUS_SUCCESS
)
70 OutData
->OutErrors
= 0;
72 TI_DbgPrint(DEBUG_INFO
, ("OutErrors = %d\n", OutData
->OutErrors
));
74 NdisStatus
= NDISCall(IF
,
75 NdisRequestQueryInformation
,
79 if (NdisStatus
!= NDIS_STATUS_SUCCESS
)
80 OutData
->InErrors
= 0;
82 TI_DbgPrint(DEBUG_INFO
, ("InErrors = %d\n", OutData
->InErrors
));
85 GetInterfaceName( Interface
, IFDescr
, MAX_IFDESCR_LEN
- 1 );
86 DescrLenMax
= strlen( IFDescr
) + 1;
88 TI_DbgPrint(DEBUG_INFO
, ("Copied in name %s\n", IFDescr
));
89 OutData
->DescrLen
= DescrLenMax
;
90 IFDescr
+= DescrLenMax
;
91 Size
= IFDescr
- (PCHAR
)OutData
+ 1;
93 TI_DbgPrint(DEBUG_INFO
, ("Finished IFEntry MIB (%04x:%d) size %d\n",
94 ID
->tei_entity
, ID
->tei_instance
, Size
));
96 Status
= InfoCopyOut( (PCHAR
)OutData
, Size
, Buffer
, BufferSize
);
97 exFreePool( OutData
);
99 TI_DbgPrint(DEBUG_INFO
,("Returning %x\n", Status
));
104 TDI_STATUS
InfoTdiQueryGetArptableMIB(TDIEntityID
*ID
,
105 PIP_INTERFACE Interface
,
109 ULONG NumNeighbors
= NBCopyNeighbors( Interface
, NULL
);
110 ULONG MemSize
= NumNeighbors
* sizeof(IPARP_ENTRY
);
111 PIPARP_ENTRY ArpEntries
=
112 exAllocatePoolWithTag
113 ( NonPagedPool
, MemSize
, FOURCC('A','R','P','t') );
115 if( !ArpEntries
) return STATUS_NO_MEMORY
;
116 NBCopyNeighbors( Interface
, ArpEntries
);
118 Status
= InfoCopyOut( (PVOID
)ArpEntries
, MemSize
, Buffer
, BufferSize
);
120 exFreePool( ArpEntries
);
125 TDI_STATUS
InfoTdiQueryGetArpCapability(TDIEntityID
*ID
,
126 PIP_INTERFACE Interface
,
130 ULONG Capability
= 0x280;
132 TI_DbgPrint(MID_TRACE
,("Copying out %d bytes (AT_ENTITY capability)\n",
133 sizeof(Capability
)));
135 ( (PVOID
)&Capability
, sizeof(Capability
), Buffer
, BufferSize
);
140 TDI_STATUS
InfoInterfaceTdiQueryEx( UINT InfoClass
,
147 if( InfoClass
== INFO_CLASS_GENERIC
&&
148 InfoType
== INFO_TYPE_PROVIDER
&&
149 InfoId
== ENTITY_TYPE_ID
&&
150 id
->tei_entity
== AT_ENTITY
) {
151 return InfoTdiQueryGetArpCapability( id
, Context
, Buffer
, BufferSize
);
152 } else if( InfoClass
== INFO_CLASS_PROTOCOL
&&
153 InfoType
== INFO_TYPE_PROVIDER
&&
154 InfoId
== IF_MIB_STATS_ID
) {
155 return InfoTdiQueryGetInterfaceMIB( id
, Context
, Buffer
, BufferSize
);
156 } else if( InfoClass
== INFO_CLASS_GENERIC
&&
157 InfoType
== INFO_TYPE_PROVIDER
&&
158 InfoId
== ENTITY_TYPE_ID
) {
160 return InfoCopyOut( (PCHAR
)&Temp
, sizeof(Temp
), Buffer
, BufferSize
);
161 } else if( InfoClass
== INFO_CLASS_PROTOCOL
&&
162 InfoType
== INFO_TYPE_PROVIDER
&&
163 InfoId
== IP_MIB_ARPTABLE_ENTRY_ID
) {
164 return InfoTdiQueryGetArptableMIB( id
, Context
, Buffer
, BufferSize
);
166 return TDI_INVALID_REQUEST
;
169 TDI_STATUS
InfoInterfaceTdiSetEx( UINT InfoClass
,
176 TI_DbgPrint(DEBUG_INFO
, ("Got Request: Class %x Type %x Id %x, EntityID %x:%x\n",
177 InfoClass
, InfoId
, id
->tei_entity
, id
->tei_instance
));
178 return TDI_INVALID_REQUEST
;