route.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
  51. #define EVENT_ROUTE REQUEST_ROUTE
  52. #define ANY_ROUTE (0xFFFFFFFF)
  53. /* The value of this variable is one of the route types defined above and it
  54. * determines the type of the route being executed, module functions can use
  55. * this value to determine the type of the route they are being executed in
  56. */
  57. extern int route_type;
  58. #define set_route_type(type) \
  59. do { \
  60. route_type = (type); \
  61. } while(0)
  62. #define get_route_type() route_type
  63. #define is_route_type(type) (route_type & (type))
  64. struct route_list{
  65. struct action** rlist;
  66. int idx; /* first empty entry */
  67. int entries; /* total number of entries */
  68. struct str_hash_table names; /* name to route index mappings */
  69. };
  70. /* main "script table" */
  71. extern struct route_list main_rt;
  72. /* main reply route table */
  73. extern struct route_list onreply_rt;
  74. extern struct route_list failure_rt;
  75. extern struct route_list branch_rt;
  76. extern struct route_list onsend_rt;
  77. extern struct route_list event_rt;
  78. /* script optimization level */
  79. extern int scr_opt_lev;
  80. int init_routes(void);
  81. void destroy_routes(void);
  82. int route_get(struct route_list* rt, char* name);
  83. int route_lookup(struct route_list* rt, char* name);
  84. void push(struct action* a, struct action** head);
  85. int add_actions(struct action* a, struct action** head);
  86. void print_rls(void);
  87. int fix_rls(void);
  88. int eval_expr(struct run_act_ctx* h, struct expr* e, struct sip_msg* msg);
  89. /* fixup functions*/
  90. int fix_actions(struct action* a);
  91. int fix_expr(struct expr* exp);
  92. #endif