summaryrefslogtreecommitdiffstats
path: root/private/ntos/tdi/st/stprocs.h
blob: 480927f48662f060aa0569d7b1f063370ea77523 (plain) (blame)
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
/*++

Copyright (c) 1989-1993  Microsoft Corporation

Module Name:

    stprocs.h

Abstract:

    This header file defines private functions for the NT Sample transport
    provider.

Author:

    David Beaver (dbeaver) 1-July-1991

Revision History:

--*/

#ifndef _STPROCS_
#define _STPROCS_

//
// MACROS.
//
//
// Debugging aids
//

//
//  VOID
//  IF_STDBG(
//      IN PSZ Message
//      );
//

#if DBG
#define IF_STDBG(flags) \
    if (StDebug & (flags))
#else
#define IF_STDBG(flags) \
    if (0)
#endif

//
//  VOID
//  PANIC(
//      IN PSZ Message
//      );
//

#if DBG
#define PANIC(Msg) \
    DbgPrint ((Msg))
#else
#define PANIC(Msg)
#endif


//
// These are define to allow DbgPrints that disappear when
// DBG is 0.
//

#if DBG
#define StPrint0(fmt) DbgPrint(fmt)
#define StPrint1(fmt,v0) DbgPrint(fmt,v0)
#define StPrint2(fmt,v0,v1) DbgPrint(fmt,v0,v1)
#define StPrint3(fmt,v0,v1,v2) DbgPrint(fmt,v0,v1,v2)
#define StPrint4(fmt,v0,v1,v2,v3) DbgPrint(fmt,v0,v1,v2,v3)
#define StPrint5(fmt,v0,v1,v2,v3,v4) DbgPrint(fmt,v0,v1,v2,v3,v4)
#define StPrint6(fmt,v0,v1,v2,v3,v4,v5) DbgPrint(fmt,v0,v1,v2,v3,v4,v5)
#else
#define StPrint0(fmt)
#define StPrint1(fmt,v0)
#define StPrint2(fmt,v0,v1)
#define StPrint3(fmt,v0,v1,v2)
#define StPrint4(fmt,v0,v1,v2,v3)
#define StPrint5(fmt,v0,v1,v2,v3,v4)
#define StPrint6(fmt,v0,v1,v2,v3,v4,v5)
#endif

//
// The REFCOUNTS message take up a lot of room, so make
// removing them easy.
//

#if 1
#define IF_REFDBG IF_STDBG (ST_DEBUG_REFCOUNTS)
#else
#define IF_REFDBG if (0)
#endif

#define StReferenceConnection(Reason, Connection)\
    StRefConnection (Connection)

#define StDereferenceConnection(Reason, Connection)\
    StDerefConnection (Connection)

#define StDereferenceConnectionSpecial(Reason, Connection)\
    StDerefConnectionSpecial (Connection)

#define StReferenceRequest(Reason, Request)\
    (VOID)InterlockedIncrement( \
        &(Request)->ReferenceCount)

#define StDereferenceRequest(Reason, Request)\
    StDerefRequest (Request)

#define StReferenceSendIrp(Reason, IrpSp)\
    (VOID)InterlockedIncrement( \
        &IRP_REFCOUNT(IrpSp))

#define StDereferenceSendIrp(Reason, IrpSp)\
    StDerefSendIrp (IrpSp)

#define StReferenceAddress(Reason, Address)\
    (VOID)InterlockedIncrement( \
        &(Address)->ReferenceCount)

#define StDereferenceAddress(Reason, Address)\
    StDerefAddress (Address)

#define StReferenceDeviceContext(Reason, DeviceContext)\
    StRefDeviceContext (DeviceContext)

#define StDereferenceDeviceContext(Reason, DeviceContext)\
    StDerefDeviceContext (DeviceContext)

#define StReferencePacket(Packet) \
    (VOID)InterlockedIncrement( \
        &(Packet)->ReferenceCount)

//
// These macros are used to create and destroy packets, due
// to the allocation or deallocation of structure which
// need them.
//


#define StAddSendPacket(DeviceContext) { \
    PTP_PACKET _SendPacket; \
    StAllocateSendPacket ((DeviceContext), &_SendPacket); \
    if (_SendPacket != NULL) { \
        ExInterlockedPushEntryList( \
            &(DeviceContext)->PacketPool, \
            (PSINGLE_LIST_ENTRY)&_SendPacket->Linkage, \
            &(DeviceContext)->Interlock); \
    } \
}

