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
12
namespace
idfxx::netif::detail
{
13
14
inline
esp_netif_ip_info_t
to_native
(
const
net::ip4_info
& info) {
15
return
{
16
.ip = {.addr = info.ip.addr()},
17
.netmask = {.addr = info.netmask.addr()},
18
.gw = {.addr = info.gateway.addr()},
19
};
20
}
21
22
inline
net::ip4_info
ip4_from_native
(
const
esp_netif_ip_info_t
&
native
) {
23
return
{
24
.
ip
=
net::ip4_addr
(
native
.ip.addr),
25
.netmask =
net::ip4_addr
(
native
.netmask.addr),
26
.gateway =
net::ip4_addr
(
native
.gw.addr),
27
};
28
}
29
30
inline
net::ip6_addr
ip6_from_native
(
const
esp_ip6_addr_t
&
native
) {
31
return
net::ip6_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
idfxx::net::ip4_addr
IPv4 address value type.
Definition
net.hpp:40
idfxx::net::ip6_addr
IPv6 address value type.
Definition
net.hpp:121
idfxx::netif::detail
Definition
conversions.hpp:12
idfxx::netif::detail::ip6_from_native
net::ip6_addr ip6_from_native(const esp_ip6_addr_t &native)
Definition
conversions.hpp:30
idfxx::netif::detail::ip4_from_native
net::ip4_info ip4_from_native(const esp_netif_ip_info_t &native)
Definition
conversions.hpp:22
idfxx::netif::detail::to_native
esp_netif_ip_info_t to_native(const net::ip4_info &info)
Definition
conversions.hpp:14
idfxx::result
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition
error.hpp:120
idfxx::net::ip4_info
IPv4 network interface information.
Definition
net.hpp:197
idfxx::net::ip4_info::ip
ip4_addr ip
Definition
net.hpp:198
idfxx_netif
src
conversions.hpp
Generated by
1.9.8