summaryrefslogtreecommitdiff
path: root/network/ndis/extension/base/SxApi.h
blob: a8c4c0dbb1b130b847aa2e116845a83d411361f0 (plain)
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
/*++

Copyright (c) Microsoft Corporation. All Rights Reserved.

Module Name:

    SxApi.h

Abstract:

    This file contains the API that must be implemented to
    create a switch extension using the SxBase library.


--*/

//
// The major version of NDIS the driver is using.
// For NDIS 6.30, use NDIS_FILTER_MAJOR_VERSION.
//
extern UCHAR  SxExtMajorNdisVersion;

//
// The minor version of NDIS the driver is using.
// For NDIS 6.30, use NDIS_FILTER_MINOR_VERSION.
//
extern UCHAR  SxExtMinorNdisVersion;

//
// The friendly name of the extension.
//
extern PWCHAR SxExtFriendlyName;

//
// The unique name of the extension.
//
extern PWCHAR SxExtUniqueName;

//
// The service name of the extension from the INF.
//
extern PWCHAR SxExtServiceName;

//
// The memory pool tag using in the extension.
//
extern ULONG  SxExtAllocationTag;

//
// The request ID used to identify OIDs initiated from this extension.
//
extern ULONG  SxExtOidRequestId;


/*++

SxExtInitialize

Routine Description:
    This function is called from the SxBase Library during DriverEntry.
    An extension should allocate/initialize all global data in this function.

Arguments:
    NULL

Return Value:
    NDIS_STATUS_SUCCESS succeeds driver entry.

    NDIS_STATUS_*** fails driver entry.

--*/
NDIS_STATUS
SxExtInitialize();


/*++

SxExtUninitialize

Routine Description:
    This function is called from the SxBase Library during DriverUnload.
    An extension should free/reset all global data in this function.

Arguments:
    NULL

Return Value:
    VOID

--*/
VOID
SxExtUninitialize();


/*++

SxExtCreateSwitch

Routine Description:
    This function is called when an extension binds to a new switch.
    All switch specific data should be allocated during this function.
    OIDs cannot be sent from this function, and both the control
    and data paths are inactive.

Arguments:
    Switch - the Switch Object currently being created

    ExtensionContext -  Extension context specific to the switch being
                        createf. This context will be passed back to the
                        extension for all function calls in SxApi

Return Value:
    NDIS_STATUS_SUCCESS succeeds switch creation.

    NDIS_STATUS_RESOURCES fails switch creation because of insufficient
                          resources.

    NDIS_STATUS_FAILURE fails switch creation.

--*/
NDIS_STATUS
SxExtCreateSwitch(
    _In_ PSX_SWITCH_OBJECT Switch,
    _Outptr_result_maybenull_ PNDIS_HANDLE *ExtensionContext
    );


/*++

SxExtDeleteSwitch

Routine Description:
    This function is called when an extension binds to a new switch.
    All switch specific data should be allocated/initialized during
    this function.

Arguments:
    Switch - the Switch being deleted

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch being deleted.

Return Value:
    VOID

--*/
VOID
SxExtDeleteSwitch(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext
    );


/*++

SxExtActivateSwitch

Routine Description:
    This function is called to activate a switch. The function can be called
    while the switch is Running or Paused and should be used to bootstrap
    the switch if it was not Active when it was created.

Arguments:
    Switch - the Switch being activated

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch being restarted.

Return Value:
    VOID

--*/
VOID
SxExtActivateSwitch(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext
    );


/*++

SxExtRestartSwitch

Routine Description:
    This function is called to restart a switch from a paused state.

Arguments:
    Switch - the Switch being restarted

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch being restarted.

Return Value:
    NDIS_STATUS_SUCCESS succeeds switch restart.

    NDIS_STATUS_RESOURCES fails switch restart because of insufficient
                          resources.

    NDIS_STATUS_FAILURE fails switch restart.

--*/
NDIS_STATUS
SxExtRestartSwitch(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext
    );


/*++

SxExtPauseSwitch

Routine Description:
    This function is called to pause a switch from a running state.

Arguments:
    Switch - the Switch being paused

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch being paused

Return Value:
    VOID

--*/
VOID
SxExtPauseSwitch(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext
    );


