ReactOS 0.4.15-dev-8245-gd24675b
lan.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ETH_HEADER
 
struct  LAN_ADAPTER
 

Macros

#define MEDIA_ETH   0
 
#define MAX_MEDIA   1
 
#define IEEE_802_ADDR_LENGTH   6
 
#define MAX_MEDIA_ETH   sizeof(ETH_HEADER)
 
#define BCAST_ETH_MASK   0x01
 
#define BCAST_ETH_CHECK   0x01
 
#define BCAST_ETH_OFFSET   0x00
 
#define IP_MAX_RECV_BACKLOG   0x20
 
#define LAN_STATE_OPENING   0
 
#define LAN_STATE_RESETTING   1
 
#define LAN_STATE_STARTED   2
 
#define LAN_STATE_STOPPED   3
 
#define LOOKAHEAD_SIZE   128
 
#define ETYPE_IPv4   WH2N(0x0800)
 
#define ETYPE_IPv6   WH2N(0x86DD)
 
#define ETYPE_ARP   WH2N(0x0806)
 
#define LAN_PROTO_IPv4   0x0000 /* Internet Protocol version 4 */
 
#define LAN_PROTO_IPv6   0x0001 /* Internet Protocol version 6 */
 
#define LAN_PROTO_ARP   0x0002 /* Address Resolution Protocol */
 

Typedefs

typedef struct ETH_HEADER ETH_HEADER
 
typedef struct ETH_HEADERPETH_HEADER
 
typedef struct LAN_ADAPTER LAN_ADAPTER
 
typedef struct LAN_ADAPTERPLAN_ADAPTER
 

Functions

NDIS_STATUS LANRegisterAdapter (PNDIS_STRING AdapterName, PNDIS_STRING RegistryPath)
 Registers protocol with an NDIS adapter.
 
NDIS_STATUS LANUnregisterAdapter (PLAN_ADAPTER Adapter)
 Unregisters protocol with NDIS adapter.
 
NTSTATUS LANRegisterProtocol (PNDIS_STRING Name)
 Registers this protocol driver with NDIS.
 
VOID NTAPI LANUnregisterProtocol (VOID)
 Unregisters this protocol driver with NDIS.
 
VOID LANStartup (VOID)
 
VOID LANShutdown (VOID)
 
NTSTATUS TcpipLanGetDwordOid (PIP_INTERFACE Interface, NDIS_OID Oid, PULONG Result)
 
NDIS_STATUS NDISCall (PLAN_ADAPTER Adapter, NDIS_REQUEST_TYPE Type, NDIS_OID OID, PVOID Buffer, UINT Length)
 Send a request to NDIS.
 

Macro Definition Documentation

◆ BCAST_ETH_CHECK

#define BCAST_ETH_CHECK   0x01

Definition at line 30 of file lan.h.

◆ BCAST_ETH_MASK

#define BCAST_ETH_MASK   0x01

Definition at line 27 of file lan.h.

◆ BCAST_ETH_OFFSET

#define BCAST_ETH_OFFSET   0x00

Definition at line 33 of file lan.h.

◆ ETYPE_ARP

#define ETYPE_ARP   WH2N(0x0806)

Definition at line 77 of file lan.h.

◆ ETYPE_IPv4

#define ETYPE_IPv4   WH2N(0x0800)

Definition at line 75 of file lan.h.

◆ ETYPE_IPv6

#define ETYPE_IPv6   WH2N(0x86DD)

Definition at line 76 of file lan.h.

◆ IEEE_802_ADDR_LENGTH

#define IEEE_802_ADDR_LENGTH   6

Definition at line 15 of file lan.h.

◆ IP_MAX_RECV_BACKLOG

#define IP_MAX_RECV_BACKLOG   0x20

Definition at line 36 of file lan.h.

◆ LAN_PROTO_ARP

#define LAN_PROTO_ARP   0x0002 /* Address Resolution Protocol */

Definition at line 82 of file lan.h.

◆ LAN_PROTO_IPv4

#define LAN_PROTO_IPv4   0x0000 /* Internet Protocol version 4 */

Definition at line 80 of file lan.h.

◆ LAN_PROTO_IPv6

#define LAN_PROTO_IPv6   0x0001 /* Internet Protocol version 6 */

Definition at line 81 of file lan.h.

◆ LAN_STATE_OPENING

#define LAN_STATE_OPENING   0

Definition at line 65 of file lan.h.

◆ LAN_STATE_RESETTING

#define LAN_STATE_RESETTING   1