#define StRemoveSendPacket(DeviceContext) { \
    PSINGLE_LIST_ENTRY s; \
    if (DeviceContext->PacketAllocated > DeviceContext->PacketInitAllocated) { \
        s = ExInterlockedPopEntryList( \
            &(DeviceContext)->PacketPool, \
            &(DeviceContext)->Interlock); \
        if (s != NULL) { \
            StDeallocateSendPacket((DeviceContext), \
                (PTP_PACKET)CONTAINING_RECORD(s, TP_PACKET, Linkage)); \
        } \
    } \
}


#define StAddReceivePacket(DeviceContext) { \
    PNDIS_PACKET _ReceivePacket; \
    StAllocateReceivePacket ((DeviceContext), &_ReceivePacket); \
    if (_ReceivePacket != NULL) { \
        ExInterlockedPushEntryList( \
            &(DeviceContext)->ReceivePacketPool, \
            (PSINGLE_LIST_ENTRY)&((PRECEIVE_PACKET_TAG)_ReceivePacket->ProtocolReserved)->Linkage, \
            &(DeviceContext)->Interlock); \
    } \
}

#define StRemoveReceivePacket(DeviceContext) { \
    PSINGLE_LIST_ENTRY s; \
    if (DeviceContext->ReceivePacketAllocated > DeviceContext->ReceivePacketInitAllocated) { \
        s = ExInterlockedPopEntryList( \
            &(DeviceContext)->ReceivePacketPool, \
            &(DeviceContext)->Interlock); \
        if (s != NULL) { \
            StDeallocateReceivePacket((DeviceContext), \
                (PNDIS_PACKET)CONTAINING_RECORD(s, NDIS_PACKET, ProtocolReserved[0])); \
        } \
    } \
}


#define StAddReceiveBuffer(DeviceContext) { \
    PBUFFER_TAG _ReceiveBuffer; \
    StAllocateReceiveBuffer ((DeviceContext), &_ReceiveBuffer); \
    if (_ReceiveBuffer != NULL) { \
        ExInterlockedPushEntryList( \
            &(DeviceContext)->ReceiveBufferPool, \
            &_ReceiveBuffer->Linkage, \
            &(DeviceContext)->Interlock); \
    } \
}

#define StRemoveReceiveBuffer(DeviceContext) { \
    PSINGLE_LIST_ENTRY s; \
    if (DeviceContext->ReceiveBufferAllocated > DeviceContext->ReceiveBufferInitAllocated) { \
        s = ExInterlockedPopEntryList( \
            &(DeviceContext)->ReceiveBufferPool, \
            &(DeviceContext)->Interlock); \
        if (s != NULL) { \
            StDeallocateReceiveBuffer(DeviceContext, \
                (PBUFFER_TAG)CONTAINING_RECORD(s, BUFFER_TAG, Linkage)); \
        } \
    } \
}


//
// These routines are used to maintain counters.
//

#define INCREMENT_COUNTER(_DeviceContext,_Field) \
    ++(_DeviceContext)->_Field

#define DECREMENT_COUNTER(_DeviceContext,_Field) \
    --(_DeviceContext)->_Field

#define ADD_TO_LARGE_INTEGER(_LargeInteger,_Ulong) \
    ExInterlockedAddLargeStatistic((_LargeInteger), (ULONG)(_Ulong))



//
// Routines in PACKET.C (TP_PACKET object manager).
//

VOID
StAllocateSendPacket(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_PACKET *TransportSendPacket
    );

VOID
StAllocateReceivePacket(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PNDIS_PACKET *TransportReceivePacket
    );

VOID
StAllocateReceiveBuffer(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PBUFFER_TAG *TransportReceiveBuffer
    );

VOID
StDeallocateSendPacket(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PTP_PACKET TransportSendPacket
    );

VOID
StDeallocateReceivePacket(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PNDIS_PACKET TransportReceivePacket
    );

VOID
StDeallocateReceiveBuffer(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PBUFFER_TAG TransportReceiveBuffer
    );

NTSTATUS
StCreatePacket(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_PACKET *Packet
    );

VOID
StDestroyPacket(
    IN PTP_PACKET Packet
    );

VOID
StWaitPacket(
    IN PTP_CONNECTION Connection,
    IN ULONG Flags
    );

//
// Routines in RCVENG.C (Receive engine).
//

VOID
AwakenReceive(
    IN PTP_CONNECTION Connection
    );

