123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #ifndef _FASTDDS_RTPS_PORT_PARAMETERS_H_
- #define _FASTDDS_RTPS_PORT_PARAMETERS_H_
- #include <fastdds/rtps/common/Types.h>
- #include <fastdds/dds/log/Log.hpp>
- namespace eprosima {
- namespace fastrtps{
- namespace rtps {
- class PortParameters
- {
- public:
- PortParameters()
- : portBase(7400),
- domainIDGain(250),
- participantIDGain(2),
- offsetd0(0),
- offsetd1(10),
- offsetd2(1),
- offsetd3(11)
- {}
- virtual ~PortParameters(){}
- bool operator==(const PortParameters& b) const
- {
- return (this->portBase == b.portBase) &&
- (this->domainIDGain == b.domainIDGain) &&
- (this->participantIDGain == b.participantIDGain) &&
- (this->offsetd0 == b.offsetd0) &&
- (this->offsetd1 == b.offsetd1) &&
- (this->offsetd2 == b.offsetd2) &&
- (this->offsetd3 == b.offsetd3);
- }
-
- inline uint32_t getMulticastPort(uint32_t domainId) const
- {
- uint32_t port = portBase + domainIDGain * domainId + offsetd0;
- if (port > 65535)
- {
- logError(RTPS, "Calculated port number is too high. Probably the domainId is over 232 "
- << "or portBase is too high.");
- std::cout << "Calculated port number is too high. Probably the domainId is over 232 "
- << "or portBase is too high." << std::endl;
- std::cout.flush();
- exit(EXIT_FAILURE);
- }
- return port;
- }
-
- inline uint32_t getUnicastPort(uint32_t domainId,uint32_t RTPSParticipantID) const
- {
- uint32_t port = portBase + domainIDGain * domainId + offsetd1 + participantIDGain * RTPSParticipantID;
- if (port > 65535)
- {
- logError(RTPS, "Calculated port number is too high. Probably the domainId is over 232, there are "
- << "too much participants created or portBase is too high.");
- std::cout << "Calculated port number is too high. Probably the domainId is over 232, there are "
- << "too much participants created or portBase is too high." << std::endl;
- std::cout.flush();
- exit(EXIT_FAILURE);
- }
- return port;
- }
- public:
-
- uint16_t portBase;
-
- uint16_t domainIDGain;
-
- uint16_t participantIDGain;
-
- uint16_t offsetd0;
-
- uint16_t offsetd1;
-
- uint16_t offsetd2;
-
- uint16_t offsetd3;
- };
- }
- }
- }
- #endif
|