Sync with trunk head (part 1 of 2)
[reactos.git] / dll / win32 / iphlpapi / iphlpapi_private.h
1 #ifndef IPPRIVATE_H
2 #define IPPRIVATE_H
3
4 #define NtCurrentTeb NtXCurrentTeb
5
6 #include <stdarg.h>
7 #include <stdlib.h>
8 #include <sys/types.h>
9 #ifdef HAVE_NETINET_IN_H
10 # include <netinet/in.h>
11 #endif
12 #ifdef HAVE_ARPA_INET_H
13 # include <arpa/inet.h>
14 #endif
15 #ifdef HAVE_ARPA_NAMESER_H
16 # include <arpa/nameser.h>
17 #endif
18 #ifdef HAVE_RESOLV_H
19 # include <resolv.h>
20 #endif
21
22 #undef _WIN32_WINNT
23 #define _WIN32_WINNT 0x500
24 #define WIN32_NO_STATUS
25 #include <winsock2.h>
26 #include <ws2tcpip.h>
27 #include <windows.h>
28 #define NTOS_MODE_USER
29 #include <ndk/ntndk.h>
30 #include <nspapi.h>
31 #include <iptypes.h>
32 #include "iphlpapi.h"
33 #include "resinfo.h"
34 #include "wine/debug.h"
35
36 //#include "ntddndis.h"
37 #include "ddk/tdiinfo.h"
38 #include "tcpioctl.h"
39
40 #include "tdilib.h"
41
42 #ifndef ETH_ALEN
43 #define ETH_ALEN 6
44 #endif
45
46 #ifndef INADDR_NONE
47 #define INADDR_NONE (~0U)
48 #endif
49
50 #ifndef IFENT_SOFTWARE_LOOPBACK
51 #define IFENT_SOFTWARE_LOOPBACK 24 /* This is an SNMP constant from rfc1213 */
52 #endif/*IFENT_SOFTWARE_LOOPBACK*/
53
54 #define INDEX_IS_LOOPBACK 0x00800000
55
56 /* Type declarations */
57
58 #ifndef IFNAMSIZ
59 #define IFNAMSIZ 0x20
60 #endif/*IFNAMSIZ*/
61
62 #define TCP_REQUEST_QUERY_INFORMATION_INIT { { { 0 } } }
63 #define TCP_REQUEST_SET_INFORMATION_INIT { { 0 } }
64
65 // As in the mib from RFC 1213
66
67 typedef struct _IPRouteEntry {
68 ULONG ire_dest;
69 ULONG ire_index; //matches if_index in IFEntry and iae_index in IPAddrEntry
70 ULONG ire_metric1;
71 ULONG ire_metric2;
72 ULONG ire_metric3;
73 ULONG ire_metric4;
74 ULONG ire_gw;
75 ULONG ire_type;
76 ULONG ire_proto;
77 ULONG ire_age;
78 ULONG ire_mask;
79 ULONG ire_metric5;
80 ULONG ire_info;
81 } IPRouteEntry;
82
83 /* No caddr_t in reactos headers */
84 typedef char *caddr_t;
85
86 typedef union _IFEntrySafelySized {
87 CHAR MaxSize[sizeof(DWORD) +
88 sizeof(IFEntry) +
89 MAX_ADAPTER_DESCRIPTION_LENGTH + 1];
90 IFEntry ent;
91 } IFEntrySafelySized;
92
93 typedef union _TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY {
94 CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
95 sizeof(IPRouteEntry)];
96 TCP_REQUEST_SET_INFORMATION_EX Req;
97 } TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY,
98 *PTCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY;
99
100 typedef union _TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY {
101 CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
102 sizeof(MIB_IPNETROW)];
103 TCP_REQUEST_SET_INFORMATION_EX Req;
104 } TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY,
105 *PTCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY;
106
107 /* Encapsulates information about an interface */
108 typedef struct _IFInfo {
109 TDIEntityID entity_id;
110 IFEntrySafelySized if_info;
111 IPAddrEntry ip_addr;
112 } IFInfo;
113
114 typedef struct _IP_SET_DATA {
115 ULONG NteContext;
116 ULONG NewAddress;
117 ULONG NewNetmask;
118 } IP_SET_DATA, *PIP_SET_DATA;
119
120 typedef enum _IPHLPAddrType {
121 IPAAddr, IPABcast, IPAMask, IFMtu, IFStatus
122 } IPHLPAddrType;
123
124 /** Prototypes **/
125 NTSTATUS getNthIpEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent );
126 NTSTATUS tdiGetIpAddrsForIpEntity( HANDLE tcpFile, TDIEntityID *ent,
127 IPAddrEntry **addrs, PDWORD numAddrs );
128 int GetLongestChildKeyName( HANDLE RegHandle );
129 LONG OpenChildKeyRead( HANDLE RegHandle,
130 PWCHAR ChildKeyName,
131 PHKEY ReturnHandle );
132 PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n );
133 void ConsumeChildKeyName( PWCHAR Name );
134 PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName );
135 void ConsumeRegValueString( PWCHAR NameServer );
136 BOOL isInterface( TDIEntityID *if_maybe );
137 BOOL hasArp( HANDLE tcpFile, TDIEntityID *arp_maybe );
138
139 typedef VOID (*EnumNameServersFunc)( PWCHAR Interface,
140 PWCHAR NameServer,
141 PVOID Data );
142 void EnumNameServers( HANDLE RegHandle, PWCHAR Interface, PVOID Data, EnumNameServersFunc cb );
143
144 #include <w32api.h>
145 /* This is here until we switch to version 2.5 of the mingw headers */
146 #if (__W32API_MAJOR_VERSION < 2 || __W32API_MINOR_VERSION < 5)
147 BOOL WINAPI
148 GetComputerNameExA(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
149 #endif
150
151 #ifdef FORCE_DEBUG
152 #undef DPRINT
153 #define DPRINT(fmt,x...) DbgPrint("%s:%d:%s: " fmt, __FILE__, __LINE__, __FUNCTION__, ## x)
154 #endif
155
156 #endif/*IPPRIVATE_H*/