Definition at line 66 of file lan.h.

◆ LAN_STATE_STARTED

#define LAN_STATE_STARTED   2

Definition at line 67 of file lan.h.

◆ LAN_STATE_STOPPED

#define LAN_STATE_STOPPED   3

Definition at line 68 of file lan.h.

◆ LOOKAHEAD_SIZE

#define LOOKAHEAD_SIZE   128

Definition at line 71 of file lan.h.

◆ MAX_MEDIA

#define MAX_MEDIA   1

Definition at line 13 of file lan.h.

◆ MAX_MEDIA_ETH

#define MAX_MEDIA_ETH   sizeof(ETH_HEADER)

Definition at line 24 of file lan.h.

◆ MEDIA_ETH

#define MEDIA_ETH   0

Definition at line 11 of file lan.h.

Typedef Documentation

◆ ETH_HEADER

◆ LAN_ADAPTER

◆ PETH_HEADER

◆ PLAN_ADAPTER

Function Documentation

◆ LANRegisterAdapter()

NDIS_STATUS LANRegisterAdapter ( PNDIS_STRING  AdapterName,
PNDIS_STRING  RegistryPath 
)

Registers protocol with an NDIS adapter.

Parameters
AdapterName= Pointer to string with name of adapter to register
Adapter= Address of pointer to a LAN_ADAPTER structure
Returns
Status of operation

Definition at line 637 of file lan.c.

