idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
conversions.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Chris Leishman
3
4#pragma once
5
6#include <idfxx/net>
7
8#include <array>
9#include <esp_netif_ip_addr.h>
10#include <esp_netif_types.h>
11
13
15 return {
16 .ip = {.addr = info.ip.addr()},
17 .netmask = {.addr = info.netmask.addr()},
18 .gw = {.addr = info.gateway.addr()},
19 };
20}
21
23 return {
24 .ip = net::ipv4_addr(native.ip.addr),
25 .netmask = net::ipv4_addr(native.netmask.addr),
26 .gateway = net::ipv4_addr(native.gw.addr),
27 };
28}
29
31 return net::ipv6_addr(
32 std::array<uint32_t, 4>{native.addr[0], native.addr[1], native.addr[2], native.addr[3]}, native.zone
33 );
34}
35
36} // namespace idfxx::netif::detail
IPv4 address value type.
Definition net.hpp:41
IPv6 address value type.
Definition net.hpp:132
esp_netif_ip_info_t to_native(const net::ipv4_info &info)
net::ipv6_addr ip6_from_native(const esp_ip6_addr_t &native)
net::ipv4_info ip4_from_native(const esp_netif_ip_info_t &native)
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120
IPv4 network interface information.
Definition net.hpp:227