• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Product
    • Design UI
    • Develop
    • Analyze and test
    • Deploy
    • Framework and toolbox
    • Compatibility
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - CDP Core
  • IpAddress
  • 4.11.14

IpAddress Class

IpAddress: int32 ip address with name, string, subnetmask, port and MAC address. More...

Header: #include <OSAPI/Network/IpAddress.h>
Inherited By:

Url

  • List of all members, including inherited members

Public Functions

IpAddress()
IpAddress(const unsigned int addr, const unsigned short port = 0)
IpAddress(const char *addr, const unsigned short port = 0)
IpAddress(const IpAddress &rhs)
void Configure(const char *pBuffer)
void Configure(XMLElementEx *networkInterfaceXML)
IpAddress Gateway() const
std::string GetInterfaceName()
const char *GetIpAddressAsString() const
unsigned char *GetMac()
std::string GetOSInterfaceName()
bool IsThisBroadcastAddress(const IpAddress &localIpAddress) const
bool IsThisMulticastAddress() const
IpAddress &Lookup(const char *strHostName)
unsigned short Port() const
void SetGateway(const IpAddress &gateway)
void SetInterfaceName(const std::string &newInterfaceName)
void SetMac(unsigned char *pMac8)
void SetOSInterfaceName(const std::string &newOSInterfaceName)
void SetPort(const unsigned short port)
void SetSubnetMask(const IpAddress &subnetMask)
IpAddress Subnet() const
IpAddress SubnetMask() const
operator const char *()
operator sockaddr *()
operator sockaddr_in *()
operator unsigned int() const
bool operator<(const IpAddress &rhs) const
IpAddress &operator=(const IpAddress &rhs)
IpAddress &operator=(const sockaddr_in &rhs)
IpAddress &operator=(const char *param)
IpAddress &operator=(const unsigned int param)
bool operator==(const unsigned int rhs) const
bool operator==(const int rhs) const
bool operator==(const IpAddress &rhs) const

Detailed Description

IpAddress: int32 ip address with name, string, subnetmask, port and MAC address.

See also Url.

Member Function Documentation

IpAddress::IpAddress()

Contructs an IpAddress.

IpAddress::IpAddress(const unsigned int addr, const unsigned short port = 0)

Contructs an IpAddress with given addr and port.

IpAddress::IpAddress(const char *addr, const unsigned short port = 0)

Contructs an IpAddress with given addr and port.

IpAddress::IpAddress(const IpAddress &rhs)

Copy constructor.

Uses assignment operator to copy data to this object.

void IpAddress::Configure(const char *pBuffer)

Reads <NetworkInterface> element from xml into this IPAddress.

void IpAddress::Configure(XMLElementEx *networkInterfaceXML)

IpAddress IpAddress::Gateway() const

Returns the gateway for this interface. Empty if "default".

std::string IpAddress::GetInterfaceName()

Returns the interface name for this ipaddress.

const char *IpAddress::GetIpAddressAsString() const

Returns the IP Address as a string.

unsigned char *IpAddress::GetMac()

Returns mac address as 8 unsigned bytes. Unused bytes are set to 0.

std::string IpAddress::GetOSInterfaceName()

Returns the OS interface name for this ipaddress, e.g. eth0, eth0.0, eth0:0 for Linux.

bool IpAddress::IsThisBroadcastAddress(const IpAddress &localIpAddress) const

Returns true if IpAddress is a broadcast address.

Checks if the IpAddress is a broadcast address on the same subnet as the localIpAddress.localIpAddress indicates which subnet the function will check for broadcast.

bool IpAddress::IsThisMulticastAddress() const

Returns true if ipAddress is a multicast address (224.0.0.0 to 239.255.255.255)

IpAddress &IpAddress::Lookup(const char *strHostName)

Stores the retrieved address in this-object, by searching for specified host name.

unsigned short IpAddress::Port() const

Reads the port associated with the ip-address.

void IpAddress::SetGateway(const IpAddress &gateway)

Sets the gateway for this interface. Empty if "default".

void IpAddress::SetInterfaceName(const std::string &newInterfaceName)

Sets the interface name for this ipaddress.

void IpAddress::SetMac(unsigned char *pMac8)

Sets the MAC address.

void IpAddress::SetOSInterfaceName(const std::string &newOSInterfaceName)

Sets the OS interface name for this ipaddress.

void IpAddress::SetPort(const unsigned short port)

Sets the port associated with the ip-address. Optional.

void IpAddress::SetSubnetMask(const IpAddress &subnetMask)

Sets the subnet associated with the ip-address. Optional.

Note: The subnet is set to the address of the subnetMask parameter. This allows operations like adapter1.SetSubnetMask("255.255.255.0"); because the ip-address object of the parameter will take care of string to number conversions.

IpAddress IpAddress::Subnet() const

Returns the subnet as the address field of the returned IpAddress object.

This allows operations like if (adapter.Subnet() == (const IpAddress) "192.168.2.0")...

IpAddress IpAddress::SubnetMask() const

Returns the subnet mask as the address field of the returned IpAddress object.

This allows operations like printf("Subnet mask: %s\n", (const char*)adapter1.SubnetMask() ); because the ip-address object of the parameter will take care of the number to string conversions.

IpAddress::operator const char *()

Returns the host interface address as string.

IpAddress::operator sockaddr *()

Returns internal sockaddr_in instance as sockaddr.

IpAddress::operator sockaddr_in *()

Returns internal sockaddr_in instance.

IpAddress::operator unsigned int() const

Returns the host interface address in network byte order.

bool IpAddress::operator<(const IpAddress &rhs) const

IpAddress less-than operator.

IpAddress &IpAddress::operator=(const IpAddress &rhs)

Assigns rhs to this class.

IpAddress &IpAddress::operator=(const sockaddr_in &rhs)

Assigns rhs to this class.

Note: The values in the rhs must always be in network byte order.

IpAddress &IpAddress::operator=(const char *param)

Updates the host interface address from string.

IpAddress &IpAddress::operator=(const unsigned int param)

Updates the host interface address from integer.

bool IpAddress::operator==(const unsigned int rhs) const

Only compares the value to host interface address.

bool IpAddress::operator==(const int rhs) const

Only compares the value to host interface address.

bool IpAddress::operator==(const IpAddress &rhs) const

Compares the equality with rhs.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

    © Copyright 2022 CDP Technologies. Privacy and cookie policy.

    Return to top