settings_writer.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (c) 2018, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #ifndef HEADER_SETTINGS_WRITER
  15. #define HEADER_SETTINGS_WRITER
  16. #include <string>
  17. #include <openssl/bytestring.h>
  18. #include <openssl/ssl.h>
  19. #include "../internal.h"
  20. #include "test_config.h"
  21. struct SettingsWriter {
  22. public:
  23. SettingsWriter();
  24. // Init initializes the writer for a new connection, given by |i|. Each
  25. // connection gets a unique output file.
  26. bool Init(int i, const TestConfig *config, SSL_SESSION *session);
  27. // Commit writes the buffered data to disk.
  28. bool Commit();
  29. bool WriteHandoff(bssl::Span<const uint8_t> handoff);
  30. bool WriteHandback(bssl::Span<const uint8_t> handback);
  31. private:
  32. std::string path_;
  33. bssl::ScopedCBB cbb_;
  34. };
  35. #endif // HEADER_SETTINGS_WRITER