Mercurial > routeflapper
annotate src/routeconfig.h @ 7:3c0db610c641
add bgpd config file and proper logrotate config
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 04 Sep 2014 08:53:18 -0700 |
parents | 180d26aa2a17 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Copyright (c) 2007 Carl Byington - 510 Software Group, released under | |
4 the GPL version 3 or any later version at your choice available at | |
5 http://www.gnu.org/licenses/gpl-3.0.txt | |
6 | |
7 */ | |
8 | |
9 | |
10 class ROUTECONFIG; | |
11 class CONFIG; | |
12 | |
13 enum pattern_style {style_reset, style_path, style_announce, style_withdraw, style_ip}; | |
14 enum suspicion {suspicious_none, suspicious_origin, suspicious_adjacency}; | |
15 | |
16 class PATTERN { | |
17 pattern_style style; | |
4
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
18 const char * pattern; // owned by the string table |
0 | 19 regex_t re; |
20 int index1; // zero based substring of the regex match that contains the as list or prefix value | |
21 int index2; // zero based substring of the regex match that contains the prefix length | |
22 public: | |
23 ~PATTERN(); | |
4
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
24 PATTERN(TOKEN &tok, pattern_style style_, const char *pattern_, int index1_, int index2_); |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
25 bool process(char *buf, CONFIG &con, const char *file_name, int pattern_index); |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
26 void dump(int level, int index, const char *token); |
0 | 27 void dump(int level); |
28 }; | |
29 | |
30 typedef ROUTECONFIG * ROUTECONFIGP; | |
31 typedef PATTERN * PATTERNP; | |
32 typedef list<ROUTECONFIGP> routeconfig_list; | |
33 typedef list<PATTERNP> pattern_list; | |
34 const int buflen = 1024; | |
35 | |
36 class ROUTECONFIG { | |
37 TOKEN * tokp; | |
4
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
38 const char * file_name; // name of the syslog file |
0 | 39 pattern_list patterns; // owns the patterns |
40 int fd; | |
41 struct stat openfdstat; | |
42 int len; // bytes in the buffer | |
43 char buf[buflen]; | |
44 public: | |
4
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
45 ROUTECONFIG(TOKEN &tok, const char *file_name_); |
0 | 46 ~ROUTECONFIG(); |
47 bool failed() { return (fd == -1); }; | |
48 void open(bool msg); | |
49 bool read(CONFIG &con); | |
50 void close(); | |
51 void add_pattern(PATTERNP pat); | |
52 void process(CONFIG &con); | |
53 void dump(int level); | |
54 }; | |
55 | |
56 class CONFIG { | |
57 public: | |
58 // the only mutable stuff once it has been loaded from the config file | |
59 int reference_count; // protected by the global config_mutex | |
60 // all the rest is constant after loading from the config file | |
61 int generation; | |
62 time_t load_time; | |
63 string_set config_files; | |
64 routeconfig_list routeconfigs; // owns all the route configs | |
65 | |
66 CONFIG(); | |
67 ~CONFIG(); | |
68 void add_routeconfig(ROUTECONFIGP con) {routeconfigs.push_back(con);}; | |
69 void dump(); | |
70 void read(); | |
71 }; | |
72 | |
73 void discard(string_set &s); | |
4
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
74 const char* register_string(string_set &s, const char *name); |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
75 const char* register_string(const char *name); |
0 | 76 void clear_strings(); |
77 void clear_rib(); | |
4
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
78 int ip_address(const char *have); |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
79 bool load_conf(CONFIG &dc, const char *fn); |
0 | 80 void routing_hourly_update(); |
81 void token_init(); | |
82 | |
4
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
83 extern const char *token_announce_aslist_index; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
84 extern const char *token_announce_pattern; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
85 extern const char *token_announce_prelen_index; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
86 extern const char *token_announce_preval_index; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
87 extern const char *token_file; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
88 extern const char *token_include; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
89 extern const char *token_lbrace; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
90 extern const char *token_rbrace; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
91 extern const char *token_semi; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
92 extern const char *token_slash; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
93 extern const char *token_withdraw_aslist_index; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
94 extern const char *token_withdraw_pattern; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
95 extern const char *token_withdraw_prelen_index; |
180d26aa2a17
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
96 extern const char *token_withdraw_preval_index; |
0 | 97 |