Fix DHCP bug (a ReadFile was being done on a BOOLEAN return value instead of the handle, and a thread was never returning), fix 99% of warnings and use PCH

svn path=/trunk/; revision=16369
This commit is contained in:
Alex Ionescu 2005-07-01 15:40:52 +00:00
parent 5cda38b218
commit ff230341e0
8 changed files with 20 additions and 23 deletions

View file

@ -10,7 +10,7 @@ PCHAR *GetSubkeyNames( PCHAR MainKeyName, PCHAR Append ) {
DWORD Error;
HKEY MainKey;
PCHAR *Out, OutKeyName;
DWORD CharTotal = 0, ThisKey, AppendLen = 1 + strlen(Append);
DWORD CharTotal = 0, AppendLen = 1 + strlen(Append);
DWORD MaxSubKeyLen = 0, MaxSubKeys = 0;
Error = RegOpenKey( HKEY_LOCAL_MACHINE, MainKeyName, &MainKey );
@ -194,7 +194,7 @@ BOOL PrepareAdapterForService( PDHCP_ADAPTER Adapter ) {
DefGatewayRow.dwForwardNextHop = inet_addr(DefaultGateway);
Error = CreateIpForwardEntry( &DefGatewayRow );
if( Error )
warning("Failed to set default gateway %s: %d\n",
warning("Failed to set default gateway %s: %ld\n",
DefaultGateway, Error);
}

View file

@ -124,11 +124,7 @@ int check_arp( struct interface_info *ip, struct client_lease *lp ) {
int
main(int argc, char *argv[])
{
extern char *__progname;
int ch, fd, quiet = 0, i = 0;
int pipe_fd[2];
struct passwd *pw;
int i = 0;
ApiInit();
AdapterInit();
PipeInit();
@ -503,7 +499,7 @@ void setup_adapter( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) {
&Adapter->NteInstance );
if( !NT_SUCCESS(Status) )
warning("AddIPAddress: %x\n", Status);
warning("AddIPAddress: %lx\n", Status);
}
if( new_lease->options[DHO_ROUTERS].len ) {
@ -526,7 +522,7 @@ void setup_adapter( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) {
Status = CreateIpForwardEntry( &RouterMib );
if( !NT_SUCCESS(Status) )
warning("CreateIpForwardEntry: %x\n", Status);
warning("CreateIpForwardEntry: %lx\n", Status);
else
old_default_route = RouterMib.dwForwardNextHop;
}
@ -551,7 +547,7 @@ bind_lease(struct interface_info *ip)
if( ip->client->active->renewal - cur_time )
add_timeout(ip->client->active->renewal, state_bound, ip);
note("bound to %s -- renewal in %d seconds.",
note("bound to %s -- renewal in %ld seconds.",
piaddr(ip->client->active->address),
ip->client->active->renewal - cur_time);
@ -917,7 +913,7 @@ send_discover(void *ipp)
if (!ip->client->offered_leases &&
ip->client->config->media) {
int fail = 0;
again:
if (ip->client->medium) {
ip->client->medium = ip->client->medium->next;
increase = 0;
@ -976,7 +972,7 @@ again:
ip->client->packet.secs = htons(65535);
ip->client->secs = ip->client->packet.secs;
note("DHCPDISCOVER on %s to %s port %d interval %d",
note("DHCPDISCOVER on %s to %s port %d interval %ld",
ip->name, inet_ntoa(sockaddr_broadcast.sin_addr),
ntohs(sockaddr_broadcast.sin_port), ip->client->interval);
@ -1030,7 +1026,7 @@ state_panic(void *ipp)
if (cur_time <
ip->client->active->renewal) {
ip->client->state = S_BOUND;
note("bound: renewal in %d seconds.",
note("bound: renewal in %ld seconds.",
ip->client->active->renewal -
cur_time);
add_timeout(
@ -1106,7 +1102,6 @@ send_request(void *ipp)
if ((ip->client->state == S_REBOOTING ||
ip->client->state == S_REQUESTING) &&
interval > ip->client->config->reboot_timeout) {
cancel:
ip->client->state = S_INIT;
cancel_timeout(send_request, ip);
state_init(ip);
@ -1632,7 +1627,6 @@ priv_script_write_params(char *prefix, struct client_lease *lease)
struct interface_info *ip = ifi;
u_int8_t dbuf[1500];
int i, len = 0;
char tbuf[128];
#if 0
script_set_env(ip->client, prefix, "ip_address",

View file

@ -8,6 +8,7 @@
<library>kernel32</library>
<library>ws2_32</library>
<library>iphlpapi</library>
<pch>include/rosdhcp.h</pch>
<file>adapter.c</file>
<file>alloc.c</file>
<file>api.c</file>

View file

@ -66,7 +66,6 @@ static int interface_status(struct interface_info *ifinfo);
void
discover_interfaces(struct interface_info *iface)
{
NTSTATUS Status;
PDHCP_ADAPTER Adapter = AdapterFindInfo( iface );
if_register_receive(iface);

View file

@ -40,6 +40,7 @@
* Enterprises, see ``http://www.vix.com''.
*/
#define lint
#ifndef lint
static char copyright[] =
"$Id: hash.c,v 1.9.2.3 1999/04/09 17:39:41 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";

View file

@ -1,11 +1,9 @@
#ifndef ROSDHCP_H
#define ROSDHCP_H
#include <roscfg.h>
#include <windows.h>
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
#include <winnt.h>
#include <iprtrmib.h>
#include <iphlpapi.h>
#include <winsock2.h>
@ -59,6 +57,8 @@ typedef DWORD (*PipeSendFunc)( COMM_DHCP_REPLY *Reply );
#define random rand
#define srandom srand
void AdapterInit(VOID);
HANDLE PipeInit(VOID);
extern PDHCP_ADAPTER AdapterFindIndex( unsigned int AdapterIndex );
extern PDHCP_ADAPTER AdapterFindInfo( struct interface_info *info );
extern VOID ApiInit();
@ -68,5 +68,5 @@ extern DWORD DSQueryHWInfo( PipeSendFunc Send, COMM_DHCP_REQ *Req );
extern DWORD DSLeaseIpAddress( PipeSendFunc Send, COMM_DHCP_REQ *Req );
extern DWORD DSRenewIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req );
extern DWORD DSReleaseIpAddressLease( PipeSendFunc Send, COMM_DHCP_REQ *Req );
int warn( char *format, ... );
#endif/*ROSDHCP_H*/

View file

@ -31,10 +31,10 @@ DWORD WINAPI PipeThreadProc( LPVOID Parameter ) {
DWORD BytesRead, BytesWritten;
COMM_DHCP_REQ Req;
BOOL Result;
HANDLE Connection;
BOOLEAN Connection;
while( (Connection = ConnectNamedPipe( CommPipe, NULL )) ) {
Result = ReadFile( Connection, &Req, sizeof(Req), &BytesRead, NULL );
Result = ReadFile( CommPipe, &Req, sizeof(Req), &BytesRead, NULL );
if( Result ) {
switch( Req.Type ) {
case DhcpReqQueryHWInfo:
@ -54,8 +54,10 @@ DWORD WINAPI PipeThreadProc( LPVOID Parameter ) {
break;
}
}
CloseHandle( Connection );
CloseHandle( CommPipe );
}
return TRUE;
}
HANDLE PipeInit() {

View file

@ -39,7 +39,7 @@
* see ``http://www.vix.com/isc''. To learn more about Vixie
* Enterprises, see ``http://www.vix.com''.
*/
#define lint
#ifndef lint
static char copyright[] =
"$Id: tables.c,v 1.13.2.4 1999/04/24 16:46:44 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";