/*++

SxExtCreatePort

Routine Description:
    This function is called to create a new port on a switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Port - the Port being created

Return Value:
    NDIS_STATUS_SUCCESS to succeed port creation

    NDIS_STATUS_*** to fail port creation

--*/
NDIS_STATUS
SxExtCreatePort(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PORT_PARAMETERS Port
    );


/*++

SxExtUpdatePort

Routine Description:
    This function is called to update an already created port.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Port - the port being updated

Return Value:
    VOID

--*/
VOID
SxExtUpdatePort(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PORT_PARAMETERS Port
    );


/*++

SxExtCreateNic

Routine Description:
    This function is called to create a new NIC to be connected
    to a switch.
    The extension may allocate context for this NIC, and traffic may
    start to flow from this NIC, but it may not be used as a destination
    until SxExtConnectNic has been called.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Nic - the NIC being created

Return Value:
    NDIS_STATUS_SUCCESS to succeed NIC creation

    NDIS_STATUS_*** to fail NIC creation

--*/
NDIS_STATUS
SxExtCreateNic(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_PARAMETERS Nic
    );


/*++

SxExtConnectNic

Routine Description:
    This function is called to connect a NIC to a switch.
    After returning from this function the extension can use this NIC
    as a destination.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Nic - the NIC being connected

Return Value:
    VOID

--*/
VOID
SxExtConnectNic(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_PARAMETERS Nic
    );


/*++

SxExtUpdateNic

Routine Description:
    This function is called to update an already created NIC.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Nic - the NIC being updated

Return Value:
    VOID

--*/
VOID
SxExtUpdateNic(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_PARAMETERS Nic
    );


/*++

SxExtDisconnectNic

Routine Description:
    This function is called to disconnect a NIC from a switch.
    After returning from this function the extension cannot use
    this NIC as a destination.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Nic - the NIC being disconnected

Return Value:
    VOID

--*/
VOID
SxExtDisconnectNic(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_PARAMETERS Nic
    );


/*++

SxExtDeleteNic

Routine Description:
    This function is called to delete a NIC from a switch.
    No further traffic/control will be received for this NIC.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Nic - the NIC being deleted

Return Value:
    VOID

--*/
VOID
SxExtDeleteNic(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_PARAMETERS Nic
    );


/*++

SxExtTeardownPort

Routine Description:
    This function is called to start deletion of a port on a switch.
    Upon receiving this call, no further references may be taken
    on the given port.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Port - the Port being deleted

Return Value:
    VOID

--*/
VOID
SxExtTeardownPort(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PORT_PARAMETERS Port
    );


/*++

SxExtDeletePort

Routine Description:
    This function is called to finish deletion of a port on a switch.
    Upon receiving this call, no traffic/control will be received
    for this port.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    Port - the Port being deleted

Return Value:
    VOID

--*/
VOID
SxExtDeletePort(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PORT_PARAMETERS Port
    );


/*++

SxExtSaveNic

Routine Description:
    This function is called to retrieve save data for a given NIC.
    This function will be called until all extensions have finished
    saving data.

    An new save for this NIC will not start until SxExtSaveNicComplete
    has been received.

    If returning NDIS_STATUS_SUCCESS from this function, and
    BytesWritten > 0 you must write to the ExtensionId,
    ExtensionFriendlyName, SaveDataSize and SaveData fields in
    SaveState. SxExtUniqueName MUST be written to ExtensionId.
    SxExtFriendlyName should be written to ExtensionFriendlyName.

    If returning NDIS_STATUS_SUCCESS with BytesWritten == 0,
    DO NOT write any data to any fields.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SaveState - the save information and buffer to save to

    BytesWritten - the # of bytes written to the save buffer

    BytesNeeded - the length of the save buffer needed

Return Value:
    NDIS_STATUS_SUCCESS - if the buffer was successfully written, or not
                          needed and BytesWritten is set to 0

    NDIS_STATUS_BUFFER_TOO_SHORT - if the buffer is too short for the
                                   necessary save, write the length needed
                                   in BytesNeeded

    NDIS_STATUS_*** - to fail the save operation

--*/
NDIS_STATUS
SxExtSaveNic(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _Inout_ PNDIS_SWITCH_NIC_SAVE_STATE SaveState,
    _Out_ PULONG BytesWritten,
    _Out_ PULONG BytesNeeded
    );


/*++

SxExtSaveNicComplete

Routine Description:
    This function is called to notify the extension that saving
    the given NIC has been completed by all extensions.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SaveState - the save information

Return Value:
    VOID

--*/
VOID
SxExtSaveNicComplete(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_SAVE_STATE SaveState
    );


