Mercurial > routeflapper
view 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 |
line wrap: on
line source
/* Copyright (c) 2007 Carl Byington - 510 Software Group, released under the GPL version 3 or any later version at your choice available at http://www.gnu.org/licenses/gpl-3.0.txt */ class ROUTECONFIG; class CONFIG; enum pattern_style {style_reset, style_path, style_announce, style_withdraw, style_ip}; enum suspicion {suspicious_none, suspicious_origin, suspicious_adjacency}; class PATTERN { pattern_style style; const char * pattern; // owned by the string table regex_t re; int index1; // zero based substring of the regex match that contains the as list or prefix value int index2; // zero based substring of the regex match that contains the prefix length public: ~PATTERN(); PATTERN(TOKEN &tok, pattern_style style_, const char *pattern_, int index1_, int index2_); bool process(char *buf, CONFIG &con, const char *file_name, int pattern_index); void dump(int level, int index, const char *token); void dump(int level); }; typedef ROUTECONFIG * ROUTECONFIGP; typedef PATTERN * PATTERNP; typedef list<ROUTECONFIGP> routeconfig_list; typedef list<PATTERNP> pattern_list; const int buflen = 1024; class ROUTECONFIG { TOKEN * tokp; const char * file_name; // name of the syslog file pattern_list patterns; // owns the patterns int fd; struct stat openfdstat; int len; // bytes in the buffer char buf[buflen]; public: ROUTECONFIG(TOKEN &tok, const char *file_name_); ~ROUTECONFIG(); bool failed() { return (fd == -1); }; void open(bool msg); bool read(CONFIG &con); void close(); void add_pattern(PATTERNP pat); void process(CONFIG &con); void dump(int level); }; class CONFIG { public: // the only mutable stuff once it has been loaded from the config file int reference_count; // protected by the global config_mutex // all the rest is constant after loading from the config file int generation; time_t load_time; string_set config_files; routeconfig_list routeconfigs; // owns all the route configs CONFIG(); ~CONFIG(); void add_routeconfig(ROUTECONFIGP con) {routeconfigs.push_back(con);}; void dump(); void read(); }; void discard(string_set &s); const char* register_string(string_set &s, const char *name); const char* register_string(const char *name); void clear_strings(); void clear_rib(); int ip_address(const char *have); bool load_conf(CONFIG &dc, const char *fn); void routing_hourly_update(); void token_init(); extern const char *token_announce_aslist_index; extern const char *token_announce_pattern; extern const char *token_announce_prelen_index; extern const char *token_announce_preval_index; extern const char *token_file; extern const char *token_include; extern const char *token_lbrace; extern const char *token_rbrace; extern const char *token_semi; extern const char *token_slash; extern const char *token_withdraw_aslist_index; extern const char *token_withdraw_pattern; extern const char *token_withdraw_prelen_index; extern const char *token_withdraw_preval_index;