dispatch.c (9febc82a) | dispatch.c (033b6639) |
---|---|
1/* $OpenBSD: dispatch.c,v 1.31 2004/09/21 04:07:03 david Exp $ */ 2 3/* 4 * Copyright 2004 Henning Brauer <henning@openbsd.org> 5 * Copyright (c) 1995, 1996, 1997, 1998, 1999 6 * The Internet Software Consortium. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 27 unchanged lines hidden (view full) --- 36 * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie 37 * Enterprises. To learn more about the Internet Software Consortium, 38 * see ``http://www.vix.com/isc''. To learn more about Vixie 39 * Enterprises, see ``http://www.vix.com''. 40 */ 41 42#include <rosdhcp.h> 43 | 1/* $OpenBSD: dispatch.c,v 1.31 2004/09/21 04:07:03 david Exp $ */ 2 3/* 4 * Copyright 2004 Henning Brauer <henning@openbsd.org> 5 * Copyright (c) 1995, 1996, 1997, 1998, 1999 6 * The Internet Software Consortium. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 27 unchanged lines hidden (view full) --- 36 * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie 37 * Enterprises. To learn more about the Internet Software Consortium, 38 * see ``http://www.vix.com/isc''. To learn more about Vixie 39 * Enterprises, see ``http://www.vix.com''. 40 */ 41 42#include <rosdhcp.h> 43 |
44#define NDEBUG 45#include <reactos/debug.h> 46 |
|
44//#include <sys/ioctl.h> 45 46//#include <net/if_media.h> 47//#include <ifaddrs.h> 48//#include <poll.h> 49 50extern SOCKET DhcpSocket; | 47//#include <sys/ioctl.h> 48 49//#include <net/if_media.h> 50//#include <ifaddrs.h> 51//#include <poll.h> 52 53extern SOCKET DhcpSocket; |
51HANDLE AdapterStateChangedEvent = NULL; | 54extern HANDLE hAdapterStateChangedEvent; 55 |
52struct protocol *protocols = NULL; 53struct timeout *timeouts = NULL; 54static struct timeout *free_timeouts = NULL; 55void (*bootp_packet_handler)(struct interface_info *, 56 struct dhcp_packet *, int, unsigned int, 57 struct iaddr, struct hardware *); 58 59/* --- 6 unchanged lines hidden (view full) --- 66dispatch(HANDLE hStopEvent) 67{ 68 int count, to_msec; 69 struct protocol *l; 70 time_t howlong, cur_time; 71 HANDLE Events[3]; 72 int EventCount = 2; 73 | 56struct protocol *protocols = NULL; 57struct timeout *timeouts = NULL; 58static struct timeout *free_timeouts = NULL; 59void (*bootp_packet_handler)(struct interface_info *, 60 struct dhcp_packet *, int, unsigned int, 61 struct iaddr, struct hardware *); 62 63/* --- 6 unchanged lines hidden (view full) --- 70dispatch(HANDLE hStopEvent) 71{ 72 int count, to_msec; 73 struct protocol *l; 74 time_t howlong, cur_time; 75 HANDLE Events[3]; 76 int EventCount = 2; 77 |
74 Events[0] = StartAdapterDiscovery(); 75 if (!Events[0]) 76 return; 77 78 AdapterStateChangedEvent = Events[0]; 79 | 78 Events[0] = hAdapterStateChangedEvent; |
80 Events[1] = hStopEvent; 81 Events[2] = WSA_INVALID_EVENT; 82 83 ApiLock(); 84 85 do { 86 /* 87 * Call any expired timeouts, and then if there's still --- 64 unchanged lines hidden (view full) --- 152 if (count == WAIT_OBJECT_0) 153 { 154 /* Adapter state change */ 155 continue; 156 } 157 else if (count == WAIT_OBJECT_0 + 1) 158 { 159 /* Stop event signalled */ | 79 Events[1] = hStopEvent; 80 Events[2] = WSA_INVALID_EVENT; 81 82 ApiLock(); 83 84 do { 85 /* 86 * Call any expired timeouts, and then if there's still --- 64 unchanged lines hidden (view full) --- 151 if (count == WAIT_OBJECT_0) 152 { 153 /* Adapter state change */ 154 continue; 155 } 156 else if (count == WAIT_OBJECT_0 + 1) 157 { 158 /* Stop event signalled */ |
159 DPRINT("Dispatch thread stop event!\n"); |
|
160 break; 161 } 162 else if (count == WAIT_OBJECT_0 + 2) 163 { 164 /* Packet received */ 165 166 /* WSA events are manual reset events */ 167 WSAResetEvent(Events[2]); --- 10 unchanged lines hidden (view full) --- 178 if (ip && (l->handler != got_one || 179 !ip->dead)) { 180 DH_DbgPrint(MID_TRACE,("Handling %x\n", l)); 181 (*(l->handler))(l); 182 } 183 } 184 } while (1); 185 | 160 break; 161 } 162 else if (count == WAIT_OBJECT_0 + 2) 163 { 164 /* Packet received */ 165 166 /* WSA events are manual reset events */ 167 WSAResetEvent(Events[2]); --- 10 unchanged lines hidden (view full) --- 178 if (ip && (l->handler != got_one || 179 !ip->dead)) { 180 DH_DbgPrint(MID_TRACE,("Handling %x\n", l)); 181 (*(l->handler))(l); 182 } 183 } 184 } while (1); 185 |
186 AdapterStateChangedEvent = NULL; 187 CloseHandle(Events[0]); 188 CloseHandle(Events[1]); | |
189 WSACloseEvent(Events[2]); 190 191 ApiUnlock(); | 186 WSACloseEvent(Events[2]); 187 188 ApiUnlock(); |
189 190 DPRINT("Dispatch thread stopped!\n"); |
|
192} 193 194void 195got_one(struct protocol *l) 196{ 197 struct sockaddr_in from; 198 struct hardware hfrom; 199 struct iaddr ifrom; --- 229 unchanged lines hidden --- | 191} 192 193void 194got_one(struct protocol *l) 195{ 196 struct sockaddr_in from; 197 struct hardware hfrom; 198 struct iaddr ifrom; --- 229 unchanged lines hidden --- |