This file is indexed.

/usr/i586-mingw32msvc/include/ddk/tdikrnl.h is in mingw32-runtime 3.15.2-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
/*
 * tdikrnl.h
 *
 * TDI kernel mode definitions
 *
 * This file is part of the w32api package.
 *
 * Contributors:
 *   Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
 *
 * THIS SOFTWARE IS NOT COPYRIGHTED
 *
 * This source code is offered for use in the public domain. You may
 * use, modify or distribute it freely.
 *
 * This code is distributed in the hope that it will be useful but
 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 * DISCLAIMED. This includes but is not limited to warranties of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

#ifndef __TDIKRNL_H
#define __TDIKRNL_H

#if __GNUC__ >=3
#pragma GCC system_header
#endif

#ifdef __cplusplus
extern "C" {
#endif

#include "ntddk.h"
#include "tdi.h"

#if defined(_TDI_)
  #define TDIKRNLAPI DECLSPEC_EXPORT
#else
  #define TDIKRNLAPI DECLSPEC_IMPORT
#endif


typedef struct _TDI_REQUEST_KERNEL {
  ULONG  RequestFlags;
  PTDI_CONNECTION_INFORMATION  RequestConnectionInformation;
  PTDI_CONNECTION_INFORMATION  ReturnConnectionInformation;
  PVOID  RequestSpecific;
} TDI_REQUEST_KERNEL, *PTDI_REQUEST_KERNEL;

/* Request codes */
#define TDI_ASSOCIATE_ADDRESS             0x01
#define TDI_DISASSOCIATE_ADDRESS          0x02
#define TDI_CONNECT                       0x03
#define TDI_LISTEN                        0x04
#define TDI_ACCEPT                        0x05
#define TDI_DISCONNECT                    0x06
#define TDI_SEND                          0x07
#define TDI_RECEIVE                       0x08
#define TDI_SEND_DATAGRAM                 0x09
#define TDI_RECEIVE_DATAGRAM              0x0A
#define TDI_SET_EVENT_HANDLER             0x0B
#define TDI_QUERY_INFORMATION             0x0C
#define TDI_SET_INFORMATION               0x0D
#define TDI_ACTION                        0x0E

#define TDI_DIRECT_SEND                   0x27
#define TDI_DIRECT_SEND_DATAGRAM          0x29

#define TDI_TRANSPORT_ADDRESS_FILE        1
#define TDI_CONNECTION_FILE               2
#define TDI_CONTROL_CHANNEL_FILE          3

/* Internal TDI IOCTLS */
#define IOCTL_TDI_QUERY_DIRECT_SEND_HANDLER   _TDI_CONTROL_CODE(0x80, METHOD_NEITHER)
#define IOCTL_TDI_QUERY_DIRECT_SENDDG_HANDLER _TDI_CONTROL_CODE(0x81, METHOD_NEITHER)

/* TdiAssociateAddress */
typedef struct _TDI_REQUEST_KERNEL_ASSOCIATE {
  HANDLE  AddressHandle;
} TDI_REQUEST_KERNEL_ASSOCIATE, *PTDI_REQUEST_KERNEL_ASSOCIATE;

/* TdiDisassociateAddress */
typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_DISASSOCIATE,
  *PTDI_REQUEST_KERNEL_DISASSOCIATE;

/* TdiAccept */
typedef struct _TDI_REQUEST_KERNEL_ACCEPT {
  PTDI_CONNECTION_INFORMATION  RequestConnectionInformation;
  PTDI_CONNECTION_INFORMATION  ReturnConnectionInformation;
} TDI_REQUEST_KERNEL_ACCEPT, *PTDI_REQUEST_KERNEL_ACCEPT;

/* TdiConnect */
typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_CONNECT,
  *PTDI_REQUEST_KERNEL_CONNECT;

/* TdiDisconnect */
typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_DISCONNECT,
  *PTDI_REQUEST_KERNEL_DISCONNECT;

/* TdiListen */
typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_LISTEN,
  *PTDI_REQUEST_KERNEL_LISTEN;

/* TdiReceive */
typedef struct _TDI_REQUEST_KERNEL_RECEIVE {
  ULONG  ReceiveLength;
  ULONG  ReceiveFlags;
} TDI_REQUEST_KERNEL_RECEIVE, *PTDI_REQUEST_KERNEL_RECEIVE;

/* TdiReceiveDatagram */
typedef struct _TDI_REQUEST_KERNEL_RECEIVEDG {
  ULONG  ReceiveLength;
  PTDI_CONNECTION_INFORMATION  ReceiveDatagramInformation;
  PTDI_CONNECTION_INFORMATION  ReturnDatagramInformation;
  ULONG  ReceiveFlags;
} TDI_REQUEST_KERNEL_RECEIVEDG, *PTDI_REQUEST_KERNEL_RECEIVEDG;

/* TdiSend */
typedef struct _TDI_REQUEST_KERNEL_SEND {
  ULONG  SendLength;
  ULONG  SendFlags;
} TDI_REQUEST_KERNEL_SEND, *PTDI_REQUEST_KERNEL_SEND;

