PIRServer.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (C) 2014 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian
  2. * This file is part of XPIR.
  3. *
  4. * XPIR is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * XPIR is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with XPIR. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef DEF_PIRSERVER
  18. #define DEF_PIRSERVER
  19. #include <string>
  20. #include "PIRSession.hpp"
  21. #include "ServerService.hpp"
  22. #include "../server/DBHandler.hpp"
  23. #include "../server/DBDirectoryProcessor.hpp"
  24. #include "../server/DBGenerator.hpp"
  25. #define DEFAULT_PORT 1234
  26. using namespace boost;
  27. class PIRSession;
  28. struct session_option_t;
  29. class PIRServer
  30. {
  31. private:
  32. boost::asio::io_service ios;
  33. boost::asio::ip::tcp::acceptor acceptor;
  34. DBHandler *dbhandler;
  35. PIRParameters savedPIRParams;
  36. session_option_t session_option;
  37. bool drivenMode;
  38. std::string pirParamsFilePath;
  39. void handleAccept(boost::shared_ptr<PIRSession> pir_session, const boost::system::error_code& error);
  40. bool no_pipeline_mode;
  41. public:
  42. PIRServer(boost::asio::io_service &ios, unsigned int port, uint64_t split_value,
  43. bool usedbgenerator, uint64_t dbgenerator_n, uint64_t dbgenerator_l);
  44. ~PIRServer();
  45. void serve();
  46. void readPIRParamsFromFile(const std::string& file_path);
  47. void processDrivenSession(const std::string& file_path);
  48. void no_pipeline(bool b);
  49. };
  50. #endif