|
-
-
- #if ARDUINO >= 100
- #ifndef IPAddress_h
- #define IPAddress_h
-
- #include <Printable.h>
-
-
-
- class IPAddress : public Printable {
- private:
- union {
- uint8_t bytes[4];
- uint32_t dword;
- } _address;
-
-
-
-
- uint8_t* raw_address() { return _address.bytes; };
-
- public:
-
- IPAddress();
- IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
- IPAddress(uint32_t address);
- IPAddress(const uint8_t *address);
-
- bool fromString(const char *address);
- bool fromString(const String &address) {
- return fromString(address.c_str());
- }
-
-
-
- operator uint32_t() { return _address.dword; };
- bool operator==(const IPAddress& addr) { return _address.dword == addr._address.dword; };
- bool operator==(const uint8_t* addr);
-
-
- uint8_t operator[](int index) const { return _address.bytes[index]; };
- uint8_t& operator[](int index) { return _address.bytes[index]; };
-
-
- IPAddress& operator=(const uint8_t *address);
- IPAddress& operator=(uint32_t address);
-
- virtual size_t printTo(Print& p) const;
-
- friend class EthernetClass;
- friend class UDP;
- friend class Client;
- friend class Server;
- friend class DhcpClass;
- friend class DNSClient;
- };
-
- const IPAddress INADDR_NONE(0,0,0,0);
-
-
- #endif
- #endif
|