First working release
[sip-router] / route.h
1 /*
2  * $Id$
3  */
4
5 #ifndef route_h
6 #define route_h
7
8 #include <sys/types.h>
9 #include <regex.h>
10 #include <netdb.h>
11
12 #include "cfg_parser.h"
13
14 #define E_OUT_OF_MEM  -2
15 #define E_BAD_RE      -3
16 #define E_BAD_ADDRESS -4
17
18 struct route_elem{
19         struct route_elem* next;
20         regex_t method;
21         regex_t uri;
22         struct hostent host;
23         int current_addr_idx;
24         short int port;
25         short int reserved; /* pad */
26         int ok; /* set to 0 if an error was found sendig a pkt*/
27         /*counters*/
28         int errors;
29         int tx;
30         int tx_bytes;
31 };
32
33 /* main "routing table" */
34 extern struct route_elem* rlist;
35
36
37 void free_re(struct route_elem* re);
38 struct route_elem* init_re();
39 void push(struct route_elem* re, struct route_elem** head);
40 void clear_rlist(struct route_elem** rl);
41 int add_rule(struct cfg_line* cl, struct route_elem** head);
42 struct route_elem* route_match(char* method, char* uri, struct route_elem** rl);void print_rl();
43
44
45
46
47
48 #endif