core_stats.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2010 iptelorg GmbH
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /**
  17. * @brief Macros used for various core statistics
  18. *
  19. * Macros used for various core statistics, (if USE_CORE_STATS is not defined
  20. * they won't do anything).
  21. * @file
  22. * @ingroup core
  23. */
  24. /*
  25. * History:
  26. * --------
  27. * 2010-02-01 initial version (andrei)
  28. */
  29. #ifndef __core_stats_h
  30. #define __core_stats_h
  31. /* define USE_CORE_STATS to enable statistics events
  32. (SREV_CORE_STATS callbacks) */
  33. /*#define USE_CORE_STATS */
  34. #ifndef USE_CORE_STATS
  35. #define STATS_REQ_FWD_DROP()
  36. #define STATS_REQ_FWD_OK()
  37. #define STATS_RPL_FWD_DROP()
  38. #define STATS_RPL_FWD_OK()
  39. #define STATS_BAD_MSG()
  40. #define STATS_BAD_RPL()
  41. #define STATS_BAD_URI()
  42. #define STATS_BAD_MSG_HDR()
  43. #else /* USE_CORE_STATS */
  44. #include "events.h"
  45. /** called each time a received request is dropped.
  46. * The request might be dropped explicitly (e.g. pre script callback)
  47. * or there might be an error while trying to forward it (e.g. send).
  48. */
  49. #define STATS_REQ_FWD_DROP() sr_event_exec(SREV_CORE_STATS, (void*)3)
  50. /** called each time forwarding a request succeeds (send).*/
  51. #define STATS_REQ_FWD_OK() sr_event_exec(SREV_CORE_STATS, (void*)1)
  52. /** called each time forwarding a reply fails.
  53. * The reply forwarding might fail due to send errors,
  54. * pre script callbacks (module denying forwarding) or explicit script
  55. * drop (drop or module function returning 0).
  56. */
  57. #define STATS_RPL_FWD_DROP() sr_event_exec(SREV_CORE_STATS, (void*)4)
  58. /* called each time forwarding a reply succeeds. */
  59. #define STATS_RPL_FWD_OK() sr_event_exec(SREV_CORE_STATS, (void*)2)
  60. /** called each time a received request is too bad to process.
  61. * For now it's called in case the message does not have any via.
  62. */
  63. #define STATS_BAD_MSG() sr_event_exec(SREV_CORE_STATS, (void*)5)
  64. /** called each time a received reply is too bad to process.
  65. * For now it's called in case the message does not have any via.
  66. */
  67. #define STATS_BAD_RPL() sr_event_exec(SREV_CORE_STATS, (void*)6)
  68. /** called each time uri parsing fails. */
  69. #define STATS_BAD_URI() sr_event_exec(SREV_CORE_STATS, (void*)7)
  70. /** called each time parsing some header fails. */
  71. #define STATS_BAD_MSG_HDR() sr_event_exec(SREV_CORE_STATS, (void*)8)
  72. #endif /* USE_CORE_STATS */
  73. #endif /*__core_stats_h*/
  74. /* vi: set ts=4 sw=4 tw=79:ai:cindent: */