examples: Add common linux component tapif_io

That can be used with linux target on lwip to pass packets from lwip to
linux host networking stack, e.g. routing the trafic to internet.
This commit is contained in:
David Cermak
2023-01-31 08:29:00 +01:00
parent 332e4902b4
commit 854e16feb3
12 changed files with 593 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* Common functions for protocol examples, to establish tap interface connection
* For linux target
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#pragma once
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Configure and connect, wait for IP
*
* @return ESP_OK on successful connection
*/
esp_err_t example_connect(void);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_err.h"
#include "esp_netif.h"
/**
* @brief Creates tapio layer as a driver interface to esp-netif
*
* @warning Implemented as singleton, can use only one tapio in the system!
*
* @return pointer to the tapio driver handle
*/
void *tapio_create(void);
/**
* @brief esp-netif driver I/O output path
*
* @param h Driver's handle
* @param buffer Data to output
* @param len Data size
* @return ESP_OK on success
*/
esp_err_t tapio_output(void *h, void *buffer, size_t len);