ProtobufSerializer.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2011-2016 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef __AE_PROTOBUF_SERIALIZER
  32. #define __AE_PROTOBUF_SERIALIZER
  33. #include <ISerializer.h>
  34. #pragma GCC diagnostic push
  35. #pragma GCC diagnostic ignored "-Wshadow"
  36. #pragma GCC diagnostic ignored "-Wconversion"
  37. #include <messages.pb.h>
  38. #pragma GCC diagnostic pop
  39. class IAERequest;
  40. class IAEResponse;
  41. class ProtobufSerializer : public ISerializer{
  42. public:
  43. ~ProtobufSerializer() {}
  44. //request serializers
  45. AEMessage* serialize(AEInitQuoteRequest* request);
  46. AEMessage* serialize(AEGetQuoteRequest* request);
  47. AEMessage* serialize(AEGetLaunchTokenRequest* request);
  48. AEMessage* serialize(AECreateSessionRequest* request);
  49. AEMessage* serialize(AEInvokeServiceRequest* request);
  50. AEMessage* serialize(AEExchangeReportRequest* request);
  51. AEMessage* serialize(AECloseSessionRequest* request);
  52. AEMessage* serialize(AEGetPsCapRequest* request);
  53. AEMessage* serialize(AEReportAttestationRequest* request);
  54. //response serializers
  55. AEMessage* serialize(AEInitQuoteResponse* response);
  56. AEMessage* serialize(AEGetQuoteResponse* response);
  57. AEMessage* serialize(AEGetLaunchTokenResponse* response);
  58. AEMessage* serialize(AECreateSessionResponse* response);
  59. AEMessage* serialize(AEInvokeServiceResponse* response);
  60. AEMessage* serialize(AEExchangeReportResponse* response);
  61. AEMessage* serialize(AECloseSessionResponse* response);
  62. AEMessage* serialize(AEGetPsCapResponse* response);
  63. AEMessage* serialize(AEReportAttestationResponse* response);
  64. //base inflate request
  65. IAERequest* inflateRequest(AEMessage* message);
  66. //response inflaters
  67. bool inflateResponse(AEMessage* message, AEInitQuoteResponse* response);
  68. bool inflateResponse(AEMessage* message, AEGetQuoteResponse* response);
  69. bool inflateResponse(AEMessage* message, AEGetLaunchTokenResponse* response);
  70. bool inflateResponse(AEMessage* message, AECreateSessionResponse* response);
  71. bool inflateResponse(AEMessage* message, AEInvokeServiceResponse* response);
  72. bool inflateResponse(AEMessage* message, AEExchangeReportResponse* response);
  73. bool inflateResponse(AEMessage* message, AECloseSessionResponse* response);
  74. bool inflateResponse(AEMessage* message, AEGetPsCapResponse* response);
  75. bool inflateResponse(AEMessage* message, AEReportAttestationResponse* response);
  76. private:
  77. //request inflaters
  78. IAERequest* inflateInitQuoteRequest(aesm::message::Request* reqMsg);
  79. IAERequest* inflateGetQuoteRequest(aesm::message::Request* reqMsg);
  80. IAERequest* inflateCloseSessionRequest(aesm::message::Request* reqMsg);
  81. IAERequest* inflateCreateSessionRequest(aesm::message::Request* reqMsg);
  82. IAERequest* inflateExchangeReportRequest(aesm::message::Request* reqMsg);
  83. IAERequest* inflateGetLaunchTokenRequest(aesm::message::Request* reqMsg);
  84. IAERequest* inflateInvokeServiceRequest(aesm::message::Request* reqMsg);
  85. IAERequest* inflateGetPsCapRequest(aesm::message::Request* reqMsg);
  86. IAERequest* inflateReportAttestationErrorRequest(aesm::message::Request* reqMsg);
  87. };
  88. #endif