route.h
512dcd98
 /*
  * $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
512dcd98
  */
 
7dd0b342
 
512dcd98
 #ifndef route_h
 #define route_h
 
 #include <sys/types.h>
 #include <regex.h>
 #include <netdb.h>
 
a15c363f
 #include "config.h"
 #include "error.h"
 #include "route_struct.h"
20fded1f
 #include "action.h"
3881f12c
 #include "parser/msg_parser.h"
e8138515
 #include "str_hash.h"
a15c363f
 
 /*#include "cfg_parser.h" */
 
1dfe92cb
 /* Various types of route sections, make sure that the values defined in the
  * macros below occupy disjunct bits so that they can also be used as flags
  */
 #define REQUEST_ROUTE (1 << 0)
 #define FAILURE_ROUTE (1 << 1)
 #define ONREPLY_ROUTE (1 << 2)
 #define BRANCH_ROUTE  (1 << 3)
 #define ONSEND_ROUTE  (1 << 4)
 #define ERROR_ROUTE   (1 << 5)
 #define LOCAL_ROUTE   (1 << 6)
31b5e3d0
 #define EVENT_ROUTE   REQUEST_ROUTE
16b47a9a
 #define ANY_ROUTE     (0xFFFFFFFF)
1dfe92cb
 
 /* The value of this variable is one of the route types defined above and it
  * determines the type of the route being executed, module functions can use
  * this value to determine the type of the route they are being executed in
  */
 extern int route_type;
 
 #define set_route_type(type) \
 	do {					 \
 		route_type = (type); \
 	} while(0)
 
593513f8
 #define get_route_type()	route_type
 
1dfe92cb
 #define is_route_type(type) (route_type == (type))
512dcd98
 
93349b4e
 struct route_list{
 	struct action** rlist;
 	int idx; /* first empty entry */ 
8f0e1af3
 	int entries; /* total number of entries */
93349b4e
 	struct str_hash_table names; /* name to route index mappings */
 };
 
 
f20a56a2
 /* main "script table" */
93349b4e
 extern struct route_list main_rt;
caf80ae6
 /* main reply route table */
93349b4e
 extern struct route_list onreply_rt;
 extern struct route_list failure_rt;
 extern struct route_list branch_rt;
 extern struct route_list onsend_rt;
31b5e3d0
 extern struct route_list event_rt;
93349b4e
 
10bb5547
 /* script optimization level */
 extern int scr_opt_lev;
512dcd98
 
93349b4e
 int init_routes();
 void destroy_routes();
 int route_get(struct route_list* rt, char* name);
bc5be349
 int route_lookup(struct route_list* rt, char* name);
a15c363f
 
f20a56a2
 void push(struct action* a, struct action** head);
 int add_actions(struct action* a, struct action** head);
93349b4e
 void print_rls();
f20a56a2
 int fix_rls();
512dcd98
 
20fded1f
 int eval_expr(struct run_act_ctx* h, struct expr* e, struct sip_msg* msg);
512dcd98
 
 
ab7f82d2
 /* fixup functions*/
 int fix_actions(struct action* a);
 int fix_expr(struct expr* exp);
512dcd98
 
 
 
 #endif