VOID
ActivateReceive(
    IN PTP_CONNECTION Connection
    );

VOID
CompleteReceive (
    IN PTP_CONNECTION Connection,
    IN BOOLEAN EndOfRecord,
    KIRQL ConnectionIrql,
    KIRQL CancelIrql
    );

VOID
StCancelReceive(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    );

//
// Routines in SENDENG.C (Send engine).
//

VOID
InitializeSend(
    PTP_CONNECTION Connection
    );

VOID
StartPacketizingConnection(
    PTP_CONNECTION Connection,
    IN BOOLEAN Immediate,
    IN KIRQL ConnectionIrql,
    IN KIRQL CancelIrql
    );

VOID
PacketizeConnections(
    IN PDEVICE_CONTEXT DeviceContext
    );

VOID
PacketizeSend(
    IN PTP_CONNECTION Connection
    );

VOID
CompleteSend(
    IN PTP_CONNECTION Connection
    );

VOID
FailSend(
    IN PTP_CONNECTION Connection,
    IN NTSTATUS RequestStatus,
    IN BOOLEAN StopConnection
    );

VOID
StCancelSend(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    );

VOID
StNdisSend(
    IN PTP_PACKET Packet
    );

VOID
StSendCompletionHandler(
    IN NDIS_HANDLE ProtocolBindingContext,
    IN PNDIS_PACKET NdisPacket,
    IN NDIS_STATUS NdisStatus
    );

NTSTATUS
BuildBufferChainFromMdlChain (
    IN NDIS_HANDLE BufferPoolHandle,
    IN PMDL CurrentMdl,
    IN ULONG ByteOffset,
    IN ULONG DesiredLength,
    OUT PNDIS_BUFFER *Destination,
    OUT PMDL *NewCurrentMdl,
    OUT ULONG *NewByteOffset,
    OUT ULONG *TrueLength
    );

//
// Routines in DEVCTX.C (TP_DEVCTX object manager).
//

VOID
StRefDeviceContext(
    IN PDEVICE_CONTEXT DeviceContext
    );

VOID
StDerefDeviceContext(
    IN PDEVICE_CONTEXT DeviceContext
    );

NTSTATUS
StCreateDeviceContext(
    IN PDRIVER_OBJECT DriverObject,
    IN PUNICODE_STRING DeviceName,
    IN OUT PDEVICE_CONTEXT *DeviceContext
    );

VOID
StDestroyDeviceContext(
    IN PDEVICE_CONTEXT DeviceContext
    );


//
// Routines in ADDRESS.C (TP_ADDRESS object manager).
//

VOID
StRefAddress(
    IN PTP_ADDRESS Address
    );

VOID
StDerefAddress(
    IN PTP_ADDRESS Address
    );

VOID
StAllocateAddressFile(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_ADDRESS_FILE *TransportAddressFile
    );

VOID
StDeallocateAddressFile(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PTP_ADDRESS_FILE TransportAddressFile
    );

NTSTATUS
StCreateAddressFile(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_ADDRESS_FILE * AddressFile
    );

VOID
StReferenceAddressFile(
    IN PTP_ADDRESS_FILE AddressFile
    );

VOID
StDereferenceAddressFile(
    IN PTP_ADDRESS_FILE AddressFile
    );

VOID
StStopAddress(
    IN PTP_ADDRESS Address
    );

VOID
StRegisterAddress(
    IN PTP_ADDRESS Address
    );

BOOLEAN
StMatchNetbiosAddress(
    IN PTP_ADDRESS Address,
    IN PUCHAR NetBIOSName
    );

VOID
StAllocateAddress(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_ADDRESS *TransportAddress
    );

VOID
StDeallocateAddress(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PTP_ADDRESS TransportAddress
    );

NTSTATUS
StCreateAddress(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PST_NETBIOS_ADDRESS NetworkName,
    OUT PTP_ADDRESS *Address
    );

PTP_ADDRESS
StLookupAddress(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PST_NETBIOS_ADDRESS NetworkName
    );

PTP_CONNECTION
StLookupRemoteName(
    IN PTP_ADDRESS Address,
    IN PUCHAR RemoteName
    );

NTSTATUS
StStopAddressFile(
    IN PTP_ADDRESS_FILE AddressFile,
    IN PTP_ADDRESS Address
    );

NTSTATUS
StVerifyAddressObject (
    IN PTP_ADDRESS_FILE AddressFile
    );

