00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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
00051
00052
00053
00054
00055
00056
00057
00058
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
00102 #define EXIT_R_F 1
00103 #define RETURN_R_F 2
00104
00105
00106 union exp_op {
00107 void* param;
00108 long numval;
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;
00120 int op;
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;
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, ...);
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