/*++

SxExtNicRestore

Routine Description:
    This function is called to restore previously saved data.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SaveState - the save information

    BytesRestored - the number of bytes restored from the saved data

Return Value:
    NDIS_STATUS_SUCCESS - if this data belongs to this extension, and was
                          successfully restored (BytesRestored written)
                          OR
                          this data does not belong to this extension
                          (BytesRestored == 0)

    NDIS_STATUS_*** - there was an error while attempting to restore
                      this data

--*/
NDIS_STATUS
SxExtNicRestore(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_SAVE_STATE SaveState,
    _Out_ PULONG BytesRestored
    );


/*++

SxExtNicRestoreComplete

Routine Description:
    This function is called to signify the end of a restore operation.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SaveState - the save information

Return Value:
    VOID

--*/
VOID
SxExtNicRestoreComplete(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_NIC_SAVE_STATE SaveState
    );


/*++

SxExtAddSwitchProperty

Routine Description:
    This function is called to add a property on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SwitchProperty - the property to be applied

Return Value:
    NDIS_STATUS_NOT_SUPPORTED - if the policy is not consumed by this extension

    NDIS_STATUS_SUCCESS - if the policy is consumed by this extension, and
                          can successfully be enforced

    STATUS_DATA_NOT_ACCEPTED - if the policy is consumed by this
                               extension, but cannot be enforced

    NDIS_STATUS_*** - if the policy is consumed by this extension, and
                      setting the valid policy failed

--*/
NDIS_STATUS
SxExtAddSwitchProperty(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PROPERTY_PARAMETERS SwitchProperty
    );


/*++

SxExtUpdateSwitchProperty

Routine Description:
    This function is called to update a property on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SwitchProperty - the property to be updated

Return Value:
    NDIS_STATUS_NOT_SUPPORTED - if the policy is not consumed by this extension

    NDIS_STATUS_SUCCESS - if the policy is consumed by this extension, and
                          can successfully be enforced

    STATUS_DATA_NOT_ACCEPTED - if the policy is consumed by this
                               extension, but cannot be enforced

    NDIS_STATUS_*** - if the policy is consumed by this extension, and
                      setting the valid policy failed

--*/
NDIS_STATUS
SxExtUpdateSwitchProperty(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PROPERTY_PARAMETERS SwitchProperty
    );


/*++

SxExtDeleteSwitchProperty

Routine Description:
    This function is called to delete a property on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SwitchProperty - the property to be deleted

Return Value:
    TRUE - if the policy belongs to this extension

    FALSE - otherwise

--*/
BOOLEAN
SxExtDeleteSwitchProperty(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PROPERTY_DELETE_PARAMETERS SwitchProperty
    );


/*++

SxExtAddPortProperty

Routine Description:
    This function is called to add a property on the given port,
    on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    PortProperty - the property to be applied

Return Value:
    NDIS_STATUS_NOT_SUPPORTED - if the policy is not consumed by this extension

    NDIS_STATUS_SUCCESS - if the policy is consumed by this extension, and
                          can successfully be enforced

    STATUS_DATA_NOT_ACCEPTED - if the policy is consumed by this
                               extension, but cannot be enforced

    NDIS_STATUS_*** - if the policy is consumed by this extension, and
                      setting the valid policy failed

--*/
NDIS_STATUS
SxExtAddPortProperty(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PORT_PROPERTY_PARAMETERS PortProperty
    );


/*++

SxExtUpdatePortProperty

Routine Description:
    This function is called to update a property on the given port,
    on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    PortProperty - the property to be applied

Return Value:
    NDIS_STATUS_NOT_SUPPORTED - if the policy is not consumed by this extension

    NDIS_STATUS_SUCCESS - if the policy is consumed by this extension, and
                          can successfully be enforced

    STATUS_DATA_NOT_ACCEPTED - if the policy is consumed by this
                               extension, but cannot be enforced

    NDIS_STATUS_*** - if the policy is consumed by this extension, and
                      setting the valid policy failed

--*/
NDIS_STATUS
SxExtUpdatePortProperty(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PORT_PROPERTY_PARAMETERS PortProperty
    );


