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