route_struct.h
c07508e2
 /*
  * $Id$
  *
7dd0b342
  *
53c7e0f1
  * Copyright (C) 2001-2003 FhG Fokus
7dd0b342
  *
  * This file is part of ser, a free SIP server.
  *
  * ser is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
  * For a license to use the ser software under conditions
  * other than those described here, or to purchase support for this
  * software, please contact iptel.org by e-mail at the following addresses:
  *    info@iptel.org
  *
  * ser is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
c07508e2
  */
3e8c3475
 /* History:
  * --------
  *
  *  2003-04-12  FORCE_RPORT_T added (andrei)
1d9f91d6
  *  2003-04-22  strip_tail added (jiri)
dda578ba
  *  2003-10-10  >,<,>=,<=, != and MSGLEN_O added (andrei)
59653eb8
  *  2003-10-28  FORCE_TCP_ALIAS added (andrei)
1bee75ad
  *  2004-02-24  added LOAD_AVP_T and AVP_TO_URI_T (bogdan)
3e8c3475
  */
c07508e2
 
7dd0b342
 
c07508e2
 #ifndef route_struct_h
 #define route_struct_h
 
a1041efe
 #define EXPR_DROP -127  /* used only by the expression and if evaluator */
 /*
  * Other important values (no macros for them yet):
  * expr true = 1
  * expr false = 0 (used only inside the expression and if evaluator)
  * 
  * action continue  or if used in condition true = 1
  * action drop/quit/stop script processing = 0
  * action error or if used in condition false = -1 (<0 and !=EXPR_DROP)
  * 
  */
 
 
c07508e2
 enum { EXP_T=1, ELEM_T };
 enum { AND_OP=1, OR_OP, NOT_OP };
dda578ba
 enum { EQUAL_OP=10, MATCH_OP, GT_OP, LT_OP, GTE_OP, LTE_OP, DIFF_OP, NO_OP };
6b7de230
 enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
dda578ba
 	   DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, DEFAULT_O, ACTION_O,
 	   NUMBER_O};
c07508e2
 
f20a56a2
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T, 
3881f12c
 		SET_PORT_T, SET_URI_T, IF_T, MODULE_T,
1f377e97
 		SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
1d9f91d6
 		LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
caf80ae6
 		APPEND_BRANCH_T,
0c5da34b
 		REVERT_URI_T,
 		FORWARD_TCP_T,
f2f969dd
 		FORWARD_UDP_T,
e9b02e8e
 		FORWARD_TLS_T,
3e8c3475
 		SEND_TCP_T,
6bfaa042
 		FORCE_RPORT_T,
 		SET_ADV_ADDR_T,
59653eb8
 		SET_ADV_PORT_T,
1580c821
 		FORCE_TCP_ALIAS_T,
1bee75ad
 		LOAD_AVP_T,
6cd48835
 		AVP_TO_URI_T,
 		FORCE_SEND_SOCKET_T
3e8c3475
 };
f20a56a2
 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
855c2e68
 		EXPR_ST, ACTIONS_ST, CMDF_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
6cd48835
 		MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST };
c07508e2
 
 	
 struct expr{
 	int type; /* exp, exp_elem */
7268726e
 	int op; /* and, or, not | ==,  =~ */
c07508e2
 	int  subtype;
 	union {
 		struct expr* expr;
 		int operand;
 	}l;
 	union {
 		struct expr* expr;
 		void* param;
09e52ebb
 		int   intval;
c07508e2
 	}r;
 };
 
 
 struct action{
 	int type;  /* forward, drop, log, send ...*/
 	int p1_type;
 	int p2_type;
f20a56a2
 	int p3_type;
c07508e2
 	union {
b667b278
 		long number;
c07508e2
 		char* string;
 		void* data;
f20a56a2
 	}p1, p2, p3;
c07508e2
 	struct action* next;
 };
 
09e52ebb
 
 
c07508e2
 struct expr* mk_exp(int op, struct expr* left, struct expr* right);
 struct expr* mk_elem(int op, int subtype, int operand, void* param);
f20a56a2
 struct action* mk_action(int type, int p1_type, int p2_type,
 							void* p1, void* p2);
 struct action* mk_action3(int type, int p1_type, int p2_type, int p3_type, 
 							void* p1, void* p2, void* p3);
09e52ebb
 struct action* append_action(struct action* a, struct action* b);
 
 
c07508e2
 void print_action(struct action* a);
 void print_expr(struct expr* exp);
 
 
 
 
 
 #endif