/*++

SxExtDeletePortProperty

Routine Description:
    This function is called to delete a property on the given port,
    on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    PortProperty - the property to be deleted

Return Value:
    TRUE - if the policy is not consumed by this extension

    FALSE - otherwise

--*/
BOOLEAN
SxExtDeletePortProperty(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_SWITCH_PORT_PROPERTY_DELETE_PARAMETERS PortProperty
    );


/*++

SxExtQuerySwitchFeatureStatus

Routine Description:
    This function is called to query the status of a custom property
    on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    SwitchFeatureStatus - the property buffer

    BytesNeeded - if SwitchFeatureStatus is too small, this should be set
                  to the size buffer needed

Return Value:
    TRUE - return true if this property belongs to this extension, if
           BytesNeeded > 0, the buffer will be reallocated and
           this function will be called again

    FALSE - otherwise

--*/
BOOLEAN
SxExtQuerySwitchFeatureStatus(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _Inout_ PNDIS_SWITCH_FEATURE_STATUS_PARAMETERS SwitchFeatureStatus,
    _Inout_ PULONG BytesNeeded
    );


/*++

SxExtQueryPortFeatureStatus

Routine Description:
    This function is called to query the status of a custom property
    on the given port, on the given switch.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    PortFeatureStatus - the property buffer

    BytesNeeded - if PortFeatureStatus is too small, this should be set
                  to the size buffer needed

Return Value:
    TRUE - return true if this property belongs to this extension, if
           BytesNeeded > 0, the buffer will be reallocated and
           this function will be called again

    FALSE - otherwise

--*/
BOOLEAN
SxExtQueryPortFeatureStatus(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _Inout_ PNDIS_SWITCH_PORT_FEATURE_STATUS_PARAMETERS PortFeatureStatus,
    _Inout_ PULONG BytesNeeded
    );


/*++

SxExtProcessNicRequest

Routine Description:
    This function is called upon the receipt of an OID_SWITCH_NIC_REQUEST
    to the extension.
    If an extension wishes to redirect the OID, it must return a valid
    DestinationPortId and DestinationNicIndex, which it has taken a
    reference on.
    If an extension wishes to set source information, it must return
    a valid SourcePortId and SourceNicIndex, which it has taken a
    reference on.
    The extension can change the OidRequest if it needs to.

    !! This function should only be used by forwarding extensions. !!

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    OidRequest - the OID wrapped by the NIC request

    SourcePortId - the source PortId to set

    SourceNicIndex - the source NicIndex to set

    DestinationPortId - the destination PortId to set

    DestinationNicIndex - the destination NicIndex to set

Return Value:
    NDIS_STATUS_SUCCESS - sends OID

    NDIS_STATUS_*** - complete OID with given status

--*/
NDIS_STATUS
SxExtProcessNicRequest(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _Inout_ PNDIS_OID_REQUEST OidRequest,
    _Inout_ PNDIS_SWITCH_PORT_ID SourcePortId,
    _Inout_ PNDIS_SWITCH_NIC_INDEX SourceNicIndex,
    _Inout_ PNDIS_SWITCH_PORT_ID DestinationPortId,
    _Inout_ PNDIS_SWITCH_NIC_INDEX DestinationNicIndex
    );


/*++

SxExtProcessNicRequestComplete

Routine Description:
    This function is called upon the completion of an OID_SWITCH_NIC_REQUEST
    that this extension has previously altered.
    The extension must derefernce all NICs it had previously taken references
    on.
    If the OidRequest buffer was changed (along with underlying buffers),
    the previous data must be replaced.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    OidRequest - the OID buffer, encapsulated with source/destination info

    SourcePortId - the source PortId of the OID completion

    SourceNicIndex - the source NicIndex of the OID completion

    DestinationPortId - the destination PortId of the OID completion

    DestinationNicIndex - the destination NicIndex of the OID completion

    Status - the status the OID completed with

Return Value:
    NDIS_STATUS - the status to complete the OID request with

--*/
NDIS_STATUS
SxExtProcessNicRequestComplete(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _Inout_ PNDIS_OID_REQUEST OidRequest,
    _In_ NDIS_SWITCH_PORT_ID SourcePortId,
    _In_ NDIS_SWITCH_NIC_INDEX SourceNicIndex,
    _In_ NDIS_SWITCH_PORT_ID DestinationPortId,
    _In_ NDIS_SWITCH_NIC_INDEX DestinationNicIndex,
    _In_ NDIS_STATUS Status
    );


