qos_cb.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2007 SOMA Networks, Inc.
  5. * Written by Ovidiu Sas (osas)
  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
  10. * it 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,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU 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 USA
  22. *
  23. * History:
  24. * --------
  25. * 2007-07-11 initial version (osas)
  26. */
  27. #ifndef _QOS_QOS_CB_H_
  28. #define _QOS_QOS_CB_H_
  29. #include "../../parser/msg_parser.h"
  30. struct qos_ctx_st;
  31. struct qos_cb_params {
  32. struct sip_msg *msg; /* sip msg related to the callback event */
  33. struct qos_sdp_st *sdp; /* pointer to the sdp that is added/updated/removed */
  34. unsigned int role;
  35. void **param; /* parameter passed at callback registration*/
  36. };
  37. /* callback function prototype */
  38. typedef void (qos_cb) (struct qos_ctx_st *qos, int type,
  39. struct qos_cb_params *params);
  40. /* register callback function prototype */
  41. typedef int (*register_qoscb_f)(struct qos_ctx_st *qos, int cb_types,
  42. qos_cb f, void *param);
  43. #define QOSCB_CREATED (1<<0)
  44. #define QOSCB_ADD_SDP (1<<1)
  45. #define QOSCB_UPDATE_SDP (1<<2)
  46. #define QOSCB_REMOVE_SDP (1<<3)
  47. #define QOSCB_TERMINATED (1<<4)
  48. /*
  49. * Callback logic ....
  50. *
  51. --INVITE(SDP)-->
  52. +----------------<QOSCB_ADD>
  53. <---183(SDP)----
  54. +----------------<QOSCB_UPDATE>
  55. <---200(SDP)----
  56. +----------------<QOSCB_UPDATE>
  57. -----ACK------->
  58. -----BYE------->
  59. +----------------<QOSCB_REMOVE>
  60. <-----200-------
  61. */
  62. struct qos_callback {
  63. int types;
  64. qos_cb* callback;
  65. void *param;
  66. struct qos_callback* next;
  67. };
  68. struct qos_head_cbl {
  69. struct qos_callback *first;
  70. int types;
  71. };
  72. int init_qos_callbacks();
  73. void destroy_qos_callbacks();
  74. void destroy_qos_callbacks_list(struct qos_callback *cb);
  75. int register_qoscb(struct qos_ctx_st* qos, int types, qos_cb f, void *param);
  76. void run_create_cbs(struct qos_ctx_st *qos, struct sip_msg *msg);
  77. void run_qos_callbacks( int type, struct qos_ctx_st *qos,
  78. struct qos_sdp_st *sdp, unsigned int role,
  79. struct sip_msg *msg);
  80. #endif