sip_transport_loop.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJSIP_TRANSPORT_LOOP_H__
  20. #define __PJSIP_TRANSPORT_LOOP_H__
  21. /**
  22. * @file sip_transport_loop.h
  23. * @brief
  24. * Loopback transport (for debugging)
  25. */
  26. #include <pjsip/sip_transport.h>
  27. /**
  28. * @defgroup PJSIP_TRANSPORT_LOOP Loop Transport
  29. * @ingroup PJSIP_TRANSPORT
  30. * @brief Loopback transport (for testing purposes).
  31. * @{
  32. * The loopback transport simply bounce back outgoing messages as
  33. * incoming messages. This feature is used mostly during automated
  34. * testing, to provide controlled behavior.
  35. */
  36. PJ_BEGIN_DECL
  37. /**
  38. * Create and start datagram loop transport.
  39. *
  40. * @param endpt The endpoint instance.
  41. * @param transport Pointer to receive the transport instance.
  42. *
  43. * @return PJ_SUCCESS on success.
  44. */
  45. PJ_DECL(pj_status_t) pjsip_loop_start( pjsip_endpoint *endpt,
  46. pjsip_transport **transport);
  47. /**
  48. * Enable/disable flag to discard any packets sent using the specified
  49. * loop transport.
  50. *
  51. * @param tp The loop transport.
  52. * @param discard If non-zero, any outgoing packets will be discarded.
  53. * @param prev_value Optional argument to receive previous value of
  54. * the discard flag.
  55. *
  56. * @return PJ_SUCCESS on success.
  57. */
  58. PJ_DECL(pj_status_t) pjsip_loop_set_discard( pjsip_transport *tp,
  59. pj_bool_t discard,
  60. pj_bool_t *prev_value );
  61. /**
  62. * Enable/disable flag to simulate network error. When this flag is set,
  63. * outgoing transmission will return either immediate error or error via
  64. * callback. If error is to be notified via callback, then the notification
  65. * will occur after some delay, which is controlled by #pjsip_loop_set_delay().
  66. *
  67. * @param tp The loop transport.
  68. * @param fail_flag If set to 1, the transport will return fail to deliver
  69. * the message. If delay is zero, failure will occur
  70. * immediately; otherwise it will be reported in callback.
  71. * If set to zero, the transport will successfully deliver
  72. * the packet.
  73. * @param prev_value Optional argument to receive previous value of
  74. * the failure flag.
  75. *
  76. * @return PJ_SUCCESS on success.
  77. */
  78. PJ_DECL(pj_status_t) pjsip_loop_set_failure( pjsip_transport *tp,
  79. int fail_flag,
  80. int *prev_value );
  81. /**
  82. * Set delay (in miliseconds) before packet is received by the other end
  83. * of the loop transport. This will also
  84. * control the delay for error notification callback.
  85. *
  86. * @param tp The loop transport.
  87. * @param delay Delay, in miliseconds.
  88. * @param prev_value Optional argument to receive previous value of the
  89. * delay.
  90. *
  91. * @return PJ_SUCCESS on success.
  92. */
  93. PJ_DECL(pj_status_t) pjsip_loop_set_recv_delay( pjsip_transport *tp,
  94. unsigned delay,
  95. unsigned *prev_value);
  96. /**
  97. * Set delay (in miliseconds) before send notification is delivered to sender.
  98. * This will also control the delay for error notification callback.
  99. *
  100. * @param tp The loop transport.
  101. * @param delay Delay, in miliseconds.
  102. * @param prev_value Optional argument to receive previous value of the
  103. * delay.
  104. *
  105. * @return PJ_SUCCESS on success.
  106. */
  107. PJ_DECL(pj_status_t) pjsip_loop_set_send_callback_delay( pjsip_transport *tp,
  108. unsigned delay,
  109. unsigned *prev_value);
  110. /**
  111. * Set both receive and send notification delay.
  112. *
  113. * @param tp The loop transport.
  114. * @param delay Delay, in miliseconds.
  115. *
  116. * @return PJ_SUCCESS on success.
  117. */
  118. PJ_DECL(pj_status_t) pjsip_loop_set_delay( pjsip_transport *tp,
  119. unsigned delay );
  120. PJ_END_DECL
  121. /**
  122. * @}
  123. */
  124. #endif /* __PJSIP_TRANSPORT_LOOP_H__ */