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
;
19 if( RememberedCBSize
< SizeOut
)
20 return TDI_BUFFER_TOO_SMALL
;
22 CopyBufferToBufferChain( ClientBuf
, 0, (PCHAR
)DataOut
, SizeOut
);
27 VOID
InsertTDIInterfaceEntity( PIP_INTERFACE Interface
) {
31 TI_DbgPrint(DEBUG_INFO
,
32 ("Inserting interface %08x (%d entities already)\n",
33 Interface
, EntityCount
));
35 TcpipAcquireSpinLock( &EntityListLock
, &OldIrql
);
37 /* Count IP Entities */
38 for( i
= 0; i
< EntityCount
; i
++ )
39 if( EntityList
[i
].tei_entity
== IF_ENTITY
) {
41 TI_DbgPrint(DEBUG_INFO
, ("Entity %d is an IF. Found %d\n",
45 EntityList
[EntityCount
].tei_entity
= IF_ENTITY
;
46 EntityList
[EntityCount
].tei_instance
= Count
;
47 EntityList
[EntityCount
].context
= Interface
;
48 EntityList
[EntityCount
].info_req
= InfoInterfaceTdiQueryEx
;
49 EntityList
[EntityCount
].info_set
= InfoInterfaceTdiSetEx
;
53 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
56 VOID
RemoveTDIInterfaceEntity( PIP_INTERFACE Interface
) {
60 TcpipAcquireSpinLock( &EntityListLock
, &OldIrql
);
62 /* Remove entities that have this interface as context
63 * In the future, this might include AT_ENTITY types, too
65 for( i
= 0; i
< EntityCount
; i
++ ) {
66 if( EntityList
[i
].context
== Interface
) {
67 if( i
!= EntityCount
-1 )
68 memcpy( &EntityList
[i
],
69 &EntityList
[--EntityCount
],
70 sizeof(EntityList
[i
]) );
74 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
77 TDI_STATUS
InfoTdiQueryListEntities(PNDIS_BUFFER Buffer
,
80 UINT Count
, Size
, BufSize
= *BufferSize
;
83 TI_DbgPrint(DEBUG_INFO
,("About to copy %d TDIEntityIDs to user\n",
86 TcpipAcquireSpinLock(&EntityListLock
, &OldIrql
);
88 Size
= EntityCount
* sizeof(TDIEntityID
);
93 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
94 /* The buffer is too small to contain requested data */
95 return TDI_BUFFER_TOO_SMALL
;
98 /* Return entity list -- Copy only the TDIEntityID parts. */
99 for( Count
= 0; Count
< EntityCount
; Count
++ ) {
100 CopyBufferToBufferChain(Buffer
,
101 Count
* sizeof(TDIEntityID
),
102 (PCHAR
)&EntityList
[Count
],
103 sizeof(TDIEntityID
));
106 TcpipReleaseSpinLock(&EntityListLock
, OldIrql
);
111 TDI_STATUS
InfoTdiQueryInformationEx(
112 PTDI_REQUEST Request
,
118 * FUNCTION: Returns extended information
120 * Request = Pointer to TDI request structure for the request
122 * Buffer = Pointer to buffer with data to use
123 * BufferSize = Pointer to buffer with size of Buffer. On return
124 * this is filled with number of bytes returned
125 * Context = Pointer to context buffer
127 * Status of operation
132 PVOID context
= NULL
;
133 NTSTATUS Status
= STATUS_SUCCESS
;
134 BOOL FoundEntity
= FALSE
;
135 InfoRequest_f InfoRequest
= NULL
;
137 TI_DbgPrint(DEBUG_INFO
,
138 ("InfoEx Req: %x %x %x!%04x:%d\n",
142 ID
->toi_entity
.tei_entity
,
143 ID
->toi_entity
.tei_instance
));
145 /* Check wether it is a query for a list of entities */
146 if (ID
->toi_entity
.tei_entity
== GENERIC_ENTITY
)
148 if ((ID
->toi_class
!= INFO_CLASS_GENERIC
) ||
149 (ID
->toi_type
!= INFO_TYPE_PROVIDER
) ||
150 (ID
->toi_id
!= ENTITY_LIST_ID
)) {
151 TI_DbgPrint(DEBUG_INFO
,("Invalid parameter\n"));
152 Status
= TDI_INVALID_PARAMETER
;
154 Status
= InfoTdiQueryListEntities(Buffer
, BufferSize
);
156 TcpipAcquireSpinLock( &EntityListLock
, &OldIrql
);
158 for( i
= 0; i
< EntityCount
; i
++ ) {
159 if( EntityList
[i
].tei_entity
== ID
->toi_entity
.tei_entity
&&
160 EntityList
[i
].tei_instance
== ID
->toi_entity
.tei_instance
) {
161 InfoRequest
= EntityList
[i
].info_req
;
162 context
= EntityList
[i
].context
;
168 TcpipReleaseSpinLock( &EntityListLock
, OldIrql
);
171 TI_DbgPrint(DEBUG_INFO
,
172 ("Calling Entity %d (%04x:%d) InfoEx (%x,%x,%x)\n",
173 i
, ID
->toi_entity
.tei_entity
,
174 ID
->toi_entity
.tei_instance
,
175 ID
->toi_class
, ID
->toi_type
, ID
->toi_id
));
176 Status
= InfoRequest( ID
->toi_class
,
186 TI_DbgPrint(DEBUG_INFO
,("Status: %08x\n", Status
));
191 TDI_STATUS InfoTdiSetInformationEx
192 (PTDI_REQUEST Request
,
197 * FUNCTION: Sets extended information
199 * Request = Pointer to TDI request structure for the request
200 * ID = Pointer to TDI object ID
201 * Buffer = Pointer to buffer with data to use
202 * BufferSize = Size of Buffer
204 * Status of operation
207 switch( ID
->toi_class
) {
208 case INFO_CLASS_PROTOCOL
:
209 switch( ID
->toi_type
) {
210 case INFO_TYPE_PROVIDER
:
211 switch( ID
->toi_id
) {
212 case IP_MIB_ROUTETABLE_ENTRY_ID
:
213 return InfoNetworkLayerTdiSetEx
226 return TDI_INVALID_PARAMETER
;