error.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * TAP-Windows -- A kernel driver to provide virtual tap
  3. * device functionality on Windows.
  4. *
  5. * This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
  6. *
  7. * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
  8. * and is released under the GPL version 2 (see below).
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program (see the file COPYING included with this
  21. * distribution); if not, write to the Free Software Foundation, Inc.,
  22. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. //-----------------
  25. // DEBUGGING OUTPUT
  26. //-----------------
  27. #define NOTE_ERROR() \
  28. { \
  29. g_LastErrorFilename = __FILE__; \
  30. g_LastErrorLineNumber = __LINE__; \
  31. }
  32. #if DBG
  33. typedef struct {
  34. unsigned int in;
  35. unsigned int out;
  36. unsigned int capacity;
  37. char *text;
  38. BOOLEAN error;
  39. MUTEX lock;
  40. } DebugOutput;
  41. VOID MyDebugPrint (const unsigned char* format, ...);
  42. VOID MyAssert (const unsigned char *file, int line);
  43. VOID DumpPacket (const char *prefix,
  44. const unsigned char *data,
  45. unsigned int len);
  46. VOID DumpPacket2 (const char *prefix,
  47. const ETH_HEADER *eth,
  48. const unsigned char *data,
  49. unsigned int len);
  50. #define CAN_WE_PRINT (DEBUGP_AT_DISPATCH || KeGetCurrentIrql () < DISPATCH_LEVEL)
  51. #if ALSO_DBGPRINT
  52. #define DEBUGP(fmt) { MyDebugPrint fmt; if (CAN_WE_PRINT) DbgPrint fmt; }
  53. #else
  54. #define DEBUGP(fmt) { MyDebugPrint fmt; }
  55. #endif
  56. #define MYASSERT(exp) \
  57. { \
  58. if (!(exp)) \
  59. { \
  60. MyAssert(__FILE__, __LINE__); \
  61. } \
  62. }
  63. #define DUMP_PACKET(prefix, data, len) \
  64. DumpPacket (prefix, data, len)
  65. #define DUMP_PACKET2(prefix, eth, data, len) \
  66. DumpPacket2 (prefix, eth, data, len)
  67. #else
  68. #define DEBUGP(fmt)
  69. #define MYASSERT(exp)
  70. #define DUMP_PACKET(prefix, data, len)
  71. #define DUMP_PACKET2(prefix, eth, data, len)
  72. #endif