.. _program_listing_file__tmp_ws_src_fastrtps_include_fastrtps_utils_IPLocator.h: Program Listing for File IPLocator.h ==================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/fastrtps/include/fastrtps/utils/IPLocator.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef IP_LOCATOR_H_ #define IP_LOCATOR_H_ #include #include #include #include #include #include namespace eprosima { namespace fastrtps { namespace rtps { class Locator_t; class IPLocator { public: RTPS_DllAPI static void createLocator( int32_t kindin, const std::string& address, uint32_t portin, Locator_t& locator); RTPS_DllAPI static bool setIPv4( Locator_t& locator, const unsigned char* addr); RTPS_DllAPI static bool setIPv4( Locator_t& locator, octet o1, octet o2, octet o3, octet o4); RTPS_DllAPI static bool setIPv4( Locator_t& locator, const std::string& ipv4); RTPS_DllAPI static bool setIPv4( Locator_t& destlocator, const Locator_t& origlocator); RTPS_DllAPI static bool setIPv4address( Locator_t& destlocator, const std::string& lan, const std::string& wan, const std::string& ipv4); RTPS_DllAPI static const octet* getIPv4( const Locator_t& locator); RTPS_DllAPI static bool hasIPv4( const Locator_t& locator); RTPS_DllAPI static std::string toIPv4string( const Locator_t& locator); RTPS_DllAPI static bool copyIPv4( const Locator_t& locator, unsigned char* dest); // IPv6 RTPS_DllAPI static bool setIPv6( Locator_t& locator, const unsigned char* addr); RTPS_DllAPI static bool setIPv6( Locator_t& locator, uint16_t group0, uint16_t group1, uint16_t group2, uint16_t group3, uint16_t group4, uint16_t group5, uint16_t group6, uint16_t group7); RTPS_DllAPI static bool setIPv6( Locator_t& locator, const std::string& ipv6); RTPS_DllAPI static bool setIPv6( Locator_t& destlocator, const Locator_t& origlocator); RTPS_DllAPI static const octet* getIPv6( const Locator_t& locator); RTPS_DllAPI static bool hasIPv6( const Locator_t& locator); RTPS_DllAPI static std::string toIPv6string( const Locator_t& locator); RTPS_DllAPI static bool copyIPv6( const Locator_t& locator, unsigned char* dest); RTPS_DllAPI static bool ip( Locator_t& locator, const std::string& ip); RTPS_DllAPI static std::string ip_to_string( const Locator_t& locator); // TCP RTPS_DllAPI static bool setLogicalPort( Locator_t& locator, uint16_t port); RTPS_DllAPI static uint16_t getLogicalPort( const Locator_t& locator); RTPS_DllAPI static bool setPhysicalPort( Locator_t& locator, uint16_t port); RTPS_DllAPI static uint16_t getPhysicalPort( const Locator_t& locator); // TCPv4 RTPS_DllAPI static bool setWan( Locator_t& locator, octet o1, octet o2, octet o3, octet o4); RTPS_DllAPI static bool setWan( Locator_t& locator, const std::string& wan); RTPS_DllAPI static const octet* getWan( const Locator_t& locator); RTPS_DllAPI static bool hasWan( const Locator_t& locator); RTPS_DllAPI static std::string toWanstring( const Locator_t& locator); RTPS_DllAPI static bool setLanID( Locator_t& locator, const std::string& lanId); RTPS_DllAPI static const octet* getLanID( const Locator_t& locator); RTPS_DllAPI static std::string toLanIDstring( const Locator_t& locator); RTPS_DllAPI static Locator_t toPhysicalLocator( const Locator_t& locator); RTPS_DllAPI static bool ip_equals_wan( const Locator_t& locator); // Common RTPS_DllAPI static bool setPortRTPS( Locator_t& locator, uint16_t port); RTPS_DllAPI static uint16_t getPortRTPS( Locator_t& locator); RTPS_DllAPI static bool isLocal( const Locator_t& locator); RTPS_DllAPI static bool isAny( const Locator_t& locator); RTPS_DllAPI static bool compareAddress( const Locator_t& loc1, const Locator_t& loc2, bool fullAddress = false); RTPS_DllAPI static bool compareAddressAndPhysicalPort( const Locator_t& loc1, const Locator_t& loc2); RTPS_DllAPI static std::string to_string( const Locator_t& locator); // UDP RTPS_DllAPI static bool isMulticast( const Locator_t& locator); RTPS_DllAPI static std::pair, std::set> resolveNameDNS( const std::string& address_name); RTPS_DllAPI static bool isIPv4( const std::string& address); RTPS_DllAPI static bool isIPv6( const std::string& address); protected: // Checks if the locator address is equal to 0 // It checks the proper locator address depending on the locator kind static bool isEmpty( const Locator_t& locator); // Checks if the locator address from index till the end is equal to 0 static bool isEmpty( const Locator_t& locator, uint16_t index); // Checks if a string matches an ipv6 address static bool IPv6isCorrect( const std::string& ipv6); private: IPLocator() = delete; ~IPLocator() = delete; }; } // namespace rtps } // namespace fastrtps } /* namespace eprosima */ #endif /* IP_LOCATOR_H_ */