ReactOS  0.4.12-dev-714-gfaac916
adapter.c
Go to the documentation of this file.
1 #include <rosdhcp.h>
2 
5 static WSADATA wsd;
6 
7 PCHAR *GetSubkeyNames( PCHAR MainKeyName, PCHAR Append ) {
8  int i = 0;
9  DWORD Error;
10  HKEY MainKey;
11  PCHAR *Out, OutKeyName;
12  DWORD CharTotal = 0, AppendLen = 1 + strlen(Append);
13  DWORD MaxSubKeyLen = 0, MaxSubKeys = 0;
14 
15  Error = RegOpenKey( HKEY_LOCAL_MACHINE, MainKeyName, &MainKey );
16 
17  if( Error ) return NULL;
18 
20  ( MainKey,
21  NULL, NULL, NULL,
22  &MaxSubKeys, &MaxSubKeyLen,
23  NULL, NULL, NULL, NULL, NULL, NULL );
24 
25  MaxSubKeyLen++;
26  DH_DbgPrint(MID_TRACE,("MaxSubKeys: %d, MaxSubKeyLen %d\n",
27  MaxSubKeys, MaxSubKeyLen));
28 
29  CharTotal = (sizeof(PCHAR) + MaxSubKeyLen + AppendLen) * (MaxSubKeys + 1);
30 
31  DH_DbgPrint(MID_TRACE,("AppendLen: %d, CharTotal: %d\n",
32  AppendLen, CharTotal));
33 
34  Out = (CHAR**) malloc( CharTotal );
35  OutKeyName = ((PCHAR)&Out[MaxSubKeys+1]);
36 
37  if( !Out ) { RegCloseKey( MainKey ); return NULL; }
38 
39  i = 0;
40  do {
41  Out[i] = OutKeyName;
42  Error = RegEnumKey( MainKey, i, OutKeyName, MaxSubKeyLen );
43  if( !Error ) {
44  strcat( OutKeyName, Append );
45  DH_DbgPrint(MID_TRACE,("[%d]: %s\n", i, OutKeyName));
46  OutKeyName += strlen(OutKeyName) + 1;
47  i++;
48  } else Out[i] = 0;
49  } while( Error == ERROR_SUCCESS );
50 
51  RegCloseKey( MainKey );
52 
53  return Out;
54 }
55 
57  PCHAR SubOut = NULL;
58  DWORD SubOutLen = 0, Error = 0;
59  HKEY ValueKey = NULL;
60 
61  DH_DbgPrint(MID_TRACE,("Looking in %x:%s:%s\n", Root, Subkey, Value ));
62 
63  if( Subkey && strlen(Subkey) ) {
64  if( RegOpenKey( Root, Subkey, &ValueKey ) != ERROR_SUCCESS )
65  goto regerror;
66  } else ValueKey = Root;
67 
68  DH_DbgPrint(MID_TRACE,("Got Key %x\n", ValueKey));
69 
70  if( (Error = RegQueryValueEx( ValueKey, Value, NULL, NULL,
71  (LPBYTE)SubOut, &SubOutLen )) != ERROR_SUCCESS )
72  goto regerror;
73 
74  DH_DbgPrint(MID_TRACE,("Value %s has size %d\n", Value, SubOutLen));
75 
76  if( !(SubOut = (CHAR*) malloc(SubOutLen)) )
77  goto regerror;
78 
79  if( (Error = RegQueryValueEx( ValueKey, Value, NULL, NULL,
80  (LPBYTE)SubOut, &SubOutLen )) != ERROR_SUCCESS )
81  goto regerror;
82 
83  DH_DbgPrint(MID_TRACE,("Value %s is %s\n", Value, SubOut));
84 
85  goto cleanup;
86 
87 regerror:
88  if( SubOut ) { free( SubOut ); SubOut = NULL; }
89 cleanup:
90  if( ValueKey && ValueKey != Root ) {
91  DH_DbgPrint(MID_TRACE,("Closing key %x\n", ValueKey));
92  RegCloseKey( ValueKey );
93  }
94 
95  DH_DbgPrint(MID_TRACE,("Returning %x with error %d\n", SubOut, Error));
96 
97  return SubOut;
98 }
99 
101  int i = 0;
102  PCHAR EnumKeyName =
103  "SYSTEM\\CurrentControlSet\\Control\\Class\\"
104  "{4D36E972-E325-11CE-BFC1-08002BE10318}";
105  PCHAR TargetKeyNameStart =
106  "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
107  PCHAR TargetKeyName = NULL;
108  PCHAR *EnumKeysLinkage = GetSubkeyNames( EnumKeyName, "\\Linkage" );
109  PCHAR *EnumKeysTop = GetSubkeyNames( EnumKeyName, "" );
110  PCHAR RootDevice = NULL;
111  HKEY EnumKey, OutKey = NULL;
113 
114  if( !EnumKeysLinkage || !EnumKeysTop ) goto cleanup;
115 
116  Error = RegOpenKey( HKEY_LOCAL_MACHINE, EnumKeyName, &EnumKey );
117 
118  if( Error ) goto cleanup;
119 
120  for( i = 0; EnumKeysLinkage[i]; i++ ) {
121  RootDevice = RegReadString
122  ( EnumKey, EnumKeysLinkage[i], "RootDevice" );
123 
124  if( RootDevice &&
125  !strcmp( RootDevice, Adapter->DhclientInfo.name ) ) {
126  TargetKeyName =
127  (CHAR*) malloc( strlen( TargetKeyNameStart ) +
128  strlen( RootDevice ) + 1);
129  if( !TargetKeyName ) goto cleanup;
130  sprintf( TargetKeyName, "%s%s",
131  TargetKeyNameStart, RootDevice );
132  Error = RegCreateKeyExA( HKEY_LOCAL_MACHINE, TargetKeyName, 0, NULL, 0, KEY_READ, NULL, &OutKey, NULL );
133  break;
134  } else {
135  free( RootDevice ); RootDevice = 0;
136  }
137  }
138 
139 cleanup:
140  if( RootDevice ) free( RootDevice );
141  if( EnumKeysLinkage ) free( EnumKeysLinkage );
142  if( EnumKeysTop ) free( EnumKeysTop );
143  if( TargetKeyName ) free( TargetKeyName );
144 
145  return OutKey;
146 }
147 
149  HKEY AdapterKey;
150  DWORD Error = ERROR_SUCCESS, DhcpEnabled, Length = sizeof(DWORD);
151 
152  Adapter->DhclientState.config = &Adapter->DhclientConfig;
153  strncpy(Adapter->DhclientInfo.name, (char*)Adapter->IfMib.bDescr,
154  sizeof(Adapter->DhclientInfo.name));
155 
156  AdapterKey = FindAdapterKey( Adapter );
157  if( AdapterKey )
158  {
159  Error = RegQueryValueEx(AdapterKey, "EnableDHCP", NULL, NULL, (LPBYTE)&DhcpEnabled, &Length);
160 
161  if (Error != ERROR_SUCCESS || Length != sizeof(DWORD))
162  DhcpEnabled = 1;
163 
164  CloseHandle(AdapterKey);
165  }
166  else
167  {
168  /* DHCP enabled by default */
169  DhcpEnabled = 1;
170  }
171 
172  if( !DhcpEnabled ) {
173  /* Non-automatic case */
174  DbgPrint("DHCPCSVC: Adapter Name: [%s] (static)\n", Adapter->DhclientInfo.name);
175 
176  Adapter->DhclientState.state = S_STATIC;
177  } else {
178  /* Automatic case */
179  DbgPrint("DHCPCSVC: Adapter Name: [%s] (dynamic)\n", Adapter->DhclientInfo.name);
180 
181  Adapter->DhclientInfo.client->state = S_INIT;
182  }
183 
184  return TRUE;
185 }
186 
187 void AdapterInit() {
188  WSAStartup(0x0101,&wsd);
189 
191 }
192 
193 int
195 {
196  if (IfEntry->dwOperStatus == IF_OPER_STATUS_CONNECTED ||
198  return 1;
199 
200  DH_DbgPrint(MID_TRACE,("Interface %d is down\n", IfEntry->dwIndex));
201  return 0;
202 }
203 
204 BOOL
206 {
207  struct protocol *proto;
208  PIP_ADAPTER_INFO AdapterInfo, Orig;
209  DWORD Size, Ret;
210  char *ZeroAddress = "0.0.0.0";
211 
213 
214  if (Adapter->DhclientInfo.client->state == S_BOUND && !proto)
215  return FALSE;
216 
217  if (Adapter->DhclientInfo.client->state != S_BOUND &&
218  Adapter->DhclientInfo.client->state != S_STATIC)
219  return FALSE;
220 
221  ApiUnlock();
222 
223  Orig = AdapterInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(IP_ADAPTER_INFO));
224  Size = sizeof(IP_ADAPTER_INFO);
225  if (!AdapterInfo)
226  {
227  ApiLock();
228  return FALSE;
229  }
230 
231  Ret = GetAdaptersInfo(AdapterInfo, &Size);
232  if (Ret == ERROR_BUFFER_OVERFLOW)
233  {
234  HeapFree(GetProcessHeap(), 0, AdapterInfo);
235  AdapterInfo = HeapAlloc(GetProcessHeap(), 0, Size);
236  if (!AdapterInfo)
237  {
238  ApiLock();
239  return FALSE;
240  }
241 
242  if (GetAdaptersInfo(AdapterInfo, &Size) != NO_ERROR)
243  {
244  ApiLock();
245  return FALSE;
246  }
247 
248  Orig = AdapterInfo;
249  for (; AdapterInfo != NULL; AdapterInfo = AdapterInfo->Next)
250  {
251  if (AdapterInfo->Index == IfEntry->dwIndex)
252  break;
253  }
254 
255  if (AdapterInfo == NULL)
256  {
257  HeapFree(GetProcessHeap(), 0, Orig);
258  ApiLock();
259  return FALSE;
260  }
261  }
262  else if (Ret != NO_ERROR)
263  {
264  HeapFree(GetProcessHeap(), 0, Orig);
265  ApiLock();
266  return FALSE;
267  }
268 
269  if (!strcmp(AdapterInfo->IpAddressList.IpAddress.String, ZeroAddress))
270  {
271  HeapFree(GetProcessHeap(), 0, Orig);
272  ApiLock();
273  return TRUE;
274  }
275  else
276  {
277  HeapFree(GetProcessHeap(), 0, Orig);
278  ApiLock();
279  return FALSE;
280  }
281 }
282 
283 /*
284  * XXX Figure out the way to bind a specific adapter to a socket.
285  */
288  DWORD Error, Size = sizeof(MIB_IFTABLE);
289  PDHCP_ADAPTER Adapter = NULL;
291  struct interface_info *ifi = NULL;
292  struct protocol *proto;
293  int i, AdapterCount = 0, Broadcast;
294 
295  /* FIXME: Kill this thread when the service is stopped */
296 
297  do {
298  DH_DbgPrint(MID_TRACE,("Getting Adapter List...\n"));
299 
300  while( (Error = GetIfTable(Table, &Size, 0 )) ==
302  DH_DbgPrint(MID_TRACE,("Error %d, New Buffer Size: %d\n", Error, Size));
303  free( Table );
304  Table = (PMIB_IFTABLE) malloc( Size );
305  }
306 
307  if( Error != NO_ERROR )
308  {
309  /* HACK: We are waiting until TCP/IP starts */
310  Sleep(2000);
311  continue;
312  }
313 
314  DH_DbgPrint(MID_TRACE,("Got Adapter List (%d entries)\n", Table->dwNumEntries));
315 
316  for( i = Table->dwNumEntries - 1; i >= 0; i-- ) {
317  DH_DbgPrint(MID_TRACE,("Getting adapter %d attributes\n",
318  Table->table[i].dwIndex));
319 
320  ApiLock();
321 
322  if ((Adapter = AdapterFindByHardwareAddress(Table->table[i].bPhysAddr, Table->table[i].dwPhysAddrLen)))
323  {
325 
326  /* This is an existing adapter */
327  if (InterfaceConnected(&Table->table[i])) {
328  /* We're still active so we stay in the list */
329  ifi = &Adapter->DhclientInfo;
330 
331  /* This is a hack because IP helper API sucks */
332  if (IsReconnectHackNeeded(Adapter, &Table->table[i]))
333  {
334  /* This handles a disconnect/reconnect */
335 
336  if (proto)
338  Adapter->DhclientInfo.client->state = S_INIT;
339 
340  /* These are already invalid since the media state change */
341  Adapter->RouterMib.dwForwardNextHop = 0;
342  Adapter->NteContext = 0;
343 
344  add_protocol(Adapter->DhclientInfo.name,
345  Adapter->DhclientInfo.rfdesc,
346  got_one, &Adapter->DhclientInfo);
347  state_init(&Adapter->DhclientInfo);
348 
350  }
351 
352  } else {
353  if (proto)
355 
356  /* We've lost our link so out we go */
357  RemoveEntryList(&Adapter->ListEntry);
358  free(Adapter);
359  }
360 
361  ApiUnlock();
362 
363  continue;
364  }
365 
366  ApiUnlock();
367 
368  Adapter = (DHCP_ADAPTER*) calloc( sizeof( DHCP_ADAPTER ) + Table->table[i].dwMtu, 1 );
369 
370  if( Adapter && Table->table[i].dwType == MIB_IF_TYPE_ETHERNET && InterfaceConnected(&Table->table[i])) {
371  memcpy( &Adapter->IfMib, &Table->table[i],
372  sizeof(Adapter->IfMib) );
373  Adapter->DhclientInfo.client = &Adapter->DhclientState;
374  Adapter->DhclientInfo.rbuf = Adapter->recv_buf;
375  Adapter->DhclientInfo.rbuf_max = Table->table[i].dwMtu;
376  Adapter->DhclientInfo.rbuf_len =
377  Adapter->DhclientInfo.rbuf_offset = 0;
378  memcpy(Adapter->DhclientInfo.hw_address.haddr,
379  Adapter->IfMib.bPhysAddr,
380  Adapter->IfMib.dwPhysAddrLen);
381  Adapter->DhclientInfo.hw_address.hlen = Adapter->IfMib.dwPhysAddrLen;
382 
383  /* I'm not sure where else to set this, but
384  some DHCP servers won't take a zero.
385  We checked the hardware type earlier in
386  the if statement. */
387  Adapter->DhclientInfo.hw_address.htype = HTYPE_ETHER;
388 
389  if( DhcpSocket == INVALID_SOCKET ) {
390  DhcpSocket =
391  Adapter->DhclientInfo.rfdesc =
392  Adapter->DhclientInfo.wfdesc =
394 
395  if (DhcpSocket != INVALID_SOCKET) {
396 
397  /* Allow broadcast on this socket */
398  Broadcast = 1;
400  SOL_SOCKET,
401  SO_BROADCAST,
402  (const char *)&Broadcast,
403  sizeof(Broadcast));
404 
405  Adapter->ListenAddr.sin_family = AF_INET;
406  Adapter->ListenAddr.sin_port = htons(LOCAL_PORT);
407  Adapter->BindStatus =
408  (bind( Adapter->DhclientInfo.rfdesc,
409  (struct sockaddr *)&Adapter->ListenAddr,
410  sizeof(Adapter->ListenAddr) ) == 0) ?
411  0 : WSAGetLastError();
412  } else {
413  error("socket() failed: %d\n", WSAGetLastError());
414  }
415  } else {
416  Adapter->DhclientInfo.rfdesc =
417  Adapter->DhclientInfo.wfdesc = DhcpSocket;
418  }
419 
420  Adapter->DhclientConfig.timeout = DHCP_PANIC_TIMEOUT;
421  Adapter->DhclientConfig.initial_interval = DHCP_DISCOVER_INTERVAL;
422  Adapter->DhclientConfig.retry_interval = DHCP_DISCOVER_INTERVAL;
423  Adapter->DhclientConfig.select_interval = 1;
424  Adapter->DhclientConfig.reboot_timeout = DHCP_REBOOT_TIMEOUT;
425  Adapter->DhclientConfig.backoff_cutoff = DHCP_BACKOFF_MAX;
426  Adapter->DhclientState.interval =
427  Adapter->DhclientConfig.retry_interval;
428 
429  if( PrepareAdapterForService( Adapter ) ) {
430  Adapter->DhclientInfo.next = ifi;
431  ifi = &Adapter->DhclientInfo;
432 
433  read_client_conf(&Adapter->DhclientInfo);
434 
435  if (Adapter->DhclientInfo.client->state == S_INIT)
436  {
437  add_protocol(Adapter->DhclientInfo.name,
438  Adapter->DhclientInfo.rfdesc,
439  got_one, &Adapter->DhclientInfo);
440 
441  state_init(&Adapter->DhclientInfo);
442  }
443 
444  ApiLock();
445  InsertTailList( &AdapterList, &Adapter->ListEntry );
446  AdapterCount++;
448  ApiUnlock();
449  } else { free( Adapter ); Adapter = 0; }
450  } else { free( Adapter ); Adapter = 0; }
451 
452  if( !Adapter )
453  DH_DbgPrint(MID_TRACE,("Adapter %d was rejected\n",
454  Table->table[i].dwIndex));
455  }
456 #if 0
458  if (Error != NO_ERROR)
459  break;
460 #else
461  Sleep(3000);
462 #endif
463  } while (TRUE);
464 
465  DbgPrint("DHCPCSVC: Adapter discovery thread is terminating! (Error: %d)\n", Error);
466 
467  if( Table ) free( Table );
468  return Error;
469 }
470 
472  HANDLE ThreadHandle, EventHandle;
473 
475  FALSE,
476  FALSE,
477  NULL);
478 
479  if (EventHandle == NULL)
480  return NULL;
481 
482  ThreadHandle = CreateThread(NULL,
483  0,
486  0,
487  NULL);
488 
489  if (ThreadHandle == NULL)
490  {
492  return NULL;
493  }
494 
495  CloseHandle(ThreadHandle);
496 
497  return EventHandle;
498 }
499 
500 void AdapterStop() {
501  PLIST_ENTRY ListEntry;
502  PDHCP_ADAPTER Adapter;
503  ApiLock();
504  while( !IsListEmpty( &AdapterList ) ) {
505  ListEntry = (PLIST_ENTRY)RemoveHeadList( &AdapterList );
506  Adapter = CONTAINING_RECORD( ListEntry, DHCP_ADAPTER, ListEntry );
507  free( Adapter );
508  }
509  ApiUnlock();
510  WSACleanup();
511 }
512 
513 PDHCP_ADAPTER AdapterFindIndex( unsigned int indx ) {
514  PDHCP_ADAPTER Adapter;
515  PLIST_ENTRY ListEntry;
516 
517  for( ListEntry = AdapterList.Flink;
518  ListEntry != &AdapterList;
519  ListEntry = ListEntry->Flink ) {
520  Adapter = CONTAINING_RECORD( ListEntry, DHCP_ADAPTER, ListEntry );
521  if( Adapter->IfMib.dwIndex == indx ) return Adapter;
522  }
523 
524  return NULL;
525 }
526 
528  PDHCP_ADAPTER Adapter;
529  PLIST_ENTRY ListEntry;
530 
531  for( ListEntry = AdapterList.Flink;
532  ListEntry != &AdapterList;
533  ListEntry = ListEntry->Flink ) {
534  Adapter = CONTAINING_RECORD( ListEntry, DHCP_ADAPTER, ListEntry );
535  if( !wcsicmp( Adapter->IfMib.wszName, name ) ) return Adapter;
536  }
537 
538  return NULL;
539 }
540 
542  PDHCP_ADAPTER Adapter;
543  PLIST_ENTRY ListEntry;
544 
545  for( ListEntry = AdapterList.Flink;
546  ListEntry != &AdapterList;
547  ListEntry = ListEntry->Flink ) {
548  Adapter = CONTAINING_RECORD( ListEntry, DHCP_ADAPTER, ListEntry );
549  if( ip == &Adapter->DhclientInfo ) return Adapter;
550  }
551 
552  return NULL;
553 }
554 
556  PDHCP_ADAPTER Adapter;
557  PLIST_ENTRY ListEntry;
558 
559  for(ListEntry = AdapterList.Flink;
560  ListEntry != &AdapterList;
561  ListEntry = ListEntry->Flink) {
562  Adapter = CONTAINING_RECORD( ListEntry, DHCP_ADAPTER, ListEntry );
563  if (Adapter->DhclientInfo.hw_address.hlen == hlen &&
564  !memcmp(Adapter->DhclientInfo.hw_address.haddr,
565  haddr,
566  hlen)) return Adapter;
567  }
568 
569  return NULL;
570 }
571 
573  if( IsListEmpty( &AdapterList ) ) return NULL; else {
574  return CONTAINING_RECORD
575  ( AdapterList.Flink, DHCP_ADAPTER, ListEntry );
576  }
577 }
578 
580 {
581  if( This->ListEntry.Flink == &AdapterList ) return NULL;
582  return CONTAINING_RECORD
583  ( This->ListEntry.Flink, DHCP_ADAPTER, ListEntry );
584 }
585 
587 
588 }
589 
591 }
struct _LIST_ENTRY * PLIST_ENTRY
#define CreateEvent
Definition: winbase.h:3562
#define RegQueryValueEx
Definition: winreg.h:524
unsigned int BindStatus
Definition: rosdhcp.h:75
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
signed char * PCHAR
Definition: retypes.h:7
PDHCP_ADAPTER AdapterGetNext(PDHCP_ADAPTER This)
Definition: adapter.c:579
Definition: dhcpd.h:175
static LIST_ENTRY AdapterList
Definition: adapter.c:4
ASMGENDATA Table[]
Definition: genincdata.c:61
WCHAR wszName[MAX_INTERFACE_NAME_LEN]
Definition: ifmib.h:37
#define TRUE
Definition: types.h:120
MIB_IFROW IfMib
Definition: rosdhcp.h:66
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define MID_TRACE
Definition: debug.h:15
#define HTYPE_ETHER
Definition: dhcp.h:85
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
#define error(str)
Definition: mkdosfs.c:1605
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ULONG NteContext
Definition: rosdhcp.h:70
int read_client_conf(struct interface_info *ifi)
Definition: util.c:106
#define DbgPrint
Definition: loader.c:25
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
#define DWORD
Definition: msvc.h:34
void AdapterInit()
Definition: adapter.c:187
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
char CHAR
Definition: xmlstorage.h:175
#define free
Definition: debug_ros.c:5
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
Definition: dhcpd.h:172
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
char String[4 *4]
Definition: iptypes.h:42
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
void got_one(struct protocol *l)
Definition: dispatch.c:195
static BOOL Append(LPWSTR *ppszText, DWORD *pdwTextLen, LPCWSTR pszAppendText, DWORD dwAppendLen)
Definition: text.c:25
#define DHCP_PANIC_TIMEOUT
Definition: rosdhcp.h:28
PCHAR RegReadString(HKEY Root, PCHAR Subkey, PCHAR Value)
Definition: adapter.c:56
#define SOL_SOCKET
Definition: winsock.h:398
#define InsertTailList(ListHead, Entry)
#define NO_ERROR
Definition: dderror.h:5
struct _IP_ADAPTER_INFO IP_ADAPTER_INFO
PDHCP_ADAPTER AdapterFindName(const WCHAR *name)
Definition: adapter.c:527
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define DHCP_DISCOVER_INTERVAL
Definition: rosdhcp.h:26
void remove_protocol(struct protocol *proto)
Definition: dispatch.c:360
void if_register_send(struct interface_info *ip)
Definition: adapter.c:586
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define SO_BROADCAST
Definition: winsock.h:183
unsigned char u_int8_t
Definition: rosdhcp.h:33
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
#define DH_DbgPrint(_t_, _x_)
Definition: debug.h:49
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define DHCP_REBOOT_TIMEOUT
Definition: rosdhcp.h:27
MIB_IPFORWARDROW RouterMib
Definition: rosdhcp.h:67
PDHCP_ADAPTER AdapterFindInfo(struct interface_info *ip)
Definition: adapter.c:541
struct client_config DhclientConfig
Definition: rosdhcp.h:73
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define PCHAR
Definition: match.c:90
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
root entry for file system trees
Definition: entries.h:148
struct protocol * find_protocol_by_adapter(struct interface_info *info)
Definition: dispatch.c:413
#define RegEnumKey
Definition: winreg.h:509
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD dwForwardNextHop
Definition: ipmib.h:74
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define INVALID_SOCKET
Definition: winsock.h:332
Definition: dhcpd.h:61
void add_protocol(char *name, int fd, void(*handler)(struct protocol *), void *local)
Definition: dispatch.c:343
HKEY FindAdapterKey(PDHCP_ADAPTER Adapter)
Definition: adapter.c:100
UCHAR bPhysAddr[MAXLEN_PHYSADDR]
Definition: ifmib.h:43
SOCKET DhcpSocket
Definition: adapter.c:3
struct _MIB_IFTABLE MIB_IFTABLE
#define MIB_IF_TYPE_ETHERNET
Definition: ipifcons.h:223
HANDLE StartAdapterDiscovery(VOID)
Definition: adapter.c:471
PVOID HANDLE
Definition: typedefs.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
void if_register_receive(struct interface_info *ip)
Definition: adapter.c:590
BOOL Error
Definition: chkdsk.c:66
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
int InterfaceConnected(const MIB_IFROW *IfEntry)
Definition: adapter.c:194
BYTE bDescr[MAXLEN_IFDESCR]
Definition: ifmib.h:60
PCHAR * GetSubkeyNames(PCHAR MainKeyName, PCHAR Append)
Definition: adapter.c:7
PDHCP_ADAPTER AdapterFindIndex(unsigned int indx)
Definition: adapter.c:513
struct interface_info DhclientInfo
Definition: rosdhcp.h:71
DWORD dwPhysAddrLen
Definition: ifmib.h:42
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: typedefs.h:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define WINAPI
Definition: msvc.h:20
#define wcsicmp
Definition: string.h:1152
Definition: cmtypes.h:239
struct client_state DhclientState
Definition: rosdhcp.h:72
DWORD WINAPI NotifyAddrChange(PHANDLE Handle, LPOVERLAPPED overlapped)
struct _MIB_IFTABLE * PMIB_IFTABLE
PDHCP_ADAPTER AdapterFindByHardwareAddress(u_int8_t haddr[16], u_int8_t hlen)
Definition: adapter.c:555
void AdapterStop()
Definition: adapter.c:500
LIST_ENTRY ListEntry
Definition: rosdhcp.h:65
PDHCP_ADAPTER AdapterGetFirst()
Definition: adapter.c:572
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define DHCP_BACKOFF_MAX
Definition: rosdhcp.h:29
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
Definition: name.c:36
#define calloc
Definition: rosglue.h:14
void state_init(void *ipp)
Definition: dhclient.c:218
#define AF_INET
Definition: tcpip.h:117
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * cleanup(char *str)
Definition: wpickclick.c:99
#define malloc
Definition: debug_ros.c:4
VOID ApiUnlock()
Definition: api.c:26
UINT_PTR SOCKET
Definition: winsock.h:47
DWORD dwIndex
Definition: ifmib.h:38
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1032
HANDLE AdapterStateChangedEvent
Definition: dispatch.c:51
BOOL PrepareAdapterForService(PDHCP_ADAPTER Adapter)
Definition: adapter.c:148
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
#define htons(x)
Definition: module.h:213
#define RegOpenKey
Definition: winreg.h:519
DWORD WINAPI AdapterDiscoveryThread(LPVOID Context)
Definition: adapter.c:286
#define SOCK_DGRAM
Definition: winsock.h:336
static WSADATA wsd
Definition: adapter.c:5
#define HeapFree(x, y, z)
Definition: compat.h:394
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
VOID ApiLock()
Definition: api.c:22
struct sockaddr_in ListenAddr
Definition: rosdhcp.h:74
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:63
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
BOOL IsReconnectHackNeeded(PDHCP_ADAPTER Adapter, const MIB_IFROW *IfEntry)
Definition: adapter.c:205
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:855
unsigned char recv_buf[1]
Definition: rosdhcp.h:76