12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // snf_sync.hpp
- // Copyright (C) 2006 - 2009 ARM Research Labs, LLC.
- // See www.armresearch.com for the copyright terms.
- //
- // SNF engine communications protocol interpreter.
- // Communications are well formed xml snippets.
- // See snf_sync.xml for examples.
-
- #ifndef snf_sync_included
- #define snf_sync_included
-
- #include <list>
- #include <cstring>
- #include "SNFMulti/GBUdb.hpp"
- #include "CodeDweller/networking.hpp"
- #include "CodeDweller/XMLReader.hpp"
-
- namespace SNFMulti {
-
- class GBUAlertHandler : public CodeDweller::Configurator {
- public:
- virtual void operator()(CodeDweller::ConfigurationElement& E,
- CodeDweller::ConfigurationData& D); // Add an alert handler :-)
-
- void reset(); // Resets the list for a new run.
-
- std::list<GBUdbAlert> AlertList; // Our list of alerts.
-
- // Input variables.
-
- std::string Alert_time; // time='YYYYMMDDhhmmss'
- std::string Alert_ip; // ip='12.34.56.78'
- std::string Alert_t; // t='Ugly', Good, Bad, Ignore
- int Alert_b; // b='0'
- int Alert_g; // g='0'
- };
-
- class GBUAlertInitializer : public CodeDweller::Configurator {
- private:
- GBUAlertHandler* MyHandler; // Handler to reset.
-
- public:
- GBUAlertInitializer() { MyHandler = NULL; } // Init safely with null.
- void link(GBUAlertHandler& H) { MyHandler = &H; } // Link to my handler.
- virtual void operator()(CodeDweller::ConfigurationElement& E,
- CodeDweller::ConfigurationData& D) { // Add an alert handler :-)
- if(NULL != MyHandler) { // If I know where it is
- MyHandler->reset(); // I hit the reset button.
- }
- }
- };
-
- class snf_sync {
- private:
- CodeDweller::ConfigurationElement Reader; // Our reader.
- void SetupReader(); // Configure the reader.
- CodeDweller::ConfiguratorSetTrueOnComplete SNFWasParsed; // Configurator sets the ReadWasGood
- bool ReadWasGood; // flag at the end of the snf element.
- void construct(); // Encapsulate the initial construction.
- void reset(); // Reset/initialize for the next read.
-
- public:
- snf_sync(); // Construct empty.
- snf_sync(const char* bfr, int len); // Construct from buffer.
- snf_sync(std::string& input); // Construct from string.
- bool read(const char* bfr, int len); // Read from buffer.
- bool read(std::string& input); // Read from string.
-
- //// And now the interpreted results ////
- bool good(); // True if read was good.
- bool bad(); // True if read was not good.
-
- std::string snf_sync_challenge_txt;
- std::string snf_sync_response_nodeid;
- std::string snf_sync_response_text;
- std::string snf_sync_error_message;
- int snf_sync_error_code;
- std::string snf_sync_rulebase_utc;
- int snf_sync_server_resync_secs;
-
- GBUAlertHandler ClientGBUAlertHandler; // GBU Alerts received from client
- GBUAlertInitializer ClientGBUAlertInitializer;
-
- GBUAlertHandler ServerGBUAlertHandler; // GBU Alerts received from server
- GBUAlertInitializer ServerGBUAlertInitializer;
- };
-
- } // namespace SNFMulti
-
- #endif
|