NTSTATUS
StSendDatagramsOnAddress(
    PTP_ADDRESS Address
    );

//
//
// Routines in CONNOBJ.C (TP_CONNECTION object manager).
//

VOID
StRefConnection(
    IN PTP_CONNECTION TransportConnection
    );

VOID
StDerefConnection(
    IN PTP_CONNECTION TransportConnection
    );

VOID
StDerefConnectionSpecial(
    IN PTP_CONNECTION TransportConnection
    );

VOID
StStopConnection(
    IN PTP_CONNECTION TransportConnection,
    IN NTSTATUS Status
    );

VOID
StCancelConnection(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    );

PTP_CONNECTION
StLookupListeningConnection(
    IN PTP_ADDRESS Address
    );

VOID
StAllocateConnection(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_CONNECTION *TransportConnection
    );

VOID
StDeallocateConnection(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PTP_CONNECTION TransportConnection
    );

NTSTATUS
StCreateConnection(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_CONNECTION *TransportConnection
    );

PTP_CONNECTION
StLookupConnectionByContext(
    IN PTP_ADDRESS Address,
    IN CONNECTION_CONTEXT ConnectionContext
    );

PTP_CONNECTION
StFindConnection(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PUCHAR LocalName,
    IN PUCHAR RemoteName
    );

NTSTATUS
StVerifyConnectionObject (
    IN PTP_CONNECTION Connection
    );

//
// Routines in REQUEST.C (TP_REQUEST object manager).
//


VOID
TdiRequestTimeoutHandler(
    IN PKDPC Dpc,
    IN PVOID DeferredContext,
    IN PVOID SystemArgument1,
    IN PVOID SystemArgument2
    );

VOID
StRefRequest(
    IN PTP_REQUEST Request
    );

VOID
StDerefRequest(
    IN PTP_REQUEST Request
    );

VOID
StCompleteRequest(
    IN PTP_REQUEST Request,
    IN NTSTATUS Status,
    IN ULONG Information
    );

VOID
StRefSendIrp(
    IN PIO_STACK_LOCATION IrpSp
    );

VOID
StDerefSendIrp(
    IN PIO_STACK_LOCATION IrpSp
    );

VOID
StCompleteSendIrp(
    IN PIRP Irp,
    IN NTSTATUS Status,
    IN ULONG Information
    );

VOID
StAllocateRequest(
    IN PDEVICE_CONTEXT DeviceContext,
    OUT PTP_REQUEST *TransportRequest
    );

VOID
StDeallocateRequest(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PTP_REQUEST TransportRequest
    );

NTSTATUS
StCreateRequest(
    IN PIRP Irp,
    IN PVOID Context,
    IN ULONG Flags,
    IN PMDL Buffer2,
    IN ULONG Buffer2Length,
    IN LARGE_INTEGER Timeout,
    OUT PTP_REQUEST * TpRequest
    );

//
// Routines in DLC.C (entrypoints from NDIS interface).
//

NDIS_STATUS
StReceiveIndication(
    IN NDIS_HANDLE BindingContext,
    IN NDIS_HANDLE ReceiveContext,
    IN PVOID HeaderBuffer,
    IN UINT HeaderBufferSize,
    IN PVOID LookaheadBuffer,
    IN UINT LookaheadBufferSize,
    IN UINT PacketSize
    );

NDIS_STATUS
StGeneralReceiveHandler (
    IN PDEVICE_CONTEXT DeviceContext,
    IN NDIS_HANDLE ReceiveContext,
    IN PHARDWARE_ADDRESS SourceAddress,
    IN PVOID HeaderBuffer,
    IN UINT PacketSize,
    IN PST_HEADER StHeader,
    IN UINT StSize
    );

VOID
StReceiveComplete (
    IN NDIS_HANDLE BindingContext
    );

VOID
StTransferDataComplete(
    IN NDIS_HANDLE BindingContext,
    IN PNDIS_PACKET NdisPacket,
    IN NDIS_STATUS Status,
    IN UINT BytesTransferred
    );

//
// Routines in UFRAMES.C, the UI-frame ST frame processor.
//

NTSTATUS
StIndicateDatagram(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PTP_ADDRESS Address,
    IN PUCHAR Header,
    IN ULONG Length
    );

NTSTATUS
StProcessConnectionless(
    IN PDEVICE_CONTEXT DeviceContext,
    IN PHARDWARE_ADDRESS SourceAddress,
    IN PST_HEADER StHeader,
    IN ULONG StLength,
    IN PUCHAR SourceRouting,
    IN UINT SourceRoutingLength,
    OUT PTP_ADDRESS * DatagramAddress
    );

