1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** match header file **
10 \*****************************************************************************/
13 /* memory structure of rulesets */
15 enum { /* value types */
18 VALUE_TYPE_INTEGER_RANGE,
20 VALUE_TYPE_STRING_RANGE,
23 enum { /* how to parse text file during startup */
38 enum { /* what to check during runtime */
81 enum { /* how to parse text file during startup */
86 PARAM_TYPE_CAPABILITY,
92 PARAM_TYPE_CALLERIDTYPE,
95 /* parameter ID bits */
96 #define PARAM_PROCEEDING 1LL
97 #define PARAM_ALERTING (1LL<<1)
98 #define PARAM_CONNECT (1LL<<2)
100 #define PARAM_EXTENSION (1LL<<3)
101 #define PARAM_EXTENSIONS (1LL<<4)
103 #define PARAM_PREFIX (1LL<<5)
104 #define PARAM_CAPA (1LL<<6)
105 #define PARAM_BMODE (1LL<<7)
106 #define PARAM_INFO1 (1LL<<8)
107 #define PARAM_HLC (1LL<<9)
108 #define PARAM_EXTHLC (1LL<<10)
109 #define PARAM_PRESENT (1LL<<11)
110 #define PARAM_DIVERSION (1LL<<12)
111 #define PARAM_DEST (1LL<<13)
112 #define PARAM_SELECT (1LL<<14)
113 #define PARAM_DELAY (1LL<<15)
114 #define PARAM_LIMIT (1LL<<16)
115 #define PARAM_HOST (1LL<<17)
116 #define PARAM_PORT (1LL<<18)
117 #define PARAM_INTERFACES (1LL<<19)
118 #define PARAM_ADDRESS (1LL<<20)
119 #define PARAM_SAMPLE (1LL<<21)
121 #define PARAM_ANNOUNCEMENT (1LL<<22)
123 #define PARAM_RULESET (1LL<<23)
124 #define PARAM_CAUSE (1LL<<24)
125 #define PARAM_LOCATION (1LL<<25)
126 #define PARAM_DISPLAY (1LL<<26)
127 #define PARAM_PORTS (1LL<<27)
128 #define PARAM_TPRESET (1LL<<28)
129 #define PARAM_FILE (1LL<<29)
130 #define PARAM_CONTENT (1LL<<30)
131 #define PARAM_APPEND (1LL<<31)
132 #define PARAM_EXECUTE (1LL<<32)
133 #define PARAM_PARAM (1LL<<33)
134 #define PARAM_TYPE (1LL<<34)
135 #define PARAM_COMPLETE (1LL<<35)
136 #define PARAM_CALLERID (1LL<<36)
137 #define PARAM_CALLERIDTYPE (1LL<<37)
138 #define PARAM_CALLTO (1LL<<38)
139 #define PARAM_ROOM (1LL<<39)
140 #define PARAM_TIMEOUT (1LL<<40)
142 #define PARAM_NOPASSWORD (1LL<<41)
147 * NOTE: The given index is the actual entry number of action_defs[], so add/remove both lists!!!
149 #define ACTION_EXTERNAL 0
150 #define ACTION_INTERNAL 1
151 #define ACTION_OUTDIAL 2
152 #define ACTION_H323 3
153 #define ACTION_CHAN 4
154 #define ACTION_VBOX_RECORD 5
155 #define ACTION_PARTYLINE 6
156 #define ACTION_LOGIN 7
157 #define ACTION_CALLERID 8
158 #define ACTION_CALLERIDNEXT 9
159 #define ACTION_FORWARD 10
160 #define ACTION_REDIAL 11
161 #define ACTION_REPLY 12
162 #define ACTION_POWERDIAL 13
163 #define ACTION_CALLBACK 14
164 #define ACTION_ABBREV 15
165 #define ACTION_TEST 16
166 #define ACTION_PLAY 17
167 #define ACTION_VBOX_PLAY 18
168 #define ACTION_CALCULATOR 19
169 #define ACTION_TIMER 20
170 #define ACTION_GOTO 21
171 #define ACTION_MENU 22
172 #define ACTION_DISCONNECT 23
173 #define ACTION_HELP 24
174 #define ACTION_DEFLECT 25
175 #define ACTION_SETFORWARD 26
176 #define ACTION_EXECUTE 27
177 #define ACTION_FILE 28
178 #define ACTION_PICK 29
179 #define ACTION_PASSWORD 30
180 #define ACTION_PASSWORD_WRITE 31
181 #define ACTION_NOTHING 32
182 #define ACTION_EFI 33
184 struct route_cond { /* an item */
185 struct route_cond *next; /* next entry */
186 int index; /* index of cond_defs */
187 int match; /* what is matching (MATCH_*) */
188 int value_type; /* type of value (VALUE_TYPE_*) */
189 int value_extension; /* will it be extended? */
190 int integer_value; /* first integer */
191 int integer_value_to; /* second integer */
192 char *string_value; /* first string */
193 char *string_value_to; /* second string */
194 int comp_string; /* compare value of strings */
197 struct route_param { /* a parameter */
198 struct route_param *next; /* next item */
199 int index; /* index of param_defs */
200 unsigned long long id; /* what is it (PARAM_*) */
201 int value_type; /* type of value (VALUE_TYPE_*) */
202 int value_extension; /* will it be extended? */
203 int integer_value; /* integer value */
204 char *string_value; /* string value */
207 struct route_action { /* an action has a list of parameters */
208 struct route_action *next; /* next item */
209 struct route_param *param_first; /* link to parameter list */
210 int index; /* index of action_defs */
211 int timeout; /* timeout value for action (0 = no timeout) */
212 int line; /* line parsed from */
215 struct route_rule { /* a rule has a list of items and actions */
216 struct route_rule *next; /* next item */
217 char file[128]; /* filename */
218 int line; /* line parsed from */
219 struct route_cond *cond_first; /* link to condition list */
220 struct route_action *action_first; /* link to action list */
223 struct route_ruleset { /* the ruleset is a list of rules */
224 struct route_ruleset *next; /* next item */
225 char file[128]; /* filename */
226 int line; /* line parsed from */
227 char name[64]; /* name of rule */
228 struct route_rule *rule_first; /* linke to rule list */
231 struct cond_defs { /* defintion of all conditions */
232 char *name; /* item's name */
233 int match; /* what to check */
234 int type; /* type of value (COND_TYPE) */
235 char *doc; /* syntax */
236 char *help; /* short help */
239 struct param_defs { /* definition of all options */
240 unsigned long long id; /* ID of parameter (just for checking) */
241 char *name; /* name of parameter */
242 int type; /* type of value (PARAM_TYPE_*) */
243 char *doc; /* syntax */
244 char *help; /* quick help */
247 struct action_defs { /* definition of all actions */
248 int id; /* ID of parameter (just for checking) */
250 void (EndpointAppPBX::*init_func)(void);
251 void (EndpointAppPBX::*dialing_func)(void);
252 void (EndpointAppPBX::*hangup_func)(void);
253 unsigned long long params;
259 extern struct cond_defs cond_defs[];
260 extern struct param_defs param_defs[];
261 extern struct action_defs action_defs[];
262 extern struct route_ruleset *ruleset_first;
263 extern struct route_ruleset *ruleset_main;
264 extern struct route_action action_external;
265 extern struct route_action action_internal;
266 extern struct route_action action_h323;
267 extern struct route_action action_chan;
268 extern struct route_action action_vbox;
269 extern struct route_action action_partyline;
270 extern struct route_action action_password;
271 extern struct route_action action_password_write;
272 extern struct route_action action_disconnect;
276 void doc_rules(const char *action);
277 void ruleset_free(struct route_ruleset *ruleset_start);
278 void ruleset_debug(struct route_ruleset *ruleset_start);
279 extern char ruleset_error[256];
280 struct route_ruleset *ruleset_parse(void);
281 struct route_ruleset *getrulesetbyname(char *name);