ReactOS  0.4.14-dev-358-gbef841c
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. More...
 
NDIS_STATUS LANUnregisterAdapter (PLAN_ADAPTER Adapter)
 Unregisters protocol with NDIS adapter. More...
 
NTSTATUS LANRegisterProtocol (PNDIS_STRING Name)
 Registers this protocol driver with NDIS. More...
 
VOID NTAPI LANUnregisterProtocol (VOID)
 Unregisters this protocol driver with NDIS. More...
 
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. More...
 

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"));
656  return NDIS_STATUS_RESOURCES;
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 
665  InitializeListHead(&Adapter->AddressList);
666  InitializeListHead(&Adapter->ForeignList);
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,
683  MediaArray,
684  MAX_MEDIA,
685  DeviceExt->NdisProtocolHandle,
686  Adapter,
687  AdapterName,
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)
801  return NDIS_STATUS_RESOURCES;
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 }
UNICODE_STRING RegistryPath
Definition: lan.h:82
UINT PacketFilter
Definition: lan.h:80
KSPIN_LOCK Lock
Definition: lan.h:103
#define MID_TRACE
Definition: debug.h:15
enum _NDIS_MEDIUM NDIS_MEDIUM
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
NDIS_HANDLE NdisProtocolHandle
Definition: lan.h:102
UINT AdapterId
Definition: lan.h:106
LIST_ENTRY ForeignList
Definition: lan.h:59
_In_ NDIS_STATUS _In_ NDIS_STATUS OpenStatus
Definition: ndis.h:6034
#define DEBUG_DATALINK
Definition: debug.h:24
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
LIST_ENTRY AdapterListHead
Definition: lan.h:104
UCHAR BCastOffset
Definition: lan.h:72
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
UINT Speed
Definition: lan.h:79
UINT HWAddressLength
Definition: lan.h:69
UINT MinFrameSize
Definition: lan.h:75
#define exFreePool(x)
Definition: memtrack.h:18
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define LAN_STATE_STOPPED
Definition: lan.h:114
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
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
int NDIS_STATUS
Definition: ntddndis.h:471
UINT Lookahead
Definition: lan.h:81
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
LIST_ENTRY AddressList
Definition: lan.h:58
LIST_ENTRY ListEntry
Definition: lan.h:57
UCHAR BCastCheck
Definition: lan.h:71
USHORT MTU
Definition: lan.h:74
UCHAR BCastMask
Definition: lan.h:70
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
UINT Index
Definition: lan.h:61
smooth NULL
Definition: ftsmooth.c:416
#define MEDIA_ETH
Definition: lan.h:26
#define LA_DbgPrint(_t_, _x_)
Definition: debug.h:66
NDIS_MEDIUM Media
Definition: lan.h:67
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
struct _ETH_HEADER ETH_HEADER
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
KSPIN_LOCK Lock
Definition: lan.h:60
PDEVICE_OBJECT LanDeviceObject
Definition: lan.c:15
UCHAR HeaderSize
Definition: lan.h:73
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define BCAST_ETH_CHECK
Definition: lan.h:45
static const WCHAR L[]
Definition: oid.c:1250
#define BCAST_ETH_MASK
Definition: lan.h:42
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define exAllocatePool(x, y)
Definition: memtrack.h:17
NDIS_HANDLE NdisHandle
Definition: lan.h:65
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
UCHAR HWAddress[IEEE_802_ADDR_LENGTH]
Definition: lan.h:68
KEVENT Event
Definition: lan.h:63
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
UCHAR State
Definition: lan.h:62
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 BCAST_ETH_OFFSET
Definition: lan.h:48
unsigned int UINT
Definition: ndis.h:50
UINT MaxSendPackets
Definition: lan.h:77
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define LAN_STATE_STARTED
Definition: lan.h:113
_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:6013
#define MAX_MEDIA
Definition: lan.h:28
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
static NDIS_MEDIUM MediaArray[MEDIA_ARRAY_SIZE]
Definition: miniport.c:33
#define NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
UINT MaxPacketSize
Definition: lan.h:76
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666

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 
901  InitializeListHead(&DeviceExt->AdapterListHead);
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;
917  ProtChars.ReceiveHandler = ProtocolReceive;
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 }
VOID NTAPI ProtocolStatusComplete(NDIS_HANDLE NdisBindingContext)
Called by NDIS when a status-change has occurred.
Definition: lan.c:478
#define MID_TRACE
Definition: debug.h:15
VOID NTAPI ProtocolResetComplete(NDIS_HANDLE BindingContext, NDIS_STATUS Status)
Called by NDIS to complete resetting an adapter.
Definition: lan.c:142
#define NDIS_VERSION_MAJOR
Definition: lan.h:11
VOID NTAPI ProtocolSendComplete(NDIS_HANDLE BindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status)
Called by NDIS to complete sending process.
Definition: lan.c:184
USHORT MaximumLength
Definition: env_spec_w32.h:370
NDIS_HANDLE NdisProtocolHandle
Definition: lan.h:102
REQUEST_COMPLETE_HANDLER RequestCompleteHandler
Definition: ndis.h:1887
VOID EXPORT NdisRegisterProtocol(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE NdisProtocolHandle, IN PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics, IN UINT CharacteristicsLength)
Definition: protocol.c:1115
#define DEBUG_DATALINK
Definition: debug.h:24
LIST_ENTRY AdapterListHead
Definition: lan.h:104
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ProtocolCloseAdapterComplete(NDIS_HANDLE BindingContext, NDIS_STATUS Status)
Called by NDIS to complete closing an adapter.
Definition: lan.c:120
CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler
Definition: ndis.h:1877
RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler
Definition: ndis.h:1892
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
STATUS_HANDLER StatusHandler
Definition: ndis.h:1893
int NDIS_STATUS
Definition: ntddndis.h:471
LIST_ENTRY ProtocolListHead
Definition: lan.h:105
#define NDIS_VERSION_MINOR
Definition: lan.h:12
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 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
PVOID DeviceExtension
Definition: env_spec_w32.h:418
BIND_HANDLER BindAdapterHandler
Definition: ndis.h:1897
RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:1886
OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler
Definition: ndis.h:1876
#define LA_DbgPrint(_t_, _x_)
Definition: debug.h:66
TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler
Definition: ndis.h:1883
PDEVICE_OBJECT LanDeviceObject
Definition: lan.c:15
STATUS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:1894
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
RECEIVE_HANDLER ReceiveHandler
Definition: ndis.h:1889
VOID NTAPI ProtocolRequestComplete(NDIS_HANDLE BindingContext, PNDIS_REQUEST NdisRequest, NDIS_STATUS Status)
Called by NDIS to complete a request.
Definition: lan.c:159
SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:1879
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
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
return STATUS_SUCCESS
Definition: btrfs.c:2938
VOID NTAPI ProtocolReceiveComplete(NDIS_HANDLE BindingContext)
Called by NDIS when we're done receiving data.
Definition: lan.c:444
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

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 {
850  KIRQL OldIrql;
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  {
869  KeWaitForSingleObject(&Adapter->Event,
870  UserRequest,
871  KernelMode,
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 }
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
#define DEBUG_DATALINK
Definition: debug.h:24
VOID FreeAdapter(PLAN_ADAPTER Adapter)
Frees memory for a LAN_ADAPTER structure.
Definition: lan.c:83
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
int NDIS_STATUS
Definition: ntddndis.h:471
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
LIST_ENTRY ListEntry
Definition: lan.h:57
NDIS_STATUS NdisStatus
Definition: lan.h:66
smooth NULL
Definition: ftsmooth.c:416
#define LA_DbgPrint(_t_, _x_)
Definition: debug.h:66
KSPIN_LOCK Lock
Definition: lan.h:60
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
NDIS_HANDLE NdisHandle
Definition: lan.h:65
KEVENT Event
Definition: lan.h:63
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
VOID EXPORT NdisCloseAdapter(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle)
Definition: protocol.c:703

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;
953  KIRQL OldIrql;
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 }
KSPIN_LOCK Lock
Definition: lan.h:103
NDIS_HANDLE NdisProtocolHandle
Definition: lan.h:102
#define DEBUG_DATALINK
Definition: debug.h:24
LIST_ENTRY AdapterListHead
Definition: lan.h:104
VOID EXPORT NdisDeregisterProtocol(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisProtocolHandle)
Definition: protocol.c:734
int NDIS_STATUS
Definition: ntddndis.h:471
UCHAR KIRQL
Definition: env_spec_w32.h:591
NDIS_STATUS LANUnregisterAdapter(PLAN_ADAPTER Adapter)
Unregisters protocol with NDIS adapter.
Definition: lan.c:847
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define LA_DbgPrint(_t_, _x_)
Definition: debug.h:66
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
PDEVICE_OBJECT LanDeviceObject
Definition: lan.c:15
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117

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  {
65  KeWaitForSingleObject(&Adapter->Event,
67  KernelMode,
68  FALSE,
69  NULL);
70  NdisStatus = Adapter->NdisStatus;
71  }
72 
73  return NdisStatus;
74 }
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1571
Type
Definition: Type.h:6
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
int NDIS_STATUS
Definition: ntddndis.h:471
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
NDIS_STATUS NdisStatus
Definition: lan.h:66
smooth NULL
Definition: ftsmooth.c:416
#define LAN_STATE_RESETTING
Definition: lan.h:112
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
UINT64 OID
Definition: marshal.c:88
NDIS_HANDLE NdisHandle
Definition: lan.h:65
KEVENT Event
Definition: lan.h:63
UCHAR State
Definition: lan.h:62
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

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

◆ TcpipLanGetDwordOid()

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

Definition at line 184 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 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
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 OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
_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:426
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938