Watt-32 tcp/ip  2.2 dev-rel.10
packet32.c
1 /*
2  * Copyright (c) 1999 - 2003
3  * Politecnico di Torino. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that: (1) source code distributions
7  * retain the above copyright notice and this paragraph in its entirety, (2)
8  * distributions including binary code include the above copyright notice and
9  * this paragraph in its entirety in the documentation or other materials
10  * provided with the distribution, and (3) all advertising materials mentioning
11  * features or use of this software display the following acknowledgement:
12  * ``This product includes software developed by the Politecnico
13  * di Torino, and its contributors.'' Neither the name of
14  * the University nor the names of its contributors may be used to endorse
15  * or promote products derived from this software without specific prior
16  * written permission.
17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20  */
21 
22  /*
23  * Changes for Watt-32:
24  * - Merged Packet32.c and AdInfo.c into one.
25  * - Rewritten for ASCII function (no Unicode).
26  * - Lots of simplifications.
27  */
28 #include "wattcp.h"
29 
30 #if defined(WIN32) /* Rest of file */
31 
32 #include <windows.h>
33 #include <windowsx.h> /* GlobalAllocPtr() */
34 #include <winsvc.h> /* SERVICE_ALL_ACCESS... */
35 #include <sys/socket.h> /* AF_INET etc. */
36 #include <process.h>
37 
38 #include "misc.h"
39 #include "timer.h"
40 #include "profile.h"
41 #include "strings.h"
42 #include "pcconfig.h"
43 #include "pcdbug.h"
44 #include "pcpkt.h"
45 #include "netaddr.h"
46 #include "ntddndis.h"
47 #include "cpumodel.h"
48 #include "packet32.h"
49 #include "winpkt.h"
50 #include "win_dll.h"
51 
55 static char npf_drv_ver[64] = "Unknown npf.sys version";
56 
60 static const char NPF_service_name[] = "NPF";
61 static const char NPF_service_descr[] = "Netgroup Packet Filter";
62 static const char NPF_registry_location[] = "SYSTEM\\CurrentControlSet\\Services\\NPF";
63 static const char NPF_driver_path[] = "system32\\drivers\\npf.sys";
64 
65 static const struct search_list serv_stat[] = {
66  { SERVICE_CONTINUE_PENDING, "SERVICE_CONTINUE_PENDING" },
67  { SERVICE_PAUSE_PENDING, "SERVICE_PAUSE_PENDING" },
68  { SERVICE_PAUSED, "SERVICE_PAUSED" },
69  { SERVICE_RUNNING, "SERVICE_RUNNING" },
70  { SERVICE_START_PENDING, "SERVICE_START_PENDING" },
71  { SERVICE_STOP_PENDING, "SERVICE_STOP_PENDING" },
72  { SERVICE_STOPPED, "SERVICE_STOPPED" },
73  };
74 
79 static ADAPTER_INFO *adapters_list = NULL;
80 
86 static HANDLE adapters_mutex = INVALID_HANDLE_VALUE;
87 
92 static BOOL use_wanpacket = FALSE;
93 
94 static BOOL PopulateAdaptersInfoList (void);
95 static BOOL FreeAdaptersInfoList (void);
96 
97 #if defined(USE_DEBUG)
98 
109  static void PacketDumpRegistryKey (const char *key_name, const char *file_name)
110  {
111  char command[256];
112 
113  /* Let regedit do the dirty work for us
114  */
115  SNPRINTF (command, sizeof(command), "regedit /e %s %s", file_name, key_name);
116  system (command);
117  }
118 #endif
119 
123 BOOL PacketInitModule (void)
124 {
125  const struct ADAPTER_INFO *ai;
126  BOOL rc;
127 
128  winpkt_trace_func = "PacketInitModule";
129  WINPKT_TRACE (("\n"));
130 
131 #if defined(USE_DEBUG)
132  if (winpkt_trace_level >= 3 && !_watt_is_win9x)
133  {
134  /* dump a bunch of registry keys
135  */
136  PacketDumpRegistryKey (
137  "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet"
138  "\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}",
139  "adapters.reg");
140  PacketDumpRegistryKey ("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet"
141  "\\Services\\Tcpip", "tcpip.reg");
142  PacketDumpRegistryKey ("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet"
143  "\\Services\\NPF", "npf.reg");
144  PacketDumpRegistryKey ("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet"
145  "\\Services", "services.reg");
146  }
147 #endif
148 
149  /* Create the mutex that will protect the adapter information list
150  */
151  adapters_mutex = CreateMutex (NULL, FALSE, NULL);
152 
153  /* Retrieve NPF.sys version information from the file.
154  * \todo: Should maybe use an absolute path: "%SystemRoot%\system32\drivers\npf.sys" ?
155  * Or we can assume %SystemRoot% is always in %PATH?
156  */
157  rc = GetFileVersion (NPF_driver_path, npf_drv_ver, sizeof(npf_drv_ver));
158 
159  WINPKT_TRACE (("GetFileVersion(): rc=%d, npf_drv_ver=\"%s\"\n", rc, npf_drv_ver));
160 
161 #if 0
162  /* We probably failed above. NPF.SYS is hidden from non-admin users on Win-Vista+.
163  */
164  if (_watt_os_ver >= 0x0600)
165  ;
166 #endif
167 
168  /* Populate the 'adapters_list' list.
169  */
170  rc = PopulateAdaptersInfoList();
171 
172  winpkt_trace_func = "PacketInitModule";
173  WINPKT_TRACE (("Known WinPcap adapters:\n"));
174 
175  for (ai = PacketGetAdInfo(); ai; ai = ai->Next)
176  {
177  winpkt_trace_func = "PacketInitModule";
178 #if 0
179  WINPKT_TRACE (("%s, `%s'\n", ai->Name, ai->Description));
180 #else
181  WINPKT_TRACE (("%s\n", ai->Name));
182 #endif
183  }
184  WINPKT_TRACE (("rc %d\n", rc));
185 
186  /* Check if we loaded WanPacket.dll okay. We don't care if it fails (since
187  * it's not critical for Watt-32/Win. These 'p_' func-ptr are et in win_dll.c
188  */
189  use_wanpacket = (p_WanPacketSetBpfFilter && p_WanPacketOpenAdapter &&
190  p_WanPacketCloseAdapter && p_WanPacketSetBufferSize &&
191  p_WanPacketReceivePacket && p_WanPacketSetMinToCopy &&
192  p_WanPacketGetStats && p_WanPacketSetReadTimeout &&
193  p_WanPacketSetMode && p_WanPacketGetReadEvent &&
194  p_WanPacketTestAdapter);
195  return (rc);
196 }
197 
209 static BOOL PacketSetMaxLookaheadsize (const ADAPTER *AdapterObject)
210 {
211  struct {
212  PACKET_OID_DATA oidData;
213  DWORD filler;
214  } oid;
215  BOOL rc;
216 
217  winpkt_trace_func = "PacketSetMaxLookaheadsize";
218 
219  /* Set the size of the lookahead buffer to the maximum available
220  * by the the NIC driver.
221  */
222  memset (&oid, 0, sizeof(oid));
223  oid.oidData.Oid = OID_GEN_MAXIMUM_LOOKAHEAD;
224  oid.oidData.Length = sizeof(oid.filler);
225  rc = PacketRequest (AdapterObject, FALSE, &oid.oidData);
226 
227  winpkt_trace_func = "PacketSetMaxLookaheadsize";
228  WINPKT_TRACE (("lookahead %lu, rc %d; %s\n",
229  *(DWORD*)&oid.oidData, rc,
230  !rc ? win_strerror(GetLastError()) : "okay"));
231 
232  memset (&oid, 0, sizeof(oid));
233  oid.oidData.Oid = OID_GEN_CURRENT_LOOKAHEAD;
234  oid.oidData.Length = sizeof(oid.filler);
235  rc = PacketRequest (AdapterObject, TRUE, &oid.oidData);
236 
237  winpkt_trace_func = "PacketSetMaxLookaheadsize";
238  WINPKT_TRACE (("rc %d; %s\n",
239  rc, !rc ? win_strerror(GetLastError()) : "okay"));
240  return (rc);
241 }
242 
257 static BOOL PacketSetReadEvt3xx (ADAPTER *AdapterObject)
258 {
259  DWORD BytesReturned;
260  char EventName[40];
261  WCHAR EventNameU[20];
262 
263  winpkt_trace_func = "PacketSetReadEvt3xx";
264 
265  /* retrieve the Unicode name of the shared event from the driver
266  */
267  memset (&EventNameU, 0, sizeof(EventNameU));
268  if (!DeviceIoControl(AdapterObject->hFile, pBIOCEVNAME, NULL, 0,
269  EventNameU, sizeof(EventNameU), &BytesReturned, NULL))
270  {
271  WINPKT_TRACE (("error retrieving the event-name from the kernel\n"));
272  return (FALSE);
273  }
274 
275  /* this tells the terminal service to retrieve the event from the global
276  * namespace
277  */
278  SNPRINTF (EventName, sizeof(EventName), "Global\\%.13S", EventNameU);
279  WINPKT_TRACE ((" event-name %s\n", EventName));
280 
281  /* open the shared event
282  */
283  AdapterObject->ReadEvent = CreateEventA (NULL, TRUE, FALSE, EventName);
284 
285  /* On Win-NT4 "Global\" is not automatically ignored: try to use
286  * simply the event name.
287  */
288  if (GetLastError() != ERROR_ALREADY_EXISTS)
289  {
290  if (AdapterObject->ReadEvent != INVALID_HANDLE_VALUE)
291  CloseHandle (AdapterObject->ReadEvent);
292 
293  /* open the shared event */
294  AdapterObject->ReadEvent = CreateEventA (NULL, TRUE, FALSE, EventName+7); /* skip "Global\" */
295  }
296 
297  if (AdapterObject->ReadEvent == INVALID_HANDLE_VALUE ||
298  GetLastError() != ERROR_ALREADY_EXISTS)
299  {
300  WINPKT_TRACE (("error retrieving the event from the kernel\n"));
301  return (FALSE);
302  }
303 
304  AdapterObject->ReadTimeOut = 0; /* block until something received */
305  WINPKT_TRACE (("okay\n"));
306  return (TRUE);
307 }
308 
309 static BOOL PacketSetReadEvt4xx (ADAPTER *AdapterObject)
310 {
311  DWORD BytesReturned;
312  HANDLE hEvent;
313 
314  winpkt_trace_func = "PacketSetReadEvt4xx";
315 
316  if (AdapterObject->ReadEvent)
317  {
318  WINPKT_TRACE (("error\n"));
319  SetLastError (ERROR_INVALID_FUNCTION);
320  return FALSE;
321  }
322 
323  hEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
324  if (!hEvent)
325  {
326  WINPKT_TRACE (("error creating event\n"));
327  return FALSE;
328  }
329 
330  if (!DeviceIoControl(AdapterObject->hFile, pBIOCSETEVENTHANDLE, &hEvent,
331  sizeof(hEvent), NULL, 0, &BytesReturned, NULL))
332  {
333  WINPKT_TRACE (("error getting event-handle\n"));
334  return (FALSE);
335  }
336 
337  WINPKT_TRACE (("event-handle %lu\n", HandleToUlong(hEvent)));
338 
339  AdapterObject->ReadEvent = hEvent;
340  AdapterObject->ReadTimeOut = 0;
341  WINPKT_TRACE (("okay\n"));
342  return (TRUE);
343 }
344 
345 static BOOL PacketSetReadEvt (ADAPTER *AdapterObject)
346 {
347  if (npf_drv_ver[0] == '3')
348  return PacketSetReadEvt3xx (AdapterObject);
349  return PacketSetReadEvt4xx (AdapterObject);
350 }
351 
363 static BOOL PacketInstallDriver (SC_HANDLE ascmHandle, SC_HANDLE *srvHandle)
364 {
365  BOOL result = FALSE;
366  DWORD error = 0UL;
367 
368  winpkt_trace_func = "PacketInstallDriver";
369  WINPKT_TRACE (("\n"));
370 
371  *srvHandle = CreateServiceA (ascmHandle,
372  NPF_service_name,
373  NPF_service_descr,
374  SERVICE_ALL_ACCESS,
375  SERVICE_KERNEL_DRIVER,
376  SERVICE_DEMAND_START,
377  SERVICE_ERROR_NORMAL,
378  NPF_driver_path, NULL, NULL,
379  NULL, NULL, NULL);
380  if (!*srvHandle)
381  {
382  if (GetLastError() == ERROR_SERVICE_EXISTS)
383  {
384  /* npf.sys already exists */
385  result = TRUE;
386  }
387  }
388  else
389  {
390  /* Created service for npf.sys */
391  result = TRUE;
392  }
393 
394  if (result && *srvHandle)
395  CloseServiceHandle (*srvHandle);
396 
397  if (!result)
398  {
399  error = GetLastError();
400  if (error != ERROR_FILE_NOT_FOUND)
401  WINPKT_TRACE (("failed; %s\n", win_strerror(error)));
402  }
403  else
404  WINPKT_TRACE (("okay\n"));
405 
406  SetLastError (error);
407  return (result);
408 }
409 
424 static ADAPTER *PacketOpenAdapterNPF (const char *AdapterName)
425 {
426  ADAPTER *lpAdapter;
427  BOOL QuerySStat, Result;
428  DWORD error, KeyRes;
429  SC_HANDLE svcHandle = NULL;
430  HKEY PathKey;
431  char SymbolicLink[128], *npf;
432  SERVICE_STATUS SStat;
433  SC_HANDLE scmHandle, srvHandle;
434 
435  winpkt_trace_func = "PacketOpenAdapterNPF";
436  WINPKT_TRACE (("\n"));
437 
438  scmHandle = OpenSCManager (NULL, NULL, GENERIC_READ);
439  if (!scmHandle)
440  {
441  error = GetLastError();
442  WINPKT_TRACE (("OpenSCManager failed; %s\n", win_strerror(error)));
443  }
444  else
445  {
446  /* Check if the NPF registry key is already present.
447  * This means that the driver is already installed and that
448  * we don't need to call PacketInstallDriver
449  */
450  KeyRes = RegOpenKeyExA (HKEY_LOCAL_MACHINE, NPF_registry_location,
451  0, KEY_READ, &PathKey);
452  if (KeyRes != ERROR_SUCCESS)
453  {
454  Result = PacketInstallDriver (scmHandle, &svcHandle);
455  }
456  else
457  {
458  Result = TRUE;
459  RegCloseKey (PathKey);
460  }
461 
462  winpkt_trace_func = "PacketOpenAdapterNPF";
463 
464  if (Result)
465  {
466  srvHandle = OpenServiceA (scmHandle, NPF_service_name,
467  SERVICE_START | SERVICE_QUERY_STATUS);
468  if (srvHandle)
469  {
470  QuerySStat = QueryServiceStatus (srvHandle, &SStat);
471 
472  WINPKT_TRACE (("%s\n", list_lookup (SStat.dwCurrentState, serv_stat, DIM(serv_stat))));
473 
474  if (!QuerySStat || SStat.dwCurrentState != SERVICE_RUNNING)
475  {
476  WINPKT_TRACE (("Calling startservice\n"));
477  if (!StartService (srvHandle, 0, NULL))
478  {
479  error = GetLastError();
480  if (error != ERROR_SERVICE_ALREADY_RUNNING &&
481  error != ERROR_ALREADY_EXISTS)
482  {
483  error = GetLastError();
484  CloseServiceHandle (scmHandle);
485  WINPKT_TRACE (("StartService failed; %s\n",
486  win_strerror(error)));
487  SetLastError (error);
488  return (NULL);
489  }
490  }
491  }
492  CloseServiceHandle (srvHandle);
493  srvHandle = NULL;
494  }
495  else
496  {
497  error = GetLastError();
498  WINPKT_TRACE (("OpenService failed; %s\n", win_strerror(error)));
499  SetLastError (error);
500  }
501  }
502  else /* Registry key not found or PacketInstallDriver() failed */
503  {
504  if (KeyRes != ERROR_SUCCESS)
505  Result = PacketInstallDriver (scmHandle, &svcHandle);
506  else Result = TRUE;
507 
508  winpkt_trace_func = "PacketOpenAdapterNPF";
509 
510  if (Result)
511  {
512  srvHandle = OpenServiceA (scmHandle, NPF_service_name, SERVICE_START);
513  if (srvHandle)
514  {
515  QuerySStat = QueryServiceStatus (srvHandle, &SStat);
516 
517  WINPKT_TRACE (("%s\n", list_lookup (SStat.dwCurrentState, serv_stat, DIM(serv_stat))));
518 
519  if (!QuerySStat || SStat.dwCurrentState != SERVICE_RUNNING)
520  {
521  WINPKT_TRACE (("Calling startservice\n"));
522 
523  if (StartService (srvHandle, 0, NULL) == 0)
524  {
525  error = GetLastError();
526  if (error != ERROR_SERVICE_ALREADY_RUNNING &&
527  error != ERROR_ALREADY_EXISTS)
528  {
529  if (scmHandle)
530  CloseServiceHandle (scmHandle);
531  WINPKT_TRACE (("StartService failed; %s\n",
532  win_strerror(error)));
533  SetLastError (error);
534  return (NULL);
535  }
536  }
537  }
538  CloseServiceHandle (srvHandle);
539  }
540  else
541  {
542  error = GetLastError();
543  WINPKT_TRACE (("OpenService failed; %s", win_strerror(error)));
544  SetLastError (error);
545  }
546  }
547  }
548  } /* OpenSCManager() */
549 
550  if (scmHandle)
551  CloseServiceHandle (scmHandle);
552 
553  lpAdapter = GlobalAllocPtr (GMEM_MOVEABLE | GMEM_ZEROINIT,
554  sizeof(*lpAdapter));
555  if (!lpAdapter)
556  {
557  WINPKT_TRACE (("Failed to allocate the adapter structure\n"));
558  return (NULL);
559  }
560 
561  /* skip "\Device" and create a symlink name
562  */
563  npf = strstr (AdapterName, "\\NPF_");
564  SNPRINTF (SymbolicLink, sizeof(SymbolicLink), "\\\\.\\%s", npf);
565 
566  /* try if it is possible to open the adapter immediately
567  */
568  lpAdapter->hFile = CreateFileA (SymbolicLink, GENERIC_WRITE | GENERIC_READ,
569  0, NULL, OPEN_EXISTING, 0, 0);
570 
571  if (lpAdapter->hFile != INVALID_HANDLE_VALUE)
572  {
573  if (!PacketSetReadEvt(lpAdapter))
574  {
575  error = GetLastError();
576  (void) GlobalFreePtr (lpAdapter);
577  WINPKT_TRACE (("failed; %s\n", win_strerror(error)));
578  SetLastError (error);
579  return (NULL);
580  }
581 
582  /* Success!
583  */
584  PacketSetMaxLookaheadsize (lpAdapter);
585  winpkt_trace_func = "PacketOpenAdapterNPF";
586  return (lpAdapter);
587  }
588 
589  error = GetLastError();
590  (void) GlobalFreePtr (lpAdapter);
591  WINPKT_TRACE (("CreateFileA (%s) failed; %s\n", SymbolicLink, win_strerror(error)));
592  SetLastError (error);
593  return (NULL);
594 }
595 
599 const char *PacketGetDriverVersion (void)
600 {
601  return (npf_drv_ver);
602 }
603 
604 #ifdef NOT_NEEDED
605 
616 BOOL PacketStopDriver (void)
617 {
618  SC_HANDLE scmHandle, schService;
619  BOOL rc = FALSE;
620 
621  winpkt_trace_func = "PacketStopDriver";
622 
623  scmHandle = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
624  if (scmHandle)
625  {
626  schService = OpenService (scmHandle, NPF_service_name, SERVICE_ALL_ACCESS);
627  if (schService)
628  {
629  SERVICE_STATUS status;
630 
631  rc = ControlService (schService, SERVICE_CONTROL_STOP, &status);
632  CloseServiceHandle (schService);
633  CloseServiceHandle (scmHandle);
634  }
635  }
636 
637  WINPKT_TRACE (("rc %d\n", rc));
638  return (rc);
639 }
640 #endif /* NOT_NEEDED */
641 
650 const ADAPTER *PacketOpenAdapter (const char *AdapterName)
651 {
652  ADAPTER *ad;
653 
654  winpkt_trace_func = "PacketOpenAdapter";
655  WINPKT_TRACE (("trying to open the adapter %s\n", AdapterName));
656 
657  ad = PacketOpenAdapterNPF (AdapterName);
658  if (ad)
659  ad->flags = INFO_FLAG_NDIS_ADAPTER;
660 
661  return (ad);
662 }
663 
673 BOOL PacketCloseAdapter (ADAPTER *adapter)
674 {
675  BOOL rc = FALSE;
676  int err = 0;
677 
678  winpkt_trace_func = "PacketCloseAdapter";
679 
680  if (!adapter || adapter->hFile == INVALID_HANDLE_VALUE)
681  {
682  WINPKT_TRACE (("adapter already closed\n"));
683  return (rc);
684  }
685 
686  WINPKT_TRACE (("adapter file 0x%" ADDR_FMT "\n", ADDR_CAST(adapter->hFile)));
687 
688  rc = CloseHandle (adapter->hFile);
689  adapter->hFile = INVALID_HANDLE_VALUE;
690  if (!rc)
691  err = GetLastError();
692 
693  SetEvent (adapter->ReadEvent); /* might already be set */
694  CloseHandle (adapter->ReadEvent);
695  (void) GlobalFreePtr (adapter);
696 
697  WINPKT_TRACE (("CloseHandle() rc %d: %s\n",
698  rc, !rc ? win_strerror(err) : "okay"));
699  return (rc);
700 
701 }
702 
706 BOOL PacketExitModule (void)
707 {
708  BOOL rc;
709 
710  winpkt_trace_func = "PacketExitModule";
711  WINPKT_TRACE (("\n"));
712 
713  FreeAdaptersInfoList();
714  ReleaseMutex (adapters_mutex);
715  rc = CloseHandle (adapters_mutex);
716  adapters_mutex = INVALID_HANDLE_VALUE;
717  return (rc);
718 }
719 
736 UINT MS_CDECL PacketReceivePacket (const ADAPTER *adapter, void *buf, UINT buf_len)
737 {
738  HANDLE handle;
739  UINT rc = 0;
740  DWORD recv = 0;
741 
742  if ((int)adapter->ReadTimeOut != -1)
743  WaitForSingleObject (adapter->ReadEvent,
744  adapter->ReadTimeOut == 0 ?
745  INFINITE : adapter->ReadTimeOut);
746 
747  handle = adapter->hFile;
748  if (handle == INVALID_HANDLE_VALUE)
749  SetLastError (ERROR_INVALID_HANDLE);
750  else rc = ReadFile (handle, buf, buf_len, &recv, NULL);
751 
752  winpkt_trace_func = "PacketReceivePacket";
753  WINPKT_TRACE (("recv %lu; rc: %d, %s\n",
754  recv, rc, rc == 0 ? win_strerror(GetLastError()) : "okay"));
755  return (UINT) recv;
756 }
757 
761 UINT PacketSendPacket (const ADAPTER *adapter, const void *buf, UINT len)
762 {
763  DWORD sent = 0UL;
764  int rc;
765 
766  TCP_CONSOLE_MSG (4, ("%s(%u): Calling WriteFile()\n", __FILE__, __LINE__));
767 
768  rc = WriteFile (adapter->hFile, buf, len, &sent, NULL);
769 
770  winpkt_trace_func = "PacketSendPacket";
771  WINPKT_TRACE (("rc %d; %s\n",
772  rc, rc == 0 ? win_strerror(GetLastError()) : "okay"));
773  return (sent);
774 }
775 
776 BOOL PacketGetMacAddress (const ADAPTER *adapter, void *mac)
777 {
778  struct {
779  PACKET_OID_DATA oidData;
780  mac_address mac;
781  } oid;
782 
783  memset (&oid, 0, sizeof(oid));
784 
785  switch (_pktdevclass)
786  {
787  case PDCLASS_ETHER:
788  oid.oidData.Oid = OID_802_3_PERMANENT_ADDRESS;
789  break;
790  case PDCLASS_TOKEN:
791  oid.oidData.Oid = OID_802_5_PERMANENT_ADDRESS;
792  break;
793  case PDCLASS_FDDI:
794  oid.oidData.Oid = OID_FDDI_LONG_PERMANENT_ADDR;
795  break;
796  case PDCLASS_ARCNET:
797  oid.oidData.Oid = OID_ARCNET_PERMANENT_ADDRESS;
798  break;
799 #if 0
800  case NdisMediumWan:
801  oid.oidData.Oid = OID_WAN_PERMANENT_ADDRESS;
802  break;
803  case NdisMediumWirelessWan:
804  oid.oidData.Oid = OID_WW_GEN_PERMANENT_ADDRESS;
805  break;
806 #endif
807  default:
808  return (FALSE);
809  }
810  oid.oidData.Length = sizeof(oid.mac);
811 
812  if (!PacketRequest(adapter, FALSE, &oid.oidData))
813  return (FALSE);
814  memcpy (mac, &oid.oidData.Data, sizeof(mac_address));
815  return (TRUE);
816 }
817 
839 BOOL PacketSetMinToCopy (const ADAPTER *AdapterObject, int nbytes)
840 {
841  DWORD BytesReturned;
842  BOOL rc;
843 
844  rc = DeviceIoControl (AdapterObject->hFile, pBIOCSMINTOCOPY, &nbytes,
845  4, NULL, 0, &BytesReturned, NULL);
846 
847  winpkt_trace_func = "PacketSetMinToCopy";
848  WINPKT_TRACE (("nbytes %d, rc %d; %s\n",
849  nbytes, rc, !rc ? win_strerror(GetLastError()) :
850  "okay"));
851  return (rc);
852 }
853 
899 BOOL PacketSetMode (const ADAPTER *AdapterObject, DWORD mode)
900 {
901  DWORD BytesReturned;
902  BOOL rc;
903 
904  rc = DeviceIoControl (AdapterObject->hFile, pBIOCSMODE, &mode,
905  sizeof(mode), NULL, 0, &BytesReturned, NULL);
906 
907  winpkt_trace_func = "PacketSetMode";
908  WINPKT_TRACE (("mode %lu, rc %d; %s\n",
909  mode, rc, !rc ? win_strerror(GetLastError()) : "okay"));
910  return (rc);
911 }
912 
922 BOOL PacketSetLoopbackBehavior (const ADAPTER *AdapterObject, UINT behavior)
923 {
924  DWORD BytesReturned;
925  BOOL rc;
926 
927  rc = DeviceIoControl (AdapterObject->hFile, pBIOCISETLOBBEH,
928  &behavior, sizeof(UINT), NULL,
929  0, &BytesReturned, NULL);
930 
931  winpkt_trace_func = "PacketSetLoopbackBehavior";
932  WINPKT_TRACE (("behaviour %u, rc %d; %s\n",
933  behavior, rc, !rc ? win_strerror(GetLastError()) : "okay"));
934  return (rc);
935 }
936 
964 HANDLE PacketGetReadEvent (const ADAPTER *AdapterObject)
965 {
966  return (AdapterObject->ReadEvent);
967 }
968 
986 BOOL PacketSetReadTimeout (ADAPTER *AdapterObject, int timeout)
987 {
988  DWORD BytesReturned;
989  int driverTimeout = -1; /* NPF return immediately if a pkt is ready */
990  BOOL rc;
991 
992  AdapterObject->ReadTimeOut = timeout;
993 
994  rc = DeviceIoControl (AdapterObject->hFile, pBIOCSRTIMEOUT, &driverTimeout,
995  sizeof(driverTimeout), NULL, 0, &BytesReturned, NULL);
996 
997  winpkt_trace_func = "PacketSetReadTimeout";
998  WINPKT_TRACE (("timeout %d, rc %d; %s\n",
999  timeout, rc, !rc ? win_strerror(GetLastError()) : "okay"));
1000  return (rc);
1001 }
1002 
1022 BOOL PacketSetBuff (const ADAPTER *AdapterObject, DWORD dim)
1023 {
1024  DWORD BytesReturned;
1025  BOOL rc;
1026 
1027  rc = DeviceIoControl (AdapterObject->hFile, pBIOCSETBUFFERSIZE,
1028  &dim, sizeof(dim), NULL, 0, &BytesReturned, NULL);
1029 
1030  winpkt_trace_func = "PacketSetBuff";
1031  WINPKT_TRACE (("size %lu, rc %d; %s\n",
1032  dim, rc, !rc ? win_strerror(GetLastError()) : "okay"));
1033  return (rc);
1034 }
1035 
1044 BOOL PacketGetStatsEx (const ADAPTER *AdapterObject, struct bpf_stat *stat)
1045 {
1046  struct bpf_stat tmp_stat;
1047  DWORD read;
1048  BOOL rc;
1049 
1050  memset (&tmp_stat, 0, sizeof(tmp_stat));
1051  rc = DeviceIoControl (AdapterObject->hFile,
1052  pBIOCGSTATS, NULL, 0, &tmp_stat, sizeof(tmp_stat),
1053  &read, NULL);
1054 
1055  winpkt_trace_func = "PacketGetStatsEx";
1056  WINPKT_TRACE (("read: %lu, rc %d; %s\n",
1057  read, rc, !rc ? win_strerror(GetLastError()) : "okay"));
1058 
1059  stat->bs_recv = tmp_stat.bs_recv;
1060  stat->bs_drop = tmp_stat.bs_drop;
1061  stat->ps_ifdrop = tmp_stat.ps_ifdrop;
1062  stat->bs_capt = tmp_stat.bs_capt;
1063  return (rc);
1064 }
1065 
1066 #if defined(USE_DEBUG)
1067 static const struct search_list oid_list[] = {
1068  { OID_802_11_ADD_KEY , "OID_802_11_ADD_KEY" },
1069  { OID_802_11_ADD_WEP , "OID_802_11_ADD_WEP" },
1070  { OID_802_11_ASSOCIATION_INFORMATION , "OID_802_11_ASSOCIATION_INFORMATION" },
1071  { OID_802_11_AUTHENTICATION_MODE , "OID_802_11_AUTHENTICATION_MODE" },
1072  { OID_802_11_BSSID , "OID_802_11_BSSID" },
1073  { OID_802_11_BSSID_LIST , "OID_802_11_BSSID_LIST" },
1074  { OID_802_11_BSSID_LIST_SCAN , "OID_802_11_BSSID_LIST_SCAN" },
1075  { OID_802_11_CAPABILITY , "OID_802_11_CAPABILITY" },
1076  { OID_802_11_CONFIGURATION , "OID_802_11_CONFIGURATION" },
1077  { OID_802_11_DESIRED_RATES , "OID_802_11_DESIRED_RATES" },
1078  { OID_802_11_DISASSOCIATE , "OID_802_11_DISASSOCIATE" },
1079  { OID_802_11_ENCRYPTION_STATUS , "OID_802_11_ENCRYPTION_STATUS" },
1080  { OID_802_11_FRAGMENTATION_THRESHOLD , "OID_802_11_FRAGMENTATION_THRESHOLD" },
1081  { OID_802_11_INFRASTRUCTURE_MODE , "OID_802_11_INFRASTRUCTURE_MODE" },
1082  { OID_802_11_NETWORK_TYPES_SUPPORTED , "OID_802_11_NETWORK_TYPES_SUPPORTED" },
1083  { OID_802_11_NETWORK_TYPE_IN_USE , "OID_802_11_NETWORK_TYPE_IN_USE" },
1084  { OID_802_11_NUMBER_OF_ANTENNAS , "OID_802_11_NUMBER_OF_ANTENNAS" },
1085  { OID_802_11_PMKID , "OID_802_11_PMKID" },
1086  { OID_802_11_POWER_MODE , "OID_802_11_POWER_MODE" },
1087  { OID_802_11_PRIVACY_FILTER , "OID_802_11_PRIVACY_FILTER" },
1088  { OID_802_11_RELOAD_DEFAULTS , "OID_802_11_RELOAD_DEFAULTS" },
1089  { OID_802_11_REMOVE_KEY , "OID_802_11_REMOVE_KEY" },
1090  { OID_802_11_REMOVE_WEP , "OID_802_11_REMOVE_WEP" },
1091  { OID_802_11_RSSI , "OID_802_11_RSSI" },
1092  { OID_802_11_RSSI_TRIGGER , "OID_802_11_RSSI_TRIGGER" },
1093  { OID_802_11_RTS_THRESHOLD , "OID_802_11_RTS_THRESHOLD" },
1094  { OID_802_11_RX_ANTENNA_SELECTED , "OID_802_11_RX_ANTENNA_SELECTED" },
1095  { OID_802_11_SSID , "OID_802_11_SSID" },
1096  { OID_802_11_STATISTICS , "OID_802_11_STATISTICS" },
1097  { OID_802_11_SUPPORTED_RATES , "OID_802_11_SUPPORTED_RATES" },
1098  { OID_802_11_TEST , "OID_802_11_TEST" },
1099  { OID_802_11_TX_ANTENNA_SELECTED , "OID_802_11_TX_ANTENNA_SELECTED" },
1100  { OID_802_11_TX_POWER_LEVEL , "OID_802_11_TX_POWER_LEVEL" },
1101  { OID_802_11_WEP_STATUS , "OID_802_11_WEP_STATUS" },
1102  { OID_802_3_CURRENT_ADDRESS , "OID_802_3_CURRENT_ADDRESS" },
1103  { OID_802_3_MAC_OPTIONS , "OID_802_3_MAC_OPTIONS" },
1104  { OID_802_3_MAXIMUM_LIST_SIZE , "OID_802_3_MAXIMUM_LIST_SIZE" },
1105  { OID_802_3_MULTICAST_LIST , "OID_802_3_MULTICAST_LIST" },
1106  { OID_802_3_PERMANENT_ADDRESS , "OID_802_3_PERMANENT_ADDRESS" },
1107  { OID_802_3_RCV_ERROR_ALIGNMENT , "OID_802_3_RCV_ERROR_ALIGNMENT" },
1108  { OID_802_3_RCV_OVERRUN , "OID_802_3_RCV_OVERRUN" },
1109  { OID_802_3_XMIT_DEFERRED , "OID_802_3_XMIT_DEFERRED" },
1110  { OID_802_3_XMIT_HEARTBEAT_FAILURE , "OID_802_3_XMIT_HEARTBEAT_FAILURE" },
1111  { OID_802_3_XMIT_LATE_COLLISIONS , "OID_802_3_XMIT_LATE_COLLISIONS" },
1112  { OID_802_3_XMIT_MAX_COLLISIONS , "OID_802_3_XMIT_MAX_COLLISIONS" },
1113  { OID_802_3_XMIT_MORE_COLLISIONS , "OID_802_3_XMIT_MORE_COLLISIONS" },
1114  { OID_802_3_XMIT_ONE_COLLISION , "OID_802_3_XMIT_ONE_COLLISION" },
1115  { OID_802_3_XMIT_TIMES_CRS_LOST , "OID_802_3_XMIT_TIMES_CRS_LOST" },
1116  { OID_802_3_XMIT_UNDERRUN , "OID_802_3_XMIT_UNDERRUN" },
1117  { OID_802_5_ABORT_DELIMETERS , "OID_802_5_ABORT_DELIMETERS" },
1118  { OID_802_5_AC_ERRORS , "OID_802_5_AC_ERRORS" },
1119  { OID_802_5_BURST_ERRORS , "OID_802_5_BURST_ERRORS" },
1120  { OID_802_5_CURRENT_ADDRESS , "OID_802_5_CURRENT_ADDRESS" },
1121  { OID_802_5_CURRENT_FUNCTIONAL , "OID_802_5_CURRENT_FUNCTIONAL" },
1122  { OID_802_5_CURRENT_GROUP , "OID_802_5_CURRENT_GROUP" },
1123  { OID_802_5_CURRENT_RING_STATE , "OID_802_5_CURRENT_RING_STATE" },
1124  { OID_802_5_CURRENT_RING_STATUS , "OID_802_5_CURRENT_RING_STATUS" },
1125  { OID_802_5_FRAME_COPIED_ERRORS , "OID_802_5_FRAME_COPIED_ERRORS" },
1126  { OID_802_5_FREQUENCY_ERRORS , "OID_802_5_FREQUENCY_ERRORS" },
1127  { OID_802_5_INTERNAL_ERRORS , "OID_802_5_INTERNAL_ERRORS" },
1128  { OID_802_5_LAST_OPEN_STATUS , "OID_802_5_LAST_OPEN_STATUS" },
1129  { OID_802_5_LINE_ERRORS , "OID_802_5_LINE_ERRORS" },
1130  { OID_802_5_LOST_FRAMES , "OID_802_5_LOST_FRAMES" },
1131  { OID_802_5_PERMANENT_ADDRESS , "OID_802_5_PERMANENT_ADDRESS" },
1132  { OID_802_5_TOKEN_ERRORS , "OID_802_5_TOKEN_ERRORS" },
1133  { OID_ARCNET_CURRENT_ADDRESS , "OID_ARCNET_CURRENT_ADDRESS" },
1134  { OID_ARCNET_PERMANENT_ADDRESS , "OID_ARCNET_PERMANENT_ADDRESS" },
1135  { OID_ARCNET_RECONFIGURATIONS , "OID_ARCNET_RECONFIGURATIONS" },
1136  { OID_ATM_ACQUIRE_ACCESS_NET_RESOURCES , "OID_ATM_ACQUIRE_ACCESS_NET_RESOURCES" },
1137  { OID_ATM_ALIGNMENT_REQUIRED , "OID_ATM_ALIGNMENT_REQUIRED" },
1138  { OID_ATM_ASSIGNED_VPI , "OID_ATM_ASSIGNED_VPI" },
1139  { OID_ATM_CELLS_HEC_ERROR , "OID_ATM_CELLS_HEC_ERROR" },
1140  { OID_ATM_DIGITAL_BROADCAST_VPIVCI , "OID_ATM_DIGITAL_BROADCAST_VPIVCI" },
1141  { OID_ATM_GET_NEAREST_FLOW , "OID_ATM_GET_NEAREST_FLOW" },
1142  { OID_ATM_HW_CURRENT_ADDRESS , "OID_ATM_HW_CURRENT_ADDRESS" },
1143  { OID_ATM_ILMI_VPIVCI , "OID_ATM_ILMI_VPIVCI" },
1144  { OID_ATM_MAX_AAL0_PACKET_SIZE , "OID_ATM_MAX_AAL0_PACKET_SIZE" },
1145  { OID_ATM_MAX_AAL1_PACKET_SIZE , "OID_ATM_MAX_AAL1_PACKET_SIZE" },
1146  { OID_ATM_MAX_AAL34_PACKET_SIZE , "OID_ATM_MAX_AAL34_PACKET_SIZE" },
1147  { OID_ATM_MAX_AAL5_PACKET_SIZE , "OID_ATM_MAX_AAL5_PACKET_SIZE" },
1148  { OID_ATM_MAX_ACTIVE_VCI_BITS , "OID_ATM_MAX_ACTIVE_VCI_BITS" },
1149  { OID_ATM_MAX_ACTIVE_VCS , "OID_ATM_MAX_ACTIVE_VCS" },
1150  { OID_ATM_MAX_ACTIVE_VPI_BITS , "OID_ATM_MAX_ACTIVE_VPI_BITS" },
1151  { OID_ATM_RCV_CELLS_DROPPED , "OID_ATM_RCV_CELLS_DROPPED" },
1152  { OID_ATM_RCV_CELLS_OK , "OID_ATM_RCV_CELLS_OK" },
1153  { OID_ATM_RCV_INVALID_VPI_VCI , "OID_ATM_RCV_INVALID_VPI_VCI" },
1154  { OID_ATM_RCV_REASSEMBLY_ERROR , "OID_ATM_RCV_REASSEMBLY_ERROR" },
1155  { OID_ATM_RELEASE_ACCESS_NET_RESOURCES , "OID_ATM_RELEASE_ACCESS_NET_RESOURCES" },
1156  { OID_ATM_SIGNALING_VPIVCI , "OID_ATM_SIGNALING_VPIVCI" },
1157  { OID_ATM_SUPPORTED_AAL_TYPES , "OID_ATM_SUPPORTED_AAL_TYPES" },
1158  { OID_ATM_SUPPORTED_SERVICE_CATEGORY , "OID_ATM_SUPPORTED_SERVICE_CATEGORY" },
1159  { OID_ATM_SUPPORTED_VC_RATES , "OID_ATM_SUPPORTED_VC_RATES" },
1160  { OID_ATM_XMIT_CELLS_OK , "OID_ATM_XMIT_CELLS_OK" },
1161  { OID_CO_ADDRESS_CHANGE , "OID_CO_ADDRESS_CHANGE" },
1162  { OID_CO_ADD_ADDRESS , "OID_CO_ADD_ADDRESS" },
1163  { OID_CO_ADD_PVC , "OID_CO_ADD_PVC" },
1164  { OID_CO_DELETE_ADDRESS , "OID_CO_DELETE_ADDRESS" },
1165  { OID_CO_DELETE_PVC , "OID_CO_DELETE_PVC" },
1166  { OID_CO_GET_ADDRESSES , "OID_CO_GET_ADDRESSES" },
1167  { OID_CO_GET_CALL_INFORMATION , "OID_CO_GET_CALL_INFORMATION" },
1168  { OID_CO_SIGNALING_DISABLED , "OID_CO_SIGNALING_DISABLED" },
1169  { OID_CO_SIGNALING_ENABLED , "OID_CO_SIGNALING_ENABLED" },
1170  { OID_FDDI_ATTACHMENT_TYPE , "OID_FDDI_ATTACHMENT_TYPE" },
1171  { OID_FDDI_DOWNSTREAM_NODE_LONG , "OID_FDDI_DOWNSTREAM_NODE_LONG" },
1172  { OID_FDDI_FRAMES_LOST , "OID_FDDI_FRAMES_LOST" },
1173  { OID_FDDI_FRAME_ERRORS , "OID_FDDI_FRAME_ERRORS" },
1174  { OID_FDDI_IF_ADMIN_STATUS , "OID_FDDI_IF_ADMIN_STATUS" },
1175  { OID_FDDI_IF_DESCR , "OID_FDDI_IF_DESCR" },
1176  { OID_FDDI_IF_IN_DISCARDS , "OID_FDDI_IF_IN_DISCARDS" },
1177  { OID_FDDI_IF_IN_ERRORS , "OID_FDDI_IF_IN_ERRORS" },
1178  { OID_FDDI_IF_IN_NUCAST_PKTS , "OID_FDDI_IF_IN_NUCAST_PKTS" },
1179  { OID_FDDI_IF_IN_OCTETS , "OID_FDDI_IF_IN_OCTETS" },
1180  { OID_FDDI_IF_IN_UCAST_PKTS , "OID_FDDI_IF_IN_UCAST_PKTS" },
1181  { OID_FDDI_IF_IN_UNKNOWN_PROTOS , "OID_FDDI_IF_IN_UNKNOWN_PROTOS" },
1182  { OID_FDDI_IF_LAST_CHANGE , "OID_FDDI_IF_LAST_CHANGE" },
1183  { OID_FDDI_IF_MTU , "OID_FDDI_IF_MTU" },
1184  { OID_FDDI_IF_OPER_STATUS , "OID_FDDI_IF_OPER_STATUS" },
1185  { OID_FDDI_IF_OUT_DISCARDS , "OID_FDDI_IF_OUT_DISCARDS" },
1186  { OID_FDDI_IF_OUT_ERRORS , "OID_FDDI_IF_OUT_ERRORS" },
1187  { OID_FDDI_IF_OUT_NUCAST_PKTS , "OID_FDDI_IF_OUT_NUCAST_PKTS" },
1188  { OID_FDDI_IF_OUT_OCTETS , "OID_FDDI_IF_OUT_OCTETS" },
1189  { OID_FDDI_IF_OUT_QLEN , "OID_FDDI_IF_OUT_QLEN" },
1190  { OID_FDDI_IF_OUT_UCAST_PKTS , "OID_FDDI_IF_OUT_UCAST_PKTS" },
1191  { OID_FDDI_IF_PHYS_ADDRESS , "OID_FDDI_IF_PHYS_ADDRESS" },
1192  { OID_FDDI_IF_SPECIFIC , "OID_FDDI_IF_SPECIFIC" },
1193  { OID_FDDI_IF_SPEED , "OID_FDDI_IF_SPEED" },
1194  { OID_FDDI_IF_TYPE , "OID_FDDI_IF_TYPE" },
1195  { OID_FDDI_LCONNECTION_STATE , "OID_FDDI_LCONNECTION_STATE" },
1196  { OID_FDDI_LCT_FAILURES , "OID_FDDI_LCT_FAILURES" },
1197  { OID_FDDI_LEM_REJECTS , "OID_FDDI_LEM_REJECTS" },
1198  { OID_FDDI_LONG_CURRENT_ADDR , "OID_FDDI_LONG_CURRENT_ADDR" },
1199  { OID_FDDI_LONG_MAX_LIST_SIZE , "OID_FDDI_LONG_MAX_LIST_SIZE" },
1200  { OID_FDDI_LONG_MULTICAST_LIST , "OID_FDDI_LONG_MULTICAST_LIST" },
1201  { OID_FDDI_LONG_PERMANENT_ADDR , "OID_FDDI_LONG_PERMANENT_ADDR" },
1202  { OID_FDDI_MAC_AVAILABLE_PATHS , "OID_FDDI_MAC_AVAILABLE_PATHS" },
1203  { OID_FDDI_MAC_BRIDGE_FUNCTIONS , "OID_FDDI_MAC_BRIDGE_FUNCTIONS" },
1204  { OID_FDDI_MAC_COPIED_CT , "OID_FDDI_MAC_COPIED_CT" },
1205  { OID_FDDI_MAC_CURRENT_PATH , "OID_FDDI_MAC_CURRENT_PATH" },
1206  { OID_FDDI_MAC_DA_FLAG , "OID_FDDI_MAC_DA_FLAG" },
1207  { OID_FDDI_MAC_DOWNSTREAM_NBR , "OID_FDDI_MAC_DOWNSTREAM_NBR" },
1208  { OID_FDDI_MAC_DOWNSTREAM_PORT_TYPE , "OID_FDDI_MAC_DOWNSTREAM_PORT_TYPE" },
1209  { OID_FDDI_MAC_DUP_ADDRESS_TEST , "OID_FDDI_MAC_DUP_ADDRESS_TEST" },
1210  { OID_FDDI_MAC_ERROR_CT , "OID_FDDI_MAC_ERROR_CT" },
1211  { OID_FDDI_MAC_FRAME_CT , "OID_FDDI_MAC_FRAME_CT" },
1212  { OID_FDDI_MAC_FRAME_ERROR_FLAG , "OID_FDDI_MAC_FRAME_ERROR_FLAG" },
1213  { OID_FDDI_MAC_FRAME_ERROR_RATIO , "OID_FDDI_MAC_FRAME_ERROR_RATIO" },
1214  { OID_FDDI_MAC_FRAME_ERROR_THRESHOLD , "OID_FDDI_MAC_FRAME_ERROR_THRESHOLD" },
1215  { OID_FDDI_MAC_FRAME_STATUS_FUNCTIONS , "OID_FDDI_MAC_FRAME_STATUS_FUNCTIONS" },
1216  { OID_FDDI_MAC_HARDWARE_PRESENT , "OID_FDDI_MAC_HARDWARE_PRESENT" },
1217  { OID_FDDI_MAC_INDEX , "OID_FDDI_MAC_INDEX" },
1218  { OID_FDDI_MAC_LATE_CT , "OID_FDDI_MAC_LATE_CT" },
1219  { OID_FDDI_MAC_LONG_GRP_ADDRESS , "OID_FDDI_MAC_LONG_GRP_ADDRESS" },
1220  { OID_FDDI_MAC_LOST_CT , "OID_FDDI_MAC_LOST_CT" },
1221  { OID_FDDI_MAC_MA_UNITDATA_AVAILABLE , "OID_FDDI_MAC_MA_UNITDATA_AVAILABLE" },
1222  { OID_FDDI_MAC_MA_UNITDATA_ENABLE , "OID_FDDI_MAC_MA_UNITDATA_ENABLE" },
1223  { OID_FDDI_MAC_NOT_COPIED_CT , "OID_FDDI_MAC_NOT_COPIED_CT" },
1224  { OID_FDDI_MAC_NOT_COPIED_FLAG , "OID_FDDI_MAC_NOT_COPIED_FLAG" },
1225  { OID_FDDI_MAC_NOT_COPIED_RATIO , "OID_FDDI_MAC_NOT_COPIED_RATIO" },
1226  { OID_FDDI_MAC_NOT_COPIED_THRESHOLD , "OID_FDDI_MAC_NOT_COPIED_THRESHOLD" },
1227  { OID_FDDI_MAC_OLD_DOWNSTREAM_NBR , "OID_FDDI_MAC_OLD_DOWNSTREAM_NBR" },
1228  { OID_FDDI_MAC_OLD_UPSTREAM_NBR , "OID_FDDI_MAC_OLD_UPSTREAM_NBR" },
1229  { OID_FDDI_MAC_REQUESTED_PATHS , "OID_FDDI_MAC_REQUESTED_PATHS" },
1230  { OID_FDDI_MAC_RING_OP_CT , "OID_FDDI_MAC_RING_OP_CT" },
1231  { OID_FDDI_MAC_RMT_STATE , "OID_FDDI_MAC_RMT_STATE" },
1232  { OID_FDDI_MAC_SHORT_GRP_ADDRESS , "OID_FDDI_MAC_SHORT_GRP_ADDRESS" },
1233  { OID_FDDI_MAC_SMT_ADDRESS , "OID_FDDI_MAC_SMT_ADDRESS" },
1234  { OID_FDDI_MAC_TOKEN_CT , "OID_FDDI_MAC_TOKEN_CT" },
1235  { OID_FDDI_MAC_TRANSMIT_CT , "OID_FDDI_MAC_TRANSMIT_CT" },
1236  { OID_FDDI_MAC_TVX_CAPABILITY , "OID_FDDI_MAC_TVX_CAPABILITY" },
1237  { OID_FDDI_MAC_TVX_EXPIRED_CT , "OID_FDDI_MAC_TVX_EXPIRED_CT" },
1238  { OID_FDDI_MAC_TVX_VALUE , "OID_FDDI_MAC_TVX_VALUE" },
1239  { OID_FDDI_MAC_T_MAX , "OID_FDDI_MAC_T_MAX" },
1240  { OID_FDDI_MAC_T_MAX_CAPABILITY , "OID_FDDI_MAC_T_MAX_CAPABILITY" },
1241  { OID_FDDI_MAC_T_NEG , "OID_FDDI_MAC_T_NEG" },
1242  { OID_FDDI_MAC_T_PRI0 , "OID_FDDI_MAC_T_PRI0" },
1243  { OID_FDDI_MAC_T_PRI1 , "OID_FDDI_MAC_T_PRI1" },
1244  { OID_FDDI_MAC_T_PRI2 , "OID_FDDI_MAC_T_PRI2" },
1245  { OID_FDDI_MAC_T_PRI3 , "OID_FDDI_MAC_T_PRI3" },
1246  { OID_FDDI_MAC_T_PRI4 , "OID_FDDI_MAC_T_PRI4" },
1247  { OID_FDDI_MAC_T_PRI5 , "OID_FDDI_MAC_T_PRI5" },
1248  { OID_FDDI_MAC_T_PRI6 , "OID_FDDI_MAC_T_PRI6" },
1249  { OID_FDDI_MAC_T_REQ , "OID_FDDI_MAC_T_REQ" },
1250  { OID_FDDI_MAC_UNDA_FLAG , "OID_FDDI_MAC_UNDA_FLAG" },
1251  { OID_FDDI_MAC_UPSTREAM_NBR , "OID_FDDI_MAC_UPSTREAM_NBR" },
1252  { OID_FDDI_PATH_CONFIGURATION , "OID_FDDI_PATH_CONFIGURATION" },
1253  { OID_FDDI_PATH_INDEX , "OID_FDDI_PATH_INDEX" },
1254  { OID_FDDI_PATH_MAX_T_REQ , "OID_FDDI_PATH_MAX_T_REQ" },
1255  { OID_FDDI_PATH_RING_LATENCY , "OID_FDDI_PATH_RING_LATENCY" },
1256  { OID_FDDI_PATH_SBA_AVAILABLE , "OID_FDDI_PATH_SBA_AVAILABLE" },
1257  { OID_FDDI_PATH_SBA_OVERHEAD , "OID_FDDI_PATH_SBA_OVERHEAD" },
1258  { OID_FDDI_PATH_SBA_PAYLOAD , "OID_FDDI_PATH_SBA_PAYLOAD" },
1259  { OID_FDDI_PATH_TRACE_STATUS , "OID_FDDI_PATH_TRACE_STATUS" },
1260  { OID_FDDI_PATH_TVX_LOWER_BOUND , "OID_FDDI_PATH_TVX_LOWER_BOUND" },
1261  { OID_FDDI_PATH_T_MAX_LOWER_BOUND , "OID_FDDI_PATH_T_MAX_LOWER_BOUND" },
1262  { OID_FDDI_PATH_T_R_MODE , "OID_FDDI_PATH_T_R_MODE" },
1263  { OID_FDDI_PORT_ACTION , "OID_FDDI_PORT_ACTION" },
1264  { OID_FDDI_PORT_AVAILABLE_PATHS , "OID_FDDI_PORT_AVAILABLE_PATHS" },
1265  { OID_FDDI_PORT_BS_FLAG , "OID_FDDI_PORT_BS_FLAG" },
1266  { OID_FDDI_PORT_CONNECTION_CAPABILITIES , "OID_FDDI_PORT_CONNECTION_CAPABILITIES" },
1267  { OID_FDDI_PORT_CONNECTION_POLICIES , "OID_FDDI_PORT_CONNECTION_POLICIES" },
1268  { OID_FDDI_PORT_CONNNECT_STATE , "OID_FDDI_PORT_CONNNECT_STATE" },
1269  { OID_FDDI_PORT_CURRENT_PATH , "OID_FDDI_PORT_CURRENT_PATH" },
1270  { OID_FDDI_PORT_EB_ERROR_CT , "OID_FDDI_PORT_EB_ERROR_CT" },
1271  { OID_FDDI_PORT_HARDWARE_PRESENT , "OID_FDDI_PORT_HARDWARE_PRESENT" },
1272  { OID_FDDI_PORT_INDEX , "OID_FDDI_PORT_INDEX" },
1273  { OID_FDDI_PORT_LCT_FAIL_CT , "OID_FDDI_PORT_LCT_FAIL_CT" },
1274  { OID_FDDI_PORT_LEM_CT , "OID_FDDI_PORT_LEM_CT" },
1275  { OID_FDDI_PORT_LEM_REJECT_CT , "OID_FDDI_PORT_LEM_REJECT_CT" },
1276  { OID_FDDI_PORT_LER_ALARM , "OID_FDDI_PORT_LER_ALARM" },
1277  { OID_FDDI_PORT_LER_CUTOFF , "OID_FDDI_PORT_LER_CUTOFF" },
1278  { OID_FDDI_PORT_LER_ESTIMATE , "OID_FDDI_PORT_LER_ESTIMATE" },
1279  { OID_FDDI_PORT_LER_FLAG , "OID_FDDI_PORT_LER_FLAG" },
1280  { OID_FDDI_PORT_MAC_INDICATED , "OID_FDDI_PORT_MAC_INDICATED" },
1281  { OID_FDDI_PORT_MAC_LOOP_TIME , "OID_FDDI_PORT_MAC_LOOP_TIME" },
1282  { OID_FDDI_PORT_MAC_PLACEMENT , "OID_FDDI_PORT_MAC_PLACEMENT" },
1283  { OID_FDDI_PORT_MAINT_LS , "OID_FDDI_PORT_MAINT_LS" },
1284  { OID_FDDI_PORT_MY_TYPE , "OID_FDDI_PORT_MY_TYPE" },
1285  { OID_FDDI_PORT_NEIGHBOR_TYPE , "OID_FDDI_PORT_NEIGHBOR_TYPE" },
1286  { OID_FDDI_PORT_PCM_STATE , "OID_FDDI_PORT_PCM_STATE" },
1287  { OID_FDDI_PORT_PC_LS , "OID_FDDI_PORT_PC_LS" },
1288  { OID_FDDI_PORT_PC_WITHHOLD , "OID_FDDI_PORT_PC_WITHHOLD" },
1289  { OID_FDDI_PORT_PMD_CLASS , "OID_FDDI_PORT_PMD_CLASS" },
1290  { OID_FDDI_PORT_REQUESTED_PATHS , "OID_FDDI_PORT_REQUESTED_PATHS" },
1291  { OID_FDDI_RING_MGT_STATE , "OID_FDDI_RING_MGT_STATE" },
1292  { OID_FDDI_SHORT_CURRENT_ADDR , "OID_FDDI_SHORT_CURRENT_ADDR" },
1293  { OID_FDDI_SHORT_MAX_LIST_SIZE , "OID_FDDI_SHORT_MAX_LIST_SIZE" },
1294  { OID_FDDI_SHORT_MULTICAST_LIST , "OID_FDDI_SHORT_MULTICAST_LIST" },
1295  { OID_FDDI_SHORT_PERMANENT_ADDR , "OID_FDDI_SHORT_PERMANENT_ADDR" },
1296  { OID_FDDI_SMT_AVAILABLE_PATHS , "OID_FDDI_SMT_AVAILABLE_PATHS" },
1297  { OID_FDDI_SMT_BYPASS_PRESENT , "OID_FDDI_SMT_BYPASS_PRESENT" },
1298  { OID_FDDI_SMT_CF_STATE , "OID_FDDI_SMT_CF_STATE" },
1299  { OID_FDDI_SMT_CONFIG_CAPABILITIES , "OID_FDDI_SMT_CONFIG_CAPABILITIES" },
1300  { OID_FDDI_SMT_CONFIG_POLICY , "OID_FDDI_SMT_CONFIG_POLICY" },
1301  { OID_FDDI_SMT_CONNECTION_POLICY , "OID_FDDI_SMT_CONNECTION_POLICY" },
1302  { OID_FDDI_SMT_ECM_STATE , "OID_FDDI_SMT_ECM_STATE" },
1303  { OID_FDDI_SMT_HI_VERSION_ID , "OID_FDDI_SMT_HI_VERSION_ID" },
1304  { OID_FDDI_SMT_HOLD_STATE , "OID_FDDI_SMT_HOLD_STATE" },
1305  { OID_FDDI_SMT_LAST_SET_STATION_ID , "OID_FDDI_SMT_LAST_SET_STATION_ID" },
1306  { OID_FDDI_SMT_LO_VERSION_ID , "OID_FDDI_SMT_LO_VERSION_ID" },
1307  { OID_FDDI_SMT_MAC_CT , "OID_FDDI_SMT_MAC_CT" },
1308  { OID_FDDI_SMT_MAC_INDEXES , "OID_FDDI_SMT_MAC_INDEXES" },
1309  { OID_FDDI_SMT_MANUFACTURER_DATA , "OID_FDDI_SMT_MANUFACTURER_DATA" },
1310  { OID_FDDI_SMT_MASTER_CT , "OID_FDDI_SMT_MASTER_CT" },
1311  { OID_FDDI_SMT_MIB_VERSION_ID , "OID_FDDI_SMT_MIB_VERSION_ID" },
1312  { OID_FDDI_SMT_MSG_TIME_STAMP , "OID_FDDI_SMT_MSG_TIME_STAMP" },
1313  { OID_FDDI_SMT_NON_MASTER_CT , "OID_FDDI_SMT_NON_MASTER_CT" },
1314  { OID_FDDI_SMT_OP_VERSION_ID , "OID_FDDI_SMT_OP_VERSION_ID" },
1315  { OID_FDDI_SMT_PEER_WRAP_FLAG , "OID_FDDI_SMT_PEER_WRAP_FLAG" },
1316  { OID_FDDI_SMT_PORT_INDEXES , "OID_FDDI_SMT_PORT_INDEXES" },
1317  { OID_FDDI_SMT_REMOTE_DISCONNECT_FLAG , "OID_FDDI_SMT_REMOTE_DISCONNECT_FLAG" },
1318  { OID_FDDI_SMT_SET_COUNT , "OID_FDDI_SMT_SET_COUNT" },
1319  { OID_FDDI_SMT_STATION_ACTION , "OID_FDDI_SMT_STATION_ACTION" },
1320  { OID_FDDI_SMT_STATION_ID , "OID_FDDI_SMT_STATION_ID" },
1321  { OID_FDDI_SMT_STATION_STATUS , "OID_FDDI_SMT_STATION_STATUS" },
1322  { OID_FDDI_SMT_STAT_RPT_POLICY , "OID_FDDI_SMT_STAT_RPT_POLICY" },
1323  { OID_FDDI_SMT_TRACE_MAX_EXPIRATION , "OID_FDDI_SMT_TRACE_MAX_EXPIRATION" },
1324  { OID_FDDI_SMT_TRANSITION_TIME_STAMP , "OID_FDDI_SMT_TRANSITION_TIME_STAMP" },
1325  { OID_FDDI_SMT_T_NOTIFY , "OID_FDDI_SMT_T_NOTIFY" },
1326  { OID_FDDI_SMT_USER_DATA , "OID_FDDI_SMT_USER_DATA" },
1327  { OID_FDDI_UPSTREAM_NODE_LONG , "OID_FDDI_UPSTREAM_NODE_LONG" },
1328  { OID_GEN_BROADCAST_BYTES_RCV , "OID_GEN_BROADCAST_BYTES_RCV" },
1329  { OID_GEN_BROADCAST_BYTES_XMIT , "OID_GEN_BROADCAST_BYTES_XMIT" },
1330  { OID_GEN_BROADCAST_FRAMES_RCV , "OID_GEN_BROADCAST_FRAMES_RCV" },
1331  { OID_GEN_BROADCAST_FRAMES_XMIT , "OID_GEN_BROADCAST_FRAMES_XMIT" },
1332  { OID_GEN_CO_BYTES_RCV , "OID_GEN_CO_BYTES_RCV" },
1333  { OID_GEN_CO_BYTES_XMIT , "OID_GEN_CO_BYTES_XMIT" },
1334  { OID_GEN_CO_BYTES_XMIT_OUTSTANDING , "OID_GEN_CO_BYTES_XMIT_OUTSTANDING" },
1335  { OID_GEN_CO_DRIVER_VERSION , "OID_GEN_CO_DRIVER_VERSION" },
1336  { OID_GEN_CO_GET_NETCARD_TIME , "OID_GEN_CO_GET_NETCARD_TIME" },
1337  { OID_GEN_CO_GET_TIME_CAPS , "OID_GEN_CO_GET_TIME_CAPS" },
1338  { OID_GEN_CO_HARDWARE_STATUS , "OID_GEN_CO_HARDWARE_STATUS" },
1339  { OID_GEN_CO_LINK_SPEED , "OID_GEN_CO_LINK_SPEED" },
1340  { OID_GEN_CO_MAC_OPTIONS , "OID_GEN_CO_MAC_OPTIONS" },
1341  { OID_GEN_CO_MEDIA_CONNECT_STATUS , "OID_GEN_CO_MEDIA_CONNECT_STATUS" },
1342  { OID_GEN_CO_MEDIA_IN_USE , "OID_GEN_CO_MEDIA_IN_USE" },
1343  { OID_GEN_CO_MEDIA_SUPPORTED , "OID_GEN_CO_MEDIA_SUPPORTED" },
1344  { OID_GEN_CO_MINIMUM_LINK_SPEED , "OID_GEN_CO_MINIMUM_LINK_SPEED" },
1345  { OID_GEN_CO_NETCARD_LOAD , "OID_GEN_CO_NETCARD_LOAD" },
1346  { OID_GEN_CO_PROTOCOL_OPTIONS , "OID_GEN_CO_PROTOCOL_OPTIONS" },
1347  { OID_GEN_CO_RCV_CRC_ERROR , "OID_GEN_CO_RCV_CRC_ERROR" },
1348  { OID_GEN_CO_RCV_PDUS_ERROR , "OID_GEN_CO_RCV_PDUS_ERROR" },
1349  { OID_GEN_CO_RCV_PDUS_NO_BUFFER , "OID_GEN_CO_RCV_PDUS_NO_BUFFER" },
1350  { OID_GEN_CO_RCV_PDUS_OK , "OID_GEN_CO_RCV_PDUS_OK" },
1351  { OID_GEN_CO_SUPPORTED_LIST , "OID_GEN_CO_SUPPORTED_LIST" },
1352  { OID_GEN_CO_TRANSMIT_QUEUE_LENGTH , "OID_GEN_CO_TRANSMIT_QUEUE_LENGTH" },
1353  { OID_GEN_CO_VENDOR_DESCRIPTION , "OID_GEN_CO_VENDOR_DESCRIPTION" },
1354  { OID_GEN_CO_VENDOR_DRIVER_VERSION , "OID_GEN_CO_VENDOR_DRIVER_VERSION" },
1355  { OID_GEN_CO_VENDOR_ID , "OID_GEN_CO_VENDOR_ID" },
1356  { OID_GEN_CO_XMIT_PDUS_ERROR , "OID_GEN_CO_XMIT_PDUS_ERROR" },
1357  { OID_GEN_CO_XMIT_PDUS_OK , "OID_GEN_CO_XMIT_PDUS_OK" },
1358  { OID_GEN_CURRENT_LOOKAHEAD , "OID_GEN_CURRENT_LOOKAHEAD" },
1359  { OID_GEN_CURRENT_PACKET_FILTER , "OID_GEN_CURRENT_PACKET_FILTER" },
1360  { OID_GEN_DIRECTED_BYTES_RCV , "OID_GEN_DIRECTED_BYTES_RCV" },
1361  { OID_GEN_DIRECTED_BYTES_XMIT , "OID_GEN_DIRECTED_BYTES_XMIT" },
1362  { OID_GEN_DIRECTED_FRAMES_RCV , "OID_GEN_DIRECTED_FRAMES_RCV" },
1363  { OID_GEN_DIRECTED_FRAMES_XMIT , "OID_GEN_DIRECTED_FRAMES_XMIT" },
1364  { OID_GEN_DRIVER_VERSION , "OID_GEN_DRIVER_VERSION" },
1365  { OID_GEN_GET_NETCARD_TIME , "OID_GEN_GET_NETCARD_TIME" },
1366  { OID_GEN_GET_TIME_CAPS , "OID_GEN_GET_TIME_CAPS" },
1367  { OID_GEN_HARDWARE_STATUS , "OID_GEN_HARDWARE_STATUS" },
1368  { OID_GEN_LINK_SPEED , "OID_GEN_LINK_SPEED" },
1369  { OID_GEN_MAC_OPTIONS , "OID_GEN_MAC_OPTIONS" },
1370  { OID_GEN_MAXIMUM_FRAME_SIZE , "OID_GEN_MAXIMUM_FRAME_SIZE" },
1371  { OID_GEN_MAXIMUM_LOOKAHEAD , "OID_GEN_MAXIMUM_LOOKAHEAD" },
1372  { OID_GEN_MAXIMUM_SEND_PACKETS , "OID_GEN_MAXIMUM_SEND_PACKETS" },
1373  { OID_GEN_MAXIMUM_TOTAL_SIZE , "OID_GEN_MAXIMUM_TOTAL_SIZE" },
1374  { OID_GEN_MEDIA_CAPABILITIES , "OID_GEN_MEDIA_CAPABILITIES" },
1375  { OID_GEN_MEDIA_CONNECT_STATUS , "OID_GEN_MEDIA_CONNECT_STATUS" },
1376  { OID_GEN_MEDIA_IN_USE , "OID_GEN_MEDIA_IN_USE" },
1377  { OID_GEN_MEDIA_SUPPORTED , "OID_GEN_MEDIA_SUPPORTED" },
1378  { OID_GEN_MULTICAST_BYTES_RCV , "OID_GEN_MULTICAST_BYTES_RCV" },
1379  { OID_GEN_MULTICAST_BYTES_XMIT , "OID_GEN_MULTICAST_BYTES_XMIT" },
1380  { OID_GEN_MULTICAST_FRAMES_RCV , "OID_GEN_MULTICAST_FRAMES_RCV" },
1381  { OID_GEN_MULTICAST_FRAMES_XMIT , "OID_GEN_MULTICAST_FRAMES_XMIT" },
1382  { OID_GEN_NETWORK_LAYER_ADDRESSES , "OID_GEN_NETWORK_LAYER_ADDRESSES" },
1383  { OID_GEN_PHYSICAL_MEDIUM , "OID_GEN_PHYSICAL_MEDIUM" },
1384  { OID_GEN_PHYSICAL_MEDIUM_EX , "OID_GEN_PHYSICAL_MEDIUM_EX" },
1385  { OID_GEN_PROTOCOL_OPTIONS , "OID_GEN_PROTOCOL_OPTIONS" },
1386  { OID_GEN_RCV_CRC_ERROR , "OID_GEN_RCV_CRC_ERROR" },
1387  { OID_GEN_RCV_ERROR , "OID_GEN_RCV_ERROR" },
1388  { OID_GEN_RCV_NO_BUFFER , "OID_GEN_RCV_NO_BUFFER" },
1389  { OID_GEN_RCV_OK , "OID_GEN_RCV_OK" },
1390  { OID_GEN_RECEIVE_BLOCK_SIZE , "OID_GEN_RECEIVE_BLOCK_SIZE" },
1391  { OID_GEN_RECEIVE_BUFFER_SPACE , "OID_GEN_RECEIVE_BUFFER_SPACE" },
1392  { OID_GEN_SUPPORTED_LIST , "OID_GEN_SUPPORTED_LIST" },
1393  { OID_GEN_TRANSMIT_BLOCK_SIZE , "OID_GEN_TRANSMIT_BLOCK_SIZE" },
1394  { OID_GEN_TRANSMIT_BUFFER_SPACE , "OID_GEN_TRANSMIT_BUFFER_SPACE" },
1395  { OID_GEN_TRANSMIT_QUEUE_LENGTH , "OID_GEN_TRANSMIT_QUEUE_LENGTH" },
1396  { OID_GEN_TRANSPORT_HEADER_OFFSET , "OID_GEN_TRANSPORT_HEADER_OFFSET" },
1397  { OID_GEN_VENDOR_DESCRIPTION , "OID_GEN_VENDOR_DESCRIPTION" },
1398  { OID_GEN_VENDOR_DRIVER_VERSION , "OID_GEN_VENDOR_DRIVER_VERSION" },
1399  { OID_GEN_VENDOR_ID , "OID_GEN_VENDOR_ID" },
1400  { OID_GEN_VLAN_ID , "OID_GEN_VLAN_ID" },
1401  { OID_GEN_XMIT_ERROR , "OID_GEN_XMIT_ERROR" },
1402  { OID_GEN_XMIT_OK , "OID_GEN_XMIT_OK" },
1403  { OID_IP4_OFFLOAD_STATS , "OID_IP4_OFFLOAD_STATS" },
1404  { OID_IP6_OFFLOAD_STATS , "OID_IP6_OFFLOAD_STATS" },
1405  { OID_IRDA_EXTRA_RCV_BOFS , "OID_IRDA_EXTRA_RCV_BOFS" },
1406  { OID_IRDA_LINK_SPEED , "OID_IRDA_LINK_SPEED" },
1407  { OID_IRDA_MAX_RECEIVE_WINDOW_SIZE , "OID_IRDA_MAX_RECEIVE_WINDOW_SIZE" },
1408  { OID_IRDA_MAX_SEND_WINDOW_SIZE , "OID_IRDA_MAX_SEND_WINDOW_SIZE" },
1409  { OID_IRDA_MAX_UNICAST_LIST_SIZE , "OID_IRDA_MAX_UNICAST_LIST_SIZE" },
1410  { OID_IRDA_MEDIA_BUSY , "OID_IRDA_MEDIA_BUSY" },
1411  { OID_IRDA_RATE_SNIFF , "OID_IRDA_RATE_SNIFF" },
1412  { OID_IRDA_RECEIVING , "OID_IRDA_RECEIVING" },
1413  { OID_IRDA_SUPPORTED_SPEEDS , "OID_IRDA_SUPPORTED_SPEEDS" },
1414  { OID_IRDA_TURNAROUND_TIME , "OID_IRDA_TURNAROUND_TIME" },
1415  { OID_IRDA_UNICAST_LIST , "OID_IRDA_UNICAST_LIST" },
1416  { OID_LTALK_COLLISIONS , "OID_LTALK_COLLISIONS" },
1417  { OID_LTALK_CURRENT_NODE_ID , "OID_LTALK_CURRENT_NODE_ID" },
1418  { OID_LTALK_DEFERS , "OID_LTALK_DEFERS" },
1419  { OID_LTALK_FCS_ERRORS , "OID_LTALK_FCS_ERRORS" },
1420  { OID_LTALK_IN_BROADCASTS , "OID_LTALK_IN_BROADCASTS" },
1421  { OID_LTALK_IN_LENGTH_ERRORS , "OID_LTALK_IN_LENGTH_ERRORS" },
1422  { OID_LTALK_NO_DATA_ERRORS , "OID_LTALK_NO_DATA_ERRORS" },
1423  { OID_LTALK_OUT_NO_HANDLERS , "OID_LTALK_OUT_NO_HANDLERS" },
1424  { OID_LTALK_RANDOM_CTS_ERRORS , "OID_LTALK_RANDOM_CTS_ERRORS" },
1425  { OID_PNP_ADD_WAKE_UP_PATTERN , "OID_PNP_ADD_WAKE_UP_PATTERN" },
1426  { OID_PNP_CAPABILITIES , "OID_PNP_CAPABILITIES" },
1427  { OID_PNP_ENABLE_WAKE_UP , "OID_PNP_ENABLE_WAKE_UP" },
1428  { OID_PNP_QUERY_POWER , "OID_PNP_QUERY_POWER" },
1429  { OID_PNP_REMOVE_WAKE_UP_PATTERN , "OID_PNP_REMOVE_WAKE_UP_PATTERN" },
1430  { OID_PNP_SET_POWER , "OID_PNP_SET_POWER" },
1431  { OID_PNP_WAKE_UP_PATTERN_LIST , "OID_PNP_WAKE_UP_PATTERN_LIST" },
1432  { OID_TAPI_ACCEPT , "OID_TAPI_ACCEPT" },
1433  { OID_TAPI_ANSWER , "OID_TAPI_ANSWER" },
1434  { OID_TAPI_CLOSE , "OID_TAPI_CLOSE" },
1435  { OID_TAPI_CLOSE_CALL , "OID_TAPI_CLOSE_CALL" },
1436  { OID_TAPI_CONDITIONAL_MEDIA_DETECTION , "OID_TAPI_CONDITIONAL_MEDIA_DETECTION" },
1437  { OID_TAPI_CONFIG_DIALOG , "OID_TAPI_CONFIG_DIALOG" },
1438  { OID_TAPI_DEV_SPECIFIC , "OID_TAPI_DEV_SPECIFIC" },
1439  { OID_TAPI_DIAL , "OID_TAPI_DIAL" },
1440  { OID_TAPI_DROP , "OID_TAPI_DROP" },
1441  { OID_TAPI_GATHER_DIGITS , "OID_TAPI_GATHER_DIGITS" },
1442  { OID_TAPI_GET_ADDRESS_CAPS , "OID_TAPI_GET_ADDRESS_CAPS" },
1443  { OID_TAPI_GET_ADDRESS_ID , "OID_TAPI_GET_ADDRESS_ID" },
1444  { OID_TAPI_GET_ADDRESS_STATUS , "OID_TAPI_GET_ADDRESS_STATUS" },
1445  { OID_TAPI_GET_CALL_ADDRESS_ID , "OID_TAPI_GET_CALL_ADDRESS_ID" },
1446  { OID_TAPI_GET_CALL_INFO , "OID_TAPI_GET_CALL_INFO" },
1447  { OID_TAPI_GET_CALL_STATUS , "OID_TAPI_GET_CALL_STATUS" },
1448  { OID_TAPI_GET_DEV_CAPS , "OID_TAPI_GET_DEV_CAPS" },
1449  { OID_TAPI_GET_DEV_CONFIG , "OID_TAPI_GET_DEV_CONFIG" },
1450  { OID_TAPI_GET_EXTENSION_ID , "OID_TAPI_GET_EXTENSION_ID" },
1451  { OID_TAPI_GET_ID , "OID_TAPI_GET_ID" },
1452  { OID_TAPI_GET_LINE_DEV_STATUS , "OID_TAPI_GET_LINE_DEV_STATUS" },
1453  { OID_TAPI_MAKE_CALL , "OID_TAPI_MAKE_CALL" },
1454  { OID_TAPI_MONITOR_DIGITS , "OID_TAPI_MONITOR_DIGITS" },
1455  { OID_TAPI_NEGOTIATE_EXT_VERSION , "OID_TAPI_NEGOTIATE_EXT_VERSION" },
1456  { OID_TAPI_OPEN , "OID_TAPI_OPEN" },
1457  { OID_TAPI_PROVIDER_INITIALIZE , "OID_TAPI_PROVIDER_INITIALIZE" },
1458  { OID_TAPI_PROVIDER_SHUTDOWN , "OID_TAPI_PROVIDER_SHUTDOWN" },
1459  { OID_TAPI_SECURE_CALL , "OID_TAPI_SECURE_CALL" },
1460  { OID_TAPI_SELECT_EXT_VERSION , "OID_TAPI_SELECT_EXT_VERSION" },
1461  { OID_TAPI_SEND_USER_USER_INFO , "OID_TAPI_SEND_USER_USER_INFO" },
1462  { OID_TAPI_SET_APP_SPECIFIC , "OID_TAPI_SET_APP_SPECIFIC" },
1463  { OID_TAPI_SET_CALL_PARAMS , "OID_TAPI_SET_CALL_PARAMS" },
1464  { OID_TAPI_SET_DEFAULT_MEDIA_DETECTION , "OID_TAPI_SET_DEFAULT_MEDIA_DETECTION" },
1465  { OID_TAPI_SET_DEV_CONFIG , "OID_TAPI_SET_DEV_CONFIG" },
1466  { OID_TAPI_SET_MEDIA_MODE , "OID_TAPI_SET_MEDIA_MODE" },
1467  { OID_TAPI_SET_STATUS_MESSAGES , "OID_TAPI_SET_STATUS_MESSAGES" },
1468  { OID_TCP4_OFFLOAD_STATS , "OID_TCP4_OFFLOAD_STATS" },
1469  { OID_TCP6_OFFLOAD_STATS , "OID_TCP6_OFFLOAD_STATS" },
1470  { OID_TCP_SAN_SUPPORT , "OID_TCP_SAN_SUPPORT" },
1471  { OID_TCP_TASK_IPSEC_ADD_SA , "OID_TCP_TASK_IPSEC_ADD_SA" },
1472  { OID_TCP_TASK_IPSEC_ADD_UDPESP_SA , "OID_TCP_TASK_IPSEC_ADD_UDPESP_SA" },
1473  { OID_TCP_TASK_IPSEC_DELETE_SA , "OID_TCP_TASK_IPSEC_DELETE_SA" },
1474  { OID_TCP_TASK_IPSEC_DELETE_UDPESP_SA , "OID_TCP_TASK_IPSEC_DELETE_UDPESP_SA" },
1475  { OID_TCP_TASK_OFFLOAD , "OID_TCP_TASK_OFFLOAD" },
1476  { OID_WAN_CURRENT_ADDRESS , "OID_WAN_CURRENT_ADDRESS" },
1477  { OID_WAN_GET_BRIDGE_INFO , "OID_WAN_GET_BRIDGE_INFO" },
1478  { OID_WAN_GET_COMP_INFO , "OID_WAN_GET_COMP_INFO" },
1479  { OID_WAN_GET_INFO , "OID_WAN_GET_INFO" },
1480  { OID_WAN_GET_LINK_INFO , "OID_WAN_GET_LINK_INFO" },
1481  { OID_WAN_GET_STATS_INFO , "OID_WAN_GET_STATS_INFO" },
1482  { OID_WAN_HEADER_FORMAT , "OID_WAN_HEADER_FORMAT" },
1483  { OID_WAN_LINE_COUNT , "OID_WAN_LINE_COUNT" },
1484  { OID_WAN_MEDIUM_SUBTYPE , "OID_WAN_MEDIUM_SUBTYPE" },
1485  { OID_WAN_PERMANENT_ADDRESS , "OID_WAN_PERMANENT_ADDRESS" },
1486  { OID_WAN_PROTOCOL_TYPE , "OID_WAN_PROTOCOL_TYPE" },
1487  { OID_WAN_QUALITY_OF_SERVICE , "OID_WAN_QUALITY_OF_SERVICE" },
1488  { OID_WAN_SET_BRIDGE_INFO , "OID_WAN_SET_BRIDGE_INFO" },
1489  { OID_WAN_SET_COMP_INFO , "OID_WAN_SET_COMP_INFO" },
1490  { OID_WAN_SET_LINK_INFO , "OID_WAN_SET_LINK_INFO" },
1491  { OID_WW_ARD_DATAGRAM , "OID_WW_ARD_DATAGRAM" },
1492  { OID_WW_ARD_SNDCP , "OID_WW_ARD_SNDCP" },
1493  { OID_WW_ARD_TMLY_MSG , "OID_WW_ARD_TMLY_MSG" },
1494  { OID_WW_CDPD_AREA_COLOR , "OID_WW_CDPD_AREA_COLOR" },
1495  { OID_WW_CDPD_CHANNEL_SELECT , "OID_WW_CDPD_CHANNEL_SELECT" },
1496  { OID_WW_CDPD_CHANNEL_STATE , "OID_WW_CDPD_CHANNEL_STATE" },
1497  { OID_WW_CDPD_CIRCUIT_SWITCHED , "OID_WW_CDPD_CIRCUIT_SWITCHED" },
1498  { OID_WW_CDPD_DATA_COMPRESSION , "OID_WW_CDPD_DATA_COMPRESSION" },
1499  { OID_WW_CDPD_EID , "OID_WW_CDPD_EID" },
1500  { OID_WW_CDPD_HEADER_COMPRESSION , "OID_WW_CDPD_HEADER_COMPRESSION" },
1501  { OID_WW_CDPD_NEI , "OID_WW_CDPD_NEI" },
1502  { OID_WW_CDPD_NEI_STATE , "OID_WW_CDPD_NEI_STATE" },
1503  { OID_WW_CDPD_RSSI , "OID_WW_CDPD_RSSI" },
1504  { OID_WW_CDPD_SERVICE_PROVIDER_IDENTIFIER, "OID_WW_CDPD_SERVICE_PROVIDER_IDENTIFIER" },
1505  { OID_WW_CDPD_SLEEP_MODE , "OID_WW_CDPD_SLEEP_MODE" },
1506  { OID_WW_CDPD_SPNI , "OID_WW_CDPD_SPNI" },
1507  { OID_WW_CDPD_TEI , "OID_WW_CDPD_TEI" },
1508  { OID_WW_CDPD_TX_POWER_LEVEL , "OID_WW_CDPD_TX_POWER_LEVEL" },
1509  { OID_WW_CDPD_WASI , "OID_WW_CDPD_WASI" },
1510  { OID_WW_GEN_BASESTATION_ID , "OID_WW_GEN_BASESTATION_ID" },
1511  { OID_WW_GEN_BATTERY_LEVEL , "OID_WW_GEN_BATTERY_LEVEL" },
1512  { OID_WW_GEN_CHANNEL_ID , "OID_WW_GEN_CHANNEL_ID" },
1513  { OID_WW_GEN_CHANNEL_QUALITY , "OID_WW_GEN_CHANNEL_QUALITY" },
1514  { OID_WW_GEN_CURRENT_ADDRESS , "OID_WW_GEN_CURRENT_ADDRESS" },
1515  { OID_WW_GEN_DEVICE_INFO , "OID_WW_GEN_DEVICE_INFO" },
1516  { OID_WW_GEN_DISABLE_TRANSMITTER , "OID_WW_GEN_DISABLE_TRANSMITTER" },
1517  { OID_WW_GEN_ENCRYPTION_IN_USE , "OID_WW_GEN_ENCRYPTION_IN_USE" },
1518  { OID_WW_GEN_ENCRYPTION_STATE , "OID_WW_GEN_ENCRYPTION_STATE" },
1519  { OID_WW_GEN_ENCRYPTION_SUPPORTED , "OID_WW_GEN_ENCRYPTION_SUPPORTED" },
1520  { OID_WW_GEN_EXTERNAL_POWER , "OID_WW_GEN_EXTERNAL_POWER" },
1521  { OID_WW_GEN_HEADER_FORMATS_SUPPORTED , "OID_WW_GEN_HEADER_FORMATS_SUPPORTED" },
1522  { OID_WW_GEN_HEADER_FORMAT_IN_USE , "OID_WW_GEN_HEADER_FORMAT_IN_USE" },
1523  { OID_WW_GEN_INDICATION_REQUEST , "OID_WW_GEN_INDICATION_REQUEST" },
1524  { OID_WW_GEN_LATENCY , "OID_WW_GEN_LATENCY" },
1525  { OID_WW_GEN_LOCK_STATUS , "OID_WW_GEN_LOCK_STATUS" },
1526  { OID_WW_GEN_NETWORK_ID , "OID_WW_GEN_NETWORK_ID" },
1527  { OID_WW_GEN_NETWORK_TYPES_SUPPORTED , "OID_WW_GEN_NETWORK_TYPES_SUPPORTED" },
1528  { OID_WW_GEN_NETWORK_TYPE_IN_USE , "OID_WW_GEN_NETWORK_TYPE_IN_USE" },
1529  { OID_WW_GEN_OPERATION_MODE , "OID_WW_GEN_OPERATION_MODE" },
1530  { OID_WW_GEN_PERMANENT_ADDRESS , "OID_WW_GEN_PERMANENT_ADDRESS" },
1531  { OID_WW_GEN_RADIO_LINK_SPEED , "OID_WW_GEN_RADIO_LINK_SPEED" },
1532  { OID_WW_GEN_REGISTRATION_STATUS , "OID_WW_GEN_REGISTRATION_STATUS" },
1533  { OID_WW_GEN_SUSPEND_DRIVER , "OID_WW_GEN_SUSPEND_DRIVER" },
1534  { OID_WW_MBX_FLEXLIST , "OID_WW_MBX_FLEXLIST" },
1535  { OID_WW_MBX_GROUPLIST , "OID_WW_MBX_GROUPLIST" },
1536  { OID_WW_MBX_LIVE_DIE , "OID_WW_MBX_LIVE_DIE" },
1537  { OID_WW_MBX_SUBADDR , "OID_WW_MBX_SUBADDR" },
1538  { OID_WW_MBX_TEMP_DEFAULTLIST , "OID_WW_MBX_TEMP_DEFAULTLIST" },
1539  { OID_WW_MBX_TRAFFIC_AREA , "OID_WW_MBX_TRAFFIC_AREA" },
1540  { OID_WW_MET_FUNCTION , "OID_WW_MET_FUNCTION" },
1541  { OID_WW_PIN_LAST_LOCATION , "OID_WW_PIN_LAST_LOCATION" },
1542  { OID_WW_PIN_LOC_AUTHORIZE , "OID_WW_PIN_LOC_AUTHORIZE" },
1543  { OID_WW_PIN_LOC_FIX , "OID_WW_PIN_LOC_FIX" },
1544  { OID_WW_TAC_COMPRESSION , "OID_WW_TAC_COMPRESSION" },
1545  { OID_WW_TAC_GET_STATUS , "OID_WW_TAC_GET_STATUS" },
1546  { OID_WW_TAC_SET_CONFIG , "OID_WW_TAC_SET_CONFIG" },
1547  { OID_WW_TAC_USER_HEADER , "OID_WW_TAC_USER_HEADER" }
1548 };
1549 #endif /* USE_DEBUG */
1550 
1570 BOOL PacketRequest2 (const ADAPTER *AdapterObject, BOOL set,
1571  PACKET_OID_DATA *oidData,
1572  const char *file, unsigned line)
1573 {
1574  DWORD transfered, in_size, out_size;
1575  DWORD in_len, out_len;
1576  BOOL rc;
1577  int error = 0;
1578  char prof_buf[100] = "";
1579 
1580 #if defined(USE_PROFILER) && defined(USE_DEBUG)
1581  uint64 start = U64_SUFFIX (0);
1582 
1583  if (profile_enable)
1584  start = win_get_perf_count();
1585 #endif
1586 
1587  transfered = 0;
1588  in_len = oidData->Length;
1589  in_size = sizeof(*oidData) - 1 + oidData->Length;
1590  out_size = in_size;
1591 
1592  rc = DeviceIoControl (AdapterObject->hFile,
1593  set ? pBIOCSETOID : pBIOCQUERYOID,
1594  oidData, in_size, oidData, out_size, &transfered, NULL);
1595 
1596  out_len = rc ? oidData->Length : 0;
1597 
1598  if (!rc)
1599  error = GetLastError();
1600 
1601 #if defined(USE_DEBUG)
1602  #if defined(USE_PROFILER)
1603  if (profile_enable)
1604  {
1605  int64 clocks = (int64) (win_get_perf_count() - start);
1606  double msec = (double)clocks / ((double)clocks_per_usec * 1000.0);
1607  SNPRINTF (prof_buf, sizeof(prof_buf), " (%.3f ms)", msec);
1608  }
1609  #endif
1610 
1611  winpkt_trace_func = "PacketRequest";
1612  winpkt_trace_file = file;
1613  winpkt_trace_line = line;
1614  winpkt_trace ("%-30.30s len %lu/%lu, xfered %lu, set %d, rc %d; %s %s\n",
1615  list_lookup (oidData->Oid,oid_list,DIM(oid_list)),
1616  in_len, out_len, transfered, set, rc,
1617  !rc ? win_strerror(error) : "okay", prof_buf);
1618 #endif
1619 
1620  if (!rc)
1621  SetLastError (error);
1622  return (rc);
1623 }
1624 
1625 /*
1626  * Formerly in AdInfo.c:
1627  *
1628  * This file contains the support functions used by packet.dll to retrieve
1629  * information about installed adapters, like
1630  *
1631  * - the adapter list
1632  * - the device associated to any adapter and the description of the adapter
1633  */
1634 
1651 static BOOL GetAddressesFromRegistry (const char *AdapterName,
1652  npf_if_addr *buffer,
1653  int *NEntries)
1654 {
1655  struct sockaddr_in *TmpAddr, *TmpBroad;
1656  const char *guid;
1657  HKEY TcpIpKey = NULL, UnderTcpKey = NULL;
1658  char String [1024+1];
1659  DWORD RegType, BufLen, StringPos, DHCPEnabled, ZeroBroadcast;
1660  LONG status;
1661  DWORD line = 0;
1662  int naddrs, nmasks;
1663 
1664  *NEntries = 0;
1665 
1666  winpkt_trace_func = "GetAddressesFromRegistry";
1667 
1668  guid = strchr (AdapterName, '{');
1669 
1670  WINPKT_TRACE (("guid %s\n", guid));
1671 
1672  if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1673  "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces",
1674  0, KEY_READ, &UnderTcpKey) == ERROR_SUCCESS)
1675  {
1676  status = RegOpenKeyExA (UnderTcpKey, guid, 0, KEY_READ, &TcpIpKey);
1677  line = __LINE__ - 1;
1678  if (status != ERROR_SUCCESS)
1679  goto fail;
1680  }
1681  else
1682  {
1683  HKEY SystemKey, ParametersKey, InterfaceKey;
1684 
1685  /* Query the registry key with the interface's addresses
1686  */
1687  status = RegOpenKeyExA (HKEY_LOCAL_MACHINE,
1688  "SYSTEM\\CurrentControlSet\\Services",
1689  0, KEY_READ, &SystemKey);
1690  if (status != ERROR_SUCCESS)
1691  goto fail;
1692 
1693  status = RegOpenKeyExA (SystemKey, guid, 0, KEY_READ, &InterfaceKey);
1694  line = __LINE__ - 1;
1695  RegCloseKey (SystemKey);
1696  if (status != ERROR_SUCCESS)
1697  goto fail;
1698 
1699  status = RegOpenKeyExA (InterfaceKey, "Parameters", 0, KEY_READ,
1700  &ParametersKey);
1701  line = __LINE__ - 1;
1702  RegCloseKey (InterfaceKey);
1703  if (status != ERROR_SUCCESS)
1704  goto fail;
1705 
1706  status = RegOpenKeyExA (ParametersKey, "TcpIp", 0, KEY_READ, &TcpIpKey);
1707  line = __LINE__ - 1;
1708  RegCloseKey (ParametersKey);
1709  if (status != ERROR_SUCCESS)
1710  goto fail;
1711 
1712  BufLen = sizeof(String);
1713  }
1714 
1715  BufLen = 4;
1716 
1717  /* Try to detect if the interface has a zero broadcast addr
1718  */
1719  status = RegQueryValueExA (TcpIpKey, "UseZeroBroadcast", NULL,
1720  &RegType, (BYTE*)&ZeroBroadcast, &BufLen);
1721  if (status != ERROR_SUCCESS)
1722  ZeroBroadcast = 0;
1723 
1724  BufLen = 4;
1725 
1726  /* See if DHCP is used by this system
1727  */
1728  status = RegQueryValueExA (TcpIpKey, "EnableDHCP", NULL,
1729  &RegType, (BYTE*)&DHCPEnabled, &BufLen);
1730  if (status != ERROR_SUCCESS)
1731  DHCPEnabled = 0;
1732 
1733  /* Retrieve the addresses
1734  */
1735  if (DHCPEnabled)
1736  {
1737  WINPKT_TRACE ((" DHCP enabled\n"));
1738 
1739  BufLen = sizeof(String);
1740  status = RegQueryValueExA (TcpIpKey, "DhcpIPAddress", NULL,
1741  &RegType, (BYTE*)String, &BufLen);
1742  line = __LINE__ - 1;
1743  if (status != ERROR_SUCCESS)
1744  goto fail;
1745 
1746  /* scan the key to obtain the addresses
1747  */
1748  StringPos = 0;
1749  for (naddrs = 0; naddrs < MAX_NETWORK_ADDRESSES; naddrs++)
1750  {
1751  TmpAddr = (struct sockaddr_in*) &buffer[naddrs].IPAddress;
1752  WINPKT_TRACE ((" addr %s\n", String+StringPos));
1753 
1754  TmpAddr->sin_addr.s_addr = htonl (aton(String+StringPos));
1755  if (TmpAddr->sin_addr.s_addr)
1756  {
1757  TmpAddr->sin_family = AF_INET;
1758  TmpBroad = (struct sockaddr_in*) &buffer[naddrs].Broadcast;
1759  TmpBroad->sin_family = AF_INET;
1760  if (!ZeroBroadcast)
1761  TmpBroad->sin_addr.s_addr = INADDR_BROADCAST;
1762  else TmpBroad->sin_addr.s_addr = INADDR_ANY;
1763 
1764  while (*(String+StringPos))
1765  StringPos++;
1766  StringPos++;
1767 
1768  if (*(String + StringPos) == '\0' || StringPos >= BufLen)
1769  break;
1770  }
1771  else
1772  break;
1773  }
1774 
1775  BufLen = sizeof(String);
1776 
1777  /* Open the key with the netmasks
1778  */
1779  status = RegQueryValueExA (TcpIpKey, "DhcpSubnetMask", NULL,
1780  &RegType, (BYTE*)String, &BufLen);
1781  line = __LINE__ - 1;
1782  if (status != ERROR_SUCCESS)
1783  goto fail;
1784 
1785  /* scan the key to obtain the masks
1786  */
1787  StringPos = 0;
1788  for (nmasks = 0; nmasks < MAX_NETWORK_ADDRESSES; nmasks++)
1789  {
1790  TmpAddr = (struct sockaddr_in*) &buffer[nmasks].SubnetMask;
1791  WINPKT_TRACE ((" addr %s\n", String+StringPos));
1792 
1793  TmpAddr->sin_addr.s_addr = htonl (aton(String+StringPos));
1794  if (TmpAddr->sin_addr.s_addr)
1795  {
1796  TmpAddr->sin_family = AF_INET;
1797 
1798  while (*(String + StringPos))
1799  StringPos++;
1800  StringPos++;
1801  if (*(String + StringPos) == '\0' || StringPos >= BufLen)
1802  break;
1803  }
1804  else
1805  break;
1806  }
1807 
1808  /* The number of masks MUST be equal to the number of addresses
1809  */
1810  if (nmasks != naddrs)
1811  goto fail;
1812  }
1813  else /* Not DHCP enabled */
1814  {
1815  WINPKT_TRACE ((" Not DHCP enabled\n"));
1816 
1817  BufLen = sizeof(String);
1818 
1819  /* Open the key with the addresses
1820  */
1821  status = RegQueryValueExA (TcpIpKey, "IPAddress", NULL,
1822  &RegType, (BYTE*)String, &BufLen);
1823  line = __LINE__ - 1;
1824  if (status != ERROR_SUCCESS)
1825  goto fail;
1826 
1827  /* scan the key to obtain the addresses
1828  */
1829  StringPos = 0;
1830  for (naddrs = 0; naddrs < MAX_NETWORK_ADDRESSES; naddrs++)
1831  {
1832  TmpAddr = (struct sockaddr_in*) &buffer[naddrs].IPAddress;
1833  WINPKT_TRACE ((" addr %s\n", String+StringPos));
1834 
1835  TmpAddr->sin_addr.s_addr = htonl (aton(String+StringPos));
1836  if (TmpAddr->sin_addr.s_addr)
1837  {
1838  TmpAddr->sin_family = AF_INET;
1839 
1840  TmpBroad = (struct sockaddr_in*) &buffer[naddrs].Broadcast;
1841  TmpBroad->sin_family = AF_INET;
1842  if (!ZeroBroadcast)
1843  TmpBroad->sin_addr.s_addr = INADDR_BROADCAST;
1844  else TmpBroad->sin_addr.s_addr = INADDR_ANY;
1845 
1846  while (*(String + StringPos))
1847  StringPos++;
1848  StringPos++;
1849 
1850  if (*(String + StringPos) == '\0' || StringPos >= BufLen)
1851  break;
1852  }
1853  else
1854  break;
1855  }
1856 
1857  /* Open the key with the netmasks
1858  */
1859  BufLen = sizeof(String);
1860  status = RegQueryValueExA (TcpIpKey, "SubnetMask", NULL,
1861  &RegType, (BYTE*)String, &BufLen);
1862  line = __LINE__ - 1;
1863  if (status != ERROR_SUCCESS)
1864  goto fail;
1865 
1866  /* scan the key to obtain the masks
1867  */
1868  StringPos = 0;
1869  for (nmasks = 0; nmasks < MAX_NETWORK_ADDRESSES; nmasks++)
1870  {
1871  TmpAddr = (struct sockaddr_in*) &buffer[nmasks].SubnetMask;
1872  WINPKT_TRACE ((" mask %s\n", String+StringPos));
1873 
1874  TmpAddr->sin_addr.s_addr = htonl (aton(String+StringPos));
1875  if (TmpAddr->sin_addr.s_addr)
1876  {
1877  TmpAddr->sin_family = AF_INET;
1878 
1879  while (*(String + StringPos) != 0)
1880  StringPos++;
1881  StringPos++;
1882 
1883  if (*(String + StringPos) == 0 || StringPos >= BufLen)
1884  break;
1885  }
1886  else
1887  break;
1888  }
1889 
1890  /* The number of masks MUST be equal to the number of addresses
1891  */
1892  if (nmasks != naddrs)
1893  goto fail;
1894  }
1895 
1896  *NEntries = naddrs + 1;
1897 
1898  RegCloseKey (TcpIpKey);
1899  RegCloseKey (UnderTcpKey);
1900 
1901  return (status != ERROR_SUCCESS);
1902 
1903 fail:
1904  WINPKT_TRACE (("failed line %lu; %s\n", line, win_strerror(GetLastError())));
1905 
1906  if (TcpIpKey)
1907  RegCloseKey (TcpIpKey);
1908  if (UnderTcpKey)
1909  RegCloseKey (UnderTcpKey);
1910  *NEntries = 0;
1911  ARGSUSED (line);
1912  return (FALSE);
1913 }
1914 
1924 static BOOL AddAdapter (const char *AdName)
1925 {
1926  ADAPTER_INFO *TmpAdInfo = NULL;
1927  ADAPTER *adapter = NULL;
1928  BOOL rc = FALSE;
1929 
1930  winpkt_trace_func = "AddAdapter";
1931  WINPKT_TRACE (("adapter %s\n", AdName));
1932 
1933  WaitForSingleObject (adapters_mutex, INFINITE);
1934 
1935  for (TmpAdInfo = adapters_list; TmpAdInfo; TmpAdInfo = TmpAdInfo->Next)
1936  {
1937  if (!strcmp(AdName, TmpAdInfo->Name))
1938  {
1939  WINPKT_TRACE (("adapter already present in the list\n"));
1940  ReleaseMutex (adapters_mutex);
1941  return (TRUE);
1942  }
1943  }
1944 
1945  TmpAdInfo = NULL;
1946 
1947  /* Here we could have released the mutex, but what happens if two
1948  * threads try to add the same adapter? The adapter would be duplicated
1949  * on the linked list.
1950  */
1951 
1952  /* Try to Open the adapter
1953  */
1954  adapter = PacketOpenAdapterNPF (AdName);
1955  winpkt_trace_func = "AddAdapter";
1956 
1957  if (!adapter)
1958  goto quit;
1959 
1960  /* PacketOpenAdapter() was succesful. Consider this a valid adapter
1961  * and allocate an entry for it In the adapter list.
1962  */
1963  TmpAdInfo = GlobalAllocPtr (GMEM_MOVEABLE | GMEM_ZEROINIT,
1964  sizeof(*TmpAdInfo));
1965  if (!TmpAdInfo)
1966  {
1967  WINPKT_TRACE (("GlobalAllocPtr Failed\n"));
1968  goto quit;
1969  }
1970 
1971  adapter->info = TmpAdInfo;
1972 
1973  /* Copy the device name
1974  */
1975  strcpy (TmpAdInfo->Name, AdName);
1976 
1977  GetAddressesFromRegistry (TmpAdInfo->Name,
1978  TmpAdInfo->NetworkAddresses,
1979  &TmpAdInfo->NNetworkAddresses);
1980 
1981  /* Update the AdaptersInfo list
1982  */
1983  TmpAdInfo->Next = adapters_list;
1984  adapters_list = TmpAdInfo;
1985 
1986  rc = TRUE;
1987 
1988 quit:
1989  /* Close it; we don't need it until user open it again.
1990  */
1991  if (adapter)
1992  PacketCloseAdapter (adapter);
1993  if (!rc && TmpAdInfo)
1994  (void) GlobalFreePtr (TmpAdInfo);
1995  ReleaseMutex (adapters_mutex);
1996  return (rc);
1997 }
1998 
2007 static BOOL PacketGetAdapters (void)
2008 {
2009  HKEY LinkageKey, AdapKey, OneAdapKey;
2010  DWORD RegKeySize = 0;
2011  DWORD dim, RegType;
2012  char TName[256];
2013  char TAName[256];
2014  char AdapName[256];
2015  const char *guid;
2016  LONG Status;
2017  int i = 0;
2018 
2019  winpkt_trace_func = "PacketGetAdapters";
2020  WINPKT_TRACE (("\n"));
2021 
2022  Status = RegOpenKeyExA (HKEY_LOCAL_MACHINE,
2023  "SYSTEM\\CurrentControlSet\\Control\\Class\\"
2024  "{4D36E972-E325-11CE-BFC1-08002BE10318}",
2025  0, KEY_READ, &AdapKey);
2026  i = 0;
2027 
2028  if (Status != ERROR_SUCCESS)
2029  {
2030  WINPKT_TRACE (("RegOpenKeyEx ( Class\\{networkclassguid} ) Failed\n"));
2031  goto nt4;
2032  }
2033 
2034  WINPKT_TRACE (("cycling through the adapters:\n"));
2035 
2036  /* Cycle through the entries inside the {4D3..} key
2037  * to get the names of the adapters
2038  */
2039  while (RegEnumKeyA (AdapKey, i, AdapName, sizeof(AdapName)) == ERROR_SUCCESS)
2040  {
2041  WINPKT_TRACE ((" loop %d: sub-key %s\n", i, AdapName));
2042  i++;
2043 
2044  /* Get the adapter name from the registry key
2045  */
2046  Status = RegOpenKeyExA (AdapKey, AdapName, 0, KEY_READ, &OneAdapKey);
2047  if (Status != ERROR_SUCCESS)
2048  {
2049  WINPKT_TRACE ((" RegOpenKeyEx (OneAdapKey) Failed\n"));
2050  continue;
2051  }
2052 
2053  Status = RegOpenKeyExA (OneAdapKey, "Linkage", 0, KEY_READ, &LinkageKey);
2054  if (Status != ERROR_SUCCESS)
2055  {
2056  RegCloseKey (OneAdapKey);
2057  WINPKT_TRACE ((" RegOpenKeyEx (LinkageKey) Failed\n"));
2058  continue;
2059  }
2060 
2061  dim = sizeof(TName);
2062  Status = RegQueryValueExA (LinkageKey, "Export", NULL, NULL,
2063  (BYTE*)TName, &dim);
2064  RegCloseKey (OneAdapKey);
2065  RegCloseKey (LinkageKey);
2066  if (Status != ERROR_SUCCESS)
2067  {
2068  WINPKT_TRACE ((" Name = SKIPPED (error reading the key)\n"));
2069  continue;
2070  }
2071  if (!TName[0])
2072  {
2073  WINPKT_TRACE ((" Name = SKIPPED (empty name)\n"));
2074  continue;
2075  }
2076  guid = strchr (TName, '{');
2077  if (!guid)
2078  {
2079  WINPKT_TRACE ((" Name = SKIPPED (missing GUID)\n"));
2080  continue;
2081  }
2082 
2083  WINPKT_TRACE ((" key %d: %s\n", i, TName));
2084 
2085  /* Put the \Device\NPF_ string at the beginning of the name
2086  */
2087  SNPRINTF (TAName, sizeof(TAName), "\\Device\\NPF_%s", guid);
2088 
2089  /* If the adapter is valid, add it to the list.
2090  */
2091  AddAdapter (TAName);
2092  winpkt_trace_func = "PacketGetAdapters";
2093  }
2094 
2095  RegCloseKey (AdapKey);
2096 
2097 nt4:
2098 
2099  /*
2100  * No adapters were found under {4D36E972-E325-11CE-BFC1-08002BE10318}.
2101  * This means with great probability that we are under Win-NT 4, so we
2102  * try to look under the tcpip bindings.
2103  */
2104 
2105  if (i == 0)
2106  WINPKT_TRACE (("Adapters not found under SYSTEM\\CurrentControlSet\\"
2107  "Control\\Class. Using the TCP/IP bindings.\n"));
2108  else WINPKT_TRACE (("Trying NT4 bindings anyway\n"));
2109 
2110  Status = RegOpenKeyExA (HKEY_LOCAL_MACHINE,
2111  "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage",
2112  0, KEY_READ, &LinkageKey);
2113  if (Status == ERROR_SUCCESS)
2114  {
2115  BYTE *bpStr;
2116 
2117  /* Retrieve the length of the binding key
2118  */
2119  Status = RegQueryValueExA (LinkageKey, "bind", NULL, &RegType,
2120  NULL, &RegKeySize);
2121 
2122  bpStr = calloc (RegKeySize+1, 1);
2123  if (!bpStr)
2124  return (FALSE);
2125 
2126  /* Query the key again to get its content
2127  */
2128  Status = RegQueryValueExA (LinkageKey, "bind", NULL, &RegType,
2129  bpStr, &RegKeySize);
2130  RegCloseKey (LinkageKey);
2131 
2132  /* Loop over the space separated "\Device\{.." strings.
2133  */
2134  for (guid = strchr((const char*)bpStr,'{');
2135  guid;
2136  guid = strchr(guid+1,'{'))
2137  {
2138  SNPRINTF (TAName, sizeof(TAName), "\\Device\\NPF_%s", guid);
2139  AddAdapter (TAName);
2140  winpkt_trace_func = "PacketGetAdapters";
2141  }
2142  free (bpStr);
2143  }
2144  else
2145  {
2146  WINPKT_TRACE (("Cannot find the TCP/IP bindings"));
2147  return (FALSE);
2148  }
2149  return (TRUE);
2150 }
2151 
2158 const ADAPTER_INFO *PacketFindAdInfo (const char *AdapterName)
2159 {
2160  const ADAPTER_INFO *ad_info;
2161 
2162  winpkt_trace_func = "PacketFindAdInfo";
2163  WINPKT_TRACE (("\n"));
2164 
2165  for (ad_info = adapters_list; ad_info; ad_info = ad_info->Next)
2166  if (!strcmp(ad_info->Name, AdapterName))
2167  break;
2168  return (ad_info);
2169 }
2170 
2174 const ADAPTER_INFO *PacketGetAdInfo (void)
2175 {
2176  winpkt_trace_func = "PacketGetAdInfo";
2177  WINPKT_TRACE (("\n"));
2178 
2179  return (adapters_list);
2180 }
2181 
2188 static BOOL PopulateAdaptersInfoList (void)
2189 {
2190  BOOL rc = TRUE;
2191 
2192  winpkt_trace_func = "PopulateAdaptersInfoList";
2193  WINPKT_TRACE (("\n"));
2194 
2195  WaitForSingleObject (adapters_mutex, INFINITE);
2196 
2197  adapters_list = NULL;
2198 
2199  /* Fill the list
2200  */
2201  if (!PacketGetAdapters())
2202  {
2203  WINPKT_TRACE (("registry scan for adapters failed!\n"));
2204  rc = FALSE;
2205  }
2206  ReleaseMutex (adapters_mutex);
2207  return (rc);
2208 }
2209 
2213 static BOOL FreeAdaptersInfoList (void)
2214 {
2215  ADAPTER_INFO *next, *ai;
2216 
2217  WaitForSingleObject (adapters_mutex, INFINITE);
2218 
2219  for (ai = adapters_list; ai; ai = next)
2220  {
2221  next = ai->Next;
2222  (void) GlobalFreePtr (ai);
2223  }
2224  adapters_list = NULL;
2225  return (TRUE);
2226 }
2227 
2228 BOOL WanPacketSetBpfFilter (WAN_ADAPTER *wan_adapter, PUCHAR FilterCode, DWORD Length)
2229 {
2230  return (use_wanpacket ? (*p_WanPacketSetBpfFilter)(wan_adapter, FilterCode, Length) : FALSE);
2231 }
2232 
2233 WAN_ADAPTER *WanPacketOpenAdapter (void)
2234 {
2235  return (use_wanpacket ? (*p_WanPacketOpenAdapter)() : NULL);
2236 }
2237 
2238 BOOL WanPacketCloseAdapter (WAN_ADAPTER *wan_adapter)
2239 {
2240  return (use_wanpacket ? (*p_WanPacketCloseAdapter)(wan_adapter) : FALSE);
2241 }
2242 
2243 BOOL WanPacketSetBufferSize (WAN_ADAPTER *wan_adapter, DWORD BufferSize)
2244 {
2245  return (use_wanpacket ? (*p_WanPacketSetBufferSize)(wan_adapter, BufferSize) : FALSE);
2246 }
2247 
2248 DWORD WanPacketReceivePacket (WAN_ADAPTER *wan_adapter, PUCHAR Buffer, DWORD BufferSize)
2249 {
2250  return (use_wanpacket ? (*p_WanPacketReceivePacket)(wan_adapter, Buffer, BufferSize) : 0UL);
2251 }
2252 
2253 BOOL WanPacketSetMinToCopy (WAN_ADAPTER *wan_adapter, DWORD MinToCopy)
2254 {
2255  return (use_wanpacket ? (*p_WanPacketSetMinToCopy)(wan_adapter, MinToCopy) : FALSE);
2256 }
2257 
2258 BOOL WanPacketGetStats (WAN_ADAPTER *wan_adapter, struct bpf_stat *s)
2259 {
2260  return (use_wanpacket ? (*p_WanPacketGetStats)(wan_adapter, s) : FALSE);
2261 }
2262 
2263 BOOL WanPacketSetReadTimeout (WAN_ADAPTER *wan_adapter, DWORD ReadTimeout)
2264 {
2265  return (use_wanpacket ? (*p_WanPacketSetReadTimeout)(wan_adapter, ReadTimeout) : FALSE);
2266 }
2267 
2268 BOOL WanPacketSetMode (WAN_ADAPTER *wan_adapter, DWORD Mode)
2269 {
2270  return (use_wanpacket ? (*p_WanPacketSetMode)(wan_adapter, Mode) : FALSE);
2271 }
2272 
2273 HANDLE WanPacketGetReadEvent (WAN_ADAPTER *wan_adapter)
2274 {
2275  return (use_wanpacket ? (*p_WanPacketGetReadEvent)(wan_adapter) : NULL);
2276 }
2277 
2278 BOOL WanPacketTestAdapter (void)
2279 {
2280  return (use_wanpacket ? (*p_WanPacketTestAdapter)() : FALSE);
2281 }
2282 #endif /* WIN32 */
DWORD W32_CALL aton(const char *str)
Converts [a.b.c.d] or a.b.c.d to 32 bit IPv4 address.
Definition: netaddr.c:86
WORD _watt_os_ver
Definition: misc.c:61
Addresses of a network adapter.
Definition: packet32.h:168
DWORD clocks_per_usec
Measured CPU speed (MHz)
Definition: timer.c:62
Contains some information about a network adapter.
Definition: packet32.h:184
Core definitions.
const char * list_lookup(DWORD type, const struct search_list *list, int num)
Search 'list' for 'type' and return it's name.
Definition: misc.c:929
unsigned long long uint64
our unsigned "long long" type
Definition: wattcp.h:60
Structure containing an OID request.
Definition: packet32.h:218
Describes an opened network adapter.
Definition: packet32.h:194
WORD _pktdevclass
Ethernet, Token, FDDI etc.
Definition: pcpkt.c:51
long long int64
our signed "long long" type
Definition: wattcp.h:61
BOOL GetFileVersion(const char *file, char *buf, size_t buf_len)
Returns the version of a PE image (.sys, .dll or .exe).
Definition: winmisc.c:219