enum_mod.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * $Id$
  3. *
  4. * Enum module
  5. *
  6. * Copyright (C) 2002-2008 Juha Heinanen
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * History:
  25. * -------
  26. * 2003-03-11: New module interface (janakj)
  27. * 2003-03-16: flags export parameter added (janakj)
  28. * 2003-12-15: added suffix parameter to enum_query (jh)
  29. */
  30. /*!
  31. * \file
  32. * \brief SIP-router enum :: Enum and E164 related functions
  33. * \ingroup enum
  34. * Module: \ref enum
  35. */
  36. #include "enum_mod.h"
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include "../../sr_module.h"
  40. #include "../../error.h"
  41. #include "../../mod_fix.h"
  42. #include "enum.h"
  43. MODULE_VERSION
  44. /*
  45. * Module parameter variables
  46. */
  47. str suffix = str_init("e164.arpa.");
  48. str param = str_init("");
  49. str i_branchlabel = str_init("i");
  50. str i_suffix = str_init("e164.arpa.");
  51. str i_bl_alg = str_init("cc");
  52. str service = {0,0};
  53. /*
  54. * Exported functions
  55. */
  56. static cmd_export_t cmds[] = {
  57. {"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE},
  58. {"enum_query", (cmd_function)enum_query_1, 1, fixup_spve_null, 0,
  59. REQUEST_ROUTE},
  60. {"enum_query", (cmd_function)enum_query_2, 2, fixup_spve_str, 0,
  61. REQUEST_ROUTE},
  62. {"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null,
  63. fixup_free_pvar_null, REQUEST_ROUTE},
  64. {"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str,
  65. fixup_free_pvar_str, REQUEST_ROUTE},
  66. {"enum_pv_query", (cmd_function)enum_pv_query_3, 3,
  67. fixup_pvar_str_str, fixup_free_pvar_str_str, REQUEST_ROUTE},
  68. {"is_from_user_enum", (cmd_function)is_from_user_enum_0, 0, 0, 0,
  69. REQUEST_ROUTE},
  70. {"is_from_user_enum", (cmd_function)is_from_user_enum_1, 1,
  71. fixup_str_null, fixup_free_str_null, REQUEST_ROUTE},
  72. {"is_from_user_enum", (cmd_function)is_from_user_enum_2, 2,
  73. fixup_str_str, fixup_free_str_str, REQUEST_ROUTE},
  74. {"i_enum_query", (cmd_function)i_enum_query_0, 0, 0, 0, REQUEST_ROUTE},
  75. {"i_enum_query", (cmd_function)i_enum_query_1, 1, fixup_str_null, 0,
  76. REQUEST_ROUTE},
  77. {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0,
  78. REQUEST_ROUTE},
  79. {0, 0, 0, 0, 0, 0}
  80. };
  81. /*
  82. * Exported parameters
  83. */
  84. static param_export_t params[] = {
  85. {"domain_suffix", PARAM_STR, &suffix},
  86. {"tel_uri_params", PARAM_STR, &param},
  87. {"branchlabel", PARAM_STR, &i_branchlabel},
  88. {"i_enum_suffix", PARAM_STR, &i_suffix},
  89. {"bl_algorithm", PARAM_STR, &i_bl_alg},
  90. {0, 0, 0}
  91. };
  92. /*
  93. * Module parameter variables
  94. */
  95. struct module_exports exports = {
  96. "enum",
  97. DEFAULT_DLFLAGS, /* dlopen flags */
  98. cmds, /* Exported functions */
  99. params, /* Exported parameters */
  100. 0, /* exported statistics */
  101. 0, /* exported MI functions */
  102. 0, /* exported pseudo-variables */
  103. 0, /* extra processes */
  104. 0, /* module initialization function */
  105. 0, /* response function*/
  106. 0, /* destroy function */
  107. 0 /* per-child init function */
  108. };