/* TdiSendDatagram */
typedef struct _TDI_REQUEST_KERNEL_SENDDG {
  ULONG  SendLength;
  PTDI_CONNECTION_INFORMATION  SendDatagramInformation;
} TDI_REQUEST_KERNEL_SENDDG, *PTDI_REQUEST_KERNEL_SENDDG;

/* TdiSetEventHandler */
typedef struct _TDI_REQUEST_KERNEL_SET_EVENT {
  LONG  EventType;
  PVOID  EventHandler;
  PVOID  EventContext;
} TDI_REQUEST_KERNEL_SET_EVENT, *PTDI_REQUEST_KERNEL_SET_EVENT;

/* TdiQueryInformation */
typedef struct _TDI_REQUEST_KERNEL_QUERY_INFO {
  LONG  QueryType;
  PTDI_CONNECTION_INFORMATION  RequestConnectionInformation;
} TDI_REQUEST_KERNEL_QUERY_INFORMATION, *PTDI_REQUEST_KERNEL_QUERY_INFORMATION;

/* TdiSetInformation */
typedef struct _TDI_REQUEST_KERNEL_SET_INFO {
  LONG  SetType;
  PTDI_CONNECTION_INFORMATION  RequestConnectionInformation;
} TDI_REQUEST_KERNEL_SET_INFORMATION, *PTDI_REQUEST_KERNEL_SET_INFORMATION;


/* Event types */
#define TDI_EVENT_CONNECT                   0
#define TDI_EVENT_DISCONNECT                1
#define TDI_EVENT_ERROR                     2
#define TDI_EVENT_RECEIVE                   3
#define TDI_EVENT_RECEIVE_DATAGRAM          4
#define TDI_EVENT_RECEIVE_EXPEDITED         5
#define TDI_EVENT_SEND_POSSIBLE             6
#define TDI_EVENT_CHAINED_RECEIVE           7
#define TDI_EVENT_CHAINED_RECEIVE_DATAGRAM  8
#define TDI_EVENT_CHAINED_RECEIVE_EXPEDITED 9
#define TDI_EVENT_ERROR_EX                  10

typedef NTSTATUS DDKAPI
(*PTDI_IND_CONNECT)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ LONG  RemoteAddressLength,
  /*IN*/ PVOID  RemoteAddress,
  /*IN*/ LONG  UserDataLength,
  /*IN*/ PVOID  UserData,
  /*IN*/ LONG  OptionsLength,
  /*IN*/ PVOID  Options,
  /*OUT*/ CONNECTION_CONTEXT  *ConnectionContext,
  /*OUT*/ PIRP  *AcceptIrp);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultConnectHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ LONG  RemoteAddressLength,
  /*IN*/ PVOID  RemoteAddress,
  /*IN*/ LONG  UserDataLength,
  /*IN*/ PVOID  UserData,
  /*IN*/ LONG  OptionsLength,
  /*IN*/ PVOID  Options,
  /*OUT*/ CONNECTION_CONTEXT *ConnectionContext,
  /*OUT*/ PIRP  *AcceptIrp);

typedef NTSTATUS DDKAPI
(*PTDI_IND_DISCONNECT)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ LONG  DisconnectDataLength,
  /*IN*/ PVOID  DisconnectData,
  /*IN*/ LONG  DisconnectInformationLength,
  /*IN*/ PVOID  DisconnectInformation,
  /*IN*/ ULONG  DisconnectFlags);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultDisconnectHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ LONG  DisconnectDataLength,
  /*IN*/ PVOID  DisconnectData,
  /*IN*/ LONG  DisconnectInformationLength,
  /*IN*/ PVOID  DisconnectInformation,
  /*IN*/ ULONG  DisconnectFlags);

typedef NTSTATUS DDKAPI
(*PTDI_IND_ERROR)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ NTSTATUS  Status);

typedef NTSTATUS DDKAPI
(*PTDI_IND_ERROR_EX)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ NTSTATUS  Status,
  /*IN*/ PVOID  Buffer);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultErrorHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ NTSTATUS  Status);

typedef NTSTATUS DDKAPI
(*PTDI_IND_RECEIVE)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  BytesIndicated,
  /*IN*/ ULONG  BytesAvailable,
  /*OUT*/ ULONG  *BytesTaken,
  /*IN*/ PVOID  Tsdu,
  /*OUT*/ PIRP  *IoRequestPacket);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultReceiveHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  BytesIndicated,
  /*IN*/ ULONG  BytesAvailable,
  /*OUT*/ ULONG  *BytesTaken,
  /*IN*/ PVOID  Tsdu,
  /*OUT*/ PIRP  *IoRequestPacket);

typedef NTSTATUS DDKAPI
(*PTDI_IND_RECEIVE_DATAGRAM)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ LONG  SourceAddressLength,
  /*IN*/ PVOID  SourceAddress,
  /*IN*/ LONG  OptionsLength,
  /*IN*/ PVOID  Options,
  /*IN*/ ULONG  ReceiveDatagramFlags,
  /*IN*/ ULONG  BytesIndicated,
  /*IN*/ ULONG  BytesAvailable,
  /*OUT*/ ULONG  *BytesTaken,
  /*IN*/ PVOID  Tsdu,
  /*OUT*/ PIRP  *IoRequestPacket);