640{
641 PLAN_ADAPTER Adapter;
643 NDIS_STATUS NdisStatus;
645 UINT MediaIndex;
646 UINT AddressOID;
647 UINT Speed;
649
650 LA_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
651
652 Adapter = exAllocatePool(NonPagedPool, sizeof(LAN_ADAPTER));
653 if (!Adapter)
654 {
655 LA_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
657 }
658
659 RtlZeroMemory(Adapter, sizeof(LAN_ADAPTER));
660
661 /* Put adapter in stopped state */
662 Adapter->State = LAN_STATE_STOPPED;
663 Adapter->Index = DeviceExt->AdapterId++;
664
667
668 /* Initialize protecting spin lock */
669 KeInitializeSpinLock(&Adapter->Lock);
670
672
673 /* Initialize array with media IDs we support */
675
676 LA_DbgPrint(DEBUG_DATALINK,("opening adapter %wZ\n", AdapterName));
677
678 /* Open the adapter. */
679 NdisOpenAdapter(&NdisStatus,
680 &OpenStatus,
681 &Adapter->NdisHandle,
682 &MediaIndex,
684 MAX_MEDIA,
685 DeviceExt->NdisProtocolHandle,
686 Adapter,
688 0,
689 NULL);
690
691 /* Wait until the adapter is opened */
692 if (NdisStatus == NDIS_STATUS_PENDING)
694 else if (NdisStatus != NDIS_STATUS_SUCCESS)
695 {
696 exFreePool(Adapter);
697 return NdisStatus;
698 }
699
700 Adapter->Media = MediaArray[MediaIndex];
701
702 /* Fill LAN_ADAPTER structure with some adapter specific information */
703 switch (Adapter->Media)
704 {
705 case NdisMedium802_3:
707 Adapter->BCastMask = BCAST_ETH_MASK;
708 Adapter->BCastCheck = BCAST_ETH_CHECK;
709 Adapter->BCastOffset = BCAST_ETH_OFFSET;
710 Adapter->HeaderSize = sizeof(ETH_HEADER);
711 Adapter->MinFrameSize = 60;
712 AddressOID = OID_802_3_CURRENT_ADDRESS;
713 Adapter->PacketFilter =
717 break;
718
719 default:
720 /* Unsupported media */
721 LA_DbgPrint(MIN_TRACE, ("Unsupported media.\n"));
722 exFreePool(Adapter);
724 }
725
726 /* Get maximum frame size */
727 NdisStatus = NDISCall(Adapter,
730 &Adapter->MTU,
731 sizeof(UINT));
732 if (NdisStatus != NDIS_STATUS_SUCCESS)
733 {
734 exFreePool(Adapter);
735 return NdisStatus;
736 }
737
738 /* Get maximum packet size */
739 NdisStatus = NDISCall(Adapter,
742 &Adapter->MaxPacketSize,
743 sizeof(UINT));
744 if (NdisStatus != NDIS_STATUS_SUCCESS)
745 {
746 LA_DbgPrint(MIN_TRACE, ("Query for maximum packet size failed.\n"));
747 exFreePool(Adapter);
748 return NdisStatus;
749 }
750
751 /* Get maximum number of packets we can pass to NdisSend(Packets) at one time */
752 NdisStatus = NDISCall(Adapter,
755 &Adapter->MaxSendPackets,
756 sizeof(UINT));
757 if (NdisStatus != NDIS_STATUS_SUCCESS)
758 {
759 /* Legacy NIC drivers may not support this query, if it fails we
760 assume it can send at least one packet per call to NdisSend(Packets) */
761 Adapter->MaxSendPackets = 1;
762 }
763
764 /* Get current hardware address */
765 NdisStatus = NDISCall(Adapter,
767 AddressOID,
768 Adapter->HWAddress,
769 Adapter->HWAddressLength);
770 if (NdisStatus != NDIS_STATUS_SUCCESS)
771 {
772 LA_DbgPrint(MIN_TRACE, ("Query for current hardware address failed.\n"));
773 exFreePool(Adapter);
774 return NdisStatus;
775 }
776
777 /* Get maximum link speed */
778 NdisStatus = NDISCall(Adapter,
781 &Speed,
782 sizeof(UINT));
783 if (NdisStatus != NDIS_STATUS_SUCCESS)
784 {
785 LA_DbgPrint(MIN_TRACE, ("Query for maximum link speed failed.\n"));
786 exFreePool(Adapter);
787 return NdisStatus;
788 }
789
790 /* Convert returned link speed to bps (it is in 100bps increments) */
791 Adapter->Speed = Speed * 100L;
792
793 /* Add adapter to the adapter list */
795 &Adapter->ListEntry,
796 &DeviceExt->Lock);
797
798 Adapter->RegistryPath.Buffer =
800 if (!Adapter->RegistryPath.Buffer)
802
804
805 NdisStatus = NDISCall(Adapter,
808 &Adapter->Lookahead,
809 sizeof(ULONG));
810 if (NdisStatus != NDIS_STATUS_SUCCESS)
811 {
813 ("Could not set lookahead buffer size (0x%X).\n",
814 NdisStatus));
815 return NdisStatus;
816 }
817
818 /* Set packet filter so we can send and receive packets */
819 NdisStatus = NDISCall(Adapter,
822 &Adapter->PacketFilter,
823 sizeof(UINT));
824 if (NdisStatus != NDIS_STATUS_SUCCESS)
825 {
826 LA_DbgPrint(MID_TRACE, ("Could not set packet filter (0x%X).\n",
827 NdisStatus));
828 return NdisStatus;
829 }
830
831 Adapter->State = LAN_STATE_STARTED;
832
833 LA_DbgPrint(DEBUG_DATALINK, ("Leaving.\n"));
834
835 return NDIS_STATUS_SUCCESS;
836}
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define LA_DbgPrint(_t_, _x_)
Definition: debug.h:66
#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
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
#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 NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define MAX_MEDIA
Definition: lan.h:28
#define BCAST_ETH_OFFSET
Definition: lan.h:48
#define MEDIA_ETH
Definition: lan.h:26
#define LAN_STATE_STOPPED
Definition: lan.h:114
#define BCAST_ETH_CHECK
Definition: lan.h:45
#define LAN_STATE_STARTED
Definition: lan.h:113
#define BCAST_ETH_MASK
Definition: lan.h:42
PDEVICE_OBJECT LanDeviceObject
Definition: lan.c:15
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 exAllocatePool(x, y)
Definition: memtrack.h:17
#define exFreePool(x)
Definition: memtrack.h:18
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
unsigned int UINT
Definition: ndis.h:50
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
#define NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
_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_ 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
#define KernelMode
Definition: asm.h:34
static NDIS_MEDIUM MediaArray[MEDIA_ARRAY_SIZE]
Definition: miniport.c:33
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
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
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
@ NdisMedium802_3
Definition: ntddndis.h:188
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
int NDIS_STATUS
Definition: ntddndis.h:475
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
@ SynchronizationEvent
Definition: lan.h:33
UINT PacketFilter
Definition: lan.h:80
LIST_ENTRY ForeignList
Definition: lan.h:59
UINT MinFrameSize
Definition: lan.h:75
UCHAR HWAddress[IEEE_802_ADDR_LENGTH]
Definition: lan.h:68
UNICODE_STRING RegistryPath
Definition: lan.h:82
KSPIN_LOCK Lock
Definition: lan.h:60
LIST_ENTRY AddressList
Definition: lan.h:58
UCHAR HeaderSize
Definition: lan.h:73
USHORT MTU
Definition: lan.h:74
KEVENT Event
Definition: lan.h:63
UCHAR State
Definition: lan.h:62
UINT Index
Definition: lan.h:61
UINT HWAddressLength
Definition: lan.h:69
UINT Lookahead
Definition: lan.h:81
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
PVOID DeviceExtension
Definition: env_spec_w32.h:418
LIST_ENTRY AdapterListHead
Definition: lan.h:104
NDIS_HANDLE NdisProtocolHandle
Definition: lan.h:102
KSPIN_LOCK Lock
Definition: lan.h:103
UINT AdapterId
Definition: lan.h:106
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
@ UserRequest
Definition: ketypes.h:421

