osip_dialog.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
  3. Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. #ifndef _DIALOG_H_
  17. #define _DIALOG_H_
  18. #include <osip2/osip.h>
  19. /**
  20. * @file osip_dialog.h
  21. * @brief oSIP dialog Routines
  22. *
  23. */
  24. /**
  25. * @defgroup oSIP_DIALOG oSIP dialog Handling
  26. * @{
  27. */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #ifndef DOXYGEN
  32. typedef enum _osip_dialog_type_t { CALLER, CALLEE } osip_dialog_type_t;
  33. #endif
  34. /**
  35. * Structure for referencing a dialog.
  36. * @var osip_dialog_t
  37. */
  38. typedef struct osip_dialog osip_dialog_t;
  39. /**
  40. * Structure for referencing a dialog.
  41. * @struct osip_dialog
  42. */
  43. struct osip_dialog {
  44. char *call_id; /**< Call-ID*/
  45. char *local_tag; /**< local tag */
  46. char *remote_tag; /**< remote tag */
  47. char *line_param; /**< line param from request uri for incoming calls */
  48. osip_list_t route_set; /**< route set */
  49. int local_cseq; /**< last local cseq */
  50. int remote_cseq; /**< last remote cseq*/
  51. osip_to_t *remote_uri; /**< remote_uri */
  52. osip_from_t *local_uri; /**< local_uri */
  53. osip_contact_t *remote_contact_uri;
  54. /**< remote contact_uri */
  55. int secure; /**< use secure transport layer */
  56. osip_dialog_type_t type; /**< type of dialog (CALLEE or CALLER) */
  57. state_t state; /**< DIALOG_EARLY || DIALOG_CONFIRMED || DIALOG_CLOSED */
  58. void *your_instance; /**< for application data reference */
  59. };
  60. /**
  61. * Link osip dialog to application
  62. * @param dialog The osip dialog
  63. * @param instance The application instance
  64. */
  65. #define osip_dialog_set_instance(dialog, instance) (dialog)->your_instance = (void *) (instance)
  66. /**
  67. * Retrieve application instance from dialog
  68. * @param dialog The osip dialog
  69. * @return instance The application instance
  70. */
  71. #define osip_dialog_get_instance(dialog) (dialog)->your_instance
  72. /**
  73. * Allocate a osip_dialog_t element as a UAC.
  74. * NOTE1: The dialog should be created when the first response is received.
  75. * (except for a 100 Trying)
  76. * NOTE2: Remote UA should be compliant! If not (not tag in the to header?)
  77. * the old mechanism is used to match the request but if 2 uncompliant
  78. * UA both answer 200 OK for the same transaction, they won't be detected.
  79. * This is a major BUG in the old rfc.
  80. * @param dialog The element to allocate.
  81. * @param response The response containing the informations.
  82. */
  83. int osip_dialog_init_as_uac(osip_dialog_t **dialog, osip_message_t *response);
  84. /**
  85. * Allocate a osip_dialog_t element as a UAC.
  86. * <UL><LI>This could be used to initiate dialog with a NOTIFY coming
  87. * before the answer for a subscribe has reached us.</LI></UL>
  88. * @param dialog The element to allocate.
  89. * @param next_request The response containing the informations.
  90. * @param local_cseq The local cseq
  91. */
  92. int osip_dialog_init_as_uac_with_remote_request(osip_dialog_t **dialog, osip_message_t *next_request, int local_cseq);
  93. /**
  94. * Allocate a osip_dialog_t element as a UAS.
  95. * NOTE1: The dialog should be created when the first response is sent.
  96. * (except for a 100 Trying)
  97. * @param dialog The element to allocate.
  98. * @param invite The INVITE request containing some informations.
  99. * @param response The response containing other informations.
  100. */
  101. int osip_dialog_init_as_uas(osip_dialog_t **dialog, osip_message_t *invite, osip_message_t *response);
  102. /**
  103. * Free all resource in a osip_dialog_t element.
  104. * @param dialog The element to free.
  105. */
  106. void osip_dialog_free(osip_dialog_t *dialog);
  107. /**
  108. * Set the state of the dialog.
  109. * This is useful to keep information on who is the initiator of the call.
  110. * @param dialog The element to work on.
  111. * @param type The type of dialog (CALLEE or CALLER).
  112. */
  113. void osip_dialog_set_state(osip_dialog_t *dialog, state_t type);
  114. /**
  115. * Update the Route-Set as UAS of a dialog.
  116. * NOTE: bis-09 says that only INVITE transactions can update the route-set.
  117. * NOTE: bis-09 says that updating the route-set means: update the contact
  118. * field only (AND NOT THE ROUTE-SET). This method follow this behaviour.
  119. * NOTE: This method should be called for each request
  120. * received for a dialog.
  121. * @param dialog The element to work on.
  122. * @param invite The invite received.
  123. */
  124. int osip_dialog_update_route_set_as_uas(osip_dialog_t *dialog, osip_message_t *invite);
  125. /**
  126. * Update the CSeq (remote cseq) during a UAS transaction of a dialog.
  127. * NOTE: All INCOMING transactions MUST update the remote CSeq.
  128. * @param dialog The element to work on.
  129. * @param request The request received.
  130. */
  131. int osip_dialog_update_osip_cseq_as_uas(osip_dialog_t *dialog, osip_message_t *request);
  132. /**
  133. * Match a response received with a dialog.
  134. * @param dialog The element to work on.
  135. * @param response The response received.
  136. */
  137. int osip_dialog_match_as_uac(osip_dialog_t *dialog, osip_message_t *response);
  138. /**
  139. * Update the tag as UAC of a dialog?. (this could be needed if the 180
  140. * does not contains any tag, but the 200 contains one.
  141. * @param dialog The element to work on.
  142. * @param response The response received.
  143. */
  144. int osip_dialog_update_tag_as_uac(osip_dialog_t *dialog, osip_message_t *response);
  145. /**
  146. * Update the Route-Set as UAC of a dialog.
  147. * NOTE: bis-09 says that only INVITE transactions can update the route-set.
  148. * NOTE: bis-09 says that updating the route-set means: update the contact
  149. * field only (AND NOT THE ROUTE-SET). This method follow this behaviour.
  150. * NOTE: This method should be called for each request (except 100 Trying)
  151. * received for a dialog.
  152. * @param dialog The element to work on.
  153. * @param response The response received.
  154. */
  155. int osip_dialog_update_route_set_as_uac(osip_dialog_t *dialog, osip_message_t *response);
  156. /**
  157. * Match a request (response sent?) received with a dialog.
  158. * @param dialog The element to work on.
  159. * @param request The request received.
  160. */
  161. int osip_dialog_match_as_uas(osip_dialog_t *dialog, osip_message_t *request);
  162. /**
  163. * Is dialog initiated by as CALLER
  164. * @param dialog The element to work on.
  165. */
  166. int osip_dialog_is_originator(osip_dialog_t *dialog);
  167. /**
  168. * Is dialog initiated by as CALLEE
  169. * @param dialog The element to work on.
  170. */
  171. int osip_dialog_is_callee(osip_dialog_t *dialog);
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175. /** @} */
  176. #endif