//
// Routines in IFRAMES.C, the I-frame ST frame processor.
//

NTSTATUS
StProcessIIndicate(
    IN PTP_CONNECTION Connection,
    IN PST_HEADER StHeader,
    IN UINT StIndicatedLength,
    IN UINT StTotalLength,
    IN NDIS_HANDLE ReceiveContext,
    IN BOOLEAN Last
    );

//
// Routines in RCV.C (data copying routines for receives).
//

NTSTATUS
StCopyMdlToBuffer(
    IN PMDL SourceMdlChain,
    IN ULONG SourceOffset,
    IN PVOID DestinationBuffer,
    IN ULONG DestinationOffset,
    IN ULONG DestinationBufferSize,
    IN PULONG BytesCopied
    );

//
// Routines in FRAMESND.C, the UI-frame (non-link) shipper.
//

NTSTATUS
StSendConnect(
    IN PTP_CONNECTION Connection
    );

NTSTATUS
StSendDisconnect(
    IN PTP_CONNECTION Connection
    );

NTSTATUS
StSendAddressFrame(
    IN PTP_ADDRESS Address
    );

VOID
StSendDatagramCompletion(
    IN PTP_ADDRESS Address,
    IN PNDIS_PACKET NdisPacket,
    IN NDIS_STATUS NdisStatus
    );


//
// Routines in stdrvr.c
//

NTSTATUS
StDispatchOpenClose(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    );

NTSTATUS
StDispatchInternal(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    );

NTSTATUS
StDispatch(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    );

//
// Routine in stndis.c
//

VOID
StOpenAdapterComplete(
    IN NDIS_HANDLE NdisBindingContext,
    IN NDIS_STATUS Status,
    IN NDIS_STATUS OpenErrorStatus
    );

VOID
StCloseAdapterComplete(
    IN NDIS_HANDLE NdisBindingContext,
    IN NDIS_STATUS Status
    );

VOID
StResetComplete(
    IN NDIS_HANDLE NdisBindingContext,
    IN NDIS_STATUS Status
    );

VOID
StRequestComplete(
    IN NDIS_HANDLE NdisBindingContext,
    IN PNDIS_REQUEST NdisRequest,
    IN NDIS_STATUS Status
    );

VOID
StStatusIndication (
    IN NDIS_HANDLE NdisBindingContext,
    IN NDIS_STATUS NdisStatus,
    IN PVOID StatusBuffer,
    IN UINT StatusBufferLength
    );

VOID
StStatusComplete (
    IN NDIS_HANDLE NdisBindingContext
    );

#if DBG
PUCHAR
StGetNdisStatus (
    IN NDIS_STATUS NdisStatus
    );
#endif

VOID
StWriteResourceErrorLog(
    IN PDEVICE_CONTEXT DeviceContext,
    IN ULONG BytesNeeded,
    IN ULONG UniqueErrorValue
    );

VOID
StWriteGeneralErrorLog(
    IN PDEVICE_CONTEXT DeviceContext,
    IN NTSTATUS ErrorCode,
    IN ULONG UniqueErrorValue,
    IN NTSTATUS FinalStatus,
    IN PWSTR SecondString,
    IN ULONG DumpDataCount,
    IN ULONG DumpData[]
    );

VOID
StWriteOidErrorLog(
    IN PDEVICE_CONTEXT DeviceContext,
    IN NTSTATUS ErrorCode,
    IN NTSTATUS FinalStatus,
    IN PWSTR AdapterString,
    IN ULONG OidValue
    );

VOID
StFreeResources(
    IN PDEVICE_CONTEXT DeviceContext
    );


//
// routines in stcnfg.c
//

NTSTATUS
StConfigureProvider(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp,
    IN PIO_STACK_LOCATION IrpSp
    );

//
// Routines in stndis.c
//

NTSTATUS
StRegisterProtocol (
    IN STRING *NameString
    );

VOID
StDeregisterProtocol (
    VOID
    );


NTSTATUS
StInitializeNdis (
    IN PDEVICE_CONTEXT DeviceContext,
    IN PCONFIG_DATA ConfigInfo,
    IN UINT ConfigInfoNameIndex
    );

VOID
StCloseNdis (
    IN PDEVICE_CONTEXT DeviceContext
    );


#endif // def _STPROCS_