TDIKRNLAPI
NTSTATUS DDKAPI
TdiDefaultRcvDatagramHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ LONG  SourceAddressLength,
  /*IN*/ PVOID  SourceAddress,
  /*IN*/ LONG  OptionsLength,
  /*IN*/ PVOID  Options,
  /*IN*/ ULONG  ReceiveDatagramFlags,
  /*IN*/ ULONG  BytesIndicated,
  /*IN*/ ULONG  BytesAvailable,
  /*OUT*/ ULONG  *BytesTaken,
  /*IN*/ PVOID  Tsdu,
  /*OUT*/ PIRP  *IoRequestPacket);

typedef NTSTATUS DDKAPI
(*PTDI_IND_RECEIVE_EXPEDITED)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  BytesIndicated,
  /*IN*/ ULONG  BytesAvailable,
  /*OUT*/ ULONG  *BytesTaken,
  /*IN*/ PVOID  Tsdu,
  /*OUT*/ PIRP  *IoRequestPacket);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultRcvExpeditedHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  BytesIndicated,
  /*IN*/ ULONG  BytesAvailable,
  /*OUT*/ ULONG  *BytesTaken,
  /*IN*/ PVOID  Tsdu,
  /*OUT*/ PIRP  *IoRequestPacket);

typedef NTSTATUS DDKAPI
(*PTDI_IND_CHAINED_RECEIVE)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  ReceiveLength,
  /*IN*/ ULONG  StartingOffset,
  /*IN*/ PMDL  Tsdu,
  /*IN*/ PVOID  TsduDescriptor);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultChainedReceiveHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  ReceiveLength,
  /*IN*/ ULONG  StartingOffset,
  /*IN*/ PMDL  Tsdu,
  /*IN*/ PVOID  TsduDescriptor);

typedef NTSTATUS DDKAPI
(*PTDI_IND_CHAINED_RECEIVE_DATAGRAM)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ LONG  SourceAddressLength,
  /*IN*/ PVOID  SourceAddress,
  /*IN*/ LONG  OptionsLength,
  /*IN*/ PVOID  Options,
  /*IN*/ ULONG  ReceiveDatagramFlags,
  /*IN*/ ULONG  ReceiveDatagramLength,
  /*IN*/ ULONG  StartingOffset,
  /*IN*/ PMDL  Tsdu,
  /*IN*/ PVOID  TsduDescriptor);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultChainedRcvDatagramHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ LONG  SourceAddressLength,
  /*IN*/ PVOID  SourceAddress,
  /*IN*/ LONG  OptionsLength,
  /*IN*/ PVOID  Options,
  /*IN*/ ULONG  ReceiveDatagramFlags,
  /*IN*/ ULONG  ReceiveDatagramLength,
  /*IN*/ ULONG  StartingOffset,
  /*IN*/ PMDL  Tsdu,
  /*IN*/ PVOID  TsduDescriptor);

typedef NTSTATUS DDKAPI
(*PTDI_IND_CHAINED_RECEIVE_EXPEDITED)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  ReceiveLength,
  /*IN*/ ULONG  StartingOffset,
  /*IN*/ PMDL  Tsdu,
  /*IN*/ PVOID  TsduDescriptor);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultChainedRcvExpeditedHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ CONNECTION_CONTEXT  ConnectionContext,
  /*IN*/ ULONG  ReceiveFlags,
  /*IN*/ ULONG  ReceiveLength,
  /*IN*/ ULONG  StartingOffset,
  /*IN*/ PMDL  Tsdu,
  /*IN*/ PVOID  TsduDescriptor);

typedef NTSTATUS DDKAPI
(*PTDI_IND_SEND_POSSIBLE)(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ PVOID  ConnectionContext,
  /*IN*/ ULONG  BytesAvailable);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDefaultSendPossibleHandler(
  /*IN*/ PVOID  TdiEventContext,
  /*IN*/ PVOID  ConnectionContext,
  /*IN*/ ULONG  BytesAvailable);



  /* Macros and functions to build IRPs */

#define TdiBuildBaseIrp(                                                  \
  bIrp, bDevObj, bFileObj, bCompRoutine, bContxt, bIrpSp, bMinor)         \
{                                                                         \
  bIrpSp->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;                 \
  bIrpSp->MinorFunction = (bMinor);                                       \
  bIrpSp->DeviceObject  = (bDevObj);                                      \
  bIrpSp->FileObject    = (bFileObj);                                     \
  if (bCompRoutine)                                                       \
    IoSetCompletionRoutine(bIrp, bCompRoutine, bContxt, TRUE, TRUE, TRUE) \
  else                                                                    \
    IoSetCompletionRoutine(bIrp, NULL, NULL, FALSE, FALSE, FALSE);        \
}

  /*
 * VOID
 * TdiBuildAccept(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PTDI_CONNECTION_INFORMATION  RequestConnectionInfo,
 * OUT PTDI_CONNECTION_INFORMATION  ReturnConnectionInfo);
 */
