2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
5 * PURPOSE: TDI query and set information routines
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * CSH 01/08-2000 Created
15 TDI_STATUS
InfoCopyOut( PCHAR DataOut
, UINT SizeOut
,
16 PNDIS_BUFFER ClientBuf
, PUINT ClientBufSize
) {
17 UINT RememberedCBSize
= *ClientBufSize
;
18 *ClientBufSize
= SizeOut
;
20 /* The driver returns success even when it couldn't fit every available
22 if( RememberedCBSize
< SizeOut
)
25 CopyBufferToBufferChain( ClientBuf
, 0, (PCHAR
)DataOut
, SizeOut
);
30 VOID
InsertTDIInterfaceEntity( PIP_INTERFACE Interface
) {
34 TI_DbgPrint(DEBUG_INFO
,
35 ("Inserting interface %08x (%d entities already)\n",
36 Interface
, EntityCount
));
38 TcpipAcquireSpinLock( &EntityListLock
, &OldIrql
);
40 /* Count IP Entities */
41 for( i
= 0; i
< EntityCount
; i
++ )
42 if( EntityList
[i
].tei_entity
== IF_ENTITY
) {
44 TI_DbgPrint(DEBUG_INFO
, ("Entity %d is an IF. Found %d\n",
48 EntityList
[EntityCount
].tei_entity
= IF_ENTITY
;
49 EntityList
[EntityCount
].tei_instance
= Count
;
50 EntityList
[EntityCount
].context
= Interface
;
51 EntityList
[EntityCount
].info_req
= InfoInterfaceTdiQueryEx
;
52 EntityList
[EntityCount
].info_set
= InfoInterfaceTdiSetEx
;
56 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
59 VOID
RemoveTDIInterfaceEntity( PIP_INTERFACE Interface
) {
63 TI_DbgPrint(DEBUG_INFO
,("Removing TDI entry 0x%x\n", Interface
));
65 TcpipAcquireSpinLock( &EntityListLock
, &OldIrql
);
67 /* Remove entities that have this interface as context
68 * In the future, this might include AT_ENTITY types, too
70 for( i
= 0; i
< EntityCount
; i
++ ) {
71 TI_DbgPrint(DEBUG_INFO
,("--> examining TDI entry 0x%x\n", EntityList
[i
].context
));
72 if( EntityList
[i
].context
== Interface
) {
73 if( i
!= EntityCount
-1 ) {
74 memcpy( &EntityList
[i
],
75 &EntityList
[--EntityCount
],
76 sizeof(EntityList
[i
]) );
83 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
86 TDI_STATUS
InfoTdiQueryListEntities(PNDIS_BUFFER Buffer
,
89 UINT Count
, Size
, BufSize
= *BufferSize
;
92 TI_DbgPrint(DEBUG_INFO
,("About to copy %d TDIEntityIDs to user\n",
95 TcpipAcquireSpinLock(&EntityListLock
, &OldIrql
);
97 Size
= EntityCount
* sizeof(TDIEntityID
);
100 TI_DbgPrint(DEBUG_INFO
,("BufSize: %d, NeededSize: %d\n", BufSize
, Size
));
104 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
105 /* The buffer is too small to contain requested data, but we return
106 * success anyway, as we did everything we wanted. */
110 /* Return entity list -- Copy only the TDIEntityID parts. */
111 for( Count
= 0; Count
< EntityCount
; Count
++ ) {
112 CopyBufferToBufferChain(Buffer
,
113 Count
* sizeof(TDIEntityID
),
114 (PCHAR
)&EntityList
[Count
],
115 sizeof(TDIEntityID
));
118 TcpipReleaseSpinLock(&EntityListLock
, OldIrql
);
123 TDI_STATUS
InfoTdiQueryInformationEx(
124 PTDI_REQUEST Request
,
130 * FUNCTION: Returns extended information
132 * Request = Pointer to TDI request structure for the request
134 * Buffer = Pointer to buffer with data to use
135 * BufferSize = Pointer to buffer with size of Buffer. On return
136 * this is filled with number of bytes returned
137 * Context = Pointer to context buffer
139 * Status of operation
144 PVOID context
= NULL
;
145 NTSTATUS Status
= TDI_INVALID_PARAMETER
;
146 BOOL FoundEntity
= FALSE
;
147 InfoRequest_f InfoRequest
= NULL
;
149 TI_DbgPrint(DEBUG_INFO
,
150 ("InfoEx Req: %x %x %x!%04x:%d\n",
154 ID
->toi_entity
.tei_entity
,
155 ID
->toi_entity
.tei_instance
));
157 /* Check wether it is a query for a list of entities */
158 if (ID
->toi_entity
.tei_entity
== GENERIC_ENTITY
)
160 if ((ID
->toi_class
!= INFO_CLASS_GENERIC
) ||
161 (ID
->toi_type
!= INFO_TYPE_PROVIDER
) ||
162 (ID
->toi_id
!= ENTITY_LIST_ID
)) {
163 TI_DbgPrint(DEBUG_INFO
,("Invalid parameter\n"));
164 Status
= TDI_INVALID_PARAMETER
;
166 Status
= InfoTdiQueryListEntities(Buffer
, BufferSize
);
167 } else if (ID
->toi_entity
.tei_entity
== AT_ENTITY
) {
168 TcpipAcquireSpinLock( &EntityListLock
, &OldIrql
);
170 for( i
= 0; i
< EntityCount
; i
++ ) {
171 if( EntityList
[i
].tei_entity
== IF_ENTITY
&&
172 EntityList
[i
].tei_instance
== ID
->toi_entity
.tei_instance
) {
173 InfoRequest
= EntityList
[i
].info_req
;
174 context
= EntityList
[i
].context
;
180 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
183 TI_DbgPrint(DEBUG_INFO
,
184 ("Calling AT Entity %d (%04x:%d) InfoEx (%x,%x,%x)\n",
185 i
, ID
->toi_entity
.tei_entity
,
186 ID
->toi_entity
.tei_instance
,
187 ID
->toi_class
, ID
->toi_type
, ID
->toi_id
));
188 Status
= InfoRequest( ID
->toi_class
,
197 TcpipAcquireSpinLock( &EntityListLock
, &OldIrql
);
199 for( i
= 0; i
< EntityCount
; i
++ ) {
200 if( EntityList
[i
].tei_entity
== ID
->toi_entity
.tei_entity
&&
201 EntityList
[i
].tei_instance
== ID
->toi_entity
.tei_instance
) {
202 InfoRequest
= EntityList
[i
].info_req
;
203 context
= EntityList
[i
].context
;
209 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
212 TI_DbgPrint(DEBUG_INFO
,
213 ("Calling Entity %d (%04x:%d) InfoEx (%x,%x,%x)\n",
214 i
, ID
->toi_entity
.tei_entity
,
215 ID
->toi_entity
.tei_instance
,
216 ID
->toi_class
, ID
->toi_type
, ID
->toi_id
));
217 Status
= InfoRequest( ID
->toi_class
,
227 TI_DbgPrint(DEBUG_INFO
,("Status: %08x\n", Status
));
232 TDI_STATUS InfoTdiSetInformationEx
233 (PTDI_REQUEST Request
,
238 * FUNCTION: Sets extended information
240 * Request = Pointer to TDI request structure for the request
241 * ID = Pointer to TDI object ID
242 * Buffer = Pointer to buffer with data to use
243 * BufferSize = Size of Buffer
245 * Status of operation
248 switch( ID
->toi_class
) {
249 case INFO_CLASS_PROTOCOL
:
250 switch( ID
->toi_type
) {
251 case INFO_TYPE_PROVIDER
:
252 switch( ID
->toi_id
) {
253 case IP_MIB_ROUTETABLE_ENTRY_ID
:
254 return InfoNetworkLayerTdiSetEx
267 return TDI_INVALID_PARAMETER
;