#pragma once // Minimal IPAddress for Arduino-AppleMIDI-Library on pico-sdk / lwIP. // Only implements what the vendored code actually uses. #include #include #include "lwip/ip_addr.h" #ifndef INADDR_NONE #define INADDR_NONE ((uint32_t)0xFFFFFFFFUL) #endif class IPAddress { public: IPAddress() : addr_(INADDR_NONE) {} IPAddress(uint32_t raw) : addr_(raw) {} IPAddress(uint8_t a, uint8_t b, uint8_t c, uint8_t d) : addr_((uint32_t)a | ((uint32_t)b << 8) | ((uint32_t)c << 16) | ((uint32_t)d << 24)) {} IPAddress(const ip_addr_t &lwip) : addr_(ip_addr_get_ip4_u32(&lwip)) {} operator uint32_t() const { return addr_; } bool operator==(const IPAddress &rhs) const { return addr_ == rhs.addr_; } bool operator!=(const IPAddress &rhs) const { return addr_ != rhs.addr_; } ip_addr_t toLwIP() const { ip_addr_t a; ip_addr_set_ip4_u32(&a, addr_); return a; } uint8_t operator[](int idx) const { return (addr_ >> (idx * 8)) & 0xFF; } private: uint32_t addr_; };