2
0

route.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser 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. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  26. */
  27. #ifndef route_h
  28. #define route_h
  29. #include <sys/types.h>
  30. #include <regex.h>
  31. #include <netdb.h>
  32. #include "config.h"
  33. #include "error.h"
  34. #include "route_struct.h"
  35. #include "action.h"
  36. #include "parser/msg_parser.h"
  37. #include "str_hash.h"
  38. /*#include "cfg_parser.h" */
  39. /* Various types of route sections, make sure that the values defined in the
  40. * macros below occupy disjunct bits so that they can also be used as flags
  41. */
  42. #define REQUEST_ROUTE (1 << 0)
  43. #define FAILURE_ROUTE (1 << 1)
  44. #define TM_ONREPLY_ROUTE (1 << 2)
  45. #define BRANCH_ROUTE (1 << 3)
  46. #define ONSEND_ROUTE (1 << 4)
  47. #define ERROR_ROUTE (1 << 5)
  48. #define LOCAL_ROUTE (1 << 6)
  49. #define CORE_ONREPLY_ROUTE (1 << 7)
  50. #define BRANCH_FAILURE_ROUTE (1 << 8)
  51. #define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
  52. #define EVENT_ROUTE REQUEST_ROUTE
  53. #define ANY_ROUTE (0xFFFFFFFF)
  54. /* The value of this variable is one of the route types defined above and it
  55. * determines the type of the route being executed, module functions can use
  56. * this value to determine the type of the route they are being executed in
  57. */
  58. extern int route_type;
  59. #define set_route_type(type) \
  60. do { \
  61. route_type = (type); \
  62. } while(0)
  63. #define get_route_type() route_type
  64. #define is_route_type(type) (route_type & (type))
  65. struct route_list{
  66. struct action** rlist;
  67. int idx; /* first empty entry */
  68. int entries; /* total number of entries */
  69. struct str_hash_table names; /* name to route index mappings */
  70. };
  71. /* main "script table" */
  72. extern struct route_list main_rt;
  73. /* main reply route table */
  74. extern struct route_list onreply_rt;
  75. extern struct route_list failure_rt;
  76. extern struct route_list branch_rt;
  77. extern struct route_list onsend_rt;
  78. extern struct route_list event_rt;
  79. /* script optimization level */
  80. extern int scr_opt_lev;
  81. int init_routes(void);
  82. void destroy_routes(void);
  83. int route_get(struct route_list* rt, char* name);
  84. int route_lookup(struct route_list* rt, char* name);
  85. void push(struct action* a, struct action** head);
  86. int add_actions(struct action* a, struct action** head);
  87. void print_rls(void);
  88. int fix_rls(void);
  89. int eval_expr(struct run_act_ctx* h, struct expr* e, struct sip_msg* msg);
  90. /* fixup functions*/
  91. int fix_actions(struct action* a);
  92. int fix_expr(struct expr* exp);
  93. #endif