route_struct.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * $Id$
  3. *
  4. *
  5. * Copyright (C) 2001-2003 Fhg Fokus
  6. *
  7. * This file is part of ser, a free SIP server.
  8. *
  9. * ser is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * For a license to use the ser software under conditions
  15. * other than those described here, or to purchase support for this
  16. * software, please contact iptel.org by e-mail at the following addresses:
  17. * [email protected]
  18. *
  19. * ser is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. */
  28. #ifndef route_struct_h
  29. #define route_struct_h
  30. #define EXPR_DROP -127 /* used only by the expression and if evaluator */
  31. /*
  32. * Other important values (no macros for them yet):
  33. * expr true = 1
  34. * expr false = 0 (used only inside the expression and if evaluator)
  35. *
  36. * action continue or if used in condition true = 1
  37. * action drop/quit/stop script processing = 0
  38. * action error or if used in condition false = -1 (<0 and !=EXPR_DROP)
  39. *
  40. */
  41. enum { EXP_T=1, ELEM_T };
  42. enum { AND_OP=1, OR_OP, NOT_OP };
  43. enum { EQUAL_OP=10, MATCH_OP, NO_OP };
  44. enum { METHOD_O=1, URI_O, SRCIP_O, DSTIP_O, DEFAULT_O, ACTION_O, NUMBER_O};
  45. enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
  46. SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
  47. SET_PORT_T, SET_URI_T, IF_T, MODULE_T,
  48. SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
  49. LEN_GT_T, PREFIX_T, STRIP_T,
  50. APPEND_BRANCH_T,
  51. REVERT_URI_T,
  52. FORWARD_TCP_T,
  53. FORWARD_UDP_T,
  54. SEND_TCP_T};
  55. enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
  56. EXPR_ST, ACTIONS_ST, CMDF_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
  57. MYSELF_ST };
  58. struct expr{
  59. int type; /* exp, exp_elem */
  60. int op; /* and, or, not | ==, =~ */
  61. int subtype;
  62. union {
  63. struct expr* expr;
  64. int operand;
  65. }l;
  66. union {
  67. struct expr* expr;
  68. void* param;
  69. int intval;
  70. }r;
  71. };
  72. struct action{
  73. int type; /* forward, drop, log, send ...*/
  74. int p1_type;
  75. int p2_type;
  76. int p3_type;
  77. union {
  78. int number;
  79. char* string;
  80. void* data;
  81. }p1, p2, p3;
  82. struct action* next;
  83. };
  84. struct expr* mk_exp(int op, struct expr* left, struct expr* right);
  85. struct expr* mk_elem(int op, int subtype, int operand, void* param);
  86. struct action* mk_action(int type, int p1_type, int p2_type,
  87. void* p1, void* p2);
  88. struct action* mk_action3(int type, int p1_type, int p2_type, int p3_type,
  89. void* p1, void* p2, void* p3);
  90. struct action* append_action(struct action* a, struct action* b);
  91. void print_action(struct action* a);
  92. void print_expr(struct expr* exp);
  93. #endif