jdk/src/windows/native/java/net/NetworkInterface.h
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 906 17568a617956
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef NETWORK_INTERFACE_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define NETWORK_INTERFACE_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "net_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Structures used when enumerating interfaces and addresses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
typedef struct _netaddr  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    SOCKETADDRESS    addr;                  /* IPv4 or IPv6 address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    SOCKETADDRESS    brdcast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    short            mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    struct _netaddr *next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
} netaddr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
typedef struct _netif {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    char *name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    char *displayName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    DWORD dwIndex;              /* Internal index */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    DWORD ifType;               /* Interface type */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    int index;                  /* Friendly index */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    struct _netif *next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /* Following fields used on Windows XP when IPv6 is used only */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    jboolean hasIpv6Address;    /* true when following fields valid */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    jboolean dNameIsUnicode;    /* Display Name is Unicode */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    int naddrs;                 /* Number of addrs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    DWORD ipv6Index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    struct _netaddr *addrs;     /* addr list for interfaces */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
} netif;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
extern void free_netif(netif *netifP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
extern void free_netaddr(netaddr *netaddrP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
/* various JNI ids */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
extern jclass ni_class;             /* NetworkInterface */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
extern jmethodID ni_ctor;           /* NetworkInterface() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
extern jfieldID ni_indexID;         /* NetworkInterface.index */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
extern jfieldID ni_addrsID;         /* NetworkInterface.addrs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
extern jfieldID ni_bindsID;         /* NetworkInterface.bindings */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
extern jfieldID ni_nameID;          /* NetworkInterface.name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
extern jfieldID ni_displayNameID;   /* NetworkInterface.displayName */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
extern jfieldID ni_childsID;        /* NetworkInterface.childs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
extern jclass ni_iacls;             /* InetAddress */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
extern jfieldID ni_iaAddr;          /* InetAddress.address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
extern jclass ni_ia4cls;            /* Inet4Address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
extern jmethodID ni_ia4Ctor;        /* Inet4Address() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
extern jclass ni_ia6cls;            /* Inet6Address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
extern jmethodID ni_ia6ctrID;       /* Inet6Address() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
extern jfieldID ni_ia6ipaddressID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
extern jfieldID ni_ia6ipaddressID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
extern jclass ni_ibcls;             /* InterfaceAddress */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
extern jmethodID ni_ibctrID;        /* InterfaceAddress() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
extern jfieldID ni_ibaddressID;     /* InterfaceAddress.address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
extern jfieldID ni_ibbroadcastID;   /* InterfaceAddress.broadcast */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
extern jfieldID ni_ibmaskID;        /* InterfaceAddress.maskLength */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * Following includes come from iptypes.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#pragma warning(push)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#pragma warning(disable:4201)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
#include <time.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
// Definitions and structures used by getnetworkparams and getadaptersinfo apis
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define MAX_ADAPTER_DESCRIPTION_LENGTH  128 // arb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define MAX_ADAPTER_NAME_LENGTH         256 // arb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#define MAX_ADAPTER_ADDRESS_LENGTH      8   // arb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
#define DEFAULT_MINIMUM_ENTITIES        32  // arb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#define MAX_HOSTNAME_LEN                128 // arb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#define MAX_DOMAIN_NAME_LEN             128 // arb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
#define MAX_SCOPE_ID_LEN                256 // arb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
// types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
// Node Type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#define BROADCAST_NODETYPE              1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#define PEER_TO_PEER_NODETYPE           2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#define MIXED_NODETYPE                  4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
#define HYBRID_NODETYPE                 8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
// IP_ADDRESS_STRING - store an IP address as a dotted decimal string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    char String[4 * 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
} IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
// IP_ADDR_STRING - store an IP address with its corresponding subnet mask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
// both as dotted decimal strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
typedef struct _IP_ADDR_STRING {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    struct _IP_ADDR_STRING* Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    IP_ADDRESS_STRING IpAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    IP_MASK_STRING IpMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    DWORD Context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
} IP_ADDR_STRING, *PIP_ADDR_STRING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
// ADAPTER_INFO - per-adapter information. All IP addresses are stored as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
// strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
typedef struct _IP_ADAPTER_INFO {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    struct _IP_ADAPTER_INFO* Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    DWORD ComboIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    UINT AddressLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    DWORD Index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    UINT Type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    UINT DhcpEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    PIP_ADDR_STRING CurrentIpAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    IP_ADDR_STRING IpAddressList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    IP_ADDR_STRING GatewayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    IP_ADDR_STRING DhcpServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    BOOL HaveWins;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    IP_ADDR_STRING PrimaryWinsServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    IP_ADDR_STRING SecondaryWinsServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    time_t LeaseObtained;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    time_t LeaseExpires;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
#ifdef _WINSOCK2API_
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
// The following types require Winsock2.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    IpPrefixOriginOther = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    IpPrefixOriginManual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    IpPrefixOriginWellKnown,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    IpPrefixOriginDhcp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    IpPrefixOriginRouterAdvertisement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
} IP_PREFIX_ORIGIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    IpSuffixOriginOther = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    IpSuffixOriginManual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    IpSuffixOriginWellKnown,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    IpSuffixOriginDhcp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    IpSuffixOriginLinkLayerAddress,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    IpSuffixOriginRandom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
} IP_SUFFIX_ORIGIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    IpDadStateInvalid    = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    IpDadStateTentative,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    IpDadStateDuplicate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    IpDadStateDeprecated,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    IpDadStatePreferred,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
} IP_DAD_STATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
typedef struct _IP_ADAPTER_UNICAST_ADDRESS {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        ULONGLONG Alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            ULONG Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            DWORD Flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    struct _IP_ADAPTER_UNICAST_ADDRESS *Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    SOCKET_ADDRESS Address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    IP_PREFIX_ORIGIN PrefixOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    IP_SUFFIX_ORIGIN SuffixOrigin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    IP_DAD_STATE DadState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    ULONG ValidLifetime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    ULONG PreferredLifetime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    ULONG LeaseLifetime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
} IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
typedef struct _IP_ADAPTER_ANYCAST_ADDRESS {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        ULONGLONG Alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            ULONG Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            DWORD Flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    struct _IP_ADAPTER_ANYCAST_ADDRESS *Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    SOCKET_ADDRESS Address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
} IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
typedef struct _IP_ADAPTER_MULTICAST_ADDRESS {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        ULONGLONG Alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            ULONG Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            DWORD Flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    struct _IP_ADAPTER_MULTICAST_ADDRESS *Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    SOCKET_ADDRESS Address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
} IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
// Per-address Flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
#define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x01
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
#define IP_ADAPTER_ADDRESS_TRANSIENT    0x02
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        ULONGLONG Alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            ULONG Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            DWORD Reserved;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    SOCKET_ADDRESS Address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
} IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
typedef struct _IP_ADAPTER_PREFIX {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        ULONGLONG Alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            ULONG Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            DWORD Flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    struct _IP_ADAPTER_PREFIX *Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    SOCKET_ADDRESS Address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    ULONG PrefixLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
} IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
// Per-adapter Flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
#define IP_ADAPTER_DDNS_ENABLED               0x01
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX    0x02
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
#define IP_ADAPTER_DHCP_ENABLED               0x04
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
#define IP_ADAPTER_RECEIVE_ONLY               0x08
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#define IP_ADAPTER_NO_MULTICAST               0x10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
// OperStatus values from RFC 2863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    IfOperStatusUp = 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    IfOperStatusDown,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    IfOperStatusTesting,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    IfOperStatusUnknown,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    IfOperStatusDormant,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    IfOperStatusNotPresent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    IfOperStatusLowerLayerDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
} IF_OPER_STATUS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
// Scope levels from RFC 2373 used with ZoneIndices array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
typedef enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    ScopeLevelInterface    = 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    ScopeLevelLink         = 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    ScopeLevelSubnet       = 3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    ScopeLevelAdmin        = 4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    ScopeLevelSite         = 5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    ScopeLevelOrganization = 8,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    ScopeLevelGlobal       = 14
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
} SCOPE_LEVEL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
typedef struct _IP_ADAPTER_ADDRESSES {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        ULONGLONG Alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            ULONG Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            DWORD IfIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    struct _IP_ADAPTER_ADDRESSES *Next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    PCHAR AdapterName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    PWCHAR DnsSuffix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    PWCHAR Description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    PWCHAR FriendlyName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    DWORD PhysicalAddressLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    DWORD Flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    DWORD Mtu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    DWORD IfType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    IF_OPER_STATUS OperStatus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    DWORD Ipv6IfIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    DWORD ZoneIndices[16];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    PIP_ADAPTER_PREFIX FirstPrefix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
// Flags used as argument to GetAdaptersAddresses().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
// "SKIP" flags are added when the default is to include the information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
// "INCLUDE" flags are added when the default is to skip the information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
#define GAA_FLAG_SKIP_UNICAST       0x0001
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
#define GAA_FLAG_SKIP_ANYCAST       0x0002
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
#define GAA_FLAG_SKIP_MULTICAST     0x0004
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
#define GAA_FLAG_SKIP_DNS_SERVER    0x0008
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
#define GAA_FLAG_INCLUDE_PREFIX     0x0010
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
#define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
#endif /* _WINSOCK2API_ */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
// IP_PER_ADAPTER_INFO - per-adapter IP information such as DNS server list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
typedef struct _IP_PER_ADAPTER_INFO {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    UINT AutoconfigEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    UINT AutoconfigActive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    PIP_ADDR_STRING CurrentDnsServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    IP_ADDR_STRING DnsServerList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
} IP_PER_ADAPTER_INFO, *PIP_PER_ADAPTER_INFO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
// FIXED_INFO - the set of IP-related information which does not depend on DHCP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    char HostName[MAX_HOSTNAME_LEN + 4] ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    char DomainName[MAX_DOMAIN_NAME_LEN + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    PIP_ADDR_STRING CurrentDnsServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    IP_ADDR_STRING DnsServerList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    UINT NodeType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    char ScopeId[MAX_SCOPE_ID_LEN + 4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    UINT EnableRouting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    UINT EnableProxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    UINT EnableDns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
} FIXED_INFO, *PFIXED_INFO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#ifndef IP_INTERFACE_NAME_INFO_DEFINED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
#define IP_INTERFACE_NAME_INFO_DEFINED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
typedef struct ip_interface_name_info {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    ULONG           Index;      // Interface Index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    ULONG           MediaType;  // Interface Types - see ipifcons.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    UCHAR           ConnectionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    UCHAR           AccessType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    GUID            DeviceGuid; // Device GUID is the guid of the device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                                // that IP exposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    GUID            InterfaceGuid; // Interface GUID, if not GUID_NULL is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                                // GUID for the interface mapped to the device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
} IP_INTERFACE_NAME_INFO, *PIP_INTERFACE_NAME_INFO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
#pragma warning(pop)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
/* from ipifcons.h */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
#ifndef IF_TYPE_PPP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
#define IF_TYPE_PPP 23
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
#ifndef IF_TYPE_SOFTWARE_LOOPBACK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
#define IF_TYPE_SOFTWARE_LOOPBACK 24
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
#ifndef IF_TYPE_SLIP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
#define IF_TYPE_SLIP 28
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
#ifndef IF_TYPE_TUNNEL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
#define IF_TYPE_TUNNEL 131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
#endif