/*++

SxExtProcessNicStatus

Routine Description:
    This function is called upon the receipt of an NDIS_STATUS_SWITCH_NIC_STATUS
    to the extension.
    If the extension wishes to modify the status indication, it should
    send its own status indication using NdisFIndicateStatus and return a
    failure status.
    If the extension wishes to drop the status indication, it should return
    failure status, though this should be done very sparingly and carefully.

    !! This function should only be used by forwarding extensions. !!

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    StatusIndication - the indication wrapped by the NIC status indication

    SourcePortId - the source PortId of the indication

    SourceNicIndex - the source NicIndex of the indication

Return Value:
    NDIS_STATUS_SUCCESS - return to continue forwarding this indication

    NDIS_STATUS_*** - if the extension wants to modify the status
                      if modifying the status the extension should indicate
                      its own modified status using
                      SxLibIssueNicStatusIndicationUnsafe as soon as possible

--*/
NDIS_STATUS
SxExtProcessNicStatus(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNDIS_STATUS_INDICATION StatusIndication,
    _In_ NDIS_SWITCH_PORT_ID SourcePortId,
    _In_ NDIS_SWITCH_NIC_INDEX SourceNicIndex
    );


/*++

SxExtStartNetBufferListsIngress

Routine Description:
    This function is called upon the receipt on an NBL on ingress.
    The extension should call SxLibSendNetBufferListsIngress to continue
    the send of the NBL on ingress.
    The extension should call SxLibCompleteNetBufferListsIngress to
    drop the NBL.
    This function may also be call from egress to inject an NBL.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    NetBufferLists - the NBL to be sent

    SendFlags - the send flags from NDIS, equivalent to NDIS send flags for
                NdisFSendNetBufferLists

Return Value:
    VOID

--*/
VOID
SxExtStartNetBufferListsIngress(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNET_BUFFER_LIST NetBufferLists,
    _In_ ULONG SendFlags
    );


/*++

SxExtStartNetBufferListsEgress

Routine Description:
    This function is called upon the receipt on an NBL on egress.
    The extension should call SxLibSendNetBufferListsEgress to continue
    the send of the NBL on egress.
    The extension should call SxLibSendNetBufferListsEgressComplete to
    drop the NBL.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    NetBufferLists - the NBL to be sent

    NumberOfNetBufferLists - the number of NBLs in NetBufferLists

    ReceiveFlags - the receive flags from NDIS, equivalent to NDIS receive flags for
                   NdisFIndicateReceiveNetBufferLists

Return Value:
    VOID

--*/
VOID
SxExtStartNetBufferListsEgress(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNET_BUFFER_LIST NetBufferLists,
    _In_ ULONG NumberOfNetBufferLists,
    _In_ ULONG ReceiveFlags
    );


/*++

SxExtStartCompleteNetBufferListsEgress

Routine Description:
    This function is called upon the completion of an NBL on egress.
    The extension must call SxLibCompleteNetBufferListsEgress
    once it has finished processing the NBL.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    NetBufferLists - the NBL being completed

    ReturnFlags - the return flags from NDIS, equivalent to NDIS return flags for
                  NdisFReturnNetBufferLists

Return Value:
    VOID

--*/
VOID
SxExtStartCompleteNetBufferListsEgress(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNET_BUFFER_LIST NetBufferLists,
    _In_ ULONG ReturnFlags
    );


/*++

SxExtStartCompleteNetBufferListsIngress

Routine Description:
    This function is called upon the completion of an NBL on ingress.
    The extension must call SxLibCompleteNetBufferListsIngress
    once it has finished processing the NBL.

    If there are NBLs injected by this extension in NetBufferLists,
    the extension must NOT call SxLibCompleteNetBufferListsIngress, and
    instead call SxLibCompletedInjectedNetBufferLists with the number
    of injected NBLs completed.

Arguments:
    Switch - the Switch context

    ExtensionContext - The extension context allocated in SxExtCreateSwitch
                       for the switch

    NetBufferLists - the NBL being completed

    SendCompleteFlags - the send complete flags from NDIS, equivalent to
                        NDIS send complete flags for
                        NdisFSendNetBufferListsComplete

Return Value:
    VOID

--*/
VOID
SxExtStartCompleteNetBufferListsIngress(
    _In_ PSX_SWITCH_OBJECT Switch,
    _In_ NDIS_HANDLE ExtensionContext,
    _In_ PNET_BUFFER_LIST NetBufferLists,
    _In_ ULONG SendCompleteFlags
    );