RTPS_messages.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @file RTPS_messages.h
  16. */
  17. #ifndef _FASTDDS_RTPS_RTPS_MESSAGES_H_
  18. #define _FASTDDS_RTPS_RTPS_MESSAGES_H_
  19. #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
  20. #include <fastdds/rtps/common/Types.h>
  21. #include <fastdds/rtps/common/Guid.h>
  22. #include <iostream>
  23. #include <bitset>
  24. namespace eprosima{
  25. namespace fastrtps{
  26. namespace rtps{
  27. // //!@brief Enumeration of the different Submessages types
  28. enum SubmessageId : uint8_t
  29. {
  30. PAD = 0x01,
  31. ACKNACK = 0x06,
  32. HEARTBEAT = 0x07,
  33. GAP = 0x08,
  34. INFO_TS = 0x09,
  35. INFO_SRC = 0x0c,
  36. INFO_REPLY_IP4 = 0x0d,
  37. INFO_DST = 0x0e,
  38. INFO_REPLY = 0x0f,
  39. NACK_FRAG = 0x12,
  40. HEARTBEAT_FRAG = 0x13,
  41. DATA = 0x15,
  42. DATA_FRAG = 0x16
  43. };
  44. //!@brief Structure Header_t, RTPS Message Header Structure.
  45. //!@ingroup COMMON_MODULE
  46. struct Header_t{
  47. //!Protocol version
  48. ProtocolVersion_t version;
  49. //!Vendor ID
  50. VendorId_t vendorId;
  51. //!GUID prefix
  52. GuidPrefix_t guidPrefix;
  53. Header_t():
  54. version(c_ProtocolVersion)
  55. , vendorId(c_VendorId_eProsima)
  56. {
  57. }
  58. ~Header_t(){
  59. }
  60. };
  61. /**
  62. * @param output
  63. * @param h
  64. * @return
  65. */
  66. inline std::ostream& operator<<(std::ostream& output,const Header_t& h){
  67. output << "RTPS HEADER of Version: " << (int)h.version.m_major << "." << (int)h.version.m_minor;
  68. output << " || VendorId: " <<std::hex<< (int)h.vendorId[0] << "." <<(int)h.vendorId[1] << std::dec;
  69. output << "GuidPrefix: " << h.guidPrefix;
  70. return output;
  71. }
  72. //!@brief Structure SubmessageHeader_t, used to contain the header information of a submessage.
  73. struct SubmessageHeader_t
  74. {
  75. octet submessageId;
  76. uint32_t submessageLength;
  77. SubmessageFlag flags;
  78. bool is_last;
  79. SubmessageHeader_t()
  80. : submessageId(0)
  81. , submessageLength(0)
  82. , flags(0)
  83. , is_last(false)
  84. {}
  85. };
  86. using std::cout;
  87. using std::endl;
  88. using std::bitset;
  89. /**
  90. * @param output
  91. * @param sh
  92. * @return
  93. */
  94. inline std::ostream& operator<<(std::ostream& output,const SubmessageHeader_t& sh){
  95. output << "Submessage Header, ID: " <<std::hex<< (int)sh.submessageId << std::dec;
  96. output << " length: " << (int)sh.submessageLength << " flags " << (bitset<8>) sh.flags;
  97. return output;
  98. }
  99. }
  100. }
  101. }
  102. #endif
  103. #endif /* _FASTDDS_RTPS_MESSAGES_H_ */