1*c2c66affSColin Finck #ifndef IPPRIVATE_H
2*c2c66affSColin Finck #define IPPRIVATE_H
3*c2c66affSColin Finck 
4*c2c66affSColin Finck #define NtCurrentTeb NtXCurrentTeb
5*c2c66affSColin Finck 
6*c2c66affSColin Finck #include <stdio.h>
7*c2c66affSColin Finck #include <stdlib.h>
8*c2c66affSColin Finck //#include <sys/types.h>
9*c2c66affSColin Finck #ifdef HAVE_NETINET_IN_H
10*c2c66affSColin Finck # include <netinet/in.h>
11*c2c66affSColin Finck #endif
12*c2c66affSColin Finck #ifdef HAVE_ARPA_INET_H
13*c2c66affSColin Finck # include <arpa/inet.h>
14*c2c66affSColin Finck #endif
15*c2c66affSColin Finck #ifdef HAVE_ARPA_NAMESER_H
16*c2c66affSColin Finck # include <arpa/nameser.h>
17*c2c66affSColin Finck #endif
18*c2c66affSColin Finck #ifdef HAVE_RESOLV_H
19*c2c66affSColin Finck # include <resolv.h>
20*c2c66affSColin Finck #endif
21*c2c66affSColin Finck 
22*c2c66affSColin Finck #define WIN32_NO_STATUS
23*c2c66affSColin Finck #define _INC_WINDOWS
24*c2c66affSColin Finck #define COM_NO_WINDOWS_H
25*c2c66affSColin Finck 
26*c2c66affSColin Finck #include <windef.h>
27*c2c66affSColin Finck #include <winbase.h>
28*c2c66affSColin Finck #include <winreg.h>
29*c2c66affSColin Finck #include <winnls.h>
30*c2c66affSColin Finck #include <ws2tcpip.h>
31*c2c66affSColin Finck #define NTOS_MODE_USER
32*c2c66affSColin Finck #include <ndk/iofuncs.h>
33*c2c66affSColin Finck #include <ndk/obfuncs.h>
34*c2c66affSColin Finck #include <ndk/rtlfuncs.h>
35*c2c66affSColin Finck #include <iphlpapi.h>
36*c2c66affSColin Finck #include "resinfo.h"
37*c2c66affSColin Finck #include <wine/debug.h>
38*c2c66affSColin Finck 
39*c2c66affSColin Finck #include "dhcp.h"
40*c2c66affSColin Finck #include <dhcpcsdk.h>
41*c2c66affSColin Finck #include <dhcpcapi.h>
42*c2c66affSColin Finck 
43*c2c66affSColin Finck #include <tdiinfo.h>
44*c2c66affSColin Finck #include <tcpioctl.h>
45*c2c66affSColin Finck 
46*c2c66affSColin Finck #include <tdilib.h>
47*c2c66affSColin Finck 
48*c2c66affSColin Finck #include "ifenum.h"
49*c2c66affSColin Finck #include "ipstats.h"
50*c2c66affSColin Finck #include "route.h"
51*c2c66affSColin Finck 
52*c2c66affSColin Finck #ifndef ETH_ALEN
53*c2c66affSColin Finck #define ETH_ALEN 6
54*c2c66affSColin Finck #endif
55*c2c66affSColin Finck 
56*c2c66affSColin Finck #ifndef INADDR_NONE
57*c2c66affSColin Finck #define INADDR_NONE (~0U)
58*c2c66affSColin Finck #endif
59*c2c66affSColin Finck 
60*c2c66affSColin Finck #ifndef IFENT_SOFTWARE_LOOPBACK
61*c2c66affSColin Finck #define IFENT_SOFTWARE_LOOPBACK 24 /* This is an SNMP constant from rfc1213 */
62*c2c66affSColin Finck #endif/*IFENT_SOFTWARE_LOOPBACK*/
63*c2c66affSColin Finck 
64*c2c66affSColin Finck #define INDEX_IS_LOOPBACK 0x00800000
65*c2c66affSColin Finck 
66*c2c66affSColin Finck /* Type declarations */
67*c2c66affSColin Finck 
68*c2c66affSColin Finck #ifndef IFNAMSIZ
69*c2c66affSColin Finck #define IFNAMSIZ 0x20
70*c2c66affSColin Finck #endif/*IFNAMSIZ*/
71*c2c66affSColin Finck 
72*c2c66affSColin Finck #define TCP_REQUEST_QUERY_INFORMATION_INIT { { { 0 } } }
73*c2c66affSColin Finck #define TCP_REQUEST_SET_INFORMATION_INIT { { 0 } }
74*c2c66affSColin Finck 
75*c2c66affSColin Finck /* FIXME: ROS headers suck */
76*c2c66affSColin Finck #ifndef GAA_FLAG_SKIP_UNICAST
77*c2c66affSColin Finck #define GAA_FLAG_SKIP_UNICAST      0x0001
78*c2c66affSColin Finck #endif
79*c2c66affSColin Finck 
80*c2c66affSColin Finck #ifndef GAA_FLAG_SKIP_FRIENDLY_NAME
81*c2c66affSColin Finck #define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
82*c2c66affSColin Finck #endif
83*c2c66affSColin Finck 
84*c2c66affSColin Finck // As in the mib from RFC 1213
85*c2c66affSColin Finck 
86*c2c66affSColin Finck typedef struct _IPRouteEntry {
87*c2c66affSColin Finck     ULONG ire_dest;
88*c2c66affSColin Finck     ULONG ire_index;            //matches if_index in IFEntry and iae_index in IPAddrEntry
89*c2c66affSColin Finck     ULONG ire_metric1;
90*c2c66affSColin Finck     ULONG ire_metric2;
91*c2c66affSColin Finck     ULONG ire_metric3;
92*c2c66affSColin Finck     ULONG ire_metric4;
93*c2c66affSColin Finck     ULONG ire_gw;
94*c2c66affSColin Finck     ULONG ire_type;
95*c2c66affSColin Finck     ULONG ire_proto;
96*c2c66affSColin Finck     ULONG ire_age;
97*c2c66affSColin Finck     ULONG ire_mask;
98*c2c66affSColin Finck     ULONG ire_metric5;
99*c2c66affSColin Finck     ULONG ire_info;
100*c2c66affSColin Finck } IPRouteEntry;
101*c2c66affSColin Finck 
102*c2c66affSColin Finck /* No caddr_t in reactos headers */
103*c2c66affSColin Finck typedef char *caddr_t;
104*c2c66affSColin Finck 
105*c2c66affSColin Finck typedef union _IFEntrySafelySized {
106*c2c66affSColin Finck     CHAR MaxSize[sizeof(DWORD) +
107*c2c66affSColin Finck 		 sizeof(IFEntry) +
108*c2c66affSColin Finck 		 MAX_ADAPTER_DESCRIPTION_LENGTH + 1];
109*c2c66affSColin Finck     IFEntry ent;
110*c2c66affSColin Finck } IFEntrySafelySized;
111*c2c66affSColin Finck 
112*c2c66affSColin Finck typedef union _TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY {
113*c2c66affSColin Finck     CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
114*c2c66affSColin Finck 		 sizeof(IPRouteEntry)];
115*c2c66affSColin Finck     TCP_REQUEST_SET_INFORMATION_EX Req;
116*c2c66affSColin Finck } TCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY,
117*c2c66affSColin Finck     *PTCP_REQUEST_SET_INFORMATION_EX_ROUTE_ENTRY;
118*c2c66affSColin Finck 
119*c2c66affSColin Finck typedef union _TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY {
120*c2c66affSColin Finck     CHAR MaxSize[sizeof(TCP_REQUEST_SET_INFORMATION_EX) - 1 +
121*c2c66affSColin Finck 		 sizeof(MIB_IPNETROW)];
122*c2c66affSColin Finck     TCP_REQUEST_SET_INFORMATION_EX Req;
123*c2c66affSColin Finck } TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY,
124*c2c66affSColin Finck     *PTCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY;
125*c2c66affSColin Finck 
126*c2c66affSColin Finck /* Encapsulates information about an interface */
127*c2c66affSColin Finck typedef struct _IFInfo {
128*c2c66affSColin Finck     TDIEntityID        entity_id;
129*c2c66affSColin Finck     IFEntrySafelySized if_info;
130*c2c66affSColin Finck     IPAddrEntry        ip_addr;
131*c2c66affSColin Finck } IFInfo;
132*c2c66affSColin Finck 
133*c2c66affSColin Finck typedef struct _IP_SET_DATA {
134*c2c66affSColin Finck     ULONG NteContext;
135*c2c66affSColin Finck     ULONG NewAddress;
136*c2c66affSColin Finck     ULONG NewNetmask;
137*c2c66affSColin Finck } IP_SET_DATA, *PIP_SET_DATA;
138*c2c66affSColin Finck 
139*c2c66affSColin Finck typedef enum _IPHLPAddrType {
140*c2c66affSColin Finck     IPAAddr, IPABcast, IPAMask, IFMtu, IFStatus
141*c2c66affSColin Finck } IPHLPAddrType;
142*c2c66affSColin Finck 
143*c2c66affSColin Finck /** Prototypes **/
144*c2c66affSColin Finck NTSTATUS getNthIpEntity( HANDLE tcpFile, DWORD index, TDIEntityID *ent );
145*c2c66affSColin Finck NTSTATUS tdiGetIpAddrsForIpEntity( HANDLE tcpFile, TDIEntityID *ent,
146*c2c66affSColin Finck 				   IPAddrEntry **addrs, PDWORD numAddrs );
147*c2c66affSColin Finck int GetLongestChildKeyName( HANDLE RegHandle );
148*c2c66affSColin Finck LONG OpenChildKeyRead( HANDLE RegHandle,
149*c2c66affSColin Finck 		       PWCHAR ChildKeyName,
150*c2c66affSColin Finck 		       PHKEY ReturnHandle );
151*c2c66affSColin Finck PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n );
152*c2c66affSColin Finck void ConsumeChildKeyName( PWCHAR Name );
153*c2c66affSColin Finck PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName );
154*c2c66affSColin Finck PWCHAR *QueryRegistryValueStringMulti( HANDLE RegHandle, PWCHAR ValueName );
155*c2c66affSColin Finck void ConsumeRegValueString( PWCHAR NameServer );
156*c2c66affSColin Finck BOOL isInterface( TDIEntityID *if_maybe );
157*c2c66affSColin Finck BOOL hasArp( HANDLE tcpFile, TDIEntityID *arp_maybe );
158*c2c66affSColin Finck 
159*c2c66affSColin Finck typedef VOID (*EnumNameServersFunc)( PWCHAR Interface,
160*c2c66affSColin Finck 				     PWCHAR NameServer,
161*c2c66affSColin Finck 				     PVOID Data );
162*c2c66affSColin Finck LSTATUS EnumNameServers( HKEY RegHandle, LPWSTR Interface, PVOID Data, EnumNameServersFunc cb );
163*c2c66affSColin Finck NTSTATUS getIPAddrEntryForIf(HANDLE tcpFile,
164*c2c66affSColin Finck                              char *name,
165*c2c66affSColin Finck                              DWORD index,
166*c2c66affSColin Finck                              IFInfo *ifInfo);
167*c2c66affSColin Finck DWORD TCPSendIoctl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, PULONG pInBufferSize, LPVOID lpOutBuffer, PULONG pOutBufferSize);
168*c2c66affSColin Finck 
169*c2c66affSColin Finck #include <w32api.h>
170*c2c66affSColin Finck /* This is here until we switch to version 2.5 of the mingw headers */
171*c2c66affSColin Finck #if (__W32API_MAJOR_VERSION < 2 || __W32API_MINOR_VERSION < 5)
172*c2c66affSColin Finck BOOL WINAPI
173*c2c66affSColin Finck GetComputerNameExA(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
174*c2c66affSColin Finck #endif
175*c2c66affSColin Finck 
176*c2c66affSColin Finck #endif /* IPPRIVATE_H */
177