arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
IPAddress Class Reference

Arduino-compatible IPAddress class implemented in pure C++. More...

#include <IPAddress.h>

Public Member Functions

 IPAddress ()
 0.0.0.0
 
 IPAddress (const char *str)
 From a dotted-decimal string; leaves address as 0.0.0.0 on parse failure.
 
 IPAddress (const uint8_t octets[4])
 From a 4-byte array.
 
 IPAddress (uint32_t dword)
 From a raw uint32 in host byte order (same as Arduino)
 
 IPAddress (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 From four octets.
 
bool fromString (const char *str)
 
 operator bool () const
 True if address is non-zero.
 
 operator uint32_t () const
 Raw uint32 (host byte order, same layout as Arduino)
 
bool operator!= (const IPAddress &other) const
 
bool operator!= (uint32_t dword) const
 
IPAddressoperator= (const char *str)
 
IPAddressoperator= (const uint8_t octets[4])
 
IPAddressoperator= (uint32_t dword)
 
bool operator== (const IPAddress &other) const
 
bool operator== (const uint8_t octets[4]) const
 
bool operator== (uint32_t dword) const
 
uint8_toperator[] (int i)
 Octet access (read/write)
 
uint8_t operator[] (int i) const
 
uint8_traw ()
 
const uint8_traw () const
 Raw byte pointer (read-only)
 
std::string toString () const
 Returns dotted-decimal string e.g. "192.168.1.1".
 

Static Public Member Functions

static IPAddress any ()
 
static IPAddress broadcast ()
 
static IPAddress loopback ()
 

Detailed Description

Arduino-compatible IPAddress class implemented in pure C++.

Supports IPv4 only. Drop-in replacement for Arduino's IPAddress for use on platforms without the Arduino core (e.g. Zephyr, Linux).

Usage: IPAddress ip(192, 168, 1, 1); IPAddress ip(0xC0A80101); // same, from uint32_t IPAddress ip("192.168.1.1"); // from string IPAddress ip; // 0.0.0.0

ip[0] // 192 (uint32_t)ip // raw big-endian uint32 ip.toString() // "192.168.1.1" if (ip) { ... } // false if 0.0.0.0 ip == other // comparison

Constructor & Destructor Documentation

◆ IPAddress() [1/5]

IPAddress ( )
inline

0.0.0.0

◆ IPAddress() [2/5]

IPAddress ( uint8_t  a,
uint8_t  b,
uint8_t  c,
uint8_t  d 
)
inline

From four octets.

◆ IPAddress() [3/5]

IPAddress ( uint32_t  dword)
inlineexplicit

From a raw uint32 in host byte order (same as Arduino)

◆ IPAddress() [4/5]

IPAddress ( const uint8_t  octets[4])
inlineexplicit

From a 4-byte array.

◆ IPAddress() [5/5]

IPAddress ( const char str)
inlineexplicit

From a dotted-decimal string; leaves address as 0.0.0.0 on parse failure.

Member Function Documentation

◆ any()

static IPAddress any ( )
inlinestatic

◆ broadcast()

static IPAddress broadcast ( )
inlinestatic

◆ fromString()

bool fromString ( const char str)
inline

Parses a dotted-decimal string into this address.

Returns
true on success, false on failure (address unchanged on failure).

◆ loopback()

static IPAddress loopback ( )
inlinestatic

◆ operator bool()

operator bool ( ) const
inlineexplicit

True if address is non-zero.

◆ operator uint32_t()

operator uint32_t ( ) const
inline

Raw uint32 (host byte order, same layout as Arduino)

◆ operator!=() [1/2]

bool operator!= ( const IPAddress other) const
inline

◆ operator!=() [2/2]

bool operator!= ( uint32_t  dword) const
inline

◆ operator=() [1/3]

IPAddress & operator= ( const char str)
inline

◆ operator=() [2/3]

IPAddress & operator= ( const uint8_t  octets[4])
inline

◆ operator=() [3/3]

IPAddress & operator= ( uint32_t  dword)
inline

◆ operator==() [1/3]

bool operator== ( const IPAddress other) const
inline

◆ operator==() [2/3]

bool operator== ( const uint8_t  octets[4]) const
inline

◆ operator==() [3/3]

bool operator== ( uint32_t  dword) const
inline

◆ operator[]() [1/2]

uint8_t & operator[] ( int  i)
inline

Octet access (read/write)

◆ operator[]() [2/2]

uint8_t operator[] ( int  i) const
inline

◆ raw() [1/2]

uint8_t * raw ( )
inline

◆ raw() [2/2]

const uint8_t * raw ( ) const
inline

Raw byte pointer (read-only)

◆ toString()

std::string toString ( ) const
inline

Returns dotted-decimal string e.g. "192.168.1.1".

Member Data Documentation

◆ bytes

uint8_t bytes[4]

◆ dword

uint32_t dword

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