routing.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2005-2009 Voice Sistem SRL
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. *
  22. * History:
  23. * ---------
  24. * 2005-02-20 first version (cristian)
  25. * 2005-02-27 ported to 0.9.0 (bogdan)
  26. */
  27. #ifndef routing_h
  28. #define routing_h
  29. #include "../../str.h"
  30. #include "../../usr_avp.h"
  31. #include "prefix_tree.h"
  32. #include "dr_time.h"
  33. #define RG_HASH_SIZE
  34. #define RG_INIT_LEN 4;
  35. /* the buckets for the rt_data rg_hash */
  36. typedef struct hb_ {
  37. int rgid;
  38. ptree_t *pt;
  39. struct hb_*next;
  40. } hb_t;
  41. /* routing data is comprised of:
  42. - a list of PSTN gw
  43. - a hash over routing groups containing
  44. pointers to the coresponding prefix trees
  45. */
  46. typedef struct rt_data_ {
  47. /* list of PSTN gw */
  48. pgw_t *pgw_l;
  49. /* list of IP addr for PSTN gw */
  50. pgw_addr_t *pgw_addr_l;
  51. /* default routing list for prefixless rules */
  52. ptree_node_t noprefix;
  53. /* hash table with routing prefixes */
  54. ptree_t *pt;
  55. }rt_data_t;
  56. typedef struct _dr_group {
  57. /* 0 - use grp ; 1 - use AVP */
  58. int type;
  59. union {
  60. unsigned int grp_id;
  61. struct _avp_id{
  62. int_str name;
  63. unsigned short type;
  64. }avp_id;
  65. }u;
  66. } dr_group_t;
  67. /* init new rt_data structure */
  68. rt_data_t*
  69. build_rt_data( void );
  70. /* add a PSTN gw in the list */
  71. int
  72. add_dst(
  73. rt_data_t*,
  74. /* id */
  75. int ,
  76. /* ip address */
  77. char*,
  78. /* strip len */
  79. int,
  80. /* pri prefix */
  81. char*,
  82. /* dst type*/
  83. int,
  84. /* dst attrs*/
  85. char*
  86. );
  87. /* build a routing info list element */
  88. rt_info_t*
  89. build_rt_info(
  90. int priority,
  91. tmrec_t* time,
  92. /* ser routing table id */
  93. int route_id,
  94. /* list of destinations indexes */
  95. char* dstlst,
  96. pgw_t* pgw_l
  97. );
  98. void
  99. del_pgw_list(
  100. pgw_t *pgw_l
  101. );
  102. void
  103. free_rt_data(
  104. rt_data_t*,
  105. int
  106. );
  107. #endif