ReactOS 0.4.16-dev-197-g92996da
lan.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: datalink/lan.c
5 * PURPOSE: Local Area Network media routines
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * REVISIONS:
8 * CSH 01/08-2000 Created
9 */
10
11#include "precomp.h"
12
13#include <ntifs.h>
14#include <receive.h>
15#include <wait.h>
16
19
20#define CCS_ROOT L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet"
21#define TCPIP_GUID L"{4D36E972-E325-11CE-BFC1-08002BE10318}"
22
23typedef struct _LAN_WQ_ITEM {
30
31typedef struct _RECONFIGURE_CONTEXT {
35
40
42 PLAN_ADAPTER Adapter,
47/*
48 * FUNCTION: Send a request to NDIS
49 * ARGUMENTS:
50 * Adapter = Pointer to a LAN_ADAPTER structure
51 * Type = Type of request (Set or Query)
52 * OID = Value to be set/queried for
53 * Buffer = Pointer to a buffer to use
54 * Length = Number of bytes in Buffer
55 * RETURNS:
56 * Status of operation
57 */
58{
60 NDIS_STATUS NdisStatus;
61
62 Request.RequestType = Type;
64 Request.DATA.SET_INFORMATION.Oid = OID;
65 Request.DATA.SET_INFORMATION.InformationBuffer = Buffer;
66 Request.DATA.SET_INFORMATION.InformationBufferLength = Length;
67 } else {
68 Request.DATA.QUERY_INFORMATION.Oid = OID;
69 Request.DATA.QUERY_INFORMATION.InformationBuffer = Buffer;
70 Request.DATA.QUERY_INFORMATION.InformationBufferLength = Length;
71 }
72
73 if (Adapter->State != LAN_STATE_RESETTING) {
74 NdisRequest(&NdisStatus, Adapter->NdisHandle, &Request);
75 } else {
76 NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
77 }
78
79 /* Wait for NDIS to complete the request */
80 if (NdisStatus == NDIS_STATUS_PENDING) {
84 FALSE,
85 NULL);
86 NdisStatus = Adapter->NdisStatus;
87 }
88
89 return NdisStatus;
90}
91
92/* Used by legacy ProtocolReceive for packet type */
95 PVOID HeaderBuffer,
96 ULONG HeaderBufferSize,
97 PULONG PacketType)
98{
99 PETH_HEADER EthHeader = HeaderBuffer;
100
101 if (HeaderBufferSize < Adapter->HeaderSize)
102 {
103 TI_DbgPrint(DEBUG_DATALINK, ("Runt frame (size %d).\n", HeaderBufferSize));
105 }
106
107 switch (Adapter->Media)
108 {
109 case NdisMedium802_3:
110 /* Ethernet and IEEE 802.3 frames can be distinguished by
111 looking at the IEEE 802.3 length field. This field is
112 less than or equal to 1500 for a valid IEEE 802.3 frame
113 and larger than 1500 is it's a valid EtherType value.
114 See RFC 1122, section 2.3.3 for more information */
115
116 *PacketType = EthHeader->EType;
117 break;
118
119 default:
120 TI_DbgPrint(MIN_TRACE, ("Unsupported media.\n"));
121
122 /* FIXME: Support other medias */
124 }
125
126 TI_DbgPrint(DEBUG_DATALINK, ("EtherType (0x%X).\n", *PacketType));
127
128 return NDIS_STATUS_SUCCESS;
129}
130
131/* Used by ProtocolReceivePacket for packet type */
134 PNDIS_PACKET NdisPacket,
135 PULONG PacketType)
136{
137 PVOID HeaderBuffer;
140
141 HeaderBuffer = ExAllocatePoolWithTag(NonPagedPool,
142 Adapter->HeaderSize,
143 HEADER_TAG);
144 if (!HeaderBuffer)
146
147 /* Copy the media header */
148 BytesCopied = CopyPacketToBuffer(HeaderBuffer,
149 NdisPacket,
150 0,
151 Adapter->HeaderSize);
152 if (BytesCopied != Adapter->HeaderSize)
153 {
154 /* Runt frame */
155 ExFreePoolWithTag(HeaderBuffer, HEADER_TAG);
156 TI_DbgPrint(DEBUG_DATALINK, ("Runt frame (size %d).\n", BytesCopied));
158 }
159
161 HeaderBuffer,
163 PacketType);
164
165 ExFreePoolWithTag(HeaderBuffer, HEADER_TAG);
166
167 return Status;
168}
169
170
172 PLAN_ADAPTER Adapter)
173/*
174 * FUNCTION: Frees memory for a LAN_ADAPTER structure
175 * ARGUMENTS:
176 * Adapter = Pointer to LAN_ADAPTER structure to free
177 */
178{
180}
181
182
185 NDIS_OID Oid,
186 PULONG Result ) {
187 /* Get maximum frame size */
188 if( Interface->Context ) {
189 return NDISCall((PLAN_ADAPTER)Interface->Context,
191 Oid,
192 Result,
193 sizeof(ULONG));
194 } else switch( Oid ) { /* Loopback Case */
197 return STATUS_SUCCESS;
200 return STATUS_SUCCESS;
201 default:
203 }
204}
205
206
208 NDIS_HANDLE BindingContext,
211/*
212 * FUNCTION: Called by NDIS to complete opening of an adapter
213 * ARGUMENTS:
214 * BindingContext = Pointer to a device context (LAN_ADAPTER)
215 * Status = Status of the operation
216 * OpenErrorStatus = Additional status information
217 */
218{
219 PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
220
221 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
222
223 Adapter->NdisStatus = Status;
224
225 KeSetEvent(&Adapter->Event, 0, FALSE);
226}
227
228
230 NDIS_HANDLE BindingContext,
232/*
233 * FUNCTION: Called by NDIS to complete closing an adapter
234 * ARGUMENTS:
235 * BindingContext = Pointer to a device context (LAN_ADAPTER)
236 * Status = Status of the operation
237 */
238{
239 PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
240
241 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
242
243 Adapter->NdisStatus = Status;
244
245 KeSetEvent(&Adapter->Event, 0, FALSE);
246}
247
248
250 NDIS_HANDLE BindingContext,
252/*
253 * FUNCTION: Called by NDIS to complete resetting an adapter
254 * ARGUMENTS:
255 * BindingContext = Pointer to a device context (LAN_ADAPTER)
256 * Status = Status of the operation
257 */
258{
259 PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
260
261 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
262
263 Adapter->NdisStatus = Status;
264
265 KeSetEvent(&Adapter->Event, 0, FALSE);
266}
267
268
270 NDIS_HANDLE BindingContext,
273/*
274 * FUNCTION: Called by NDIS to complete a request
275 * ARGUMENTS:
276 * BindingContext = Pointer to a device context (LAN_ADAPTER)
277 * NdisRequest = Pointer to an object describing the request
278 * Status = Status of the operation
279 */
280{
281 PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
282
283 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
284
285 /* Save status of request and signal an event */
286 Adapter->NdisStatus = Status;
287
288 KeSetEvent(&Adapter->Event, 0, FALSE);
289}
290
291
293 NDIS_HANDLE BindingContext,
296/*
297 * FUNCTION: Called by NDIS to complete sending process
298 * ARGUMENTS:
299 * BindingContext = Pointer to a device context (LAN_ADAPTER)
300 * Packet = Pointer to a packet descriptor
301 * Status = Status of the operation
302 */
303{
305}
306
308 ULONG PacketType;
311 PLAN_ADAPTER Adapter;
313 IP_PACKET IPPacket;
314 BOOLEAN LegacyReceive;
316
317 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
318
319 Packet = WorkItem->Packet;
320 Adapter = WorkItem->Adapter;
321 BytesTransferred = WorkItem->BytesTransferred;
322 LegacyReceive = WorkItem->LegacyReceive;
323
325
326 Interface = Adapter->Context;
327
328 IPInitializePacket(&IPPacket, 0);
329
330 IPPacket.NdisPacket = Packet;
331 IPPacket.ReturnPacket = !LegacyReceive;
332
333 if (LegacyReceive)
334 {
335 /* Packet type is precomputed */
336 PacketType = PC(IPPacket.NdisPacket)->PacketType;
337
338 /* Data is at position 0 */
339 IPPacket.Position = 0;
340
341 /* Packet size is determined by bytes transferred */
342 IPPacket.TotalSize = BytesTransferred;
343 }
344 else
345 {
346 /* Determine packet type from media header */
347 if (GetPacketTypeFromNdisPacket(Adapter,
348 IPPacket.NdisPacket,
349 &PacketType) != NDIS_STATUS_SUCCESS)
350 {
351 /* Bad packet */
352 IPPacket.Free(&IPPacket);
353 return;
354 }
355
356 /* Data is at the end of the media header */
357 IPPacket.Position = Adapter->HeaderSize;
358
359 /* Calculate packet size (excluding media header) */
360 NdisQueryPacketLength(IPPacket.NdisPacket, &IPPacket.TotalSize);
361 }
362
365 ("Ether Type = %x Total = %d\n",
366 PacketType, IPPacket.TotalSize));
367
368 /* Update interface stats */
369 Interface->Stats.InBytes += IPPacket.TotalSize + Adapter->HeaderSize;
370
371 /* NDIS packet is freed in all of these cases */
372 switch (PacketType) {
373 case ETYPE_IPv4:
374 case ETYPE_IPv6:
375 TI_DbgPrint(MID_TRACE,("Received IP Packet\n"));
376 IPReceive(Adapter->Context, &IPPacket);
377 break;
378 case ETYPE_ARP:
379 TI_DbgPrint(MID_TRACE,("Received ARP Packet\n"));
380 ARPReceive(Adapter->Context, &IPPacket);
381 break;
382 default:
383 IPPacket.Free(&IPPacket);
384 break;
385 }
386}
387
389 NDIS_HANDLE BindingContext,
392 BOOLEAN LegacyReceive) {
395 PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
396
397 TI_DbgPrint(DEBUG_DATALINK,("called\n"));
398
399 if (!WQItem) return;
400
401 WQItem->Packet = Packet;
402 WQItem->Adapter = Adapter;
404 WQItem->LegacyReceive = LegacyReceive;
405
406 if (!ChewCreate( LanReceiveWorker, WQItem ))
408}
409
411 NDIS_HANDLE BindingContext,
415/*
416 * FUNCTION: Called by NDIS to complete reception of data
417 * ARGUMENTS:
418 * BindingContext = Pointer to a device context (LAN_ADAPTER)
419 * Packet = Pointer to a packet descriptor
420 * Status = Status of the operation
421 * BytesTransferred = Number of bytes transferred
422 * NOTES:
423 * If the packet was successfully received, determine the protocol
424 * type and pass it to the correct receive handler
425 */
426{
428
429 TI_DbgPrint(DEBUG_DATALINK,("called\n"));
430
433
434 if( Status != NDIS_STATUS_SUCCESS ) return;
435
436 LanSubmitReceiveWork(BindingContext,
437 Packet,
439 TRUE);
440}
441
443 NDIS_HANDLE BindingContext,
444 PNDIS_PACKET NdisPacket)
445{
446 PLAN_ADAPTER Adapter = BindingContext;
447
448 if (Adapter->State != LAN_STATE_STARTED) {
449 TI_DbgPrint(DEBUG_DATALINK, ("Adapter is stopped.\n"));
450 return 0;
451 }
452
453 LanSubmitReceiveWork(BindingContext,
454 NdisPacket,
455 0, /* Unused */
456 FALSE);
457
458 /* Hold 1 reference on this packet */
459 return 1;
460}
461
463 NDIS_HANDLE BindingContext,
464 NDIS_HANDLE MacReceiveContext,
465 PVOID HeaderBuffer,
466 UINT HeaderBufferSize,
467 PVOID LookaheadBuffer,
468 UINT LookaheadBufferSize,
470/*
471 * FUNCTION: Called by NDIS when a packet has been received on the physical link
472 * ARGUMENTS:
473 * BindingContext = Pointer to a device context (LAN_ADAPTER)
474 * MacReceiveContext = Handle used by underlying NIC driver
475 * HeaderBuffer = Pointer to a buffer containing the packet header
476 * HeaderBufferSize = Number of bytes in HeaderBuffer
477 * LookaheadBuffer = Pointer to a buffer containing buffered packet data
478 * LookaheadBufferSize = Size of LookaheadBuffer. May be less than asked for
479 * PacketSize = Overall size of the packet (not including header)
480 * RETURNS:
481 * Status of operation
482 */
483{
484 ULONG PacketType;
486 PCHAR BufferData;
487 NDIS_STATUS NdisStatus;
488 PNDIS_PACKET NdisPacket;
489 PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
490
491 TI_DbgPrint(DEBUG_DATALINK, ("Called. (packetsize %d)\n",PacketSize));
492
493 if (Adapter->State != LAN_STATE_STARTED) {
494 TI_DbgPrint(DEBUG_DATALINK, ("Adapter is stopped.\n"));
496 }
497
498 if (HeaderBufferSize < Adapter->HeaderSize) {
499 TI_DbgPrint(DEBUG_DATALINK, ("Runt frame received.\n"));
501 }
502
503 NdisStatus = GetPacketTypeFromHeaderBuffer(Adapter,
504 HeaderBuffer,
505 HeaderBufferSize,
506 &PacketType);
507 if (NdisStatus != NDIS_STATUS_SUCCESS)
509
510 TI_DbgPrint(DEBUG_DATALINK, ("Adapter: %x (MTU %d)\n",
511 Adapter, Adapter->MTU));
512
513 /* Get a transfer data packet */
514 NdisStatus = AllocatePacketWithBuffer( &NdisPacket, NULL,
515 PacketSize );
516 if( NdisStatus != NDIS_STATUS_SUCCESS ) {
518 }
519
520 PC(NdisPacket)->PacketType = PacketType;
521
522 TI_DbgPrint(DEBUG_DATALINK, ("pretransfer LookaheadBufferSize %d packsize %d\n",LookaheadBufferSize,PacketSize));
523
524 GetDataPtr( NdisPacket, 0, &BufferData, &PacketSize );
525
527
528 if (LookaheadBufferSize == PacketSize)
529 {
530 /* Optimized code path for packets that are fully contained in
531 * the lookahead buffer. */
532 NdisCopyLookaheadData(BufferData,
533 LookaheadBuffer,
534 LookaheadBufferSize,
535 Adapter->MacOptions);
536 }
537 else
538 {
539 NdisTransferData(&NdisStatus, Adapter->NdisHandle,
540 MacReceiveContext, 0, PacketSize,
541 NdisPacket, &BytesTransferred);
542 }
543 TI_DbgPrint(DEBUG_DATALINK, ("Calling complete\n"));
544
545 if (NdisStatus != NDIS_STATUS_PENDING)
546 ProtocolTransferDataComplete(BindingContext,
547 NdisPacket,
548 NdisStatus,
549 PacketSize);
550
551 TI_DbgPrint(DEBUG_DATALINK, ("leaving\n"));
552
553 return NDIS_STATUS_SUCCESS;
554}
555
556
558 NDIS_HANDLE BindingContext)
559/*
560 * FUNCTION: Called by NDIS when we're done receiving data
561 * ARGUMENTS:
562 * BindingContext = Pointer to a device context (LAN_ADAPTER)
563 */
564{
565 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
566}
567
569{
571 HANDLE ParameterHandle;
573 ULONG KeyValueInfoLength;
574 WCHAR Buffer[150];
575 UNICODE_STRING IPAddress = RTL_CONSTANT_STRING(L"IPAddress");
576 UNICODE_STRING Netmask = RTL_CONSTANT_STRING(L"SubnetMask");
577 UNICODE_STRING Gateway = RTL_CONSTANT_STRING(L"DefaultGateway");
578 UNICODE_STRING EnableDhcp = RTL_CONSTANT_STRING(L"EnableDHCP");
579 UNICODE_STRING Prefix = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\");
580 UNICODE_STRING TcpipRegistryPath;
581 UNICODE_STRING RegistryDataU;
582 ANSI_STRING RegistryDataA;
585 IP_ADDRESS DefaultMask, Router;
586
587 AddrInitIPv4(&DefaultMask, 0);
588
589 TcpipRegistryPath.MaximumLength = sizeof(WCHAR) * 150;
590 TcpipRegistryPath.Length = 0;
591 TcpipRegistryPath.Buffer = Buffer;
592
593 /* Build the registry path */
594 RtlAppendUnicodeStringToString(&TcpipRegistryPath, &Prefix);
595 RtlAppendUnicodeStringToString(&TcpipRegistryPath, &Interface->Name);
596
598 &TcpipRegistryPath,
600 0,
601 NULL);
602
603 /* Open a handle to the adapter parameters */
604 Status = ZwOpenKey(&ParameterHandle, KEY_READ, &ObjectAttributes);
605
606 if (!NT_SUCCESS(Status))
607 {
608 return FALSE;
609 }
610 else
611 {
612 KeyValueInfoLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) + 16 * sizeof(WCHAR);
613 KeyValueInfo = ExAllocatePoolWithTag(PagedPool,
614 KeyValueInfoLength,
616 if (!KeyValueInfo)
617 {
618 ZwClose(ParameterHandle);
619 return FALSE;
620 }
621
622 /* Read the EnableDHCP entry */
623 Status = ZwQueryValueKey(ParameterHandle,
624 &EnableDhcp,
626 KeyValueInfo,
627 KeyValueInfoLength,
628 &Unused);
629 if (NT_SUCCESS(Status) && KeyValueInfo->DataLength == sizeof(ULONG) && (*(PULONG)KeyValueInfo->Data) == 0)
630 {
631 RegistryDataU.MaximumLength = KeyValueInfoLength - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data);
632 RegistryDataU.Buffer = (PWCHAR)KeyValueInfo->Data;
633
634 /* Read the IP address */
635 Status = ZwQueryValueKey(ParameterHandle,
636 &IPAddress,
638 KeyValueInfo,
639 KeyValueInfoLength,
640 &Unused);
641 if (NT_SUCCESS(Status))
642 {
643 RegistryDataU.Length = KeyValueInfo->DataLength;
644
645 Status = RtlUnicodeStringToAnsiString(&RegistryDataA,
646 &RegistryDataU,
647 TRUE);
648 if (NT_SUCCESS(Status))
649 {
650 AddrInitIPv4(&Interface->Unicast,
651 inet_addr(RegistryDataA.Buffer));
652 RtlFreeAnsiString(&RegistryDataA);
653 }
654 }
655
656 Status = ZwQueryValueKey(ParameterHandle,
657 &Netmask,
659 KeyValueInfo,
660 KeyValueInfoLength,
661 &Unused);
662 if (NT_SUCCESS(Status))
663 {
664 RegistryDataU.Length = KeyValueInfo->DataLength;
665
666 Status = RtlUnicodeStringToAnsiString(&RegistryDataA,
667 &RegistryDataU,
668 TRUE);
669 if (NT_SUCCESS(Status))
670 {
671 AddrInitIPv4(&Interface->Netmask,
672 inet_addr(RegistryDataA.Buffer));
673 RtlFreeAnsiString(&RegistryDataA);
674 }
675 }
676
677 /* We have to wait until both IP address and subnet mask
678 * are read to add the interface route, but we must do it
679 * before we add the default gateway */
680 if (!AddrIsUnspecified(&Interface->Unicast) &&
681 !AddrIsUnspecified(&Interface->Netmask))
683
684 /* Read default gateway info */
685 Status = ZwQueryValueKey(ParameterHandle,
686 &Gateway,
688 KeyValueInfo,
689 KeyValueInfoLength,
690 &Unused);
691 if (NT_SUCCESS(Status))
692 {
693 RegistryDataU.Length = KeyValueInfo->DataLength;
694
695 Status = RtlUnicodeStringToAnsiString(&RegistryDataA,
696 &RegistryDataU,
697 TRUE);
698 if (NT_SUCCESS(Status))
699 {
700 AddrInitIPv4(&Router, inet_addr(RegistryDataA.Buffer));
701
702 if (!AddrIsUnspecified(&Router))
703 RouterCreateRoute(&DefaultMask, &DefaultMask, &Router, Interface, 1);
704
705 RtlFreeAnsiString(&RegistryDataA);
706 }
707 }
708 }
709
710 ExFreePoolWithTag(KeyValueInfo, KEY_VALUE_TAG);
711 ZwClose(ParameterHandle);
712 }
713
714 return TRUE;
715}
716
718{
719 PLAN_ADAPTER Adapter = Context->Adapter;
721 NDIS_STATUS NdisStatus;
722 IP_ADDRESS DefaultMask;
723
724 /* Initialize the default unspecified address (0.0.0.0) */
725 AddrInitIPv4(&DefaultMask, 0);
726 if (Context->State == LAN_STATE_STARTED &&
727 !Context->Adapter->CompletingReset)
728 {
729 /* Read the IP configuration */
731
732 /* Compute the broadcast address */
733 Interface->Broadcast.Type = IP_ADDRESS_V4;
734 Interface->Broadcast.Address.IPv4Address = Interface->Unicast.Address.IPv4Address |
735 ~Interface->Netmask.Address.IPv4Address;
736 }
737 else if (!Context->Adapter->CompletingReset)
738 {
739 /* Clear IP configuration */
740 Interface->Unicast = DefaultMask;
741 Interface->Netmask = DefaultMask;
742 Interface->Broadcast = DefaultMask;
743
744 /* Remove all interface routes */
746
747 /* Destroy all cached neighbors */
749 }
750
751 Context->Adapter->CompletingReset = FALSE;
752
753 if (Context->State == LAN_STATE_STARTED)
754 {
755 /* Get maximum link speed */
756 NdisStatus = NDISCall(Adapter,
759 &Interface->Speed,
760 sizeof(Interface->Speed));
761
762 if (!NT_SUCCESS(NdisStatus))
764
765 Adapter->Speed = Interface->Speed * 100L;
766
767 /* Get maximum frame size */
768 NdisStatus = NDISCall(Adapter,
771 &Adapter->MTU,
772 sizeof(Adapter->MTU));
773 if (NdisStatus != NDIS_STATUS_SUCCESS)
774 return FALSE;
775
776 Interface->MTU = Adapter->MTU;
777
778 /* Get maximum packet size */
779 NdisStatus = NDISCall(Adapter,
782 &Adapter->MaxPacketSize,
783 sizeof(Adapter->MaxPacketSize));
784 if (NdisStatus != NDIS_STATUS_SUCCESS)
785 return FALSE;
786 }
787
788 Adapter->State = Context->State;
789
790 /* Update the IP and link status information cached in TCP */
793
794 return TRUE;
795}
796
798{
799 PRECONFIGURE_CONTEXT ReconfigureContext = Context;
800
801 /* Complete the reconfiguration asynchronously */
802 ReconfigureAdapter(ReconfigureContext);
803
804 /* Free the context */
805 ExFreePool(ReconfigureContext);
806}
807
809 NDIS_HANDLE BindingContext,
813/*
814 * FUNCTION: Called by NDIS when the underlying driver has changed state
815 * ARGUMENTS:
816 * BindingContext = Pointer to a device context (LAN_ADAPTER)
817 * GeneralStatus = A general status code
818 * StatusBuffer = Pointer to a buffer with medium-specific data
819 * StatusBufferSize = Number of bytes in StatusBuffer
820 */
821{
822 PLAN_ADAPTER Adapter = BindingContext;
824
825 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
826
827 /* Ignore the status indication if we have no context yet. We'll get another later */
828 if (!Adapter->Context)
829 return;
830
832 if (!Context)
833 return;
834
835 Context->Adapter = Adapter;
836
837 switch(GeneralStatus)
838 {
840 DbgPrint("NDIS_STATUS_MEDIA_CONNECT\n");
841
842 if (Adapter->State == LAN_STATE_STARTED)
843 {
845 return;
846 }
847
848 Context->State = LAN_STATE_STARTED;
849 break;
850
852 DbgPrint("NDIS_STATUS_MEDIA_DISCONNECT\n");
853
854 if (Adapter->State == LAN_STATE_STOPPED)
855 {
857 return;
858 }
859
860 Context->State = LAN_STATE_STOPPED;
861 break;
862
864 Adapter->OldState = Adapter->State;
865 Adapter->State = LAN_STATE_RESETTING;
866 /* Nothing else to do here */
868 return;
869
871 Adapter->CompletingReset = TRUE;
872 Context->State = Adapter->OldState;
873 break;
874
875 default:
876 DbgPrint("Unhandled status: %x", GeneralStatus);
878 return;
879 }
880
881 /* Queue the work item */
884}
885
887/*
888 * FUNCTION: Called by NDIS when a status-change has occurred
889 * ARGUMENTS:
890 * BindingContext = Pointer to a device context (LAN_ADAPTER)
891 */
892{
893 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
894}
895
898 NDIS_HANDLE NdisBindingContext,
899 PNET_PNP_EVENT PnPEvent)
900{
901 switch(PnPEvent->NetEvent)
902 {
903 case NetEventSetPower:
904 DbgPrint("Device transitioned to power state %ld\n", PnPEvent->Buffer);
905 return NDIS_STATUS_SUCCESS;
906
908 DbgPrint("Device wants to go into power state %ld\n", PnPEvent->Buffer);
909 return NDIS_STATUS_SUCCESS;
910
912 DbgPrint("Device is about to be removed\n");
913 return NDIS_STATUS_SUCCESS;
914
916 DbgPrint("Device removal cancelled\n");
917 return NDIS_STATUS_SUCCESS;
918
919 default:
920 DbgPrint("Unhandled event type: %ld\n", PnPEvent->NetEvent);
921 return NDIS_STATUS_SUCCESS;
922 }
923}
924
927 IN NDIS_HANDLE BindContext,
929 IN PVOID SystemSpecific1,
931/*
932 * FUNCTION: Called by NDIS during NdisRegisterProtocol to set up initial
933 * bindings, and periodically thereafter as new adapters come online
934 * ARGUMENTS:
935 * Status: Return value to NDIS
936 * BindContext: Handle provided by NDIS to track pending binding operations
937 * DeviceName: Name of the miniport device to bind to
938 * SystemSpecific1: Pointer to a registry path with protocol-specific configuration information
939 * SystemSpecific2: Unused & must not be touched
940 */
941{
942 TI_DbgPrint(DEBUG_DATALINK, ("Called with registry path %wZ for %wZ\n", SystemSpecific1, DeviceName));
943 *Status = LANRegisterAdapter(DeviceName, SystemSpecific1);
944}
945
946
949 PNDIS_PACKET NdisPacket,
950 UINT Offset,
951 PVOID LinkAddress,
952 USHORT Type)
953/*
954 * FUNCTION: Transmits a packet
955 * ARGUMENTS:
956 * Context = Pointer to context information (LAN_ADAPTER)
957 * NdisPacket = Pointer to NDIS packet to send
958 * Offset = Offset in packet where data starts
959 * LinkAddress = Pointer to link address of destination (NULL = broadcast)
960 * Type = LAN protocol type (LAN_PROTO_*)
961 */
962{
963 NDIS_STATUS NdisStatus;
964 PETH_HEADER EHeader;
965 PCHAR Data, OldData;
966 UINT Size, OldSize;
969 PNDIS_PACKET XmitPacket;
971
973 ("Called( NdisPacket %x, Offset %d, Adapter %x )\n",
974 NdisPacket, Offset, Adapter));
975
976 if (Adapter->State != LAN_STATE_STARTED) {
977 (*PC(NdisPacket)->DLComplete)(PC(NdisPacket)->Context, NdisPacket, NDIS_STATUS_NOT_ACCEPTED);
978 return;
979 }
980
982 ("Adapter Address [%02x %02x %02x %02x %02x %02x]\n",
983 Adapter->HWAddress[0] & 0xff,
984 Adapter->HWAddress[1] & 0xff,
985 Adapter->HWAddress[2] & 0xff,
986 Adapter->HWAddress[3] & 0xff,
987 Adapter->HWAddress[4] & 0xff,
988 Adapter->HWAddress[5] & 0xff));
989
990 GetDataPtr( NdisPacket, 0, &OldData, &OldSize );
991
992 NdisStatus = AllocatePacketWithBuffer(&XmitPacket, NULL, OldSize + Adapter->HeaderSize);
993 if (NdisStatus != NDIS_STATUS_SUCCESS) {
994 (*PC(NdisPacket)->DLComplete)(PC(NdisPacket)->Context, NdisPacket, NDIS_STATUS_RESOURCES);
995 return;
996 }
997
998 GetDataPtr(XmitPacket, 0, &Data, &Size);
999
1000 RtlCopyMemory(Data + Adapter->HeaderSize, OldData, OldSize);
1001
1002 (*PC(NdisPacket)->DLComplete)(PC(NdisPacket)->Context, NdisPacket, NDIS_STATUS_SUCCESS);
1003
1004 switch (Adapter->Media) {
1005 case NdisMedium802_3:
1006 EHeader = (PETH_HEADER)Data;
1007
1008 if (LinkAddress) {
1009 /* Unicast address */
1010 RtlCopyMemory(EHeader->DstAddr, LinkAddress, IEEE_802_ADDR_LENGTH);
1011 } else {
1012 /* Broadcast address */
1014 }
1015
1017
1018 switch (Type) {
1019 case LAN_PROTO_IPv4:
1020 EHeader->EType = ETYPE_IPv4;
1021 break;
1022 case LAN_PROTO_ARP:
1023 EHeader->EType = ETYPE_ARP;
1024 break;
1025 case LAN_PROTO_IPv6:
1026 EHeader->EType = ETYPE_IPv6;
1027 break;
1028 default:
1029 ASSERT(FALSE);
1030 return;
1031 }
1032 break;
1033
1034 default:
1035 /* FIXME: Support other medias */
1036 break;
1037 }
1038
1039 TI_DbgPrint( MID_TRACE, ("LinkAddress: %x\n", LinkAddress));
1040 if( LinkAddress ) {
1042 ( MID_TRACE,
1043 ("Link Address [%02x %02x %02x %02x %02x %02x]\n",
1044 ((PCHAR)LinkAddress)[0] & 0xff,
1045 ((PCHAR)LinkAddress)[1] & 0xff,
1046 ((PCHAR)LinkAddress)[2] & 0xff,
1047 ((PCHAR)LinkAddress)[3] & 0xff,
1048 ((PCHAR)LinkAddress)[4] & 0xff,
1049 ((PCHAR)LinkAddress)[5] & 0xff));
1050 }
1051
1052 if (Adapter->MTU < Size) {
1053 /* This is NOT a pointer. MSDN explicitly says so. */
1055 TcpLargeSendPacketInfo) = (PVOID)((ULONG_PTR)Adapter->MTU);
1056 }
1057
1058 /* Update interface stats */
1059 Interface->Stats.OutBytes += Size;
1060
1061 TcpipAcquireSpinLock( &Adapter->Lock, &OldIrql );
1062 TI_DbgPrint(MID_TRACE, ("NdisSend\n"));
1063 NdisSend(&NdisStatus, Adapter->NdisHandle, XmitPacket);
1064 TI_DbgPrint(MID_TRACE, ("NdisSend %s\n",
1065 NdisStatus == NDIS_STATUS_PENDING ?
1066 "Pending" : "Complete"));
1067 TcpipReleaseSpinLock( &Adapter->Lock, OldIrql );
1068
1069 /* I had a talk with vizzini: these really ought to be here.
1070 * we're supposed to see these completed by ndis *only* when
1071 * status_pending is returned. Note that this is different from
1072 * the situation with IRPs. */
1073 if (NdisStatus != NDIS_STATUS_PENDING)
1074 ProtocolSendComplete((NDIS_HANDLE)Context, XmitPacket, NdisStatus);
1075}
1076
1077static NTSTATUS
1081
1083 Status = ZwOpenKey(RegHandle, KEY_ALL_ACCESS, &Attributes);
1084 return Status;
1085}
1086
1088 PWCHAR RegistryValue,
1094 UCHAR buf[1024];
1096
1097 RtlInitUnicodeString(&ValueName, RegistryValue);
1098 Status =
1099 ZwQueryValueKey(RegHandle,
1100 &ValueName,
1103 sizeof(buf),
1104 &ResultLength);
1105
1106 if (!NT_SUCCESS(Status))
1107 return Status;
1108 /* IP address is stored as a REG_MULTI_SZ - we only pay attention to the first one though */
1109 TI_DbgPrint(MIN_TRACE, ("Information DataLength: 0x%x\n", Information->DataLength));
1110
1111 UnicodeString.Buffer = (PWCHAR)&Information->Data;
1112 UnicodeString.Length = Information->DataLength - sizeof(WCHAR);
1113 UnicodeString.MaximumLength = Information->DataLength;
1114
1115 String->Buffer =
1117 UnicodeString.MaximumLength + sizeof(WCHAR), REG_STR_TAG );
1118
1119 if( !String->Buffer ) return STATUS_NO_MEMORY;
1120
1121 String->MaximumLength = UnicodeString.MaximumLength;
1123
1124 return STATUS_SUCCESS;
1125}
1126
1127/*
1128 * Utility to copy and append two unicode strings.
1129 *
1130 * IN OUT PUNICODE_STRING ResultFirst -> First string and result
1131 * IN PUNICODE_STRING Second -> Second string to append
1132 * IN BOOL Deallocate -> TRUE: Deallocate First string before
1133 * overwriting.
1134 *
1135 * Returns NTSTATUS.
1136 */
1137
1140 BOOLEAN Deallocate) {
1142 UNICODE_STRING Ustr = *ResultFirst;
1143 PWSTR new_string = ExAllocatePoolWithTag
1144 (PagedPool,
1145 (ResultFirst->Length + Second->Length + sizeof(WCHAR)), TEMP_STRING_TAG);
1146 if( !new_string ) {
1147 return STATUS_NO_MEMORY;
1148 }
1149 memcpy( new_string, ResultFirst->Buffer, ResultFirst->Length );
1150 memcpy( new_string + ResultFirst->Length / sizeof(WCHAR),
1151 Second->Buffer, Second->Length );
1152 if( Deallocate ) RtlFreeUnicodeString(ResultFirst);
1153 ResultFirst->Length = Ustr.Length + Second->Length;
1154 ResultFirst->MaximumLength = ResultFirst->Length;
1155 new_string[ResultFirst->Length / sizeof(WCHAR)] = 0;
1156 Status = RtlCreateUnicodeString(ResultFirst,new_string) ?
1159 return Status;
1160}
1161
1163 PUNICODE_STRING TargetKeyName,
1165 PUNICODE_STRING DeviceDesc ) {
1166 UNICODE_STRING RootDevice = { 0, 0, NULL }, LinkageKeyName = { 0, 0, NULL };
1167 UNICODE_STRING DescKeyName = { 0, 0, NULL }, Linkage = { 0, 0, NULL };
1168 UNICODE_STRING BackSlash = { 0, 0, NULL };
1169 HANDLE DescKey = NULL, LinkageKey = NULL;
1171
1172 TI_DbgPrint(DEBUG_DATALINK,("EnumKeyName %wZ\n", EnumKeyName));
1173
1175 RtlInitUnicodeString(&Linkage, L"\\Linkage");
1176
1177 RtlInitUnicodeString(&DescKeyName, L"");
1178 AppendUnicodeString( &DescKeyName, EnumKeyName, FALSE );
1179 AppendUnicodeString( &DescKeyName, &BackSlash, TRUE );
1180 AppendUnicodeString( &DescKeyName, TargetKeyName, TRUE );
1181
1182 RtlInitUnicodeString(&LinkageKeyName, L"");
1183 AppendUnicodeString( &LinkageKeyName, &DescKeyName, FALSE );
1184 AppendUnicodeString( &LinkageKeyName, &Linkage, TRUE );
1185
1186 Status = OpenRegistryKey( &LinkageKeyName, &LinkageKey );
1187 if( !NT_SUCCESS(Status) ) goto cleanup;
1188
1189 Status = ReadStringFromRegistry( LinkageKey, L"RootDevice", &RootDevice );
1190 if( !NT_SUCCESS(Status) ) goto cleanup;
1191
1192 if( RtlCompareUnicodeString( &RootDevice, Name, TRUE ) == 0 ) {
1193 Status = OpenRegistryKey( &DescKeyName, &DescKey );
1194 if( !NT_SUCCESS(Status) ) goto cleanup;
1195
1196 Status = ReadStringFromRegistry( DescKey, L"DriverDesc", DeviceDesc );
1197 if( !NT_SUCCESS(Status) ) goto cleanup;
1198
1199 TI_DbgPrint(DEBUG_DATALINK,("ADAPTER DESC: %wZ\n", DeviceDesc));
1200 } else Status = STATUS_UNSUCCESSFUL;
1201
1202cleanup:
1203 RtlFreeUnicodeString( &RootDevice );
1204 RtlFreeUnicodeString( &LinkageKeyName );
1205 RtlFreeUnicodeString( &DescKeyName );
1206 if( LinkageKey ) ZwClose( LinkageKey );
1207 if( DescKey ) ZwClose( DescKey );
1208
1209 TI_DbgPrint(DEBUG_DATALINK,("Returning %x\n", Status));
1210
1211 return Status;
1212}
1213
1215 PUNICODE_STRING DeviceDesc ) {
1216 UNICODE_STRING EnumKeyName, TargetKeyName;
1219 ULONG i;
1220 KEY_BASIC_INFORMATION *Kbio =
1222 ULONG KbioLength = sizeof(KEY_BASIC_INFORMATION), ResultLength;
1223
1224 RtlInitUnicodeString( DeviceDesc, NULL );
1225
1226 if( !Kbio ) return STATUS_INSUFFICIENT_RESOURCES;
1227
1229 (&EnumKeyName, CCS_ROOT L"\\Control\\Class\\" TCPIP_GUID);
1230
1231 Status = OpenRegistryKey( &EnumKeyName, &EnumKey );
1232
1233 if( !NT_SUCCESS(Status) ) {
1234 TI_DbgPrint(DEBUG_DATALINK,("Couldn't open Enum key %wZ: %x\n",
1235 &EnumKeyName, Status));
1236 ExFreePoolWithTag( Kbio, KBIO_TAG );
1237 return Status;
1238 }
1239
1240 for( i = 0; NT_SUCCESS(Status); i++ ) {
1241 Status = ZwEnumerateKey( EnumKey, i, KeyBasicInformation,
1242 Kbio, KbioLength, &ResultLength );
1243
1245 ExFreePoolWithTag( Kbio, KBIO_TAG );
1246 KbioLength = ResultLength;
1247 Kbio = ExAllocatePoolWithTag( NonPagedPool, KbioLength, KBIO_TAG );
1248 if( !Kbio ) {
1249 TI_DbgPrint(DEBUG_DATALINK,("Failed to allocate memory\n"));
1250 ZwClose( EnumKey );
1251 return STATUS_NO_MEMORY;
1252 }
1253
1254 Status = ZwEnumerateKey( EnumKey, i, KeyBasicInformation,
1255 Kbio, KbioLength, &ResultLength );
1256
1257 if( !NT_SUCCESS(Status) ) {
1258 TI_DbgPrint(DEBUG_DATALINK,("Couldn't enum key child %d\n", i));
1259 ZwClose( EnumKey );
1260 ExFreePoolWithTag( Kbio, KBIO_TAG );
1261 return Status;
1262 }
1263 }
1264
1265 if( NT_SUCCESS(Status) ) {
1266 TargetKeyName.Length = TargetKeyName.MaximumLength =
1267 Kbio->NameLength;
1268 TargetKeyName.Buffer = Kbio->Name;
1269
1271 ( &EnumKeyName, &TargetKeyName, Name, DeviceDesc );
1272 if( NT_SUCCESS(Status) ) {
1273 ZwClose( EnumKey );
1274 ExFreePoolWithTag( Kbio, KBIO_TAG );
1275 return Status;
1276 } else Status = STATUS_SUCCESS;
1277 }
1278 }
1279
1280 ZwClose( EnumKey );
1281 ExFreePoolWithTag( Kbio, KBIO_TAG );
1282 return STATUS_UNSUCCESSFUL;
1283}
1284
1286 PUNICODE_STRING OutName ) {
1287 PWCHAR Ptr;
1288 UNICODE_STRING PartialRegistryKey;
1289
1290 PartialRegistryKey.Buffer =
1291 RegistryKey->Buffer + wcslen(CCS_ROOT L"\\Services\\");
1292 Ptr = PartialRegistryKey.Buffer;
1293
1294 while( *Ptr != L'\\' &&
1295 ((PCHAR)Ptr) < ((PCHAR)RegistryKey->Buffer) + RegistryKey->Length )
1296 Ptr++;
1297
1298 PartialRegistryKey.Length = PartialRegistryKey.MaximumLength =
1299 (Ptr - PartialRegistryKey.Buffer) * sizeof(WCHAR);
1300
1301 RtlInitUnicodeString( OutName, L"" );
1302 AppendUnicodeString( OutName, &PartialRegistryKey, FALSE );
1303}
1304
1306 PLAN_ADAPTER Adapter,
1308/*
1309 * FUNCTION: Binds a LAN adapter to IP layer
1310 * ARGUMENTS:
1311 * Adapter = Pointer to LAN_ADAPTER structure
1312 * NOTES:
1313 * We set the lookahead buffer size, set the packet filter and
1314 * bind the adapter to IP layer
1315 */
1316{
1317 PIP_INTERFACE IF;
1318 NDIS_STATUS NdisStatus;
1319 LLIP_BIND_INFO BindInfo;
1320 ULONG Lookahead = LOOKAHEAD_SIZE;
1322 NDIS_MEDIA_STATE MediaState;
1323
1324 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
1325
1326 Adapter->State = LAN_STATE_OPENING;
1327
1328 NdisStatus = NDISCall(Adapter,
1331 &Lookahead,
1332 sizeof(ULONG));
1333 if (NdisStatus != NDIS_STATUS_SUCCESS) {
1334 TI_DbgPrint(DEBUG_DATALINK, ("Could not set lookahead buffer size (0x%X).\n", NdisStatus));
1335 return FALSE;
1336 }
1337
1338 /* Bind the adapter to IP layer */
1339 BindInfo.Context = Adapter;
1340 BindInfo.HeaderSize = Adapter->HeaderSize;
1341 BindInfo.MinFrameSize = Adapter->MinFrameSize;
1342 BindInfo.Address = (PUCHAR)&Adapter->HWAddress;
1343 BindInfo.AddressLength = Adapter->HWAddressLength;
1344 BindInfo.Transmit = LANTransmit;
1345
1346 IF = IPCreateInterface(&BindInfo);
1347
1348 if (!IF) {
1349 TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1350 return FALSE;
1351 }
1352
1353 /*
1354 * Query per-adapter configuration from the registry
1355 * In case anyone is curious: there *is* an Ndis configuration api
1356 * for this sort of thing, but it doesn't really support things like
1357 * REG_MULTI_SZ very well, and there is a note in the DDK that says that
1358 * protocol drivers developed for win2k and above just use the native
1359 * services (ZwOpenKey, etc).
1360 */
1361
1362 GetName( RegistryPath, &IF->Name );
1363
1365 if (!NT_SUCCESS(Status)) {
1366 TI_DbgPrint(MIN_TRACE, ("Failed to get device description.\n"));
1368 return FALSE;
1369 }
1370
1371 TI_DbgPrint(DEBUG_DATALINK,("Adapter Description: %wZ\n",
1372 &IF->Description));
1373
1374 /* Register interface with IP layer */
1376
1377 /* Store adapter context */
1378 Adapter->Context = IF;
1379
1380 /* Get the media state */
1381 NdisStatus = NDISCall(Adapter,
1384 &MediaState,
1385 sizeof(MediaState));
1386 if (NdisStatus != NDIS_STATUS_SUCCESS) {
1387 TI_DbgPrint(DEBUG_DATALINK, ("Could not query media status (0x%X).\n", NdisStatus));
1390 return FALSE;
1391 }
1392
1393 /* Indicate the current media state */
1394 ProtocolStatus(Adapter,
1396 NULL, 0);
1397
1398 /* Set packet filter so we can send and receive packets */
1399 NdisStatus = NDISCall(Adapter,
1402 &Adapter->PacketFilter,
1403 sizeof(UINT));
1404
1405 if (NdisStatus != NDIS_STATUS_SUCCESS) {
1406 TI_DbgPrint(DEBUG_DATALINK, ("Could not set packet filter (0x%X).\n", NdisStatus));
1409 return FALSE;
1410 }
1411
1412 return TRUE;
1413}
1414
1415
1417 PLAN_ADAPTER Adapter)
1418/*
1419 * FUNCTION: Unbinds a LAN adapter from IP layer
1420 * ARGUMENTS:
1421 * Adapter = Pointer to LAN_ADAPTER structure
1422 */
1423{
1424 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
1425
1426 if (Adapter->State == LAN_STATE_STARTED) {
1427 PIP_INTERFACE IF = Adapter->Context;
1428
1430
1432 }
1433}
1434
1435
1439/*
1440 * FUNCTION: Registers protocol with an NDIS adapter
1441 * ARGUMENTS:
1442 * AdapterName = Pointer to string with name of adapter to register
1443 * Adapter = Address of pointer to a LAN_ADAPTER structure
1444 * RETURNS:
1445 * Status of operation
1446 */
1447{
1448 PLAN_ADAPTER IF;
1449 NDIS_STATUS NdisStatus;
1451 UINT MediaIndex;
1453 UINT AddressOID;
1454
1455 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
1456
1458 if (!IF) {
1459 TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1460 return NDIS_STATUS_RESOURCES;
1461 }
1462
1463 RtlZeroMemory(IF, sizeof(LAN_ADAPTER));
1464
1465 /* Put adapter in stopped state */
1467
1468 /* Initialize protecting spin lock */
1470
1472
1473 /* Initialize array with media IDs we support */
1475
1476 TI_DbgPrint(DEBUG_DATALINK,("opening adapter %wZ\n", AdapterName));
1477 /* Open the adapter. */
1478 NdisOpenAdapter(&NdisStatus,
1479 &OpenStatus,
1480 &IF->NdisHandle,
1481 &MediaIndex,
1482 MediaArray,
1483 MAX_MEDIA,
1485 IF,
1487 0,
1488 NULL);
1489
1490 /* Wait until the adapter is opened */
1491 if (NdisStatus == NDIS_STATUS_PENDING)
1493 else if (NdisStatus != NDIS_STATUS_SUCCESS) {
1494 TI_DbgPrint(DEBUG_DATALINK,("denying adapter %wZ\n", AdapterName));
1496 return NdisStatus;
1497 }
1498
1499 IF->Media = MediaArray[MediaIndex];
1500
1501 /* Fill LAN_ADAPTER structure with some adapter specific information */
1502 switch (IF->Media) {
1503 case NdisMedium802_3:
1508 IF->HeaderSize = sizeof(ETH_HEADER);
1509 IF->MinFrameSize = 60;
1510 AddressOID = OID_802_3_CURRENT_ADDRESS;
1511 IF->PacketFilter =
1515 break;
1516
1517 default:
1518 /* Unsupported media */
1519 TI_DbgPrint(MIN_TRACE, ("Unsupported media.\n"));
1522 }
1523
1524 /* Get maximum number of packets we can pass to NdisSend(Packets) at one time */
1525 NdisStatus = NDISCall(IF,
1528 &IF->MaxSendPackets,
1529 sizeof(UINT));
1530 if (NdisStatus != NDIS_STATUS_SUCCESS)
1531 /* Legacy NIC drivers may not support this query, if it fails we
1532 assume it can send at least one packet per call to NdisSend(Packets) */
1533 IF->MaxSendPackets = 1;
1534
1535 /* Get current hardware address */
1536 NdisStatus = NDISCall(IF,
1538 AddressOID,
1539 &IF->HWAddress,
1540 IF->HWAddressLength);
1541 if (NdisStatus != NDIS_STATUS_SUCCESS) {
1542 TI_DbgPrint(MIN_TRACE, ("Query for current hardware address failed.\n"));
1544 return NdisStatus;
1545 }
1546
1547 /* Bind adapter to IP layer */
1548 if( !BindAdapter(IF, RegistryPath) ) {
1549 TI_DbgPrint(DEBUG_DATALINK,("denying adapter %wZ (BindAdapter)\n", AdapterName));
1552 }
1553
1554 /* Add adapter to the adapter list */
1556 &IF->ListEntry,
1558
1559 TI_DbgPrint(DEBUG_DATALINK, ("Leaving.\n"));
1560
1561 return NDIS_STATUS_SUCCESS;
1562}
1563
1564
1566 PLAN_ADAPTER Adapter)
1567/*
1568 * FUNCTION: Unregisters protocol with NDIS adapter
1569 * ARGUMENTS:
1570 * Adapter = Pointer to a LAN_ADAPTER structure
1571 * RETURNS:
1572 * Status of operation
1573 */
1574{
1575 KIRQL OldIrql;
1576 NDIS_HANDLE NdisHandle;
1577 NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS;
1578
1579 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
1580
1581 /* Unlink the adapter from the list */
1582 RemoveEntryList(&Adapter->ListEntry);
1583
1584 /* Unbind adapter from IP layer */
1585 UnbindAdapter(Adapter);
1586
1587 TcpipAcquireSpinLock(&Adapter->Lock, &OldIrql);
1588 NdisHandle = Adapter->NdisHandle;
1589 if (NdisHandle) {
1590 Adapter->NdisHandle = NULL;
1591 TcpipReleaseSpinLock(&Adapter->Lock, OldIrql);
1592
1593 NdisCloseAdapter(&NdisStatus, NdisHandle);
1594 if (NdisStatus == NDIS_STATUS_PENDING) {
1597 KernelMode,
1598 FALSE,
1599 NULL);
1600 NdisStatus = Adapter->NdisStatus;
1601 }
1602 } else
1603 TcpipReleaseSpinLock(&Adapter->Lock, OldIrql);
1604
1605 FreeAdapter(Adapter);
1606
1607 return NdisStatus;
1608}
1609
1610VOID
1611NTAPI
1613/*
1614 * FUNCTION: Unregisters this protocol driver with NDIS
1615 * NOTES: Does not care wether we are already registered
1616 */
1617{
1618 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
1619
1620 if (ProtocolRegistered) {
1621 NDIS_STATUS NdisStatus;
1622 PLIST_ENTRY CurrentEntry;
1623 PLIST_ENTRY NextEntry;
1624 PLAN_ADAPTER Current;
1625 KIRQL OldIrql;
1626
1628
1629 /* Search the list and remove every adapter we find */
1630 CurrentEntry = AdapterListHead.Flink;
1631 while (CurrentEntry != &AdapterListHead) {
1632 NextEntry = CurrentEntry->Flink;
1633 Current = CONTAINING_RECORD(CurrentEntry, LAN_ADAPTER, ListEntry);
1634 /* Unregister it */
1635 LANUnregisterAdapter(Current);
1636 CurrentEntry = NextEntry;
1637 }
1638
1640
1643 }
1644}
1645
1646VOID
1647NTAPI
1651 NDIS_HANDLE UnbindContext)
1652{
1653 /* We don't pend any unbinding so we can just ignore UnbindContext */
1655}
1656
1659/*
1660 * FUNCTION: Registers this protocol driver with NDIS
1661 * ARGUMENTS:
1662 * Name = Name of this protocol driver
1663 * RETURNS:
1664 * Status of operation
1665 */
1666{
1667 NDIS_STATUS NdisStatus;
1669
1670 TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
1671
1674
1675 /* Set up protocol characteristics */
1676 RtlZeroMemory(&ProtChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
1679 ProtChars.Name.Length = Name->Length;
1680 ProtChars.Name.Buffer = Name->Buffer;
1681 ProtChars.Name.MaximumLength = Name->MaximumLength;
1689 ProtChars.ReceiveHandler = ProtocolReceive;
1691 ProtChars.StatusHandler = ProtocolStatus;
1697
1698 /* Try to register protocol */
1699 NdisRegisterProtocol(&NdisStatus,
1701 &ProtChars,
1703 if (NdisStatus != NDIS_STATUS_SUCCESS)
1704 {
1705 TI_DbgPrint(DEBUG_DATALINK, ("NdisRegisterProtocol failed, status 0x%x\n", NdisStatus));
1706 return (NTSTATUS)NdisStatus;
1707 }
1708
1710
1711 return STATUS_SUCCESS;
1712}
1713
1714/* EOF */
WCHAR Second[]
Definition: FormatMessage.c:12
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define AddrInitIPv4(IPAddress, RawAddress)
Definition: address.h:16
BOOLEAN AddrIsUnspecified(PIP_ADDRESS Address)
Definition: address.c:113
VOID ARPReceive(PVOID Context, PIP_PACKET Packet)
Definition: arp.c:175
LONG NTSTATUS
Definition: precomp.h:26
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
UINT CopyPacketToBuffer(PUCHAR DstData, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
Definition: buffer.c:172
Definition: bufpool.h:45
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static void cleanup(void)
Definition: main.c:1335
static const WCHAR BackSlash[]
Definition: devclass.c:29
struct _ETH_HEADER * PETH_HEADER
#define DEBUG_DATALINK
Definition: debug.h:24
VOID EXPORT NdisOpenAdapter(OUT PNDIS_STATUS Status, OUT PNDIS_STATUS OpenErrorStatus, OUT PNDIS_HANDLE NdisBindingHandle, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, IN UINT MediumArraySize, IN NDIS_HANDLE NdisProtocolHandle, IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_STRING AdapterName, IN UINT OpenOptions, IN PSTRING AddressingInformation OPTIONAL)
Definition: protocol.c:764
VOID EXPORT NdisDeregisterProtocol(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisProtocolHandle)
Definition: protocol.c:734
VOID EXPORT NdisSend(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN PNDIS_PACKET Packet)
Definition: protocol.c:1272
VOID EXPORT NdisCloseAdapter(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle)
Definition: protocol.c:703
VOID EXPORT NdisTransferData(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN NDIS_HANDLE MacReceiveContext, IN UINT ByteOffset, IN UINT BytesToTransfer, IN OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred)
Definition: protocol.c:1307
VOID EXPORT NdisRegisterProtocol(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE NdisProtocolHandle, IN PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics, IN UINT CharacteristicsLength)
Definition: protocol.c:1115
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
VOID IPAddInterfaceRoute(PIP_INTERFACE IF)
Definition: ip.c:262
#define PC(Packet)
Definition: ip.h:106
#define IP_DEFAULT_LINK_SPEED
Definition: ip.h:201
#define IP_ADDRESS_V4
Definition: ip.h:32
VOID IPDestroyInterface(PIP_INTERFACE IF)
Definition: ip.c:244
VOID IPUnregisterInterface(PIP_INTERFACE IF)
Definition: ip.c:349
BOOLEAN IPRegisterInterface(PIP_INTERFACE IF)
Definition: ip.c:289
PIP_INTERFACE IPCreateInterface(PLLIP_BIND_INFO BindInfo)
Definition: ip.c:182
PIP_PACKET IPInitializePacket(PIP_PACKET IPPacket, ULONG Type)
Definition: ip.c:92
VOID TcpipReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL Irql)
Definition: lock.c:26
VOID TcpipAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL Irql)
Definition: lock.c:18
#define CONTEXT_TAG
Definition: tags.h:43
#define KEY_VALUE_TAG
Definition: tags.h:44
#define TEMP_STRING_TAG
Definition: tags.h:42
#define HEADER_TAG
Definition: tags.h:45
#define LAN_ADAPTER_TAG
Definition: tags.h:36
#define WQ_CONTEXT_TAG
Definition: tags.h:37
#define KBIO_TAG
Definition: tags.h:41
#define REG_STR_TAG
Definition: tags.h:46
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define PagedPool
Definition: env_spec_w32.h:308
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DbgPrint
Definition: hal.h:12
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
VOID TCPUpdateInterfaceIPInformation(PIP_INTERFACE IF)
Definition: if.c:144
VOID TCPUpdateInterfaceLinkStatus(PIP_INTERFACE IF)
Definition: if.c:82
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define inet_addr(cp)
Definition: inet.h:98
#define MAX_MEDIA
Definition: lan.h:28
#define BCAST_ETH_OFFSET
Definition: lan.h:48
#define NDIS_VERSION_MAJOR
Definition: lan.h:11
void GetDataPtr(PNDIS_PACKET Packet, UINT Offset, PCHAR *DataOut, PUINT Size)
Definition: routines.c:65
#define LAN_STATE_OPENING
Definition: lan.h:111
#define LAN_PROTO_IPv4
Definition: lan.h:126
#define LOOKAHEAD_SIZE
Definition: lan.h:117
#define ETYPE_IPv4
Definition: lan.h:121
#define LAN_PROTO_ARP
Definition: lan.h:128
#define MEDIA_ETH
Definition: lan.h:26
#define LAN_STATE_STOPPED
Definition: lan.h:114
#define NDIS_VERSION_MINOR
Definition: lan.h:12
#define BCAST_ETH_CHECK
Definition: lan.h:45
#define LAN_STATE_STARTED
Definition: lan.h:113
struct LAN_ADAPTER * PLAN_ADAPTER
#define LAN_STATE_RESETTING
Definition: lan.h:112
#define ETYPE_ARP
Definition: lan.h:123
#define BCAST_ETH_MASK
Definition: lan.h:42
#define ETYPE_IPv6
Definition: lan.h:122
#define LAN_PROTO_IPv6
Definition: lan.h:127
VOID NTAPI ProtocolCloseAdapterComplete(NDIS_HANDLE BindingContext, NDIS_STATUS Status)
Called by NDIS to complete closing an adapter.
Definition: lan.c:120
VOID BindAdapter(PLAN_ADAPTER Adapter, PNDIS_STRING RegistryPath)
Binds a LAN adapter to IP layer.
Definition: lan.c:617
VOID NTAPI ProtocolStatusComplete(NDIS_HANDLE NdisBindingContext)
Called by NDIS when a status-change has occurred.
Definition: lan.c:478
VOID NTAPI ProtocolRequestComplete(NDIS_HANDLE BindingContext, PNDIS_REQUEST NdisRequest, NDIS_STATUS Status)
Called by NDIS to complete a request.
Definition: lan.c:159
VOID NTAPI ProtocolReceiveComplete(NDIS_HANDLE BindingContext)
Called by NDIS when we're done receiving data.
Definition: lan.c:444
VOID NTAPI ProtocolOpenAdapterComplete(NDIS_HANDLE BindingContext, NDIS_STATUS Status, NDIS_STATUS OpenErrorStatus)
Called by NDIS to complete opening of an adapter.
Definition: lan.c:99
NDIS_STATUS NTAPI ProtocolReceive(NDIS_HANDLE BindingContext, NDIS_HANDLE MacReceiveContext, PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookaheadBuffer, UINT LookaheadBufferSize, UINT PacketSize)
Called by NDIS when a packet has been received on the physical link.
Definition: lan.c:355
VOID NTAPI ProtocolTransferDataComplete(NDIS_HANDLE BindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status, UINT BytesTransferred)
Called by NDIS to complete reception of data.
Definition: lan.c:210
VOID LANTransmit(PLAN_ADAPTER Adapter, PNDIS_PACKET NdisPacket, PVOID LinkAddress, USHORT Type)
Transmits a packet ARGUMENTS:
Definition: lan.c:520
VOID LANUnregisterProtocol(VOID)
Unregisters this protocol driver with NDIS.
Definition: lan.c:943
VOID NTAPI ProtocolResetComplete(NDIS_HANDLE BindingContext, NDIS_STATUS Status)
Called by NDIS to complete resetting an adapter.
Definition: lan.c:142
NDIS_STATUS LANRegisterAdapter(PNDIS_STRING AdapterName, PNDIS_STRING RegistryPath)
Registers protocol with an NDIS adapter.
Definition: lan.c:637
VOID NTAPI ProtocolStatus(NDIS_HANDLE BindingContext, NDIS_STATUS GenerelStatus, PVOID StatusBuffer, UINT StatusBufferSize)
Called by NDIS when the underlying driver has changed state.
Definition: lan.c:461
VOID NTAPI ProtocolBindAdapter(OUT PNDIS_STATUS Status, IN NDIS_HANDLE BindContext, IN PNDIS_STRING DeviceName, IN PVOID SystemSpecific1, IN PVOID SystemSpecific2)
Called by NDIS during NdisRegisterProtocol to set up initial bindings, and periodically thereafter as...
Definition: lan.c:497
NDIS_STATUS LANUnregisterAdapter(PLAN_ADAPTER Adapter)
Unregisters protocol with NDIS adapter.
Definition: lan.c:847
VOID FreeAdapter(PLAN_ADAPTER Adapter)
Frees memory for a LAN_ADAPTER structure.
Definition: lan.c:83
NTSTATUS LANRegisterProtocol(PNDIS_STRING Name)
Registers this protocol driver with NDIS.
Definition: lan.c:893
VOID NTAPI ProtocolSendComplete(NDIS_HANDLE BindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status)
Called by NDIS to complete sending process.
Definition: lan.c:184
NDIS_STATUS NDISCall(PLAN_ADAPTER Adapter, NDIS_REQUEST_TYPE Type, NDIS_OID OID, PVOID Buffer, UINT Length)
Send a request to NDIS.
Definition: lan.c:29
#define Unused(x)
Definition: atlwin.h:28
static LONG WINAPI EnumKey(HANDLE hcKey, DWORD dwIndex, LPWSTR pszName, PDWORD pcchName, PFILETIME pftLastWriteTime, HANDLE hSpooler)
Definition: localmon.c:169
#define AllocatePacketWithBuffer(x, y, z)
Definition: memtrack.h:7
#define FreeNdisPacket(x)
Definition: memtrack.h:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UINT64 OID
Definition: marshal.c:88
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
#define NDIS_STATUS_MEDIA_CONNECT
Definition: ndis.h:361
#define NdisQueryPacketLength(_Packet, _TotalPacketLength)
Definition: ndis.h:3645
_In_ PVOID _In_ PVOID SystemSpecific2
Definition: ndis.h:638
#define NDIS_STATUS_RESET_START
Definition: ndis.h:354
unsigned int UINT
Definition: ndis.h:50
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID _In_ UINT StatusBufferSize
Definition: ndis.h:1558
PVOID NDIS_HANDLE
Definition: ndis.h:338
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_STATUS_MEDIA_DISCONNECT
Definition: ndis.h:362
#define NdisCopyLookaheadData(Destination, Source, Length, MacOptions)
Definition: ndis.h:3289
#define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType)
Definition: ndis.h:1351
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3171
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6015
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
enum _NDIS_REQUEST_TYPE NDIS_REQUEST_TYPE
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
@ TcpLargeSendPacketInfo
Definition: ndis.h:1180
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350
#define NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS OpenErrorStatus
Definition: ndis.h:6009
#define NDIS_STATUS_RESET_END
Definition: ndis.h:355
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID StatusBuffer
Definition: ndis.h:1557
* PNDIS_STATUS
Definition: ndis.h:45
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE _In_ PNDIS_STRING AdapterName
Definition: ndis.h:6016
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1573
_In_ NDIS_STATUS _In_ NDIS_STATUS OpenStatus
Definition: ndis.h:6035
@ NdisRequestQueryInformation
Definition: ndis.h:790
@ NdisRequestSetInformation
Definition: ndis.h:791
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS GeneralStatus
Definition: ndis.h:1556
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
VOID NBDestroyNeighborsForInterface(PIP_INTERFACE Interface)
Definition: neighbor.c:237
@ NetEventSetPower
Definition: netpnp.h:15
@ NetEventQueryRemoveDevice
Definition: netpnp.h:17
@ NetEventCancelRemoveDevice
Definition: netpnp.h:18
@ NetEventQueryPower
Definition: netpnp.h:16
static NDIS_MEDIUM MediaArray[MEDIA_ARRAY_SIZE]
Definition: miniport.c:33
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
@ KeyBasicInformation
Definition: nt_native.h:1131
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_READ
Definition: nt_native.h:1023
struct _KEY_BASIC_INFORMATION KEY_BASIC_INFORMATION
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
enum _NDIS_MEDIUM NDIS_MEDIUM
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
@ NdisMediaStateConnected
Definition: ntddndis.h:470
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
enum _NDIS_MEDIA_STATE NDIS_MEDIA_STATE
@ NdisMedium802_3
Definition: ntddndis.h:188
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
int NDIS_STATUS
Definition: ntddndis.h:475
@ NdisHardwareStatusReady
Definition: ntddndis.h:450
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
ULONG NDIS_OID
Definition: ntddndis.h:230
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ SynchronizationEvent
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
VOID IPReceive(PIP_INTERFACE IF, PIP_PACKET IPPacket)
Definition: receive.c:638
VOID RouterRemoveRoutesForInterface(PIP_INTERFACE Interface)
Definition: router.c:341
PFIB_ENTRY RouterCreateRoute(PIP_ADDRESS NetworkAddress, PIP_ADDRESS Netmask, PIP_ADDRESS RouterAddress, PIP_INTERFACE Interface, UINT Metric)
Definition: router.c:421
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
Definition: lan.h:33
Definition: ip.h:23
UINT PacketFilter
Definition: lan.h:80
UCHAR OldState
Definition: lan.h:42
PVOID Context
Definition: lan.h:64
UINT MinFrameSize
Definition: lan.h:75
UCHAR HWAddress[IEEE_802_ADDR_LENGTH]
Definition: lan.h:68
KSPIN_LOCK Lock
Definition: lan.h:60
UCHAR HeaderSize
Definition: lan.h:73
USHORT MTU
Definition: lan.h:74
KEVENT Event
Definition: lan.h:63
BOOLEAN CompletingReset
Definition: lan.h:43
UCHAR State
Definition: lan.h:62
NDIS_STATUS NdisStatus
Definition: lan.h:66
UINT HWAddressLength
Definition: lan.h:69
UINT MacOptions
Definition: lan.h:78
LIST_ENTRY ListEntry
Definition: lan.h:57
NDIS_HANDLE NdisHandle
Definition: lan.h:65
UINT MaxSendPackets
Definition: lan.h:77
UCHAR BCastMask
Definition: lan.h:70
UCHAR BCastCheck
Definition: lan.h:71
NDIS_MEDIUM Media
Definition: lan.h:67
UCHAR BCastOffset
Definition: lan.h:72
UINT Speed
Definition: lan.h:79
UINT MaxPacketSize
Definition: lan.h:76
UCHAR SrcAddr[ETH_LENGTH_OF_ADDRESS]
Definition: ethernetutils.h:48
UCHAR DstAddr[ETH_LENGTH_OF_ADDRESS]
Definition: ethernetutils.h:47
UNICODE_STRING Description
Definition: ip.h:164
UNICODE_STRING Name
Definition: ip.h:163
Definition: ip.h:77
OBJECT_FREE_ROUTINE Free
Definition: ip.h:78
BOOLEAN ReturnPacket
Definition: ip.h:82
UINT Position
Definition: ip.h:87
PNDIS_PACKET NdisPacket
Definition: ip.h:88
UINT TotalSize
Definition: ip.h:86
PLAN_ADAPTER Adapter
Definition: lan.c:26
PNDIS_PACKET Packet
Definition: lan.c:25
LIST_ENTRY ListEntry
Definition: lan.c:24
BOOLEAN LegacyReceive
Definition: lan.c:28
UINT BytesTransferred
Definition: lan.c:27
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PUCHAR Address
Definition: ip.h:130
UINT MinFrameSize
Definition: ip.h:129
PVOID Context
Definition: ip.h:127
UINT HeaderSize
Definition: ip.h:128
UINT AddressLength
Definition: ip.h:131
LL_TRANSMIT_ROUTINE Transmit
Definition: ip.h:132
STATUS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:1894
TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler
Definition: ndis.h:1883
RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler
Definition: ndis.h:1892
PNP_EVENT_HANDLER PnPEventHandler
Definition: ndis.h:1899
REQUEST_COMPLETE_HANDLER RequestCompleteHandler
Definition: ndis.h:1887
SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:1879
RECEIVE_HANDLER ReceiveHandler
Definition: ndis.h:1889
BIND_HANDLER BindAdapterHandler
Definition: ndis.h:1897
RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:1886
RECEIVE_PACKET_HANDLER ReceivePacketHandler
Definition: ndis.h:1896
STATUS_HANDLER StatusHandler
Definition: ndis.h:1893
UNBIND_HANDLER UnbindAdapterHandler
Definition: ndis.h:1898
OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler
Definition: ndis.h:1876
CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler
Definition: ndis.h:1877
UNLOAD_PROTOCOL_HANDLER UnloadHandler
Definition: ndis.h:1900
PVOID Buffer
Definition: netpnp.h:33
NET_PNP_EVENT_CODE NetEvent
Definition: netpnp.h:32
PLAN_ADAPTER Adapter
Definition: lan.c:33
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS TcpipWaitForSingleObject(PVOID Object, KWAIT_REASON Reason, KPROCESSOR_MODE WaitMode, BOOLEAN Alertable, PLARGE_INTEGER Timeout)
Definition: mockwait.c:12
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1342
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115
_In_opt_ PETWENABLECALLBACK _In_opt_ PVOID _Out_ PREGHANDLE RegHandle
Definition: wmifuncs.h:78
BOOLEAN ChewCreate(VOID(*Worker)(PVOID), PVOID WorkerContext)
Definition: workqueue.c:61
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_In_ USHORT PacketSize
Definition: iofuncs.h:1058
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ UserRequest
Definition: ketypes.h:421
_In_ __drv_aliasesMem PSTRING Prefix
Definition: rtlfuncs.h:1644
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180