#define TdiBuildAccept(                                             \
  Irp, DevObj, FileObj, CompRoutine, Contxt,                        \
  RequestConnectionInfo, ReturnConnectionInfo)                      \
{                                                                   \
  PTDI_REQUEST_KERNEL_ACCEPT _Request;                              \
  PIO_STACK_LOCATION _IrpSp;                                        \
                                                                    \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                          \
                                                                    \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,                \
                  Contxt, _IrpSp, TDI_ACCEPT);                      \
                                                                    \
  _Request = (PTDI_REQUEST_KERNEL_ACCEPT)&_IrpSp->Parameters;       \
  _Request->RequestConnectionInformation = (RequestConnectionInfo); \
  _Request->ReturnConnectionInformation  = (ReturnConnectionInfo);  \
}

  /*
 * VOID
 * TdiBuildAction(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PMDL  MdlAddr);
 */
#define TdiBuildAction(                               \
  Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr) \
{                                                     \
  PIO_STACK_LOCATION _IrpSp;                          \
                                                      \
  _IrpSp = IoGetNextIrpStackLocation(Irp);            \
                                                      \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,  \
                  Contxt, _IrpSp, TDI_ACTION);        \
                                                      \
  (Irp)->MdlAddress = (MdlAddr);                      \
}

  /*
 * VOID
 * TdiBuildAssociateAddress(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN HANDLE  AddrHandle);
 */
#define TdiBuildAssociateAddress(                                \
  Irp, DevObj, FileObj, CompRoutine, Contxt, AddrHandle)         \
{                                                                \
  PTDI_REQUEST_KERNEL_ASSOCIATE _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                     \
                                                                 \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                       \
                                                                 \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,             \
                  Contxt, _IrpSp, TDI_ASSOCIATE_ADDRESS);        \
                                                                 \
  _Request = (PTDI_REQUEST_KERNEL_ASSOCIATE)&_IrpSp->Parameters; \
  _Request->AddressHandle = (HANDLE)(AddrHandle);                \
}

  /*
 * VOID
 * TdiBuildConnect(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PLARGE_INTEGER  Time,
 * IN PTDI_CONNECTION_INFORMATION  RequestConnectionInfo,
 * OUT PTDI_CONNECTION_INFORMATION  ReturnConnectionInfo); 
 */
#define TdiBuildConnect(                                            \
  Irp, DevObj, FileObj, CompRoutine, Contxt,                        \
  Time, RequestConnectionInfo, ReturnConnectionInfo)                \
{                                                                   \
  PTDI_REQUEST_KERNEL _Request;                                     \
  PIO_STACK_LOCATION _IrpSp;                                        \
                                                                    \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                          \
                                                                    \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,                \
                  Contxt, _IrpSp, TDI_CONNECT);                     \
                                                                    \
  _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters;              \
  _Request->RequestConnectionInformation = (RequestConnectionInfo); \
  _Request->ReturnConnectionInformation  = (ReturnConnectionInfo);  \
  _Request->RequestSpecific              = (PVOID)(Time);           \
}

  /*
 * VOID
 * TdiBuildDisassociateAddress(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt);
 */
#define TdiBuildDisassociateAddress(                                \
  Irp, DevObj, FileObj, CompRoutine, Contxt)                        \
{                                                                   \
  PIO_STACK_LOCATION _IrpSp;                                        \
                                                                    \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                          \
                                                                    \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,                \
                  Contxt, _IrpSp, TDI_DISASSOCIATE_ADDRESS);        \
}

  /*
 * VOID
 * TdiBuildDisconnect(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PLARGE_INTEGER  Time,
 * IN PULONG  Flags,
 * IN PTDI_CONNECTION_INFORMATION  RequestConnectionInfo,
 * OUT PTDI_CONNECTION_INFORMATION  ReturnConnectionInfo); 
 */
#define TdiBuildDisconnect(                                         \
  Irp, DevObj, FileObj, CompRoutine, Contxt, Time,                  \
  Flags, RequestConnectionInfo, ReturnConnectionInfo)               \
{                                                                   \
  PTDI_REQUEST_KERNEL _Request;                                     \
  PIO_STACK_LOCATION _IrpSp;                                        \
                                                                    \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                          \
                                                                    \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,                \
                  Contxt, _IrpSp, TDI_DISCONNECT);                  \
                                                                    \
  _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters;              \
  _Request->RequestConnectionInformation = (RequestConnectionInfo); \
  _Request->ReturnConnectionInformation  = (ReturnConnectionInfo);  \
  _Request->RequestSpecific = (PVOID)(Time);                        \
  _Request->RequestFlags    = (Flags);                              \
}

  /*
 * PIRP
 * TdiBuildInternalDeviceControlIrp(
 * IN CCHAR IrpSubFunction,
 * IN PDEVICE_OBJECT DeviceObject,
 * IN PFILE_OBJECT FileObject,
 * IN PKEVENT Event,
 * IN PIO_STATUS_BLOCK IoStatusBlock);
 */
