Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // snf_sync.hpp
  2. // Copyright (C) 2006 - 2009 ARM Research Labs, LLC.
  3. // See www.armresearch.com for the copyright terms.
  4. //
  5. // SNF engine communications protocol interpreter.
  6. // Communications are well formed xml snippets.
  7. // See snf_sync.xml for examples.
  8. #ifndef snf_sync_included
  9. #define snf_sync_included
  10. #include <list>
  11. #include <cstring>
  12. #include "GBUdb.hpp"
  13. #include "networking.hpp"
  14. #include "configuration.hpp"
  15. class GBUAlertHandler : public Configurator {
  16. public:
  17. virtual void operator()(ConfigurationElement& E, ConfigurationData& D); // Add an alert handler :-)
  18. void reset(); // Resets the list for a new run.
  19. list<GBUdbAlert> AlertList; // Our list of alerts.
  20. // Input variables.
  21. string Alert_time; // time='YYYYMMDDhhmmss'
  22. string Alert_ip; // ip='12.34.56.78'
  23. string Alert_t; // t='Ugly', Good, Bad, Ignore
  24. int Alert_b; // b='0'
  25. int Alert_g; // g='0'
  26. };
  27. class GBUAlertInitializer : public Configurator {
  28. private:
  29. GBUAlertHandler* MyHandler; // Handler to reset.
  30. public:
  31. GBUAlertInitializer() { MyHandler = NULL; } // Init safely with null.
  32. void link(GBUAlertHandler& H) { MyHandler = &H; } // Link to my handler.
  33. virtual void operator()(ConfigurationElement& E, ConfigurationData& D) { // Add an alert handler :-)
  34. if(NULL != MyHandler) { // If I know where it is
  35. MyHandler->reset(); // I hit the reset button.
  36. }
  37. }
  38. };
  39. class snf_sync {
  40. private:
  41. ConfigurationElement Reader; // Our reader.
  42. void SetupReader(); // Configure the reader.
  43. ConfiguratorSetTrueOnComplete SNFWasParsed; // Configurator sets the ReadWasGood
  44. bool ReadWasGood; // flag at the end of the snf element.
  45. void construct(); // Encapsulate the initial construction.
  46. void reset(); // Reset/initialize for the next read.
  47. public:
  48. snf_sync(); // Construct empty.
  49. snf_sync(const char* bfr, int len); // Construct from buffer.
  50. snf_sync(string& input); // Construct from string.
  51. bool read(const char* bfr, int len); // Read from buffer.
  52. bool read(string& input); // Read from string.
  53. //// And now the interpreted results ////
  54. bool good(); // True if read was good.
  55. bool bad(); // True if read was not good.
  56. string snf_sync_challenge_txt;
  57. string snf_sync_response_nodeid;
  58. string snf_sync_response_text;
  59. string snf_sync_error_message;
  60. int snf_sync_error_code;
  61. string snf_sync_rulebase_utc;
  62. int snf_sync_server_resync_secs;
  63. GBUAlertHandler ClientGBUAlertHandler; // GBU Alerts received from client
  64. GBUAlertInitializer ClientGBUAlertInitializer;
  65. GBUAlertHandler ServerGBUAlertHandler; // GBU Alerts received from server
  66. GBUAlertInitializer ServerGBUAlertInitializer;
  67. };
  68. #endif