⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntddip6.h

📁 WinCE下的ping源码
💻 H
📖 第 1 页 / 共 3 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//
// Abstract:
//
// This header file defines constants and types for accessing
// the MSR IPv6 driver via ioctls.
//


#ifndef _NTDDIP6_
#define _NTDDIP6_

#include <windef.h>
#include <ipexport.h>

//
// We need a definition of CTL_CODE for use below.
// When compiling kernel components in the DDK environment,
// ntddk.h supplies this definition. Otherwise get it
// from devioctl.h in the SDK environment.
//
#ifndef CTL_CODE
#ifdef UNDER_CE
#include <winioctl.h>
#else
#include <devioctl.h>
#endif
#endif

#pragma warning(push)
#pragma warning(disable:4201) // nameless struct/union

//
// We also need a definition of TDI_ADDRESS_IP6.
// In the DDK environment, tdi.h supplies this.
// We provide a definition here for the SDK environment.
//
#ifndef TDI_ADDRESS_LENGTH_IP6
#include <packon.h>
typedef struct _TDI_ADDRESS_IP6 {
    USHORT sin6_port;
    ULONG  sin6_flowinfo;
    USHORT sin6_addr[8];
    ULONG  sin6_scope_id;
} TDI_ADDRESS_IP6, *PTDI_ADDRESS_IP6;
#include <packoff.h>

#define TDI_ADDRESS_LENGTH_IP6 sizeof (TDI_ADDRESS_IP6)
#endif

//
// This is the key name of the TCP/IPv6 protocol stack in the registry.
// The protocol driver and the winsock helper both use it.
//
#define TCPIPV6_NAME L"Tcpip6"

//
// Device Name - this string is the name of the device.  It is the name
// that should be passed to NtCreateFile when accessing the device.
//
#define DD_TCPV6_DEVICE_NAME      L"\\Device\\Tcp6"
#define DD_UDPV6_DEVICE_NAME      L"\\Device\\Udp6"
#define DD_RAW_IPV6_DEVICE_NAME   L"\\Device\\RawIp6"
#ifndef UNDER_CE
#define DD_IPV6_DEVICE_NAME       L"\\Device\\Ip6"
#else
#define DD_IPV6_DEVICE_NAME       TEXT("IP60:")
#endif //UNDER_CE
//
// The Windows-accessible device name.  It is the name that
// (prepended with "\\\\.\\") should be passed to CreateFile.
//
#define WIN_IPV6_BASE_DEVICE_NAME L"Ip6"
#define WIN_IPV6_DEVICE_NAME      L"\\\\.\\" WIN_IPV6_BASE_DEVICE_NAME


//
// When an interface is bound, we are passed a name beginning with
// IPV6_BIND_STRING_PREFIX.  However, we register our interfaces with
// TDI using names beginning with IPV6_EXPORT_STRING_PREFIX.
//
#ifdef UNDER_CE
#define IPV6_BIND_STRING_PREFIX   L'\0'
#else //UNDER_CE
#define IPV6_BIND_STRING_PREFIX   L"\\DEVICE\\"
#endif //UNDER_CE
#define IPV6_EXPORT_STRING_PREFIX L"\\DEVICE\\TCPIP6_"

//
// For buffer sizing convenience, bound the link-layer address size.
//
#define MAX_LINK_LAYER_ADDRESS_LENGTH   64

//
// IPv6 IOCTL code definitions.
//
// The codes that use FILE_ANY_ACCESS are open to all users.
// The codes that use FILE_WRITE_ACCESS require local Administrator privs.
//

#define FSCTL_IPV6_BASE FILE_DEVICE_NETWORK

#define _IPV6_CTL_CODE(function, method, access) \
            CTL_CODE(FSCTL_IPV6_BASE, function, method, access)