#define TdiBuildInternalDeviceControlIrp( \
  IrpSubFunction, DeviceObject,           \
  FileObject, Event, IoStatusBlock)       \
  IoBuildDeviceIoControlRequest(          \
		0x00000003, DeviceObject,             \
		NULL, 0, NULL, 0,                     \
		TRUE, Event, IoStatusBlock)

  /*
 * VOID
 * TdiBuildListen(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN ULONG  Flags,
 * IN PTDI_CONNECTION_INFORMATION  RequestConnectionInfo,
 * OUT PTDI_CONNECTION_INFORMATION  ReturnConnectionInfo); 
 */
#define TdiBuildListen(                                             \
  Irp, DevObj, FileObj, CompRoutine, Contxt,                        \
  Flags, RequestConnectionInfo, ReturnConnectionInfo)               \
{                                                                   \
  PTDI_REQUEST_KERNEL _Request;                                     \
  PIO_STACK_LOCATION _IrpSp;                                        \
                                                                    \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                          \
                                                                    \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,                \
                  Contxt, _IrpSp, TDI_LISTEN);                      \
                                                                    \
  _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters;              \
  _Request->RequestConnectionInformation = (RequestConnectionInfo); \
  _Request->ReturnConnectionInformation  = (ReturnConnectionInfo);  \
  _Request->RequestFlags = (Flags);                                 \
}

TDIKRNLAPI
VOID
DDKAPI
TdiBuildNetbiosAddress(
  /*IN*/ PUCHAR  NetbiosName,
  /*IN*/ BOOLEAN  IsGroupName,
  /*IN OUT*/ PTA_NETBIOS_ADDRESS  NetworkName);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiBuildNetbiosAddressEa(
  /*IN*/ PUCHAR  Buffer,
  /*IN*/ BOOLEAN  IsGroupName,
  /*IN*/ PUCHAR  NetbiosName);

  /*
 * VOID
 * TdiBuildQueryInformation(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN UINT  QType,
 * IN PMDL  MdlAddr);
 */
#define TdiBuildQueryInformation(                                        \
  Irp, DevObj, FileObj, CompRoutine, Contxt, QType, MdlAddr)             \
{                                                                        \
  PTDI_REQUEST_KERNEL_QUERY_INFORMATION _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                             \
                                                                         \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                               \
                                                                         \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,                     \
                  Contxt, _IrpSp, TDI_QUERY_INFORMATION);                \
                                                                         \
  _Request = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&_IrpSp->Parameters; \
  _Request->RequestConnectionInformation = NULL;                         \
  _Request->QueryType = (ULONG)(QType);                                  \
  (Irp)->MdlAddress   = (MdlAddr);                                       \
}

  /*
 * VOID
 * TdiBuildReceive(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PMDL  MdlAddr,
 * IN ULONG  InFlags, 
 * IN ULONG  ReceiveLen); 
 */
#define TdiBuildReceive(                                       \
  Irp, DevObj, FileObj, CompRoutine, Contxt,                   \
  MdlAddr, InFlags, ReceiveLen)                                \
{                                                              \
  PTDI_REQUEST_KERNEL_RECEIVE _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                   \
                                                               \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                     \
                                                               \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,           \
                  Contxt, _IrpSp, TDI_RECEIVE);                \
                                                               \
  _Request = (PTDI_REQUEST_KERNEL_RECEIVE)&_IrpSp->Parameters; \
  _Request->ReceiveFlags  = (InFlags);                         \
  _Request->ReceiveLength = (ReceiveLen);                      \
  (Irp)->MdlAddress       = (MdlAddr);                         \
}

  /*
 * VOID
 * TdiBuildReceiveDatagram(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PMDL  MdlAddr,
 * IN ULONG  ReceiveLen,
 * IN PTDI_CONNECTION_INFORMATION  ReceiveDatagramInfo,
 * OUT PTDI_CONNECTION_INFORMATION  ReturnInfo,
 *   ULONG InFlags); 
 */
#define TdiBuildReceiveDatagram(                                 \
  Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr,            \
  ReceiveLen, ReceiveDatagramInfo, ReturnInfo, InFlags)          \
{                                                                \
  PTDI_REQUEST_KERNEL_RECEIVEDG _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                     \
                                                                 \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                       \
                                                                 \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,             \
                  Contxt, _IrpSp, TDI_RECEIVE_DATAGRAM);         \
                                                                 \
  _Request = (PTDI_REQUEST_KERNEL_RECEIVEDG)&_IrpSp->Parameters; \
  _Request->ReceiveDatagramInformation = (ReceiveDatagramInfo);  \
  _Request->ReturnDatagramInformation  = (ReturnInfo);           \
  _Request->ReceiveLength = (ReceiveLen);                        \
  _Request->ReceiveFlags  = (InFlags);                           \
  (Irp)->MdlAddress       = (MdlAddr);                           \
}

  /*
 * VOID
 * TdiBuildSend(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PMDL  MdlAddr,
 * IN ULONG  InFlags,
 * IN ULONG  SendLen);
 */
