Merge from amd64-branch:
[reactos.git] / reactos / 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 // As in the mib from RFC 1213
64
65 typedef struct _IPRouteEntry {
66 ULONG ire_dest;
67 ULONG ire_index; //matches if_index in IFEntry and iae_index in IPAddrEntry
68 ULONG ire_metric1;
69 ULONG ire_metric2;
70 ULONG ire_metric3;
71 ULONG ire_metric4;
72 ULONG ire_gw;
73 ULONG ire_type;
74 ULONG ire_proto;
75 ULONG ire_age;
76 ULONG ire_mask;
77 ULONG ire_metric5;
78 ULONG ire_info;
79 } IPRouteEntry;
80
81 /* No caddr_t in reactos headers */
82 typedef char *caddr_t;
83
84 typedef union _IFEntrySafelySized {
85 CHAR MaxSize[sizeof(DWORD) +
86 sizeof(IFEntry) +
87 MAX_ADAPTER_DESCRIPTION_LENGTH + 1];
88 IFEntry ent;
89 } IFEntrySafelySized;
90
91 typedef union _TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY {
92 CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
93 sizeof(IPRouteEntry)];
94 TCP_REQUEST_SET_INFORMATION_EX Req;
95 } TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY,
96 *PTCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY;
97
98 typedef union _TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY {
99 CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
100 sizeof(MIB_IPNETROW)];
101 TCP_REQUEST_SET_INFORMATION_EX Req;
102 } TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY,
103 *PTCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY;
104
105 /* Encapsulates information about an interface */
106 typedef struct _IFInfo {
107 TDIEntityID entity_id;
108 IFEntrySafelySized if_info;
109 IPAddrEntry ip_addr;
110 } IFInfo;
111
112 typedef struct _IP_SET_DATA {
113 ULONG NteContext;
114 ULONG NewAddress;
115 ULONG NewNetmask;
116 } IP_SET_DATA, *PIP_SET_DATA;
117
118 typedef enum _IPHLPAddrType {
119 IPAAddr, IPABcast, IPAMask, IFMtu, IFStatus
120 } IPHLPAddrType;
121
122 /** Prototypes **/
123 NTSTATUS getNthIpEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent );
124 NTSTATUS tdiGetIpAddrsForIpEntity( HANDLE tcpFile, TDIEntityID *ent,
125 IPAddrEntry **addrs, PDWORD numAddrs );
126 int GetLongestChildKeyName( HANDLE RegHandle );
127 LONG OpenChildKeyRead( HANDLE RegHandle,
128 PWCHAR ChildKeyName,
129 PHKEY ReturnHandle );
130 PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n );
131 void ConsumeChildKeyName( PWCHAR Name );
132 PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName );
133 void ConsumeRegValueString( PWCHAR NameServer );
134 BOOL isInterface( TDIEntityID *if_maybe );
135 BOOL hasArp( HANDLE tcpFile, TDIEntityID *arp_maybe );
136
137 typedef VOID (*EnumNameServersFunc)( PWCHAR Interface,
138 PWCHAR NameServer,
139 PVOID Data );
140 void EnumNameServers( HANDLE RegHandle, PWCHAR Interface, PVOID Data, EnumNameServersFunc cb );
141
142 #include <w32api.h>
143 /* This is here until we switch to version 2.5 of the mingw headers */
144 #if (__W32API_MAJOR_VERSION < 2 || __W32API_MINOR_VERSION < 5)
145 BOOL WINAPI
146 GetComputerNameExA(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
147 #endif
148
149 #ifdef FORCE_DEBUG
150 #undef DPRINT
151 #define DPRINT(fmt,x...) DbgPrint("%s:%d:%s: " fmt, __FILE__, __LINE__, __FUNCTION__, ## x)
152 #endif
153
154 #endif/*IPPRIVATE_H*/