/*IPAddress.h - Base class that provides IPAddressCopyright (c) 2011 Adrian McEwen. All right reserved.This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*/#ifndef IPAddress_h#define IPAddress_h#include <stdint.h>#include "Printable.h"#include "WString.h"// A class to make it easier to handle and pass around IP addressesclass IPAddress : public Printable {private:union {uint8_t bytes[4]; // IPv4 addressuint32_t dword;} _address;// Access the raw byte array containing the address. Because this returns a pointer// to the internal structure rather than a copy of the address this function should only// be used when you know that the usage of the returned uint8_t* will be transient and not// stored.uint8_t* raw_address() { return _address.bytes; };public:// ConstructorsIPAddress();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()); }// Overloaded cast operator to allow IPAddress objects to be used where a pointer// to a four-byte uint8_t array is expectedoperator uint32_t() const { return _address.dword; };bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; };bool operator==(const uint8_t* addr) const;// Overloaded index operator to allow getting and setting individual octets of the addressuint8_t operator[](int index) const { return _address.bytes[index]; };uint8_t& operator[](int index) { return _address.bytes[index]; };// Overloaded copy operators to allow initialisation of IPAddress objects from other typesIPAddress& 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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. Open source ecosystem
2. Collaboration, People, Software
3. Evaluation model