#define TdiBuildSend(                                       \
  Irp, DevObj, FileObj, CompRoutine, Contxt,                \
  MdlAddr, InFlags, SendLen)                                \
{                                                           \
  PTDI_REQUEST_KERNEL_SEND _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                \
                                                            \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                  \
                                                            \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,        \
                  Contxt, _IrpSp, TDI_SEND);                \
                                                            \
  _Request = (PTDI_REQUEST_KERNEL_SEND)&_IrpSp->Parameters; \
  _Request->SendFlags  = (InFlags);                         \
  _Request->SendLength = (SendLen);                         \
  (Irp)->MdlAddress    = (MdlAddr);                         \
}

  /*
 * VOID
 * TdiBuildSendDatagram(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN PMDL  MdlAddr,
 * IN ULONG  SendLen,
 * IN PTDI_CONNECTION_INFORMATION  SendDatagramInfo); 
 */
#define TdiBuildSendDatagram(                                 \
  Irp, DevObj, FileObj, CompRoutine, Contxt,                  \
  MdlAddr, SendLen, SendDatagramInfo)                         \
{                                                             \
  PTDI_REQUEST_KERNEL_SENDDG _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                  \
                                                              \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                    \
                                                              \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,          \
                  Contxt, _IrpSp, TDI_SEND_DATAGRAM);         \
                                                              \
  _Request = (PTDI_REQUEST_KERNEL_SENDDG)&_IrpSp->Parameters; \
  _Request->SendDatagramInformation = (SendDatagramInfo);     \
  _Request->SendLength = (SendLen);                           \
  (Irp)->MdlAddress    = (MdlAddr);                           \
}

  /*
 * VOID
 * TdiBuildSetEventHandler(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN INT  InEventType,
 * IN PVOID  InEventHandler,
 * IN PVOID  InEventContext);
 */
#define TdiBuildSetEventHandler(                                 \
  Irp, DevObj, FileObj, CompRoutine, Contxt,                     \
  InEventType, InEventHandler, InEventContext)                   \
{                                                                \
  PTDI_REQUEST_KERNEL_SET_EVENT _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                     \
                                                                 \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                       \
                                                                 \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,             \
                  Contxt, _IrpSp, TDI_SET_EVENT_HANDLER);        \
                                                                 \
  _Request = (PTDI_REQUEST_KERNEL_SET_EVENT)&_IrpSp->Parameters; \
  _Request->EventType    = (InEventType);                        \
  _Request->EventHandler = (PVOID)(InEventHandler);              \
  _Request->EventContext = (PVOID)(InEventContext);              \
}

  /*
 * VOID
 * TdiBuildSetInformation(
 * IN PIRP  Irp,
 * IN PDEVICE_OBJECT  DevObj,
 * IN PFILE_OBJECT  FileObj,
 * IN PVOID  CompRoutine,
 * IN PVOID  Contxt,
 * IN UINT  SType,
 * IN PMDL  MdlAddr);
 */
#define TdiBuildSetInformation(                                        \
  Irp, DevObj, FileObj, CompRoutine, Contxt, SType, MdlAddr)           \
{                                                                      \
  PTDI_REQUEST_KERNEL_SET_INFORMATION _Request;                        \
  PIO_STACK_LOCATION _IrpSp;                                           \
                                                                       \
  _IrpSp = IoGetNextIrpStackLocation(Irp);                             \
                                                                       \
  TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine,                   \
                  Contxt, _IrpSp, TDI_SET_INFORMATION);                \
                                                                       \
  _Request = (PTDI_REQUEST_KERNEL_SET_INFORMATION)&_IrpSp->Parameters; \
  _Request->RequestConnectionInformation = NULL;                       \
  _Request->SetType = (ULONG)(SType);                                  \
  (Irp)->MdlAddress = (MdlAddr);                                       \
}

  /* TDI20_CLIENT_INTERFACE_INFO.TdiVersion constants */
#define TDI_CURRENT_MAJOR_VERSION         2
#define TDI_CURRENT_MINOR_VERSION         0

#define TDI_CURRENT_VERSION ((TDI_CURRENT_MINOR_VERSION) << 8 \
  | (TDI_CURRENT_MAJOR_VERSION))

#define TDI_VERSION_ONE                   0x0001

typedef enum _TDI_PNP_OPCODE {
  TDI_PNP_OP_MIN,
  TDI_PNP_OP_ADD,
  TDI_PNP_OP_DEL,
  TDI_PNP_OP_UPDATE,
  TDI_PNP_OP_PROVIDERREADY,
  TDI_PNP_OP_NETREADY,
  TDI_PNP_OP_ADD_IGNORE_BINDING,
  TDI_PNP_OP_DELETE_IGNORE_BINDING,
  TDI_PNP_OP_MAX
} TDI_PNP_OPCODE;

  /* TDI_PNP_CONTEXT.ContextType */
