enum_mod.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 initialization function prototype
  46. */
  47. static int mod_init(void);
  48. /*
  49. * Module parameter variables
  50. */
  51. char* domain_suffix = "e164.arpa.";
  52. char* tel_uri_params = "";
  53. char* branchlabel = "i";
  54. char* i_enum_suffix = "e164.arpa.";
  55. char* bl_algorithm = "cc";
  56. /*
  57. * Internal module variables
  58. */
  59. str suffix;
  60. str param;
  61. str service;
  62. str i_suffix;
  63. str i_branchlabel;
  64. str i_bl_alg;
  65. /*
  66. * Exported functions
  67. */
  68. static cmd_export_t cmds[] = {
  69. {"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE},
  70. {"enum_query", (cmd_function)enum_query_1, 1, fixup_str_null,
  71. fixup_free_str_null, REQUEST_ROUTE},
  72. {"enum_query", (cmd_function)enum_query_2, 2, fixup_str_str,
  73. fixup_free_str_str, REQUEST_ROUTE},
  74. {"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null,
  75. fixup_free_pvar_null, REQUEST_ROUTE},
  76. {"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str,
  77. fixup_free_pvar_str, REQUEST_ROUTE},
  78. {"enum_pv_query", (cmd_function)enum_pv_query_3, 3,
  79. fixup_pvar_str_str, fixup_free_pvar_str_str, REQUEST_ROUTE},
  80. {"is_from_user_enum", (cmd_function)is_from_user_enum_0, 0, 0, 0,
  81. REQUEST_ROUTE},
  82. {"is_from_user_enum", (cmd_function)is_from_user_enum_1, 1,
  83. fixup_str_null, fixup_free_str_null, REQUEST_ROUTE},
  84. {"is_from_user_enum", (cmd_function)is_from_user_enum_2, 2,
  85. fixup_str_str, fixup_free_str_str, REQUEST_ROUTE},
  86. {"i_enum_query", (cmd_function)i_enum_query_0, 0, 0, 0, REQUEST_ROUTE},
  87. {"i_enum_query", (cmd_function)i_enum_query_1, 1, fixup_str_null, 0,
  88. REQUEST_ROUTE},
  89. {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0,
  90. REQUEST_ROUTE},
  91. {0, 0, 0, 0, 0, 0}
  92. };
  93. /*
  94. * Exported parameters
  95. */
  96. static param_export_t params[] = {
  97. {"domain_suffix", STR_PARAM, &domain_suffix},
  98. {"tel_uri_params", STR_PARAM, &tel_uri_params},
  99. {"branchlabel", STR_PARAM, &branchlabel},
  100. {"i_enum_suffix", STR_PARAM, &i_enum_suffix},
  101. {"bl_algorithm", STR_PARAM, &bl_algorithm},
  102. {0, 0, 0}
  103. };
  104. /*
  105. * Module parameter variables
  106. */
  107. struct module_exports exports = {
  108. "enum",
  109. DEFAULT_DLFLAGS, /* dlopen flags */
  110. cmds, /* Exported functions */
  111. params, /* Exported parameters */
  112. 0, /* exported statistics */
  113. 0, /* exported MI functions */
  114. 0, /* exported pseudo-variables */
  115. 0, /* extra processes */
  116. mod_init, /* module initialization function */
  117. 0, /* response function*/
  118. 0, /* destroy function */
  119. 0 /* per-child init function */
  120. };
  121. static int mod_init(void)
  122. {
  123. suffix.s = domain_suffix;
  124. suffix.len = strlen(suffix.s);
  125. param.s = tel_uri_params;
  126. param.len = strlen(param.s);
  127. service.len = 0;
  128. i_suffix.s = i_enum_suffix;
  129. i_suffix.len = strlen(i_enum_suffix);
  130. i_branchlabel.s = branchlabel;
  131. i_branchlabel.len = strlen(branchlabel);
  132. i_bl_alg.s = bl_algorithm;
  133. i_bl_alg.len = strlen(bl_algorithm);
  134. return 0;
  135. }