error.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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-2014 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. extern const char *g_LastErrorFilename;
  28. extern int g_LastErrorLineNumber;
  29. // Debug info output
  30. #define ALSO_DBGPRINT 1
  31. #define DEBUGP_AT_DISPATCH 1
  32. // Uncomment line below to allow packet dumps
  33. //#define ALLOW_PACKET_DUMP 1
  34. #define NOTE_ERROR() \
  35. { \
  36. g_LastErrorFilename = __FILE__; \
  37. g_LastErrorLineNumber = __LINE__; \
  38. }
  39. #if DBG
  40. typedef struct
  41. {
  42. unsigned int in;
  43. unsigned int out;
  44. unsigned int capacity;
  45. char *text;
  46. BOOLEAN error;
  47. MUTEX lock;
  48. } DebugOutput;
  49. VOID MyDebugPrint (const unsigned char* format, ...);
  50. VOID PrMac (const MACADDR mac);
  51. VOID PrIP (IPADDR ip_addr);
  52. #ifdef ALLOW_PACKET_DUMP
  53. VOID
  54. DumpPacket(
  55. __in const char *prefix,
  56. __in const unsigned char *data,
  57. __in unsigned int len
  58. );
  59. DumpPacket2(
  60. __in const char *prefix,
  61. __in const ETH_HEADER *eth,
  62. __in const unsigned char *data,
  63. __in unsigned int len
  64. );
  65. #else
  66. #define DUMP_PACKET(prefix, data, len)
  67. #define DUMP_PACKET2(prefix, eth, data, len)
  68. #endif
  69. #define CAN_WE_PRINT (DEBUGP_AT_DISPATCH || KeGetCurrentIrql () < DISPATCH_LEVEL)
  70. #if ALSO_DBGPRINT
  71. #define DEBUGP(fmt) { MyDebugPrint fmt; if (CAN_WE_PRINT) DbgPrint fmt; }
  72. #else
  73. #define DEBUGP(fmt) { MyDebugPrint fmt; }
  74. #endif
  75. #ifdef ALLOW_PACKET_DUMP
  76. #define DUMP_PACKET(prefix, data, len) \
  77. DumpPacket (prefix, data, len)
  78. #define DUMP_PACKET2(prefix, eth, data, len) \
  79. DumpPacket2 (prefix, eth, data, len)
  80. #endif
  81. BOOLEAN
  82. GetDebugLine (
  83. __in char *buf,
  84. __in const int len
  85. );
  86. #else
  87. #define DEBUGP(fmt)
  88. #define DUMP_PACKET(prefix, data, len)
  89. #define DUMP_PACKET2(prefix, eth, data, len)
  90. #endif