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