qos.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * $Id$
  3. *
  4. * QoS module - support for tracking dialogs and SDP
  5. *
  6. * Copyright (C) 2007 SOMA Networks, Inc.
  7. * Written by: Ovidiu Sas (osas)
  8. *
  9. * This file is part of Kamailio, a free SIP server.
  10. *
  11. * Kamailio is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version
  15. *
  16. * Kamailio is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  24. * USA
  25. *
  26. * History:
  27. * --------
  28. * 2007-07-16 initial version (osas)
  29. */
  30. #include <stdio.h>
  31. #include <string.h>
  32. #include <stdlib.h>
  33. #include "../../sr_module.h"
  34. #include "qos_load.h"
  35. #include "qos_handlers.h" /* also includes sr_module.h needed by
  36. handlers */
  37. MODULE_VERSION
  38. static int mod_init(void);
  39. static void mod_destroy(void);
  40. /* The qos message flag value */
  41. static int qos_flag = -1;
  42. /*
  43. * Binding to the dialog module
  44. */
  45. struct dlg_binds dialog_st;
  46. struct dlg_binds *dlg_binds = &dialog_st;
  47. static cmd_export_t cmds[]={
  48. {"load_qos", (cmd_function)load_qos, 0, 0, 0, 0},
  49. {0,0,0,0,0,0}
  50. };
  51. /*
  52. * Script parameters
  53. */
  54. static param_export_t mod_params[]={
  55. { "qos_flag", INT_PARAM, &qos_flag},
  56. { 0,0,0 }
  57. };
  58. struct module_exports exports= {
  59. "qos", /* module's name */
  60. DEFAULT_DLFLAGS, /* dlopen flags */
  61. cmds, /* exported functions */
  62. mod_params, /* param exports */
  63. 0, /* exported statistics */
  64. 0, /* exported MI functions */
  65. 0, /* exported pseudo-variables */
  66. 0, /* extra processes */
  67. mod_init, /* module initialization function */
  68. 0, /* reply processing function */
  69. mod_destroy, /* Destroy function */
  70. 0 /* per-child init function */
  71. };
  72. int load_qos( struct qos_binds *qosb)
  73. {
  74. qosb->register_qoscb = register_qoscb;
  75. return 1;
  76. }
  77. /**
  78. * The initialization function, called when the module is loaded by
  79. * the script. This function is called only once.
  80. *
  81. * Bind to the dialog module and setup the callbacks. Also initialize
  82. * the shared memory to store our interninal information in.
  83. */
  84. static int mod_init(void)
  85. {
  86. if (qos_flag == -1) {
  87. LM_ERR("no qos flag set!!\n");
  88. return -1;
  89. }
  90. else if (qos_flag > MAX_FLAG) {
  91. LM_ERR("invalid qos flag %d!!\n", qos_flag);
  92. return -1;
  93. }
  94. /* init callbacks */
  95. if (init_qos_callbacks()!=0) {
  96. LM_ERR("cannot init callbacks\n");
  97. return -1;
  98. }
  99. /* Register the main (static) dialog call back. */
  100. if (load_dlg_api(&dialog_st) != 0) {
  101. LM_ERR("Can't load dialog hooks");
  102. return(-1);
  103. }
  104. /* Load dialog hooks */
  105. dialog_st.register_dlgcb(NULL, DLGCB_CREATED, qos_dialog_created_CB, NULL, NULL);
  106. /*
  107. * We are GOOD-TO-GO.
  108. */
  109. return 0;
  110. }
  111. static void mod_destroy(void)
  112. {
  113. destroy_qos_callbacks();
  114. }