VSF Documented
esp_netif_types.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * Clean-room re-implementation of ESP-IDF public API "esp_netif_types.h".
20 *
21 * Authored from ESP-IDF v5.x public API only. No code copied from the
22 * ESP-IDF source tree. Layouts and enum values are kept compatible with
23 * the upstream contract so that user code can be dropped in as-is.
24 */
25
26#ifndef __VSF_ESPIDF_ESP_NETIF_TYPES_H__
27#define __VSF_ESPIDF_ESP_NETIF_TYPES_H__
28
29#include <stdint.h>
30#include <stdbool.h>
31#include <stddef.h>
32
33#include "esp_err.h"
34#include "esp_event_base.h"
35#include "esp_netif_ip_addr.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/*============================ TYPES =========================================*/
42
43/* Opaque per-interface handle. The concrete layout lives in the port. */
45
46/* I/O driver handle passed to esp_netif_attach(). The port casts this to
47 * an esp_netif_driver_base_t * and, if post_attach is set, invokes it so
48 * the driver can call esp_netif_set_driver_config(). */
50
51/* IPv4 configuration snapshot. All fields in network byte order. */
52typedef struct {
57
58/* IPv6 configuration snapshot. */
59typedef struct {
62
63/* DNS server record. */
64typedef struct {
67
68/* Which DNS slot to read or write. */
69typedef enum {
75
76/* DHCP client / server state. */
77typedef enum {
83
84/* Bitmask of per-interface feature flags (esp_netif_inherent_config_t). */
85typedef enum {
95
96/* Initial L3 configuration applied when the interface is created. */
103 const char * if_key;
104 const char * if_desc;
108
109/* I/O driver contract passed back through esp_netif_driver_base_t::post_attach.
110 * transmit / driver_free_rx_buffer are invoked by esp_netif when the stack
111 * wants to send a frame or release a received buffer. */
114 esp_err_t (*transmit)(void *h, void *buffer, size_t len);
115 esp_err_t (*transmit_wrap)(void *h, void *buffer, size_t len, void *netstack_buf);
116 void (*driver_free_rx_buffer)(void *h, void *buffer);
118
119/* Driver-side base object. Users typedef their own struct with this as the
120 * first member so esp_netif_attach() can downcast and call post_attach. */
121typedef struct esp_netif_driver_base {
125
126/* Layered config accepted by esp_netif_new(). stack_config and driver_config
127 * are optional; a zero-filled struct is enough when the port supplies its
128 * own defaults (see esp_netif_defaults.h). */
129typedef struct esp_netif_config {
131 const void *driver_config;
132 const void *stack_config;
134
135/* --- IP_EVENT --------------------------------------------------------- */
136
137/* Event ids dispatched through the process-wide default event loop on the
138 * IP_EVENT base. Values match the ESP-IDF v5.x public contract. */
139typedef enum {
148} ip_event_t;
149
150/* Payload dispatched with IP_EVENT_STA_GOT_IP / IP_EVENT_ETH_GOT_IP. */
151typedef struct {
156
157/* Payload dispatched with IP_EVENT_GOT_IP6. */
158typedef struct {
163
164/* Payload dispatched with IP_EVENT_AP_STAIPASSIGNED. */
165typedef struct {
168 uint8_t mac[6];
170
171/*============================ GLOBALS =======================================*/
172
173/* Event base for all ip_event_t values. Defined in esp_netif_port.c. */
175
176#ifdef __cplusplus
177}
178#endif
179
180#endif // __VSF_ESPIDF_ESP_NETIF_TYPES_H__
int esp_err_t
Definition esp_err.h:41
#define ESP_EVENT_DECLARE_BASE(id)
Definition esp_event_base.h:65
struct esp_netif_config esp_netif_config_t
ip_event_t
Definition esp_netif_types.h:139
@ IP_EVENT_PPP_GOT_IP
Definition esp_netif_types.h:146
@ IP_EVENT_STA_LOST_IP
Definition esp_netif_types.h:141
@ IP_EVENT_STA_GOT_IP
Definition esp_netif_types.h:140
@ IP_EVENT_PPP_LOST_IP
Definition esp_netif_types.h:147
@ IP_EVENT_ETH_LOST_IP
Definition esp_netif_types.h:145
@ IP_EVENT_ETH_GOT_IP
Definition esp_netif_types.h:144
@ IP_EVENT_GOT_IP6
Definition esp_netif_types.h:143
@ IP_EVENT_AP_STAIPASSIGNED
Definition esp_netif_types.h:142
struct esp_netif_driver_ifconfig esp_netif_driver_ifconfig_t
struct esp_netif_inherent_config esp_netif_inherent_config_t
esp_netif_flags_t
Definition esp_netif_types.h:85
@ ESP_NETIF_FLAG_MLDV6_REPORT
Definition esp_netif_types.h:93
@ ESP_NETIF_DHCP_SERVER
Definition esp_netif_types.h:87
@ ESP_NETIF_DHCP_CLIENT
Definition esp_netif_types.h:86
@ ESP_NETIF_FLAG_EVENT_IP_MODIFIED
Definition esp_netif_types.h:90
@ ESP_NETIF_FLAG_IS_BRIDGE
Definition esp_netif_types.h:92
@ ESP_NETIF_FLAG_GARP
Definition esp_netif_types.h:89
@ ESP_NETIF_FLAG_IS_PPP
Definition esp_netif_types.h:91
@ ESP_NETIF_FLAG_AUTOUP
Definition esp_netif_types.h:88
esp_netif_dns_type_t
Definition esp_netif_types.h:69
@ ESP_NETIF_DNS_BACKUP
Definition esp_netif_types.h:71
@ ESP_NETIF_DNS_MAIN
Definition esp_netif_types.h:70
@ ESP_NETIF_DNS_MAX
Definition esp_netif_types.h:73
@ ESP_NETIF_DNS_FALLBACK
Definition esp_netif_types.h:72
esp_netif_dhcp_status_t
Definition esp_netif_types.h:77
@ ESP_NETIF_DHCP_STARTED
Definition esp_netif_types.h:79
@ ESP_NETIF_DHCP_INIT
Definition esp_netif_types.h:78
@ ESP_NETIF_DHCP_STATUS_MAX
Definition esp_netif_types.h:81
@ ESP_NETIF_DHCP_STOPPED
Definition esp_netif_types.h:80
void * esp_netif_iodriver_handle
Definition esp_netif_types.h:49
struct esp_netif_driver_base esp_netif_driver_base_t
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition esp_netif_ip_addr.h:39
Definition esp_netif_ip_addr.h:45
Definition esp_netif_ip_addr.h:52
Definition esp_netif_types.h:129
const void * driver_config
Definition esp_netif_types.h:131
const esp_netif_inherent_config_t * base
Definition esp_netif_types.h:130
const void * stack_config
Definition esp_netif_types.h:132
Definition esp_netif_types.h:64
esp_ip_addr_t ip
Definition esp_netif_types.h:65
Definition esp_netif_types.h:121
esp_err_t(* post_attach)(esp_netif_t *netif, esp_netif_iodriver_handle h)
Definition esp_netif_types.h:122
esp_netif_t * netif
Definition esp_netif_types.h:123
Definition esp_netif_types.h:112
void(* driver_free_rx_buffer)(void *h, void *buffer)
Definition esp_netif_types.h:116
esp_err_t(* transmit)(void *h, void *buffer, size_t len)
Definition esp_netif_types.h:114
esp_netif_iodriver_handle handle
Definition esp_netif_types.h:113
esp_err_t(* transmit_wrap)(void *h, void *buffer, size_t len, void *netstack_buf)
Definition esp_netif_types.h:115
Definition esp_netif_types.h:97
const esp_netif_ip_info_t * ip_info
Definition esp_netif_types.h:100
const char * if_key
Definition esp_netif_types.h:103
esp_netif_flags_t flags
Definition esp_netif_types.h:98
int route_prio
Definition esp_netif_types.h:105
uint8_t mac[6]
Definition esp_netif_types.h:99
const char * if_desc
Definition esp_netif_types.h:104
uint32_t get_ip_event
Definition esp_netif_types.h:101
uint32_t bridge_info
Definition esp_netif_types.h:106
uint32_t lost_ip_event
Definition esp_netif_types.h:102
Definition esp_netif_types.h:59
esp_ip6_addr_t ip
Definition esp_netif_types.h:60
Definition esp_netif_types.h:52
esp_ip4_addr_t ip
Definition esp_netif_types.h:53
esp_ip4_addr_t gw
Definition esp_netif_types.h:55
esp_ip4_addr_t netmask
Definition esp_netif_types.h:54
Definition esp_netif_port.c:80
Definition esp_netif_types.h:165
esp_ip4_addr_t ip
Definition esp_netif_types.h:167
esp_netif_t * esp_netif
Definition esp_netif_types.h:166
Definition esp_netif_types.h:158
esp_netif_t * esp_netif
Definition esp_netif_types.h:159
int ip_index
Definition esp_netif_types.h:161
esp_netif_ip6_info_t ip6_info
Definition esp_netif_types.h:160
Definition esp_netif_types.h:151
esp_netif_ip_info_t ip_info
Definition esp_netif_types.h:153
bool ip_changed
Definition esp_netif_types.h:154
esp_netif_t * esp_netif
Definition esp_netif_types.h:152
Generated from commit: vsfteam/vsf@015f4d1