Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

route_struct.h

Go to the documentation of this file.
00001 /*
00002  * $Id: route_struct.h,v 1.45 2009/03/10 16:26:35 tirpi Exp $
00003  *
00004  *
00005  * Copyright (C) 2001-2003 FhG Fokus
00006  *
00007  * This file is part of ser, a free SIP server.
00008  *
00009  * ser is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * For a license to use the ser software under conditions
00015  * other than those described here, or to purchase support for this
00016  * software, please contact iptel.org by e-mail at the following addresses:
00017  *    info@iptel.org
00018  *
00019  * ser is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  */
00028 /* History:
00029  * --------
00030  *
00031  *  2003-04-12  FORCE_RPORT_T added (andrei)
00032  *  2003-04-22  strip_tail added (jiri)
00033  *  2003-10-10  >,<,>=,<=, != and MSGLEN_O added (andrei)
00034  *  2003-10-28  FORCE_TCP_ALIAS added (andrei)
00035  *  2004-02-24  added LOAD_AVP_T and AVP_TO_URI_T (bogdan)
00036  *  2005-12-11  added SND{IP,PORT,PROTO,AF}_O & TO{IP,PORT}_O (andrei)
00037  *  2005-12-19  select framework added SELECT_O and SELECT_ST (mma)
00038  *  2008-12-17  added UDP_MTU_TRY_PROTO_T (andrei)
00039  */
00040 
00041 
00042 #ifndef route_struct_h
00043 #define route_struct_h
00044 
00045 #include <sys/types.h>
00046 #include <regex.h>
00047 #include "select.h"
00048 #include "usr_avp.h"
00049 
00050 #define EXPR_DROP -127  /* used only by the expression and if evaluator */
00051 /*
00052  * Other important values (no macros for them yet):
00053  * expr true = 1
00054  * expr false = 0 (used only inside the expression and if evaluator)
00055  *
00056  * action continue  or if used in condition true = 1
00057  * action drop/quit/stop script processing = 0
00058  * action error or if used in condition false = -1 (<0 and !=EXPR_DROP)
00059  *
00060  */
00061 
00062 
00063 enum { EXP_T=1, ELEM_T };
00064 enum { LOGAND_OP=1, LOGOR_OP, NOT_OP, BINAND_OP, BINOR_OP };
00065 enum { EQUAL_OP=10, MATCH_OP, GT_OP, LT_OP, GTE_OP, LTE_OP, DIFF_OP, NO_OP };
00066 enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
00067            DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, DEFAULT_O, ACTION_O,
00068            NUMBER_O, AVP_O, SNDIP_O, SNDPORT_O, TOIP_O, TOPORT_O, SNDPROTO_O,
00069            SNDAF_O, RETCODE_O, SELECT_O};
00070 
00071 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
00072                 SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
00073                 SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_USERPHONE_T,
00074                 IF_T, MODULE_T,
00075                 SETFLAG_T, RESETFLAG_T, ISFLAGSET_T ,
00076                 AVPFLAG_OPER_T,
00077                 LEN_GT_T, PREFIX_T, STRIP_T,STRIP_TAIL_T,
00078                 APPEND_BRANCH_T,
00079                 REVERT_URI_T,
00080                 FORWARD_TCP_T,
00081                 FORWARD_UDP_T,
00082                 FORWARD_TLS_T,
00083                 FORWARD_SCTP_T,
00084                 SEND_TCP_T,
00085                 FORCE_RPORT_T,
00086                 SET_ADV_ADDR_T,
00087                 SET_ADV_PORT_T,
00088                 FORCE_TCP_ALIAS_T,
00089                 LOAD_AVP_T,
00090                 AVP_TO_URI_T,
00091                 FORCE_SEND_SOCKET_T,
00092                 ASSIGN_T,
00093                 ADD_T,
00094                 UDP_MTU_TRY_PROTO_T
00095 };
00096 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
00097                 EXPR_ST, ACTIONS_ST, MODEXP_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
00098                 MYSELF_ST, STR_ST, SOCKID_ST, SOCKETINFO_ST, ACTION_ST, AVP_ST, SELECT_ST,
00099                 RETCODE_ST};
00100 
00101 /* run flags */
00102 #define EXIT_R_F   1
00103 #define RETURN_R_F 2
00104 
00105 /* Expression operand */
00106 union exp_op {
00107         void* param;
00108         long numval; /* must have the same size as a void*/
00109         struct expr* expr;
00110         char* string;
00111         avp_spec_t* attr;
00112         select_t* select;
00113         regex_t* re;
00114         struct net* net;
00115         struct _str str;
00116 };
00117 
00118 struct expr{
00119         int type; /* exp, exp_elem */
00120         int op; /* and, or, not | ==,  =~ */
00121         int l_type, r_type;
00122         union exp_op l;
00123         union exp_op r;
00124 };
00125 
00126 typedef struct {
00127         int type;
00128         union {
00129                 long number;
00130                 char* string;
00131                 struct _str str;
00132                 void* data;
00133                 avp_spec_t* attr;
00134                 select_t* select;
00135         } u;
00136 } action_u_t;
00137 
00138 #define MAX_ACTIONS 4
00139 
00140 struct action{
00141         int type;  /* forward, drop, log, send ...*/
00142         int count;
00143         action_u_t val[MAX_ACTIONS];
00144         struct action* next;
00145 };
00146 
00147 struct expr* mk_exp(int op, struct expr* left, struct expr* right);
00148 struct expr* mk_elem(int op, int ltype, void* lparam, int rtype, void* rparam);
00149 
00150 struct action* mk_action(int type, int count/* of couples {type,val} */, .../* int type1, void *val1 [, int type2, void *val2, ...] */);
00151 struct action* append_action(struct action* a, struct action* b);
00152 
00153 void print_action(struct action* a);
00154 void print_actions(struct action* a);
00155 void print_expr(struct expr* exp);
00156 
00157 #endif
00158 

Generated on Thu Sep 9 04:16:04 2010 for SIPExpressRouter by  doxygen 1.3.9.1