#define TDI_PNP_CONTEXT_TYPE_IF_NAME            0x1
#define TDI_PNP_CONTEXT_TYPE_IF_ADDR            0x2
#define TDI_PNP_CONTEXT_TYPE_PDO                0x3
#define TDI_PNP_CONTEXT_TYPE_FIRST_OR_LAST_IF   0x4

typedef struct _TDI_PNP_CONTEXT {
  USHORT  ContextSize;
  USHORT  ContextType;
  UCHAR  ContextData[1];
} TDI_PNP_CONTEXT, *PTDI_PNP_CONTEXT;

typedef VOID DDKAPI
(*TDI_ADD_ADDRESS_HANDLER)(
  /*IN*/ PTA_ADDRESS  Address);

typedef VOID DDKAPI
(*TDI_ADD_ADDRESS_HANDLER_V2)(
  /*IN*/ PTA_ADDRESS  Address,
  /*IN*/ PUNICODE_STRING  DeviceName,
  /*IN*/ PTDI_PNP_CONTEXT  Context);

typedef VOID DDKAPI
(*TDI_BINDING_HANDLER)(
  /*IN*/ TDI_PNP_OPCODE  PnPOpcode,
  /*IN*/ PUNICODE_STRING  DeviceName,
  /*IN*/ PWSTR  MultiSZBindList);

typedef VOID DDKAPI
(*TDI_BIND_HANDLER)(
  /*IN*/ PUNICODE_STRING  DeviceName);

typedef VOID DDKAPI
(*TDI_DEL_ADDRESS_HANDLER)(
  /*IN*/ PTA_ADDRESS  Address);

typedef VOID DDKAPI
(*TDI_DEL_ADDRESS_HANDLER_V2)(
  /*IN*/ PTA_ADDRESS  Address,
  /*IN*/ PUNICODE_STRING  DeviceName,
  /*IN*/ PTDI_PNP_CONTEXT  Context);

typedef NTSTATUS DDKAPI
(*TDI_PNP_POWER_HANDLER)(
  /*IN*/ PUNICODE_STRING  DeviceName,
  /*IN*/ PNET_PNP_EVENT  PowerEvent,
  /*IN*/ PTDI_PNP_CONTEXT  Context1,
  /*IN*/ PTDI_PNP_CONTEXT  Context2);

typedef VOID DDKAPI
(*TDI_UNBIND_HANDLER)(
  /*IN*/ PUNICODE_STRING  DeviceName);

typedef VOID DDKAPI
(*ProviderPnPPowerComplete)(
  /*IN*/ PNET_PNP_EVENT  NetEvent,
  /*IN*/ NTSTATUS  ProviderStatus);

typedef struct _TDI20_CLIENT_INTERFACE_INFO {
  _ANONYMOUS_UNION union {
    _ANONYMOUS_STRUCT struct {
      UCHAR  MajorTdiVersion;
      UCHAR  MinorTdiVersion;
    } DUMMYSTRUCTNAME;
    USHORT TdiVersion;
  } DUMMYUNIONNAME;
  USHORT  Unused;
  PUNICODE_STRING  ClientName;
  TDI_PNP_POWER_HANDLER  PnPPowerHandler;
  _ANONYMOUS_UNION union {
    TDI_BINDING_HANDLER  BindingHandler;
    _ANONYMOUS_STRUCT struct {
      TDI_BIND_HANDLER  BindHandler;
      TDI_UNBIND_HANDLER  UnBindHandler;
    } DUMMYSTRUCTNAME;
  }DUMMYUNIONNAME2;
  _ANONYMOUS_UNION union {
    _ANONYMOUS_STRUCT struct {
      TDI_ADD_ADDRESS_HANDLER_V2  AddAddressHandlerV2;
      TDI_DEL_ADDRESS_HANDLER_V2  DelAddressHandlerV2;
    } DUMMYSTRUCTNAME;
    _ANONYMOUS_STRUCT struct {
      TDI_ADD_ADDRESS_HANDLER  AddAddressHandler;
      TDI_DEL_ADDRESS_HANDLER  DelAddressHandler;
    } DUMMYSTRUCTNAME2;
  } DUMMYUNIONNAME3;
} TDI20_CLIENT_INTERFACE_INFO, *PTDI20_CLIENT_INTERFACE_INFO;

typedef TDI20_CLIENT_INTERFACE_INFO TDI_CLIENT_INTERFACE_INFO;
typedef TDI_CLIENT_INTERFACE_INFO *PTDI_CLIENT_INTERFACE_INFO;


  /* TDI functions */

  /*
 * VOID
 * TdiCompleteRequest(
 * IN PIRP Irp,
 * IN NTSTATUS Status);
 */
#define TdiCompleteRequest(Irp, Status)           \
{                                                 \
  (Irp)->IoStatus.Status = (Status);              \
  IoCompleteRequest((Irp), IO_NETWORK_INCREMENT); \
}

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiCopyBufferToMdl(
  /*IN*/ PVOID  SourceBuffer,
  /*IN*/ ULONG  SourceOffset,
  /*IN*/ ULONG  SourceBytesToCopy,
  /*IN*/ PMDL  DestinationMdlChain,
  /*IN*/ ULONG  DestinationOffset,
  /*IN*/ PULONG  BytesCopied);

  /*
 * VOID
 * TdiCopyLookaheadData(
 * IN PVOID  Destination,
 * IN PVOID  Source,
 * IN ULONG  Length,
 * IN ULONG  ReceiveFlags);
 */