//
// This IOCTL is used to send an ICMPv6 Echo request.
// It returns the reply (unless there was a timeout or TTL expired).
//
#define IOCTL_ICMPV6_ECHO_REQUEST \
            _IPV6_CTL_CODE(0, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct icmpv6_echo_request {
    TDI_ADDRESS_IP6 DstAddress; // Destination address.
    TDI_ADDRESS_IP6 SrcAddress; // Source address.
    unsigned int Timeout;       // Request timeout in milliseconds.
    unsigned char TTL;          // TTL or Hop Count.
    unsigned int Flags;
    // Request data follows this structure in memory.
} ICMPV6_ECHO_REQUEST, *PICMPV6_ECHO_REQUEST;

#define ICMPV6_ECHO_REQUEST_FLAG_REVERSE        0x1     // Use routing header.

typedef struct icmpv6_echo_reply {
    TDI_ADDRESS_IP6 Address;    // Replying address.
    IP_STATUS Status;           // Reply IP_STATUS.
    unsigned int RoundTripTime; // RTT in milliseconds.
    // Reply data follows this structure in memory.
} ICMPV6_ECHO_REPLY, *PICMPV6_ECHO_REPLY;


//
// This IOCTL retrieves information about an interface,
// given an interface index or guid.
// It takes as input an IPV6_QUERY_INTERFACE structure
// and returns as output an IPV6_INFO_INTERFACE structure.
// To perform an iteration, start with Index set to -1, in which case
// only an IPV6_QUERY_INTERFACE is returned, for the first interface.
// If there are no more interfaces, then the Index in the returned
// IPV6_QUERY_INTERFACE will be -1.
//
#define IOCTL_IPV6_QUERY_INTERFACE \
            _IPV6_CTL_CODE(1, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct ipv6_query_interface {
    unsigned int Index;         // -1 means start/finish iteration,
                                // 0 means use the Guid.
    GUID Guid;
} IPV6_QUERY_INTERFACE;

//
// This IOCTL retrieves persisted information about an interface,
// given a registry index or guid.
// It takes as input an IPV6_PERSISTENT_QUERY_INTERFACE structure
// and returns as output an IPV6_INFO_INTERFACE structure.
//
#define IOCTL_IPV6_PERSISTENT_QUERY_INTERFACE \
            _IPV6_CTL_CODE(48, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct ipv6_persistent_query_interface {
    unsigned int RegistryIndex; // -1 means use the Guid.
    GUID Guid;
} IPV6_PERSISTENT_QUERY_INTERFACE;

typedef struct ipv6_info_interface {
    IPV6_QUERY_INTERFACE Next;      // For non-persistent queries only.
    IPV6_QUERY_INTERFACE This;

    //
    // Length of this structure in bytes, not including
    // any link-layer addresses following in memory.
    //
    unsigned int Length;

    //
    // These fields are ignored for updates.
    //
    unsigned int LinkLayerAddressLength;
    unsigned int LocalLinkLayerAddress;  // Offset, zero indicates absence.
    unsigned int RemoteLinkLayerAddress; // Offset, zero indicates absence.

    unsigned int Type;                   // Ignored for updates.
    int RouterDiscovers;                 // Ignored for updates.
    int NeighborDiscovers;               // Ignored for updates.
    int PeriodicMLD;                     // Ignored for updates.
    int Advertises;                      // -1 means no change, else boolean.
    int Forwards;                        // -1 means no change, else boolean.
    unsigned int MediaStatus;            // Ignored for updates.
    int OtherStatefulConfig;             // Ignored for updates.

#if defined MIPV6 || defined UNDER_CE
    unsigned int ReconnectStateFlush;    // Milliseconds, 0 means no change.
    unsigned int HeuristicStateFlush;    // Milliseconds, 0 means no change.
#endif // MIPV6

    unsigned int ZoneIndices[16];        // 0 means no change.

    unsigned int TrueLinkMTU;            // Ignored for updates.
    unsigned int LinkMTU;                // 0 means no change.
    unsigned int CurHopLimit;            // -1 means no change.
    unsigned int BaseReachableTime;      // Milliseconds, 0 means no change.
    unsigned int ReachableTime;          // Milliseconds, ignored for updates.
    unsigned int RetransTimer;           // Milliseconds, 0 means no change.
    unsigned int DupAddrDetectTransmits; // -1 means no change.
    unsigned int Preference;             // -1 means no change.
    int FirewallEnabled;                 // -1 means no change, else boolean.
    unsigned int DefSitePrefixLength;    // -1 means no change, 0 means none.
#if defined MIPV6 || defined UNDER_CE
    unsigned int MaxRtrAdvInterval;      // Milliseconds, 0 means no change.
    unsigned int MinRtrAdvInterval;      // Milliseconds, 0 means no change.
#endif // MIPV6

    // Link-layer addresses may follow.
} IPV6_INFO_INTERFACE;

//
// These values should agree with definitions also
// found in llip6if.h and ip6def.h.
//

#define IPV6_IF_TYPE_LOOPBACK           0
#define IPV6_IF_TYPE_ETHERNET           1
#define IPV6_IF_TYPE_FDDI               2
#define IPV6_IF_TYPE_TUNNEL_AUTO        3
#define IPV6_IF_TYPE_TUNNEL_6OVER4      4
#define IPV6_IF_TYPE_TUNNEL_V6V4        5
#define IPV6_IF_TYPE_TUNNEL_6TO4        6
#define IPV6_IF_TYPE_TUNNEL_TEREDO      7
#define IPV6_IF_TYPE_MIPV6              8

#define IPV6_IF_MEDIA_STATUS_DISCONNECTED       0
#define IPV6_IF_MEDIA_STATUS_RECONNECTING       1
#define IPV6_IF_MEDIA_STATUS_CONNECTED          2

//
// Initialize the fields of the IPV6_INFO_INTERFACE structure
// to values that indicate no change.
//
__inline void
IPV6_INIT_INFO_INTERFACE(IPV6_INFO_INTERFACE *Info)
{
    memset(Info, 0, sizeof *Info);
    Info->Length = sizeof *Info;

    Info->Type = (unsigned int)-1;
    Info->RouterDiscovers = -1;
    Info->NeighborDiscovers = -1;
    Info->PeriodicMLD = -1;
    Info->Advertises = -1;
    Info->Forwards = -1;
    Info->MediaStatus = (unsigned int)-1;
    Info->CurHopLimit = (unsigned int)-1;
    Info->DupAddrDetectTransmits = (unsigned int)-1;
    Info->Preference = (unsigned int)-1;
    Info->FirewallEnabled = -1;
    Info->DefSitePrefixLength = (unsigned int)-1;
}


//
// This IOCTL retrieves information about an address
// on an interface.
//
#define IOCTL_IPV6_QUERY_ADDRESS \
            _IPV6_CTL_CODE(2, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct ipv6_query_address {
    IPV6_QUERY_INTERFACE IF;  // Fields that identify an interface.
    IPv6Addr Address;
} IPV6_QUERY_ADDRESS;

typedef struct ipv6_info_address {
    IPV6_QUERY_ADDRESS Next;
    IPV6_QUERY_ADDRESS This;

    unsigned int Type;
    unsigned int Scope;
    unsigned int ScopeId;

    union {
        struct {  // If it's a unicast address.
            unsigned int DADState;
            unsigned int PrefixConf;
            unsigned int InterfaceIdConf;
            unsigned int ValidLifetime;            // Seconds.
            unsigned int PreferredLifetime;        // Seconds.
            int IsHomeAddress;                     // Boolean.
        };
        struct {  // If it's a multicast address.
            unsigned int MCastRefCount;
            unsigned int MCastFlags;
            unsigned int MCastTimer;               // Seconds.
        };
    };
} IPV6_INFO_ADDRESS;

//
// Values for address Type.
//
#define ADE_UNICAST   0x00
#define ADE_ANYCAST   0x01
#define ADE_MULTICAST 0x02
#define ADE_PROXY     0x03

//
// Values for address Scope.
//
#define ADE_SMALLEST_SCOPE      0x00
#define ADE_INTERFACE_LOCAL     0x01
#define ADE_LINK_LOCAL          0x02
#define ADE_SUBNET_LOCAL        0x03
#define ADE_ADMIN_LOCAL         0x04
#define ADE_SITE_LOCAL          0x05
#define ADE_ORG_LOCAL           0x08
#define ADE_GLOBAL              0x0e
#define ADE_LARGEST_SCOPE       0x0f

#define ADE_NUM_SCOPES          (ADE_LARGEST_SCOPE - ADE_SMALLEST_SCOPE + 1)

//
// Bit values for MCastFlags.
//
#define MAE_REPORTABLE          0x01
#define MAE_LAST_REPORTER       0x02

//
// Values for PrefixConf.
// These must match the IP_PREFIX_ORIGIN values in iptypes.h.
//
#define PREFIX_CONF_OTHER       0       // None of the ones below.
#define PREFIX_CONF_MANUAL      1       // From a user or administrator.
#define PREFIX_CONF_WELLKNOWN   2       // IANA-assigned.
#define PREFIX_CONF_DHCP        3       // Configured via DHCP.
#define PREFIX_CONF_RA          4       // From a Router Advertisement.

//
// Values for InterfaceIdConf.
// These must match the IP_SUFFIX_ORIGIN values in iptypes.h.
//
#define IID_CONF_OTHER          0       // None of the ones below.
#define IID_CONF_MANUAL         1       // From a user or administrator.
#define IID_CONF_WELLKNOWN      2       // IANA-assigned.
#define IID_CONF_DHCP           3       // Configured via DHCP.
#define IID_CONF_LL_ADDRESS     4       // Derived from the link-layer address.
#define IID_CONF_RANDOM         5       // Random, e.g. temporary address.

//
// Values for DADState.
//
// The low bit set indicates whether the state is valid.
// Among valid states, bigger is better
// for source address selection.
//
#define DAD_STATE_INVALID    0
#define DAD_STATE_TENTATIVE  1
#define DAD_STATE_DUPLICATE  2
#define DAD_STATE_DEPRECATED 3
#define DAD_STATE_PREFERRED  4

//
// We use this infinite lifetime value for prefix lifetimes,
// router lifetimes, address lifetimes, etc.
//
#define INFINITE_LIFETIME 0xffffffff


//
// This IOCTL retrieves information about an address
// that has been assigned persistently to an interface.
// It takes the IPV6_PERSISTENT_QUERY_ADDRESS structure
// and returns the IPV6_UPDATE_ADDRESS structure.
//
#define IOCTL_IPV6_PERSISTENT_QUERY_ADDRESS \
            _IPV6_CTL_CODE(47, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct ipv6_persistent_query_address {
    IPV6_PERSISTENT_QUERY_INTERFACE IF;
    unsigned int RegistryIndex; // -1 means use the Address.
    IPv6Addr Address;
} IPV6_PERSISTENT_QUERY_ADDRESS;


//
// This IOCTL retrieves information from the neighbor cache.
//
#define IOCTL_IPV6_QUERY_NEIGHBOR_CACHE \
            _IPV6_CTL_CODE(3, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct ipv6_query_neighbor_cache {
    IPV6_QUERY_INTERFACE IF;  // Fields that identify an interface.

    IPv6Addr Address;
} IPV6_QUERY_NEIGHBOR_CACHE;

typedef struct ipv6_info_neighbor_cache {
    IPV6_QUERY_NEIGHBOR_CACHE Query;

    unsigned int IsRouter;                // Whether neighbor is a router.
    unsigned int IsUnreachable;           // Whether neighbor is unreachable.
    unsigned int NDState;                 // Current state of entry.
    unsigned int ReachableTimer;          // Reachable time remaining (in ms).

    unsigned int LinkLayerAddressLength;
    // Link-layer address follows.
} IPV6_INFO_NEIGHBOR_CACHE;

#define ND_STATE_INCOMPLETE 0
#define ND_STATE_PROBE      1
#define ND_STATE_DELAY      2
#define ND_STATE_STALE      3
#define ND_STATE_REACHABLE  4
#define ND_STATE_PERMANENT  5

//
// This IOCTL retrieves information from the route cache.
//
#define IOCTL_IPV6_QUERY_ROUTE_CACHE \
            _IPV6_CTL_CODE(4, METHOD_BUFFERED, FILE_ANY_ACCESS)

typedef struct ipv6_query_route_cache {
    IPV6_QUERY_INTERFACE IF;  // Fields that identify an interface.
    IPv6Addr Address;  //MIPV6_TODO: Change to Destination.
#if defined MIPV6 || defined UNDER_CE
    IPv6Addr Source;
#endif //MIPV6
} IPV6_QUERY_ROUTE_CACHE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -