dialog.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2010, Digium, Inc.
  5. *
  6. * See http://www.asterisk.org for more information about
  7. * the Asterisk project. Please do not directly contact
  8. * any of the maintainers of this project for assistance;
  9. * the project provides a web site, mailing lists and IRC
  10. * channels for your use.
  11. *
  12. * This program is free software, distributed under the terms of
  13. * the GNU General Public License Version 2. See the LICENSE file
  14. * at the top of the source tree.
  15. */
  16. /*!
  17. * \file
  18. * \brief sip dialog management header file
  19. */
  20. #include "sip.h"
  21. #ifndef _SIP_DIALOG_H
  22. #define _SIP_DIALOG_H
  23. /*! \brief
  24. * when we create or delete references, make sure to use these
  25. * functions so we keep track of the refcounts.
  26. * To simplify the code, we allow a NULL to be passed to dialog_unref().
  27. */
  28. #define dialog_ref(dialog, tag) ao2_t_bump(dialog, tag)
  29. #define dialog_unref(dialog, tag) ({ ao2_t_cleanup(dialog, tag); (NULL); })
  30. struct sip_pvt *__sip_alloc(ast_string_field callid, struct ast_sockaddr *sin,
  31. int useglobal_nat, const int intended_method, struct sip_request *req, struct ast_callid *logger_callid,
  32. const char *file, int line, const char *func);
  33. #define sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid) \
  34. __sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid, __FILE__, __LINE__, __PRETTY_FUNCTION__)
  35. /*!
  36. * \brief Schedule final destruction of SIP dialog.
  37. *
  38. * \note This cannot be canceled.
  39. *
  40. * \details
  41. * This function is used to keep a dialog around for a period of time in order
  42. * to properly respond to any retransmits.
  43. */
  44. void sip_scheddestroy_final(struct sip_pvt *p, int ms);
  45. /*! \brief Schedule destruction of SIP dialog */
  46. void sip_scheddestroy(struct sip_pvt *p, int ms);
  47. /*! \brief Cancel destruction of SIP dialog. */
  48. void sip_cancel_destroy(struct sip_pvt *pvt);
  49. /*!
  50. * \brief Unlink a dialog from the dialogs container, as well as any other places
  51. * that it may be currently stored.
  52. *
  53. * \note A reference to the dialog must be held before calling
  54. * this function, and this function does not release that
  55. * reference.
  56. *
  57. * \note The dialog must not be locked when called.
  58. */
  59. void dialog_unlink_all(struct sip_pvt *dialog);
  60. /*! \brief Acknowledges receipt of a packet and stops retransmission
  61. * called with p locked*/
  62. int __sip_ack(struct sip_pvt *p, uint32_t seqno, int resp, int sipmethod, uint32_t rseqno);
  63. /*! \brief Pretend to ack all packets
  64. * called with p locked */
  65. void __sip_pretend_ack(struct sip_pvt *p);
  66. /*! \brief Acks receipt of packet, keep it around (used for provisional responses) */
  67. int __sip_semi_ack(struct sip_pvt *p, uint32_t seqno, int resp, int sipmethod);
  68. #endif /* defined(_SIP_DIALOG_H) */