1*c2c66affSColin Finck #ifndef ROSDHCP_H
2*c2c66affSColin Finck #define ROSDHCP_H
3*c2c66affSColin Finck 
4*c2c66affSColin Finck #include <stdarg.h>
5*c2c66affSColin Finck 
6*c2c66affSColin Finck #define WIN32_NO_STATUS
7*c2c66affSColin Finck #define _INC_WINDOWS
8*c2c66affSColin Finck #define COM_NO_WINDOWS_H
9*c2c66affSColin Finck 
10*c2c66affSColin Finck #include <windef.h>
11*c2c66affSColin Finck #include <winbase.h>
12*c2c66affSColin Finck #include <winreg.h>
13*c2c66affSColin Finck #define NTOS_MODE_USER
14*c2c66affSColin Finck #include <ndk/rtlfuncs.h>
15*c2c66affSColin Finck #include <dhcpcsdk.h>
16*c2c66affSColin Finck #include <dhcp/rosdhcp_public.h>
17*c2c66affSColin Finck 
18*c2c66affSColin Finck #include "debug.h"
19*c2c66affSColin Finck 
20*c2c66affSColin Finck #define IFNAMSIZ MAX_INTERFACE_NAME_LEN
21*c2c66affSColin Finck #undef interface /* wine/objbase.h -- Grrr */
22*c2c66affSColin Finck 
23*c2c66affSColin Finck #undef IGNORE
24*c2c66affSColin Finck #undef ACCEPT
25*c2c66affSColin Finck #undef PREFER
26*c2c66affSColin Finck #define DHCP_DISCOVER_INTERVAL 5
27*c2c66affSColin Finck #define DHCP_REBOOT_TIMEOUT 10
28*c2c66affSColin Finck #define DHCP_PANIC_TIMEOUT 20
29*c2c66affSColin Finck #define DHCP_BACKOFF_MAX 300
30*c2c66affSColin Finck #define DHCP_DEFAULT_LEASE_TIME 43200 /* 12 hours */
31*c2c66affSColin Finck #define _PATH_DHCLIENT_PID "\\systemroot\\system32\\drivers\\etc\\dhclient.pid"
32*c2c66affSColin Finck typedef void *VOIDPTR;
33*c2c66affSColin Finck typedef unsigned char u_int8_t;
34*c2c66affSColin Finck typedef unsigned short u_int16_t;
35*c2c66affSColin Finck typedef unsigned int u_int32_t;
36*c2c66affSColin Finck typedef char *caddr_t;
37*c2c66affSColin Finck 
38*c2c66affSColin Finck #ifndef _SSIZE_T_DEFINED
39*c2c66affSColin Finck #define _SSIZE_T_DEFINED
40*c2c66affSColin Finck #undef ssize_t
41*c2c66affSColin Finck #ifdef _WIN64
42*c2c66affSColin Finck #if defined(__GNUC__) && defined(__STRICT_ANSI__)
43*c2c66affSColin Finck   typedef int ssize_t __attribute__ ((mode (DI)));
44*c2c66affSColin Finck #else
45*c2c66affSColin Finck   typedef __int64 ssize_t;
46*c2c66affSColin Finck #endif
47*c2c66affSColin Finck #else
48*c2c66affSColin Finck   typedef int ssize_t;
49*c2c66affSColin Finck #endif
50*c2c66affSColin Finck #endif
51*c2c66affSColin Finck 
52*c2c66affSColin Finck typedef u_int32_t uintTIME;
53*c2c66affSColin Finck #define TIME uintTIME
54*c2c66affSColin Finck #include "dhcpd.h"
55*c2c66affSColin Finck 
56*c2c66affSColin Finck #define INLINE inline
57*c2c66affSColin Finck #define PROTO(x) x
58*c2c66affSColin Finck 
59*c2c66affSColin Finck typedef void (*handler_t) PROTO ((struct packet *));
60*c2c66affSColin Finck 
61*c2c66affSColin Finck struct iaddr;
62*c2c66affSColin Finck struct interface_info;
63*c2c66affSColin Finck 
64*c2c66affSColin Finck typedef struct _DHCP_ADAPTER {
65*c2c66affSColin Finck     LIST_ENTRY     ListEntry;
66*c2c66affSColin Finck     MIB_IFROW      IfMib;
67*c2c66affSColin Finck     MIB_IPFORWARDROW RouterMib;
68*c2c66affSColin Finck     MIB_IPADDRROW  IfAddr;
69*c2c66affSColin Finck     SOCKADDR       Address;
70*c2c66affSColin Finck     ULONG NteContext,NteInstance;
71*c2c66affSColin Finck     struct interface_info DhclientInfo;
72*c2c66affSColin Finck     struct client_state DhclientState;
73*c2c66affSColin Finck     struct client_config DhclientConfig;
74*c2c66affSColin Finck     struct sockaddr_in ListenAddr;
75*c2c66affSColin Finck     unsigned int BindStatus;
76*c2c66affSColin Finck     unsigned char recv_buf[1];
77*c2c66affSColin Finck } DHCP_ADAPTER, *PDHCP_ADAPTER;
78*c2c66affSColin Finck 
79*c2c66affSColin Finck typedef DWORD (*PipeSendFunc)( COMM_DHCP_REPLY *Reply );
80*c2c66affSColin Finck 
81*c2c66affSColin Finck #define random rand
82*c2c66affSColin Finck #define srandom srand
83*c2c66affSColin Finck 
84*c2c66affSColin Finck int  init_client(void);
85*c2c66affSColin Finck void stop_client(void);
86*c2c66affSColin Finck 
87*c2c66affSColin Finck void AdapterInit(VOID);
88*c2c66affSColin Finck HANDLE StartAdapterDiscovery(VOID);
89*c2c66affSColin Finck void AdapterStop(VOID);
90*c2c66affSColin Finck extern PDHCP_ADAPTER AdapterGetFirst(VOID);
91*c2c66affSColin Finck extern PDHCP_ADAPTER AdapterGetNext(PDHCP_ADAPTER);
92*c2c66affSColin Finck extern PDHCP_ADAPTER AdapterFindIndex( unsigned int AdapterIndex );
93*c2c66affSColin Finck extern PDHCP_ADAPTER AdapterFindInfo( struct interface_info *info );
94*c2c66affSColin Finck extern PDHCP_ADAPTER AdapterFindByHardwareAddress( u_int8_t haddr[16], u_int8_t hlen );
95*c2c66affSColin Finck extern HANDLE PipeInit(VOID);
96*c2c66affSColin Finck extern VOID ApiInit(VOID);
97*c2c66affSColin Finck extern VOID ApiFree(VOID);
98*c2c66affSColin Finck extern VOID ApiLock(VOID);
99*c2c66affSColin Finck extern VOID ApiUnlock(VOID);
100*c2c66affSColin Finck extern DWORD DSQueryHWInfo( PipeSendFunc Send, COMM_DHCP_REQ *Req );
101*c2c66affSColin Finck extern DWORD DSLeaseIpAddress( PipeSendFunc Send, COMM_DHCP_REQ *Req );
102*c2c66affSColin Finck extern DWORD DSRenewIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req );
103*c2c66affSColin Finck extern DWORD DSReleaseIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req );
104*c2c66affSColin Finck extern DWORD DSStaticRefreshParams( PipeSendFunc Send, COMM_DHCP_REQ *Req );
105*c2c66affSColin Finck extern DWORD DSGetAdapterInfo( PipeSendFunc Send, COMM_DHCP_REQ *Req );
106*c2c66affSColin Finck extern int inet_aton(const char *s, struct in_addr *addr);
107*c2c66affSColin Finck int warn( char *format, ... );
108*c2c66affSColin Finck 
109*c2c66affSColin Finck #endif /* ROSDHCP_H */
110