qos_ctx_helpers.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2007 SOMA Networks, INC.
  5. * Written By Ovidiu Sas
  6. *
  7. * This file is part of Kamailio, a free SIP server.
  8. *
  9. * Kamailio is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * Kamailio is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  22. * USA
  23. *
  24. * History:
  25. * --------
  26. * 2007-07-16 initial version (osas)
  27. */
  28. #ifndef _QOS_CTX_HELPERS_H_
  29. #define _QOS_CTX_HELPERS_H_
  30. #include "../../parser/sdp/sdp.h"
  31. #include "qos_cb.h"
  32. #define QOS_CALLER 0
  33. #define QOS_CALLEE 1
  34. typedef struct qos_sdp_st {
  35. struct qos_sdp_st *prev;
  36. struct qos_sdp_st *next;
  37. unsigned int method_dir; /* the transaction initiator: CALLER/CALLEE */
  38. int method_id; /* the method id that is carrying the sdp */
  39. str method; /* the method that is carrying the sdp */
  40. str cseq; /* the cseq of the method */
  41. unsigned int negotiation; /* the negotiation type */
  42. sdp_session_cell_t *sdp_session[2]; /* CALLER's and CALLEE's sdp */
  43. } qos_sdp_t;
  44. /**
  45. * The QoS context.
  46. */
  47. typedef struct qos_ctx_st {
  48. qos_sdp_t *negotiated_sdp;
  49. qos_sdp_t *pending_sdp;
  50. gen_lock_t lock;
  51. struct qos_head_cbl cbs;
  52. } qos_ctx_t;
  53. /*
  54. ** AFTER INVITE/183 **
  55. qos_ctx:
  56. +----------------+
  57. | *negotiated_sdp|
  58. +----------------+ qos_sdp (pending)
  59. | *pending_sdp------->+----------------+
  60. +----------------+ | *prev |
  61. +----------------+
  62. | *next |
  63. +----------------+
  64. | method_dir | sdp_session (caller)
  65. | method_id | +-->+----------+
  66. | method | | | |
  67. | cseq | | | |
  68. | negotiation | | +----------+
  69. +----------------+ |
  70. | sdp_session[0]----+
  71. +----------------+ sdp_session (callee)
  72. | sdp_session[1]------->+----------+
  73. +----------------+ | |
  74. | |
  75. +----------+
  76. ** AFTER INVITE/200ok **
  77. qos_ctx:
  78. +----------------+ qos_sdp (negotiated)
  79. | *negotiated_sdp---->+----------------+
  80. +----------------+ | *prev |
  81. | *pending_sdp | +----------------+
  82. +----------------+ | *next |
  83. +----------------+
  84. | method_dir | sdp_session (caller)
  85. | method_id | +-->+----------+
  86. | method | | | |
  87. | cseq | | | |
  88. | negotiation | | +----------+
  89. +----------------+ |
  90. | sdp_session[0]----+
  91. +----------------+ sdp_session (callee)
  92. | sdp_session[1]------->+----------+
  93. +----------------+ | |
  94. | |
  95. +----------+
  96. */
  97. qos_ctx_t* build_new_qos_ctx();
  98. void destroy_qos_ctx(qos_ctx_t *ctx);
  99. void add_sdp(qos_ctx_t *qos_ctx, unsigned int dir, struct sip_msg *_m, unsigned int role, unsigned int other_role);
  100. void remove_sdp(qos_ctx_t *qos_ctx, unsigned int dir, struct sip_msg *_m, unsigned int role, unsigned int other_role);
  101. #endif /* _QOS_CTX_HELPERS_H_ */