sctp_stats.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2009 iptelorg GmbH
  5. *
  6. * Permission to use, copy, modify, and distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /*
  19. * sctp_stats.h - sctp statistics macros
  20. */
  21. /*
  22. * History:
  23. * --------
  24. * 2009-04-28 initial version (andrei)
  25. */
  26. #ifndef __sctp_stats_h
  27. #define __sctp_stats_h
  28. /* enable sctp stats by default */
  29. #ifndef NO_SCTP_STATS
  30. #define USE_SCTP_STATS
  31. #endif
  32. #ifndef USE_SCTP_STATS
  33. #define INIT_SCTP_STATS() 0 /* success */
  34. #define DESTROY_SCTP_STATS()
  35. #define SCTP_STATS_ESTABLISHED()
  36. #define SCTP_STATS_CONNECT_FAILED()
  37. #define SCTP_STATS_LOCAL_REJECT()
  38. #define SCTP_STATS_REMOTE_SHUTDOWN()
  39. #define SCTP_STATS_ASSOC_SHUTDOWN()
  40. #define SCTP_STATS_COMM_LOST()
  41. #define SCTP_STATS_SENDQ_FULL()
  42. #define SCTP_STATS_SEND_FAILED()
  43. #define SCTP_STATS_SEND_FORCE_RETRY()
  44. #else /* USE_SCTP_STATS */
  45. #include "../../counters.h"
  46. struct sctp_counters_h {
  47. counter_handle_t established;
  48. counter_handle_t connect_failed;
  49. counter_handle_t local_reject;
  50. counter_handle_t remote_shutdown;
  51. counter_handle_t assoc_shutdown;
  52. counter_handle_t comm_lost;
  53. counter_handle_t sendq_full;
  54. counter_handle_t send_failed;
  55. counter_handle_t send_force_retry;
  56. };
  57. extern struct sctp_counters_h sctp_cnts_h;
  58. int sctp_stats_init();
  59. void sctp_stats_destroy();
  60. #define INIT_SCTP_STATS() sctp_stats_init() /* success */
  61. #define DESTROY_SCTP_STATS() sctp_stats_destroy()
  62. /** called each time a new sctp assoc. is established.
  63. * sctp notification: SCTP_COMM_UP.
  64. */
  65. #define SCTP_STATS_ESTABLISHED() \
  66. counter_inc(sctp_cnts_h.established)
  67. /** called each time a new outgoing connection/assoc open fails.
  68. * sctp notification: SCTP_CANT_STR_ASSOC
  69. */
  70. #define SCTP_STATS_CONNECT_FAILED() \
  71. counter_inc(sctp_cnts_h.connect_failed)
  72. /** called each time a new incoming connection is rejected. */
  73. #define SCTP_STATS_LOCAL_REJECT() \
  74. counter_inc(sctp_cnts_h.local_reject)
  75. /** called each time a connection is closed by the peer.
  76. * sctp notification: SCTP_SHUTDOWN_EVENT
  77. */
  78. #define SCTP_STATS_REMOTE_SHUTDOWN() \
  79. counter_inc(sctp_cnts_h.remote_shutdown)
  80. /** called each time a connection is shutdown.
  81. * sctp notification: SCTP_SHUTDOWN_COMP
  82. */
  83. #define SCTP_STATS_ASSOC_SHUTDOWN() \
  84. counter_inc(sctp_cnts_h.assoc_shutdown)
  85. /** called each time an established connection is closed due to some error.
  86. * sctp notification: SCTP_COMM_LOST
  87. */
  88. #define SCTP_STATS_COMM_LOST() \
  89. counter_inc(sctp_cnts_h.comm_lost)
  90. /** called each time a send fails due to the buffering capacity being exceeded.
  91. * (send fails due to full kernel buffers)
  92. */
  93. #define SCTP_STATS_SENDQ_FULL() \
  94. counter_inc(sctp_cnts_h.sendq_full)
  95. /** called each time a send fails.
  96. * (send fails for any reason except buffers full)
  97. * sctp notification: SCTP_SEND_FAILED
  98. */
  99. #define SCTP_STATS_SEND_FAILED() \
  100. counter_inc(sctp_cnts_h.send_failed)
  101. /** called each time a failed send is force-retried.
  102. * (possible only if sctp_send_retries is != 0)
  103. */
  104. #define SCTP_STATS_SEND_FORCE_RETRY() \
  105. counter_inc(sctp_cnts_h.send_force_retry)
  106. #endif /* USE_SCTP_STATS */
  107. #endif /*__sctp_stats_h*/
  108. /* vi: set ts=4 sw=4 tw=79:ai:cindent: */