|
- //////////////////////////////////////////////////////////////////////
- // Base CLI app classes for TrafficMon tools
- // Written by Jonathan A. Foster <jon@jfpossibilities.com>
- // Started December 29th, 2021
- // Copyright JF Possibilities, Inc. All rights reserved.
- //
- //
- //////////////////////////////////////////////////////////////////////
- // NOTE: since GNU doesn't discard unused classes these two classes should
- // probably get put in separate sets of files. :-/
- #ifndef __IDS_MONITOR_BASE_APP_H__
- #define __IDS_MONITOR_BASE_APP_H__
- #include <cppdb/frontend.h>
- #include "../cli.h"
- #include "../miniini.h"
-
-
-
- //////////////////////////////////////////////////////////////////////
- // The core configuration file
- //
- // This is designed so that all parts can use the same config. Tools
- // ignore the parts they aren't interested in.
- //////////////////////////////////////////////////////////////////////
-
- struct MonitorBaseConf: public MiniINI {
- MiniINIvars traffic_mon; // This app's config variables
-
- MonitorBaseConf() { groups["Traffic Mon"] = &traffic_mon; }
- };
-
-
-
- //////////////////////////////////////////////////////////////////////
- // The base CLI application class used by the tools in this directory.
- //
- // Essentially this is a CLI app with a DB connection and a place
- // holder for a config file.
- //////////////////////////////////////////////////////////////////////
-
- struct TrafficMonBaseApp: public cBaseApp {
- cppdb::session db;
- MonitorBaseConf *config;
-
- // this init() will create a MonitorBaseConf if a config hasn't been assigned.
- virtual cBaseApp &init(int argc, char **argv);
-
- // process config file switch and load the file
- virtual unsigned do_switch(const char *arg);
- virtual void do_switch_arg(const char *sw, const std::string &val);
-
- // process CLI args, test for [traffic mon] and connect to DB.
- virtual int main();
-
- // close out and free config object.
- virtual ~TrafficMonBaseApp();
- };
-
-
-
- //////////////////////////////////////////////////////////////////////
- // Blacklist report base class
- //
- // This provides generic switch handling
- //////////////////////////////////////////////////////////////////////
-
- struct BlackListBaseApp: public TrafficMonBaseApp {
- std::string ipv4, ipv6;
-
- BlackListBaseApp():
- ipv4("127.0.0.1"),
- ipv6("::1")
- {}
-
- // Display generic CLI help text
- virtual int help();
-
- // process -4 & -6 switches.
- virtual unsigned do_switch(const char *sw);
- virtual void do_switch_arg(const char *sw, const std::string &val);
- virtual void do_arg(const char *arg);
- virtual int main();
- };
-
- #endif
|