forked from OpenSIPS/opensips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute.h
156 lines (123 loc) · 4.03 KB
/
route.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of opensips, a free SIP server.
*
* opensips 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
*
* opensips 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
* \file
* \brief SIP routing engine
*/
#ifndef route_h
#define route_h
#include <sys/types.h>
#include <regex.h>
#include <netdb.h>
#include "pvar.h"
#include "config.h"
#include "error.h"
#include "route_struct.h"
#include "parser/msg_parser.h"
/*
* Definition of a script route
*/
struct script_route{
char *name; /* name of the route */
struct action *a; /* the actions tree defining the route logic */
};
struct script_timer_route{
char *name;
unsigned int interval;
struct action* a;
};
struct os_script_routes {
/* request routing script table */
struct script_route request[RT_NO];
/* reply routing table */
struct script_route onreply[ONREPLY_RT_NO];
/* failure routes */
struct script_route failure[FAILURE_RT_NO];
/* branch routes */
struct script_route branch[BRANCH_RT_NO];
/* local requests route */
struct script_route local;
/* error route */
struct script_route error;
/* startup route */
struct script_route startup;
/* timer route */
struct script_timer_route timer[TIMER_RT_NO];
/* event route */
struct script_route event[EVENT_RT_NO];
};
extern struct os_script_routes *sroutes;
#define REQUEST_ROUTE 1 /*!< Request route block */
#define FAILURE_ROUTE 2 /*!< Negative-reply route block */
#define ONREPLY_ROUTE 4 /*!< Received-reply route block */
#define BRANCH_ROUTE 8 /*!< Sending-branch route block */
#define ERROR_ROUTE 16 /*!< Error-handling route block */
#define LOCAL_ROUTE 32 /*!< Local-requests route block */
#define STARTUP_ROUTE 64 /*!< Startup route block */
#define TIMER_ROUTE 128 /*!< Timer route block */
#define EVENT_ROUTE 256 /*!< Event route block */
#define ALL_ROUTES \
(REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE| \
ERROR_ROUTE|LOCAL_ROUTE|STARTUP_ROUTE|TIMER_ROUTE|EVENT_ROUTE)
extern str str_route;
extern str str_request_route;
extern str str_failure_route;
extern str str_onreply_route;
extern str str_branch_route;
extern str str_error_route;
extern str str_local_route;
extern str str_startup_route;
extern str str_timer_route;
extern str str_event_route;
extern int route_type;
/**
* Extract information about the top-level @route_type
*
* @type: string representation of the route's type
* @has_name: whether the top route has a name or not
*/
void get_top_route_type(str *type, int *has_name);
#define set_route_type(_new_type) \
do{\
route_type=_new_type;\
}while(0)
#define swap_route_type(_backup, _new_type) \
do{\
_backup=route_type;\
route_type=_new_type;\
}while(0)
#define is_route_type(_type) (route_type==_type)
struct os_script_routes* new_sroutes_holder(void);
void free_route_lists(struct os_script_routes *sr);
int run_startup_route(void);
int get_script_route_idx( char* name, struct script_route *sr,
int size, int set);
int get_script_route_ID_by_name(char *name,
struct script_route *sr, int size);
int get_script_route_ID_by_name_str(str *name,
struct script_route *sr, int size);
int is_script_func_used( char *name, int param_no);
int is_script_async_func_used( char *name, int param_no);
void push(struct action* a, struct action** head);
void print_rl(struct os_script_routes *srs);
int fix_rls(void);
int check_rls(void);
int eval_expr(struct expr* e, struct sip_msg* msg, pv_value_t *val);
#endif