Referenced by ProtocolBindAdapter().

◆ LANRegisterProtocol()

NTSTATUS LANRegisterProtocol ( PNDIS_STRING  Name)

Registers this protocol driver with NDIS.

Parameters
Name= Name of this protocol driver
Returns
Status of operation

Definition at line 893 of file lan.c.

894{
895 NDIS_STATUS NdisStatus;
898
899 LA_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
900
903
904 /* Set up protocol characteristics */
905 RtlZeroMemory(&ProtChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
908 ProtChars.Name.Length = Name->Length;
909 ProtChars.Name.Buffer = Name->Buffer;
910 ProtChars.Name.MaximumLength = Name->MaximumLength;
919 ProtChars.StatusHandler = ProtocolStatus;
922
923 /* Try to register protocol */
924 NdisRegisterProtocol(&NdisStatus,
925 &DeviceExt->NdisProtocolHandle,
926 &ProtChars,
928 if (NdisStatus != NDIS_STATUS_SUCCESS)
929 {
930 LA_DbgPrint(MID_TRACE, ("NdisRegisterProtocol failed, status 0x%x\n", NdisStatus));
931 return (NTSTATUS)NdisStatus;
932 }
933
934 return STATUS_SUCCESS;
935}
LONG NTSTATUS
Definition: precomp.h:26
VOID EXPORT NdisRegisterProtocol(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE NdisProtocolHandle, IN PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics, IN UINT CharacteristicsLength)
Definition: protocol.c:1115
#define NDIS_VERSION_MAJOR
Definition: lan.h:11
#define NDIS_VERSION_MINOR
Definition: lan.h:12
VOID NTAPI ProtocolCloseAdapterComplete(NDIS_HANDLE BindingContext, NDIS_STATUS Status)
Called by NDIS to complete closing an adapter.
Definition: lan.c:120
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 NTAPI ProtocolResetComplete(NDIS_HANDLE BindingContext, NDIS_STATUS Status)
Called by NDIS to complete resetting an adapter.
Definition: lan.c:142
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
VOID NTAPI ProtocolSendComplete(NDIS_HANDLE BindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status)
Called by NDIS to complete sending process.
Definition: lan.c:184
#define STATUS_SUCCESS
Definition: shellext.h:65
LIST_ENTRY ProtocolListHead
Definition: lan.h:105
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
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
STATUS_HANDLER StatusHandler
Definition: ndis.h:1893
OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler
Definition: ndis.h:1876
CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler
Definition: ndis.h:1877
USHORT MaximumLength
Definition: env_spec_w32.h:370

Referenced by DriverEntry().

◆ LANShutdown()

VOID LANShutdown ( VOID  )

◆ LANStartup()

VOID LANStartup ( VOID  )

◆ LANUnregisterAdapter()

NDIS_STATUS LANUnregisterAdapter ( PLAN_ADAPTER  Adapter)

Unregisters protocol with NDIS adapter.

Parameters
Adapter= Pointer to a LAN_ADAPTER structure
Returns
Status of operation

Definition at line 847 of file lan.c.

849{
851 NDIS_HANDLE NdisHandle;
852 NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS;
853
854 LA_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
855
856 /* Unlink the adapter from the list */
857 RemoveEntryList(&Adapter->ListEntry);
858
859 KeAcquireSpinLock(&Adapter->Lock, &OldIrql);
860 NdisHandle = Adapter->NdisHandle;
861 if (NdisHandle)
862 {
863 Adapter->NdisHandle = NULL;
864 KeReleaseSpinLock(&Adapter->Lock, OldIrql);
865
866 NdisCloseAdapter(&NdisStatus, NdisHandle);
867 if (NdisStatus == NDIS_STATUS_PENDING)
868 {
872 FALSE,
873 NULL);
874 NdisStatus = Adapter->NdisStatus;
875 }
876 }
877 else
878 KeReleaseSpinLock(&Adapter->Lock, OldIrql);
879
880 FreeAdapter(Adapter);
881
882 return NDIS_STATUS_SUCCESS;
883}
VOID EXPORT NdisCloseAdapter(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle)
Definition: protocol.c:703
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
VOID FreeAdapter(PLAN_ADAPTER Adapter)
Frees memory for a LAN_ADAPTER structure.
Definition: lan.c:83
NDIS_STATUS NdisStatus
Definition: lan.h:66
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by LANUnregisterProtocol(), and ProtocolUnbindAdapter().

◆ LANUnregisterProtocol()

VOID NTAPI LANUnregisterProtocol ( VOID  )

Unregisters this protocol driver with NDIS.

Note
Does not care wether we are already registered

Definition at line 943 of file lan.c.

944{
946
947 LA_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
948
949 NDIS_STATUS NdisStatus;
950 PLIST_ENTRY CurrentEntry;
951 PLIST_ENTRY NextEntry;
952 PLAN_ADAPTER Current;
954
955 KeAcquireSpinLock(&DeviceExt->Lock, &OldIrql);
956
957 /* Search the list and remove every adapter we find */
958 CurrentEntry = DeviceExt->AdapterListHead.Flink;
959 while (CurrentEntry != &DeviceExt->AdapterListHead)
960 {
961 NextEntry = CurrentEntry->Flink;
962 Current = CONTAINING_RECORD(CurrentEntry, LAN_ADAPTER, ListEntry);
963 /* Unregister it */
964 LANUnregisterAdapter(Current);
965 CurrentEntry = NextEntry;
966 }
967
968 NdisDeregisterProtocol(&NdisStatus, DeviceExt->NdisProtocolHandle);
969}
VOID EXPORT NdisDeregisterProtocol(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisProtocolHandle)
Definition: protocol.c:734
NDIS_STATUS LANUnregisterAdapter(PLAN_ADAPTER Adapter)
Unregisters protocol with NDIS adapter.
Definition: lan.c:847
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by LANRegisterProtocol(), and LanUnload().

◆ NDISCall()

NDIS_STATUS NDISCall ( PLAN_ADAPTER  Adapter,
NDIS_REQUEST_TYPE  Type,
NDIS_OID  OID,
PVOID  Buffer,
UINT  Length 
)

Send a request to NDIS.

Parameters
Adapter= Pointer to a LAN_ADAPTER structure
Type= Type of request (Set or Query)
OID= Value to be set/queried for
Buffer= Pointer to a buffer to use
Length= Number of bytes in Buffer
Returns
Status of operation

Definition at line 29 of file lan.c.

35{
37 NDIS_STATUS NdisStatus;
38
39 Request.RequestType = Type;
41 {
42 Request.DATA.SET_INFORMATION.Oid = OID;
43 Request.DATA.SET_INFORMATION.InformationBuffer = Buffer;
44 Request.DATA.SET_INFORMATION.InformationBufferLength = Length;
45 }
46 else
47 {
48 Request.DATA.QUERY_INFORMATION.Oid = OID;
49 Request.DATA.QUERY_INFORMATION.InformationBuffer = Buffer;
50 Request.DATA.QUERY_INFORMATION.InformationBufferLength = Length;
51 }
52
53 if (Adapter->State != LAN_STATE_RESETTING)
54 {
55 NdisRequest(&NdisStatus, Adapter->NdisHandle, &Request);
56 }
57 else
58 {
59 NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
60 }
61
62 /* Wait for NDIS to complete the request */
63 if (NdisStatus == NDIS_STATUS_PENDING)
64 {
68 FALSE,
69 NULL);
70 NdisStatus = Adapter->NdisStatus;
71 }
72
73 return NdisStatus;
74}
Type
Definition: Type.h:7
Definition: bufpool.h:45
#define LAN_STATE_RESETTING
Definition: lan.h:112
UINT64 OID
Definition: marshal.c:88
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1573
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547

Referenced by BindAdapter(), LANRegisterAdapter(), ReconfigureAdapter(), and TcpipLanGetDwordOid().

◆ TcpipLanGetDwordOid()

NTSTATUS TcpipLanGetDwordOid ( PIP_INTERFACE  Interface,
NDIS_OID  Oid,
PULONG  Result 
)

Definition at line 183 of file lan.c.

186 {
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}
@ NdisMediaStateConnected
Definition: ntddndis.h:470
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
@ NdisHardwareStatusReady
Definition: ntddndis.h:450
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_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