1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
/*++
Copyright (c) Microsoft Corporation. All Rights Reserved.
Module Name:
SxLibrary.h
Abstract:
This file contains the common library function headers that can be
used by any extension using the SxBase library.
--*/
/*++
SxLibSendNetBufferListsIngress
Routine Description:
This function is called to forward NBLs on ingress.
The extension MUST call this function, or call
SxLibCompleteNetBufferListsIngress for every NBL in NetBufferLists,
received in SxExtStartNetBufferListsIngress.
This function can also be called to inject NBLs.
If there are NBLs in NetBufferLists that are initiated by the
extension, NumInjectedNetBufferLists must be the number of new NBLs.
Arguments:
Switch - the Switch context
NetBufferLists - the NBLs to send
SendFlags - the SendFlags equivalent to NDIS flags for
NdisFSendNetBufferLists
NumInjectedNetBufferLists - the number of NBLs in NetBufferLists initiated
by the extension
Return Value:
VOID
--*/
VOID
SxLibSendNetBufferListsIngress(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ PNET_BUFFER_LIST NetBufferLists,
_In_ ULONG SendFlags,
_In_ ULONG NumInjectedNetBufferLists
);
/*++
SxLibSendNetBufferListsEgress
Routine Description:
This function is called to forward NBLs on egress.
The extension MUST call this function, or call
SxLibCompleteNetBufferListsEgress for every NBL in NetBufferLists
received in SxExtStartNetBufferListsEgress.
Arguments:
Switch - the Switch context
NetBufferLists - the NBLs to send
NumberOfNetBufferLists - the number of NBLs in NetBufferLists
ReceiveFlags - the ReceiveFlags equivalent to NDIS flags for
NdisFIndicateReceiveNetBufferLists
Return Value:
VOID
--*/
VOID
SxLibSendNetBufferListsEgress(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ PNET_BUFFER_LIST NetBufferLists,
_In_ ULONG NumberOfNetBufferLists,
_In_ ULONG ReceiveFlags
);
/*++
SxLibCompleteNetBufferListsEgress
Routine Description:
This function is called to complete NBLs on egress.
The extension MUST call this function for all NBLs received
in SxExtStartCompleteNetBufferListsEgress.
Arguments:
Switch - the Switch context
NetBufferLists - the NBLs to send
ReturnFlags - the ReceiveFlags equivalent to NDIS flags for
NdisFReturnNetBufferLists
Return Value:
VOID
--*/
VOID
SxLibCompleteNetBufferListsEgress(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ PNET_BUFFER_LIST NetBufferLists,
_In_ ULONG ReturnFlags
);
/*++
SxLibCompleteNetBufferListsIngress
Routine Description:
This function is called to complete NBLs on ingress.
The extension MUST call this function, or
SxLibCompletedInjectedNetBufferLists for all NBLs received in
SxExtStartCompleteNetBufferListsEgress.
Arguments:
Switch - the Switch context
NetBufferLists - the NBLs to send
SendCompleteFlags - the ReceiveFlags equivalent to NDIS flags for
NdisFSendNetBufferListsComplete
Return Value:
VOID
--*/
VOID
SxLibCompleteNetBufferListsIngress(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ PNET_BUFFER_LIST NetBufferLists,
_In_ ULONG SendCompleteFlags
);
/*++
SxLibCompletedInjectedNetBufferLists
Routine Description:
This function is called after completing NBLs injected
by the extension.
Arguments:
Switch - the Switch context
NumInjectedNetBufferLists - the number of NBLs completed
Return Value:
VOID
--*/
VOID
SxLibCompletedInjectedNetBufferLists(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ ULONG NumInjectedNetBufferLists
);
/*++
SxLibIssueOidRequest
Routine Description:
Utility routine that forms and sends an NDIS_OID_REQUEST to the
miniport, waits for it to complete, and returns status
to the caller.
NOTE: this assumes that the calling routine ensures validity
of the filter handle until this returns.
This function can only be called at PASSIVE_LEVEL.
Arguments:
SxSwitch - pointer to our switch object.
RequestType - NdisRequest[Set|Query|method]Information.
Oid - the object being set/queried.
InformationBuffer - data for the request.
InformationBufferLength - length of the above.
OutputBufferLength - valid only for method request.
MethodId - valid only for method request.
Timeout - The timeout in seconds for the OID.
BytesNeeded - place to return bytes read/written.
Return Value:
NDIS_STATUS_***
--*/
NDIS_STATUS
SxLibIssueOidRequest(
_In_ PSX_SWITCH_OBJECT SxSwitch,
_In_ NDIS_REQUEST_TYPE RequestType,
_In_ NDIS_OID Oid,
_In_opt_ PVOID InformationBuffer,
_In_ ULONG InformationBufferLength,
_In_ ULONG OutputBufferLength,
_In_ ULONG MethodId,
_In_ UINT Timeout,
_Out_ PULONG BytesNeeded
);
/*++
SxLibGetSwitchParametersUnsafe
Routine Description:
This function is called to get the current state of the switch.
Arguments:
Switch - the Switch context
SwitchParameters - the returned switch parameters
Return Value:
NDIS_STATUS_SUCCESS - if SwitchParameters was successfully returned
NDIS_STATUS_*** - otherwise
--*/
NDIS_STATUS
SxLibGetSwitchParametersUnsafe(
_In_ PSX_SWITCH_OBJECT Switch,
_Out_ PNDIS_SWITCH_PARAMETERS SwitchParameters
);
/*++
SxLibGetPortArrayUnsafe
Routine Description:
This function is called to get the current array
of ports.
NOTE: It is necessary to synchronize this with SxExtPortCreate
and SxExtPortTeardown.
Arguments:
Switch - the Switch context
PortArray - the returned port array
Return Value:
NDIS_STATUS_SUCCESS - if PortArray was successfully allocated
and returned
NDIS_STATUS_*** - otherwise
--*/
NDIS_STATUS
SxLibGetPortArrayUnsafe(
_In_ PSX_SWITCH_OBJECT Switch,
_Out_ PNDIS_SWITCH_PORT_ARRAY *PortArray
);
/*++
SxLibGetNicArrayUnsafe
Routine Description:
This function is called to get the current array
of NICs.
NOTE: It is necessary to synchronize this with SxExtNicConnect
and SxExtNicDisconnect.
Arguments:
SxSwitch - the Switch context
NicArray - the returned NIC array
Return Value:
NDIS_STATUS_SUCCESS - if NicArray was successfully allocated
and returned
NDIS_STATUS_*** - otherwise
--*/
NDIS_STATUS
SxLibGetNicArrayUnsafe(
_In_ PSX_SWITCH_OBJECT SxSwitch,
_Out_ PNDIS_SWITCH_NIC_ARRAY *NicArray
);
/*++
SxLibGetSwitchPropertyUnsafe
Routine Description:
This function is called to get the current array of the switch
property queried.
NOTE: It is necessary to synchronize this with SxExtAddSwitchProperty
and SxExtDeleteSwitchProperty.
Arguments:
Switch - the Switch context
PropertyType - the PropertyType to query for
PropertyId - the GUID of the property (from mof file)
SwitchPropertyEnumParameters - the returned property enum
Return Value:
NDIS_STATUS_SUCCESS - if SwitchPropertyEnumParameters was
successfully allocated and returned
NDIS_STATUS_*** - otherwise
--*/
NDIS_STATUS
SxLibGetSwitchPropertyUnsafe(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ NDIS_SWITCH_PROPERTY_TYPE PropertyType,
_In_opt_ PNDIS_SWITCH_OBJECT_ID PropertyId,
_Outptr_ PNDIS_SWITCH_PROPERTY_ENUM_PARAMETERS *SwitchPropertyEnumParameters
);
/*++
SxLibGetPortPropertyUnsafe
Routine Description:
This function is called to get the current array of the switch
property queried.
NOTE: It is necessary to synchronize this with SxExtAddPortProperty
and SxExtDeletePortProperty.
Arguments:
Switch - the Switch context
PortId - the port to query from
PropertyType - the PropertyType to query for
PropertyId - the GUID of the property (from mof file)
PortPropertyEnumParameters - the returned property enum
Return Value:
NDIS_STATUS_SUCCESS - if PortPropertyEnumParameters was
successfully allocated and returned
NDIS_STATUS_*** - otherwise
--*/
NDIS_STATUS
SxLibGetPortPropertyUnsafe(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ NDIS_SWITCH_PORT_ID PortId,
_In_ NDIS_SWITCH_PORT_PROPERTY_TYPE PropertyType,
_In_opt_ PNDIS_SWITCH_OBJECT_ID PropertyId,
_Outptr_ PNDIS_SWITCH_PORT_PROPERTY_ENUM_PARAMETERS *PortPropertyEnumParameters
);
/*++
SxLibRevokeVfUnsafe
Routine Description:
This function is called revoke the VF assignment for the
given VM.
NOTE: This must be synchonized with SxExtNicConnect and
SxExtNicDisconnect for the PortId given, and ReferenceSwitchNic
must have been successfully called.
Arguments:
Switch - the Switch context
PortId - the port the VM is connected to
Return Value:
VOID
--*/
VOID
SxLibRevokeVfUnsafe(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ NDIS_SWITCH_PORT_ID PortId
);
/*++
SxLibIssueNicStatusIndicationUnsafe
Routine Description:
This function is called issue a NIC status indication.
NOTE: This must be synchonized with SxExtNicConnect and
SxExtNicDisconnect for the PortId given, and ReferenceSwitchNic
must have been successfully called.
Arguments:
Switch - the Switch context
StatusCode - the status code to indicate
PortId - the port to indicate to/from
NicIndex - the nic index to indicate to/from
IsDestination - TRUE if PortId/NicIndex is destination info
FALSE if PortId/NicIndex is source info
StatusBuffer - the StatusBuffer for the indication
StatusBufferSize - the size of StatusBuffer
Return Value:
VOID
--*/
VOID
SxLibIssueNicStatusIndicationUnsafe(
_In_ PSX_SWITCH_OBJECT Switch,
_In_ NDIS_STATUS StatusCode,
_In_ NDIS_SWITCH_PORT_ID PortId,
_In_ NDIS_SWITCH_NIC_INDEX NicIndex,
_In_ BOOLEAN IsDestination,
_In_opt_ PVOID StatusBuffer,
_In_ ULONG StatusBufferSize
);
|