📄 ndis.h
字号:
/* * Copyright (C) 2003-2005 Pontus Fuchs, Giridhar Pemmasani * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */#ifndef NDIS_H#define NDIS_H#include "ntoskernel.h"#define NDIS_DMA_24BITS 0#define NDIS_DMA_32BITS 1#define NDIS_DMA_64BITS 2#ifdef CONFIG_X86_64#define MAXIMUM_PROCESSORS 64#else#define MAXIMUM_PROCESSORS 32#endiftypedef UINT NDIS_STATUS;typedef UCHAR NDIS_DMA_SIZE;typedef LONG ndis_rssi;typedef ULONG ndis_key_index;typedef ULONG ndis_tx_power_level;typedef ULONGULONG ndis_key_rsc;typedef UCHAR ndis_rates[NDIS_MAX_RATES_EX];typedef UCHAR mac_address[ETH_ALEN];typedef ULONG ndis_fragmentation_threshold;typedef ULONG ndis_rts_threshold;typedef ULONG ndis_antenna;typedef ULONG ndis_oid;typedef uint64_t NDIS_PHY_ADDRESS;struct ndis_sg_element { PHYSICAL_ADDRESS address; ULONG length; ULONG_PTR reserved;};struct ndis_sg_list { ULONG nent; ULONG_PTR reserved; struct ndis_sg_element *elements;};struct ndis_phy_addr_unit { NDIS_PHY_ADDRESS phy_addr; UINT length;};struct ndis_buffer_pool { int max_descr; int num_allocated_descr; ndis_buffer *free_descr; KSPIN_LOCK lock;};#define fPACKET_WRAPPER_RESERVED 0x3F#define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40#define fPACKET_ALLOCATED_BY_NDIS 0x80enum ndis_per_packet_info { TcpIpChecksumPacketInfo, IpSecPacketInfo, TcpLargeSendPacketInfo, ClassificationHandlePacketInfo, NdisReserved, ScatterGatherListPacketInfo, Ieee8021QInfo, OriginalPacketInfo, PacketCancelId, MaxPerPacketInfo};struct ndis_packet_extension { void *info[MaxPerPacketInfo];};struct ndis_packet_private { UINT nr_pages; UINT len; ndis_buffer *buffer_head; ndis_buffer *buffer_tail; void *pool; UINT count; ULONG flags; BOOLEAN valid_counts; UCHAR packet_flags; USHORT oob_offset;};/* OOB data */struct ndis_packet_oob_data { union { ULONGLONG time_to_tx; ULONGLONG time_txed; } oob_tx; ULONGLONG time_rxed; UINT header_size; UINT mediaspecific_size; void *mediaspecific; NDIS_STATUS status;};struct ndis_packet { struct ndis_packet_private private; /* for use by miniport */ union { /* for connectionless mininports */ struct { UCHAR miniport_reserved[2 * sizeof(void *)]; UCHAR wrapper_reserved[2 * sizeof(void *)]; } cl_reserved; /* for deserialized miniports */ struct { UCHAR miniport_reserved_ex[3 * sizeof(void *)]; UCHAR wrapper_reserved_ex[sizeof(void *)]; } deserailized_reserved; struct { UCHAR mac_reserved[4 * sizeof(void *)]; } mac_reserved; } u; ULONG_PTR reserved[2]; UCHAR protocol_reserved[1]; struct ndis_packet_oob_data oob_data; struct ndis_packet_extension extension; /* ndiswrapper specific info */ struct ndis_packet *next; struct scatterlist *sg_list; unsigned int sg_ents; /* ndiswrapper-specific info */ struct ndis_sg_list ndis_sg_list; struct ndis_sg_element *ndis_sg_elements; /* RTL8180L overshoots past ndis_eg_elements (during * MiniportSendPackets) and overwrites what is below, if SG * DMA is used, so don't use ndis_sg_element in that * case. This structure is used only when SG is disabled */ struct ndis_sg_element ndis_sg_element; unsigned char header[ETH_HLEN]; unsigned char *look_ahead; UINT look_ahead_size;};struct ndis_packet_pool { int max_descr; int num_allocated_descr; struct ndis_packet *free_descr; KSPIN_LOCK lock;};enum ndis_device_pnp_event { NdisDevicePnPEventQueryRemoved, NdisDevicePnPEventRemoved, NdisDevicePnPEventSurpriseRemoved, NdisDevicePnPEventQueryStopped, NdisDevicePnPEventStopped, NdisDevicePnPEventPowerProfileChanged, NdisDevicePnPEventMaximum};enum ndis_request_type { NdisRequestQueryInformation, NdisRequestSetInformation, NdisRequestQueryStatistics, NdisRequestOpen, NdisRequestClose, NdisRequestSend, NdisRequestTransferData, NdisRequestReset, NdisRequestGeneric1, NdisRequestGeneric2, NdisRequestGeneric3, NdisRequestGeneric4};struct ndis_request { mac_address mac; enum ndis_request_type request_type; union data { struct query_info { UINT oid; void *buf; UINT buf_len; UINT written; UINT needed; } query_info; struct set_info { UINT oid; void *buf; UINT buf_len; UINT written; UINT needed; } set_info; } data;};enum ndis_medium { NdisMedium802_3, NdisMedium802_5, NdisMediumFddi, NdisMediumWan, NdisMediumLocalTalk, NdisMediumDix, NdisMediumArcnetRaw, NdisMediumArcnet878_2, NdisMediumAtm, NdisMediumWirelessWan, NdisMediumIrda, NdisMediumBpc, NdisMediumCoWan, NdisMedium1394, NdisMediumMax};enum ndis_phys_medium { NdisPhysicalMediumUnspecified, NdisPhysicalMediumWirelessLan, NdisPhysicalMediumCableModem, NdisPhysicalMediumPhoneLine, NdisPhysicalMediumPowerLine, NdisPhysicalMediumDSL, NdisPhysicalMediumFibreChannel, NdisPhysicalMedium1394, NdisPhysicalMediumWirelessWan, NdisPhysicalMediumMax};enum ndis_pm_state { NdisDeviceStateUnspecified = 0, NdisDeviceStateD0, NdisDeviceStateD1, NdisDeviceStateD2, NdisDeviceStateD3, NdisDeviceStateMaximum};typedef void (*ndis_isr_handler)(unsigned int *taken, unsigned int *callme, void *ctx) STDCALL;typedef void (*ndis_interrupt_handler)(void *ctx) STDCALL;struct miniport_char { /* NDIS 3.0 */ UCHAR majorVersion; UCHAR minorVersion; USHORT filler; UINT reserved; BOOLEAN (*hangcheck)(void *ctx) STDCALL; void (*disable_interrupts)(void *ctx) STDCALL; void (*enable_interrupts)(void *ctx) STDCALL; /* Stop miniport */ void (*halt)(void *ctx) STDCALL; /* Interrupt BH */ ndis_interrupt_handler handle_interrupt; /* Start miniport driver */ UINT (*init)(UINT *status, UINT *medium_index, enum ndis_medium medium[], UINT medium_array_size, void *ndis_handle, void *conf_handle) STDCALL; /* Interrupt TH */ ndis_isr_handler isr; /* Query parameters */ UINT (*query)(void *ctx, UINT oid, char *buffer, UINT buflen, UINT *written, UINT *needed) STDCALL; void *reconfig; INT (*reset)(INT *needs_set, void *ctx) STDCALL; /* Send one packet */ UINT (*send)(void *ctx, struct ndis_packet *packet, UINT flags) STDCALL; /* Set parameters */ UINT (*setinfo)(void *ctx, UINT oid, char *buffer, UINT buflen, UINT *written, UINT *needed) STDCALL; /* transfer data from received packet */ UINT (*tx_data)(struct ndis_packet *ndis_packet, UINT *bytes_txed, void *adapter_ctx, void *rx_ctx, UINT offset, UINT bytes_to_tx) STDCALL; /* NDIS 4.0 extensions */ /* upper layer is done with RX packet */ void (*return_packet)(void *ctx, void *packet) STDCALL; /* Send packets */ UINT (*send_packets)(void *ctx, struct ndis_packet **packets, INT nr_of_packets) STDCALL; void (*alloc_complete)(void *handle, void *virt, NDIS_PHY_ADDRESS *phys, ULONG size, void *ctx) STDCALL; /* NDIS 5.0 extensions */ UINT (*co_create_vc)(void *ctx, void *vc_handle, void *vc_ctx) STDCALL; UINT (*co_delete_vc)(void *vc_ctx) STDCALL; UINT (*co_activate_vc)(void *vc_ctx, void *call_params) STDCALL; UINT (*co_deactivate_vc)(void *vc_ctx) STDCALL; UINT (*co_send_packets)(void *vc_ctx, void **packets, UINT nr_of_packets) STDCALL; UINT (*co_request)(void *ctx, void *vc_ctx, UINT *req) STDCALL; /* NDIS 5.1 extensions */ void *cancel_send_packets; void (*pnp_event_notify)(void *ctx, enum ndis_device_pnp_event, void *inf_buf, ULONG inf_buf_len) STDCALL; void (*adapter_shutdown)(void *ctx) STDCALL; void *reserved1; void *reserved2; void *reserved3; void *reserved4;};struct ndis_spinlock { KSPIN_LOCK klock; KIRQL irql;};union ndis_rw_lock_refcount { UINT ref_count; UCHAR cache_line[16];};struct ndis_rw_lock { union { struct { KSPIN_LOCK klock; void *context; } s; UCHAR reserved[16]; } u; union ndis_rw_lock_refcount ref_count[MAXIMUM_PROCESSORS];};struct handle_ctx_entry { struct list_head list; void *handle; void *ctx;};struct ndis_sched_work_item { void *ctx; void (*func)(struct ndis_sched_work_item *, void *) STDCALL; UCHAR reserved[8 * sizeof(void *)];};struct ndis_io_work_item { void *ctx; void *device_object; void (*func)(void *device_object, void *ctx) STDCALL;};struct ndis_alloc_mem_work_item { unsigned long size; char cached; void *ctx;};struct ndis_free_mem_work_item { void *addr; unsigned int length; unsigned int flags;};enum ndis_work_entry_type { NDIS_SCHED_WORK_ITEM, NDIS_ALLOC_MEM_WORK_ITEM, NDIS_FREE_MEM_WORK_ITEM, NDIS_IO_WORK_ITEM, NDIS_RETURN_PACKET_WORK_ITEM,};struct ndis_work_entry { struct list_head list; enum ndis_work_entry_type type; struct ndis_handle *handle; union { struct ndis_sched_work_item *sched_work_item; struct ndis_alloc_mem_work_item alloc_mem_work_item; struct ndis_free_mem_work_item free_mem_work_item; struct ndis_io_work_item *io_work_item; struct ndis_packet *return_packet; } entry;};struct ndis_irq { /* void *intr_obj is used for irq */ union { void *intr_obj; unsigned int irq; } irq; /* Taken by ISR, DisableInterrupt and SynchronizeWithInterrupt */ KSPIN_LOCK lock; void *id; ndis_isr_handler isr; void *dpc; struct kdpc intr_dpc; struct ndis_handle *handle; UCHAR dpc_count; /* unsigned char filler1 is used for enabled */ UCHAR enabled; struct kevent completed_event; UCHAR shared; UCHAR req_isr;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -