VSF Documented
esp_netif_defaults.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_defaults.h".
20 *
21 * Authored from ESP-IDF v5.x public API only. No code copied from the
22 * ESP-IDF source tree. The macros below synthesize inherent-config
23 * templates with sensible defaults so user code can write:
24 *
25 * esp_netif_inherent_config_t base = ESP_NETIF_INHERENT_DEFAULT_ETH();
26 * esp_netif_config_t cfg = { .base = &base };
27 * esp_netif_t *eth = esp_netif_new(&cfg);
28 */
29
30#ifndef __VSF_ESPIDF_ESP_NETIF_DEFAULTS_H__
31#define __VSF_ESPIDF_ESP_NETIF_DEFAULTS_H__
32
33#include "esp_netif_types.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*============================ MACROS ========================================*/
40
41#define ESP_NETIF_INHERENT_DEFAULT_ETH() \
42 { \
43 .flags = (esp_netif_flags_t) \
44 (ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | \
45 ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
46 .mac = { 0 }, \
47 .ip_info = NULL, \
48 .get_ip_event = IP_EVENT_ETH_GOT_IP, \
49 .lost_ip_event = IP_EVENT_ETH_LOST_IP, \
50 .if_key = "ETH_DEF", \
51 .if_desc = "eth", \
52 .route_prio = 50, \
53 .bridge_info = 0, \
54 }
55
56#define ESP_NETIF_INHERENT_DEFAULT_WIFI_STA() \
57 { \
58 .flags = (esp_netif_flags_t) \
59 (ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | \
60 ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
61 .mac = { 0 }, \
62 .ip_info = NULL, \
63 .get_ip_event = IP_EVENT_STA_GOT_IP, \
64 .lost_ip_event = IP_EVENT_STA_LOST_IP, \
65 .if_key = "WIFI_STA_DEF", \
66 .if_desc = "sta", \
67 .route_prio = 100, \
68 .bridge_info = 0, \
69 }
70
71#define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \
72 { \
73 .flags = (esp_netif_flags_t) \
74 (ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \
75 .mac = { 0 }, \
76 .ip_info = NULL, \
77 .get_ip_event = 0, \
78 .lost_ip_event = 0, \
79 .if_key = "WIFI_AP_DEF", \
80 .if_desc = "ap", \
81 .route_prio = 10, \
82 .bridge_info = 0, \
83 }
84
85/* Helpers that wrap the inherent-config into a full esp_netif_config_t. */
86#define ESP_NETIF_DEFAULT_ETH_CFG(_base) \
87 { .base = (_base), .driver_config = NULL, .stack_config = NULL }
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif // __VSF_ESPIDF_ESP_NETIF_DEFAULTS_H__
Generated from commit: vsfteam/vsf@015f4d1