#define TdiCopyLookaheadData(Destination, Source, Length, ReceiveFlags) \
  RtlCopyMemory(Destination, Source, Length)

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiCopyMdlChainToMdlChain (
  /*IN*/ PMDL  SourceMdlChain,
  /*IN*/ ULONG  SourceOffset,
  /*IN*/ PMDL  DestinationMdlChain,
  /*IN*/ ULONG  DestinationOffset,
  /*OUT*/ PULONG  BytesCopied);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiCopyMdlToBuffer(
  /*IN*/ PMDL  SourceMdlChain,
  /*IN*/ ULONG  SourceOffset,
  /*IN*/ PVOID  DestinationBuffer,
  /*IN*/ ULONG  DestinationOffset,
  /*IN*/ ULONG  DestinationBufferSize,
  /*OUT*/ PULONG  BytesCopied);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDeregisterAddressChangeHandler(
  /*IN*/ HANDLE  BindingHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDeregisterDeviceObject(
  /*IN*/ HANDLE  DevRegistrationHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDeregisterNetAddress(
  /*IN*/ HANDLE  AddrRegistrationHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDeregisterPnPHandlers(
  /*IN*/ HANDLE  BindingHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiDeregisterProvider(
  /*IN*/ HANDLE  ProviderHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiEnumerateAddresses(
  /*IN*/ HANDLE  BindingHandle);

TDIKRNLAPI
VOID
DDKAPI
TdiInitialize(
  VOID);

TDIKRNLAPI
VOID
DDKAPI
TdiMapBuffer(
  /*IN*/ PMDL  MdlChain);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiMapUserRequest(
  /*IN*/ PDEVICE_OBJECT  DeviceObject,
  /*IN*/ PIRP  Irp,
  /*IN*/ PIO_STACK_LOCATION  IrpSp);

TDIKRNLAPI
BOOLEAN
DDKAPI
TdiMatchPdoWithChainedReceiveContext(
  /*IN*/ PVOID TsduDescriptor,
  /*IN*/ PVOID PDO);

TDIKRNLAPI
VOID
DDKAPI
TdiPnPPowerComplete(
  /*IN*/ HANDLE  BindingHandle,
  /*IN*/ PNET_PNP_EVENT  PowerEvent,
  /*IN*/ NTSTATUS  Status);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiPnPPowerRequest(
  /*IN*/ PUNICODE_STRING  DeviceName,
  /*IN*/ PNET_PNP_EVENT  PowerEvent,
  /*IN*/ PTDI_PNP_CONTEXT  Context1,
  /*IN*/ PTDI_PNP_CONTEXT  Context2,
  /*IN*/ ProviderPnPPowerComplete  ProtocolCompletionHandler);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiProviderReady(
  /*IN*/ HANDLE  ProviderHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiRegisterAddressChangeHandler(
  /*IN*/ TDI_ADD_ADDRESS_HANDLER  AddHandler,
  /*IN*/ TDI_DEL_ADDRESS_HANDLER  DeleteHandler,
  /*OUT*/ HANDLE  *BindingHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiRegisterDeviceObject(
  /*IN*/ PUNICODE_STRING  DeviceName,
  /*OUT*/ HANDLE  *DevRegistrationHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiRegisterNetAddress(
  /*IN*/ PTA_ADDRESS  Address,
  /*IN*/ PUNICODE_STRING  DeviceName,
  /*IN*/ PTDI_PNP_CONTEXT  Context,
  /*OUT*/ HANDLE  *AddrRegistrationHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiRegisterNotificationHandler(
  /*IN*/ TDI_BIND_HANDLER  BindHandler,
  /*IN*/ TDI_UNBIND_HANDLER  UnbindHandler,
  /*OUT*/ HANDLE  *BindingHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiRegisterPnPHandlers(
  /*IN*/ PTDI_CLIENT_INTERFACE_INFO  ClientInterfaceInfo,
  /*IN*/ ULONG  InterfaceInfoSize,
  /*OUT*/ HANDLE  *BindingHandle);

TDIKRNLAPI
NTSTATUS
DDKAPI
TdiRegisterProvider(
  /*IN*/ PUNICODE_STRING  ProviderName,
  /*OUT*/ HANDLE  *ProviderHandle);

TDIKRNLAPI
VOID
DDKAPI
TdiReturnChainedReceives(
  /*IN*/ PVOID  *TsduDescriptors,
  /*IN*/ ULONG   NumberOfTsdus);

TDIKRNLAPI
VOID
DDKAPI
TdiUnmapBuffer(
  /*IN*/ PMDL  MdlChain);

#ifdef __cplusplus
}
#endif

#endif /* __TDIKRNL_H */