📄 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];typedef UCHAR ndis_rates_ex[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[];};/* when sending packets, ndiswrapper associates exactly one sg element * in sg list */struct wrap_tx_sg_list { ULONG nent; ULONG_PTR reserved; struct ndis_sg_element elements[1];};struct ndis_phy_addr_unit { NDIS_PHY_ADDRESS phy_addr; UINT length;};typedef struct mdl ndis_buffer;struct ndis_buffer_pool { int max_descr; int num_allocated_descr; ndis_buffer *free_descr; NT_SPIN_LOCK lock;};#define NDIS_PROTOCOL_ID_DEFAULT 0x00#define NDIS_PROTOCOL_ID_TCP_IP 0x02#define NDIS_PROTOCOL_ID_IPX 0x06#define NDIS_PROTOCOL_ID_NBF 0x07#define NDIS_PROTOCOL_ID_MAX 0x0F#define NDIS_PROTOCOL_ID_MASK 0x0F#define fPACKET_WRAPPER_RESERVED 0x3F#define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40#define fPACKET_ALLOCATED_BY_NDIS 0x80#define PROTOCOL_RESERVED_SIZE_IN_PACKET (4 * sizeof(void *))struct transport_header_offset { USHORT protocol_type; USHORT header_offset;};struct ndis_network_address { USHORT length; USHORT type; UCHAR address[1];};struct ndis_network_address_list { LONG count; USHORT type; struct ndis_network_address address[1];};struct ndis_tcp_ip_checksum_packet_info { union { struct { ULONG v4:1; ULONG v6:1; ULONG tcp:1; ULONG udp:1; ULONG ip:1; } tx; struct { ULONG tcp_failed:1; ULONG udp_failed:1; ULONG ip_failed:1; ULONG tcp_succeeded:1; ULONG udp_succeeded:1; ULONG ip_succeeded:1; ULONG loopback:1; } rx; ULONG value; };};enum ndis_task { TcpIpChecksumNdisTask, IpSecNdisTask, TcpLargeSendNdisTask, MaxNdisTask};enum ndis_encapsulation { UNSPECIFIED_Encapsulation, NULL_Encapsulation, IEEE_802_3_Encapsulation, IEEE_802_5_Encapsulation, LLC_SNAP_ROUTED_Encapsulation, LLC_SNAP_BRIDGED_Encapsulation};#define NDIS_TASK_OFFLOAD_VERSION 1struct ndis_encapsulation_format { enum ndis_encapsulation encap; struct { ULONG fixed_header_size:1; ULONG reserved:31; } flags; ULONG header_size;};struct ndis_task_offload_header { ULONG version; ULONG size; ULONG reserved; ULONG offset_first_task; struct ndis_encapsulation_format encap_format;};struct ndis_task_offload { ULONG version; ULONG size; enum ndis_task task; ULONG offset_next_task; ULONG task_buf_length; UCHAR task_buf[1];};struct v4_checksum { union { struct { ULONG ip_opts:1; ULONG tcp_opts:1; ULONG tcp_csum:1; ULONG udp_csum:1; ULONG ip_csum:1; }; ULONG value; };};struct v6_checksum { ULONG ip_supported:1; ULONG tcp_supported:1; ULONG tcp_csum:1; ULONG udp_csum:1;};struct ndis_task_tcp_ip_checksum { struct v4_checksum v4_tx; struct v4_checksum v4_rx; struct v6_checksum v6_tx; struct v6_checksum v6_rx;};struct ndis_task_tcp_large_send { ULONG version; ULONG max_size; ULONG min_seg_count; BOOLEAN tcp_opts; BOOLEAN ip_opts;};enum 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;};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; }; ULONG_PTR reserved[2]; UCHAR protocol_reserved[1];};/* OOB data */struct ndis_packet_oob_data { union { ULONGLONG time_to_tx; ULONGLONG time_txed; }; ULONGLONG time_rxed; UINT header_size; UINT media_size; void *media; NDIS_STATUS status; /* ndiswrapper specific info; extension should be right after * ndis's oob_data */ struct ndis_packet_extension ext; union { /* used for tx only */ struct { struct sk_buff *tx_skb; union { struct wrap_tx_sg_list wrap_tx_sg_list; struct ndis_sg_list *tx_sg_list; }; }; /* used for rx only */ struct { unsigned char header[ETH_HLEN]; unsigned char *look_ahead; UINT look_ahead_size; }; };};#define NDIS_PACKET_OOB_DATA(packet) \ (struct ndis_packet_oob_data *)(((void *)(packet)) + \ (packet)->private.oob_offset)struct ndis_packet_pool { UINT max_descr; UINT num_allocated_descr; UINT num_used_descr; struct ndis_packet *free_descr; NT_SPIN_LOCK lock; UINT proto_rsvd_length; struct nt_list list;};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_physical_medium { NdisPhysicalMediumUnspecified, NdisPhysicalMediumWirelessLan, NdisPhysicalMediumCableModem, NdisPhysicalMediumPhoneLine, NdisPhysicalMediumPowerLine, NdisPhysicalMediumDSL, NdisPhysicalMediumFibreChannel, NdisPhysicalMedium1394, NdisPhysicalMediumWirelessWan, NdisPhysicalMediumMax};enum ndis_power_state { NdisDeviceStateUnspecified = 0, NdisDeviceStateD0, NdisDeviceStateD1, NdisDeviceStateD2, NdisDeviceStateD3, NdisDeviceStateMaximum};enum ndis_power_profile { NdisPowerProfileBattery, NdisPowerProfileAcOnLine};struct ndis_pm_wakeup_capabilities { enum ndis_power_state min_magic_packet_wakeup; enum ndis_power_state min_pattern_wakeup; enum ndis_power_state min_link_change_wakeup;};#define NDIS_PNP_WAKE_UP_MAGIC_PACKET 0x00000001#define NDIS_PNP_WAKE_UP_PATTERN_MATCH 0x00000002#define NDIS_PNP_WAKE_UP_LINK_CHANGE 0x00000004enum net_pnp_event_code { NetEventSetPower, NetEventQueryPower, NetEventQueryRemoveDevice, NetEventCancelRemoveDevice, NetEventReconfigure, NetEventBindList, NetEventBindsComplete, NetEventPnPCapabilities, NetEventMaximum};struct net_pnp_event { enum net_pnp_event_code code; void *buf; ULONG buf_length; ULONG_PTR ndis_reserved[4]; ULONG_PTR transport_reserved[4]; ULONG_PTR tdi_reserved[4]; ULONG_PTR tdi_client_reserved[4];};struct ndis_pnp_capabilities { ULONG flags; struct ndis_pm_wakeup_capabilities wakeup_capa;};typedef void (*ndis_isr_handler)(BOOLEAN *recognized, BOOLEAN *queue_handler, void *handle) wstdcall;typedef void (*ndis_interrupt_handler)(void *ctx) wstdcall;struct miniport_char { /* NDIS 3.0 */ UCHAR major_version; UCHAR minor_version; USHORT filler; UINT reserved; BOOLEAN (*hangcheck)(void *ctx) wstdcall; void (*disable_interrupt)(void *ctx) wstdcall; void (*enable_interrupt)(void *ctx) wstdcall; void (*miniport_halt)(void *ctx) wstdcall; ndis_interrupt_handler handle_interrupt; NDIS_STATUS (*init)(NDIS_STATUS *error_status, UINT *medium_index, enum ndis_medium medium[], UINT medium_array_size, void *handle, void *conf_handle) wstdcall; ndis_isr_handler isr; NDIS_STATUS (*query)(void *ctx, ndis_oid oid, void *buffer, ULONG buflen, ULONG *written, ULONG *needed) wstdcall; void *reconfig; NDIS_STATUS (*reset)(BOOLEAN *reset_address, void *ctx) wstdcall; NDIS_STATUS (*send)(void *ctx, struct ndis_packet *packet, UINT flags) wstdcall; NDIS_STATUS (*setinfo)(void *ctx, ndis_oid oid, void *buffer, ULONG buflen, ULONG *written, ULONG *needed) wstdcall; NDIS_STATUS (*tx_data)(struct ndis_packet *ndis_packet, UINT *bytes_txed, void *adapter_ctx, void *rx_ctx, UINT offset, UINT bytes_to_tx) wstdcall; /* NDIS 4.0 extensions */ void (*return_packet)(void *ctx, void *packet) wstdcall; void (*send_packets)(void *ctx, struct ndis_packet **packets, INT nr_of_packets) wstdcall; void (*alloc_complete)(void *handle, void *virt, NDIS_PHY_ADDRESS *phys, ULONG size, void *ctx) wstdcall; /* NDIS 5.0 extensions */ NDIS_STATUS (*co_create_vc)(void *ctx, void *vc_handle, void *vc_ctx) wstdcall;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -