| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
IPLocator Class Reference
eProsima Fast DDS API Reference » Shared Utilities

Class IPLocator, to provide helper functions to the IP based transports. More...

`#include <IPLocator.hpp>`

## Static Public Member Functions

static FASTDDS_EXPORTED_API void | createLocator (int32_t kindin, const std::string &address, uint32_t portin, Locator_t &locator)
| Fills locator with the given parameters.
static FASTDDS_EXPORTED_API bool | setIPv4 (Locator_t &locator, const unsigned char *addr)
| Sets locator's IPv4.
static FASTDDS_EXPORTED_API bool | setIPv4 (Locator_t &locator, octet o1, octet o2, octet o3, octet o4)
| Sets locator's IPv4.
static FASTDDS_EXPORTED_API bool | setIPv4 (Locator_t &locator, const std::string &ipv4)
| Sets locator's IPv4.
static FASTDDS_EXPORTED_API bool | setIPv4 (Locator_t &destlocator, const Locator_t &origlocator)
| Copies locator's IPv4.
static FASTDDS_EXPORTED_API bool | setIPv4address (Locator_t &destlocator, const std::string &lan, const std::string &wan, const std::string &ipv4)
| Copies locator's IPv4.
static FASTDDS_EXPORTED_API const octet * | getIPv4 (const Locator_t &locator)
| Retrieves locator's IPv4 as octet array.
static FASTDDS_EXPORTED_API bool | hasIPv4 (const Locator_t &locator)
| Check if the locator has IPv4.
static FASTDDS_EXPORTED_API std::string | toIPv4string (const Locator_t &locator)
| Returns a string representation of the locator's IPv4.
static FASTDDS_EXPORTED_API bool | copyIPv4 (const Locator_t &locator, unsigned char *dest)
| Copies locator's IPv4 to a destination array.
static FASTDDS_EXPORTED_API bool | copyIPv4 (const Locator_t &locator, Locator_t &dest)
| Copies locator's IPv4 to a destination locator.
static FASTDDS_EXPORTED_API bool | setIPv6 (Locator_t &locator, const unsigned char *addr)
| Sets locator's IPv6.
static FASTDDS_EXPORTED_API 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)
| Sets locator's IPv6.
static FASTDDS_EXPORTED_API bool | setIPv6 (Locator_t &locator, const std::string &ipv6)
| Sets locator's IPv6.
static FASTDDS_EXPORTED_API bool | setIPv6 (Locator_t &destlocator, const Locator_t &origlocator)
| Copies locator's IPv6.
static FASTDDS_EXPORTED_API const octet * | getIPv6 (const Locator_t &locator)
| Retrieves locator's IPv6 as octet array.
static FASTDDS_EXPORTED_API bool | hasIPv6 (const Locator_t &locator)
| Check if the locator has IPv6.
static FASTDDS_EXPORTED_API std::string | toIPv6string (const Locator_t &locator)
| Returns a string representation of the locator's IPv6 following RFC 5952 recommendation.
static FASTDDS_EXPORTED_API bool | copyIPv6 (const Locator_t &locator, unsigned char *dest)
| Copies locator's IPv6.
static FASTDDS_EXPORTED_API bool | ip (Locator_t &locator, const std::string &ip)
| Sets locator's IP.
static FASTDDS_EXPORTED_API std::string | ip_to_string (const Locator_t &locator)
| Returns a string representation of the locator's IP.
static FASTDDS_EXPORTED_API bool | setLogicalPort (Locator_t &locator, uint16_t port)
| Sets locator's logical port (as in RTCP protocol).
static FASTDDS_EXPORTED_API uint16_t | getLogicalPort (const Locator_t &locator)
| Gets locator's logical port (as in RTCP protocol).
static FASTDDS_EXPORTED_API bool | setPhysicalPort (Locator_t &locator, uint16_t port)
| Sets locator's physical port (as in RTCP protocol).
static FASTDDS_EXPORTED_API uint16_t | getPhysicalPort (const Locator_t &locator)
| Gets locator's physical port (as in RTCP protocol).
static FASTDDS_EXPORTED_API bool | setWan (Locator_t &locator, octet o1, octet o2, octet o3, octet o4)
| Sets locator's WAN address (as in RTCP protocol).
static FASTDDS_EXPORTED_API bool | setWan (Locator_t &locator, const std::string &wan)
| Sets locator's WAN address (as in RTCP protocol).
static FASTDDS_EXPORTED_API const octet * | getWan (const Locator_t &locator)
| Gets locator's WAN address (as in RTCP protocol).
static FASTDDS_EXPORTED_API bool | hasWan (const Locator_t &locator)
| Checks if the locator has WAN address (as in RTCP protocol).
static FASTDDS_EXPORTED_API std::string | toWanstring (const Locator_t &locator)
| Retrieves a string representation of the locator's WAN address (as in RTCP protocol).
static FASTDDS_EXPORTED_API Locator_t | WanToLanLocator (const Locator_t &locator)
| This method is useful in the case of having a tcp client with an initial peer pointing to a WAN locator, and receiving a locator with LAN and WAN addresses (TCP Client from TCP Server).
static FASTDDS_EXPORTED_API bool | setLanID (Locator_t &locator, const std::string &lanId)
| Sets locator's LAN ID (as in RTCP protocol).
static FASTDDS_EXPORTED_API const octet * | getLanID (const Locator_t &locator)
| Gets locator's LAN ID (as in RTCP protocol).
static FASTDDS_EXPORTED_API std::string | toLanIDstring (const Locator_t &locator)
| Retrieves a string representation of the locator's LAN ID (as in RTCP protocol).
static FASTDDS_EXPORTED_API Locator_t | toPhysicalLocator (const Locator_t &locator)
| Returns a new locator without logical port (as in RTCP protocol).
static FASTDDS_EXPORTED_API bool | ip_equals_wan (const Locator_t &locator)
| Checks if a locator WAN address and IP address are the same (as in RTCP protocol).
static FASTDDS_EXPORTED_API bool | setPortRTPS (Locator_t &locator, uint16_t port)
| Sets locator's RTCP port. Physical for UDP and logical for TCP (as in RTCP protocol).
static FASTDDS_EXPORTED_API uint16_t | getPortRTPS (Locator_t &locator)
| Gets locator's RTCP port. Physical for UDP and logical for TCP (as in RTCP protocol).
static FASTDDS_EXPORTED_API bool | isLocal (const Locator_t &locator)
| Checks if a locator has local IP address.
static FASTDDS_EXPORTED_API bool | isAny (const Locator_t &locator)
| Checks if a locator has any IP address.
static FASTDDS_EXPORTED_API bool | compareAddress (const Locator_t &loc1, const Locator_t &loc2, bool fullAddress=false)
| Checks if both locators has the same IP address.
static FASTDDS_EXPORTED_API bool | copy_address (const Locator_t &loc1, Locator_t &loc2)
| Copies the whole address from one locator to another.
static FASTDDS_EXPORTED_API bool | compareAddressAndPhysicalPort (const Locator_t &loc1, const Locator_t &loc2)
| Checks if a both locators has the same IP address and physical port (as in RTCP protocol).
static FASTDDS_EXPORTED_API std::string | to_string (const Locator_t &locator)
| Returns a string representation of the given locator.
static FASTDDS_EXPORTED_API bool | isMulticast (const Locator_t &locator)
| Checks if the locator has a multicast IP address.
static FASTDDS_EXPORTED_API std::pair< std::set< std::string >, std::set< std::string > > | resolveNameDNS (const std::string &address_name)
| Resolve an address name by a DNS request and return the IP that this address references by a DNS server.
static FASTDDS_EXPORTED_API bool | isIPv4 (const std::string &address)
| Check whether a string contains an IPv4 format.
static FASTDDS_EXPORTED_API bool | isIPv6 (const std::string &address)
| Check whether a string contains an IPv6 format.

## Static Protected Member Functions

static bool | isEmpty (const Locator_t &locator)
static bool | isEmpty (const Locator_t &locator, uint16_t index)
static bool | IPv6isCorrect (const std::string &ipv6)

## Detailed Description

Class IPLocator, to provide helper functions to the IP based transports.

## Member Function Documentation

## ◆ compareAddress()

FASTDDS_EXPORTED_API bool compareAddress | ( | const Locator_t & | loc1,
|  | const Locator_t & | loc2,
|  | bool | fullAddress = false )

static

Checks if both locators has the same IP address.

## ◆ compareAddressAndPhysicalPort()

FASTDDS_EXPORTED_API bool compareAddressAndPhysicalPort | ( | const Locator_t & | loc1,
|  | const Locator_t & | loc2 )

static

Checks if a both locators has the same IP address and physical port (as in RTCP protocol).

## ◆ copy_address()

FASTDDS_EXPORTED_API bool copy_address | ( | const Locator_t & | loc1,
|  | Locator_t & | loc2 )

static

Copies the whole address from one locator to another.

Parameters

  loc1 | Locator to copy from.
  loc2 | Locator to copy to.

Returns
  True if the copy was successful.

## ◆ copyIPv4() [1/2]

FASTDDS_EXPORTED_API bool copyIPv4 | ( | const Locator_t & | locator,
|  | Locator_t & | dest )

static

Copies locator's IPv4 to a destination locator.

It only copies the IPv4 part (last 4 bytes), leaving other parts unchanged.

Parameters

  locator | Locator from which to copy the IPv4.
  dest | Destination locator where the IPv4 will be copied.

Returns
  true if the copy was successful, false otherwise.

## ◆ copyIPv4() [2/2]

FASTDDS_EXPORTED_API bool copyIPv4 | ( | const Locator_t & | locator,
|  | unsigned char * | dest )

static

Copies locator's IPv4 to a destination array.

Parameters

  locator | Locator from which to copy the IPv4.
  dest | Destination array where the IPv4 will be copied.

Returns
  true if the copy was successful, false otherwise.

## ◆ copyIPv6()

FASTDDS_EXPORTED_API bool copyIPv6 | ( | const Locator_t & | locator,
|  | unsigned char * | dest )

static

Copies locator's IPv6.

## ◆ createLocator()

FASTDDS_EXPORTED_API void createLocator | ( | int32_t | kindin,
|  | const std::string & | address,
|  | uint32_t | portin,
|  | Locator_t & | locator )

static

Fills locator with the given parameters.

Parameters

  kindin | Kind of the locator.
  address | IP Address of the locator as string.
  portin | Port of the locator.
  locator | Locator to be filled.

## ◆ getIPv4()

FASTDDS_EXPORTED_API const octet * getIPv4 | ( | const Locator_t & | locator | ) |

static

Retrieves locator's IPv4 as octet array.

## ◆ getIPv6()

FASTDDS_EXPORTED_API const octet * getIPv6 | ( | const Locator_t & | locator | ) |

static

Retrieves locator's IPv6 as octet array.

## ◆ getLanID()

FASTDDS_EXPORTED_API const octet * getLanID | ( | const Locator_t & | locator | ) |

static

Gets locator's LAN ID (as in RTCP protocol).

## ◆ getLogicalPort()

FASTDDS_EXPORTED_API uint16_t getLogicalPort | ( | const Locator_t & | locator | ) |

static

Gets locator's logical port (as in RTCP protocol).

## ◆ getPhysicalPort()

FASTDDS_EXPORTED_API uint16_t getPhysicalPort | ( | const Locator_t & | locator | ) |

static

Gets locator's physical port (as in RTCP protocol).

## ◆ getPortRTPS()

FASTDDS_EXPORTED_API uint16_t getPortRTPS | ( | Locator_t & | locator | ) |

static

Gets locator's RTCP port. Physical for UDP and logical for TCP (as in RTCP protocol).

## ◆ getWan()

FASTDDS_EXPORTED_API const octet * getWan | ( | const Locator_t & | locator | ) |

static

Gets locator's WAN address (as in RTCP protocol).

## ◆ hasIPv4()

FASTDDS_EXPORTED_API bool hasIPv4 | ( | const Locator_t & | locator | ) |

static

Check if the locator has IPv4.

## ◆ hasIPv6()

FASTDDS_EXPORTED_API bool hasIPv6 | ( | const Locator_t & | locator | ) |

static

Check if the locator has IPv6.

## ◆ hasWan()

FASTDDS_EXPORTED_API bool hasWan | ( | const Locator_t & | locator | ) |

static

Checks if the locator has WAN address (as in RTCP protocol).

## ◆ ip()

FASTDDS_EXPORTED_API bool ip | ( | Locator_t & | locator,
|  | const std::string & | ip )

static

Sets locator's IP.

## ◆ ip_equals_wan()

FASTDDS_EXPORTED_API bool ip_equals_wan | ( | const Locator_t & | locator | ) |

static

Checks if a locator WAN address and IP address are the same (as in RTCP protocol).

## ◆ ip_to_string()

FASTDDS_EXPORTED_API std::string ip_to_string | ( | const Locator_t & | locator | ) |

static

Returns a string representation of the locator's IP.

## ◆ IPv6isCorrect()

bool IPv6isCorrect | ( | const std::string & | ipv6 | ) |

static protected

## ◆ isAny()

FASTDDS_EXPORTED_API bool isAny | ( | const Locator_t & | locator | ) |

static

Checks if a locator has any IP address.

## ◆ isEmpty() [1/2]

bool isEmpty | ( | const Locator_t & | locator | ) |

static protected

## ◆ isEmpty() [2/2]

bool isEmpty | ( | const Locator_t & | locator,
|  | uint16_t | index )

static protected

## ◆ isIPv4()

FASTDDS_EXPORTED_API bool isIPv4 | ( | const std::string & | address | ) |

static

Check whether a string contains an IPv4 format.

## ◆ isIPv6()

FASTDDS_EXPORTED_API bool isIPv6 | ( | const std::string & | address | ) |

static

Check whether a string contains an IPv6 format.

## ◆ isLocal()

FASTDDS_EXPORTED_API bool isLocal | ( | const Locator_t & | locator | ) |

static

Checks if a locator has local IP address.

## ◆ isMulticast()

FASTDDS_EXPORTED_API bool isMulticast | ( | const Locator_t & | locator | ) |

static

Checks if the locator has a multicast IP address.

## ◆ resolveNameDNS()

FASTDDS_EXPORTED_API std::pair< std::set< std::string >, std::set< std::string > > resolveNameDNS | ( | const std::string & | address_name | ) |

static

Resolve an address name by a DNS request and return the IP that this address references by a DNS server.

## ◆ setIPv4() [1/4]

FASTDDS_EXPORTED_API bool setIPv4 | ( | Locator_t & | destlocator,
|  | const Locator_t & | origlocator )

static

Copies locator's IPv4.

## ◆ setIPv4() [2/4]

FASTDDS_EXPORTED_API bool setIPv4 | ( | Locator_t & | locator,
|  | const std::string & | ipv4 )

static

Sets locator's IPv4.

## ◆ setIPv4() [3/4]

FASTDDS_EXPORTED_API bool setIPv4 | ( | Locator_t & | locator,
|  | const unsigned char * | addr )

static

Sets locator's IPv4.

## ◆ setIPv4() [4/4]

FASTDDS_EXPORTED_API bool setIPv4 | ( | Locator_t & | locator,
|  | octet | o1,
|  | octet | o2,
|  | octet | o3,
|  | octet | o4 )

static

Sets locator's IPv4.

## ◆ setIPv4address()

FASTDDS_EXPORTED_API bool setIPv4address | ( | Locator_t & | destlocator,
|  | const std::string & | lan,
|  | const std::string & | wan,
|  | const std::string & | ipv4 )

static

Copies locator's IPv4.

## ◆ setIPv6() [1/4]

FASTDDS_EXPORTED_API bool setIPv6 | ( | Locator_t & | destlocator,
|  | const Locator_t & | origlocator )

static

Copies locator's IPv6.

## ◆ setIPv6() [2/4]

FASTDDS_EXPORTED_API bool setIPv6 | ( | Locator_t & | locator,
|  | const std::string & | ipv6 )

static

Sets locator's IPv6.

## ◆ setIPv6() [3/4]

FASTDDS_EXPORTED_API bool setIPv6 | ( | Locator_t & | locator,
|  | const unsigned char * | addr )

static

Sets locator's IPv6.

## ◆ setIPv6() [4/4]

FASTDDS_EXPORTED_API 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 )

static

Sets locator's IPv6.

## ◆ setLanID()

FASTDDS_EXPORTED_API bool setLanID | ( | Locator_t & | locator,
|  | const std::string & | lanId )

static

Sets locator's LAN ID (as in RTCP protocol).

## ◆ setLogicalPort()

FASTDDS_EXPORTED_API bool setLogicalPort | ( | Locator_t & | locator,
|  | uint16_t | port )

static

Sets locator's logical port (as in RTCP protocol).

## ◆ setPhysicalPort()

FASTDDS_EXPORTED_API bool setPhysicalPort | ( | Locator_t & | locator,
|  | uint16_t | port )

static

Sets locator's physical port (as in RTCP protocol).

## ◆ setPortRTPS()

FASTDDS_EXPORTED_API bool setPortRTPS | ( | Locator_t & | locator,
|  | uint16_t | port )

static

Sets locator's RTCP port. Physical for UDP and logical for TCP (as in RTCP protocol).

## ◆ setWan() [1/2]

FASTDDS_EXPORTED_API bool setWan | ( | Locator_t & | locator,
|  | const std::string & | wan )

static

Sets locator's WAN address (as in RTCP protocol).

## ◆ setWan() [2/2]

FASTDDS_EXPORTED_API bool setWan | ( | Locator_t & | locator,
|  | octet | o1,
|  | octet | o2,
|  | octet | o3,
|  | octet | o4 )

static

Sets locator's WAN address (as in RTCP protocol).

## ◆ to_string()

FASTDDS_EXPORTED_API std::string to_string | ( | const Locator_t & | locator | ) |

static

Returns a string representation of the given locator.

## ◆ toIPv4string()

FASTDDS_EXPORTED_API std::string toIPv4string | ( | const Locator_t & | locator | ) |

static

Returns a string representation of the locator's IPv4.

## ◆ toIPv6string()

FASTDDS_EXPORTED_API std::string toIPv6string | ( | const Locator_t & | locator | ) |

static

Returns a string representation of the locator's IPv6 following RFC 5952 recommendation.

## ◆ toLanIDstring()

FASTDDS_EXPORTED_API std::string toLanIDstring | ( | const Locator_t & | locator | ) |

static

Retrieves a string representation of the locator's LAN ID (as in RTCP protocol).

## ◆ toPhysicalLocator()

FASTDDS_EXPORTED_API Locator_t toPhysicalLocator | ( | const Locator_t & | locator | ) |

static

Returns a new locator without logical port (as in RTCP protocol).

## ◆ toWanstring()

FASTDDS_EXPORTED_API std::string toWanstring | ( | const Locator_t & | locator | ) |

static

Retrieves a string representation of the locator's WAN address (as in RTCP protocol).

## ◆ WanToLanLocator()

FASTDDS_EXPORTED_API Locator_t WanToLanLocator | ( | const Locator_t & | locator | ) |

static

This method is useful in the case of having a tcp client with an initial peer pointing to a WAN locator, and receiving a locator with LAN and WAN addresses (TCP Client from TCP Server).

The documentation for this class was generated from the following file:

- include/fastdds/utils/IPLocator.hpp