Skip to content

Commit 7a6cf0f

Browse files
committed
fix(eppp): Fix tun netif to (optionally) return errors
1 parent 318e41b commit 7a6cf0f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

components/eppp_link/eppp_netif_tun.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@
1717
#include "esp_check.h"
1818
#include "esp_idf_version.h"
1919

20+
#if defined(CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS)
21+
typedef esp_err_t esp_netif_recv_ret_t;
22+
#define ESP_NETIF_OPTIONAL_RETURN_CODE(expr) expr
23+
#else
24+
typedef void esp_netif_recv_ret_t;
25+
#define ESP_NETIF_OPTIONAL_RETURN_CODE(expr)
26+
#endif // CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS
27+
2028
static const char *TAG = "eppp_tun_netif";
2129

22-
static void tun_input(void *h, void *buffer, unsigned int len, void *eb)
30+
static esp_netif_recv_ret_t tun_input(void *h, void *buffer, unsigned int len, void *eb)
2331
{
2432
__attribute__((unused)) esp_err_t ret = ESP_OK;
2533
struct netif *netif = h;
@@ -31,11 +39,12 @@ static void tun_input(void *h, void *buffer, unsigned int len, void *eb)
3139
ESP_GOTO_ON_FALSE(pbuf_remove_header(p, SIZEOF_ETH_HDR) == 0, ESP_FAIL, err, TAG, "pbuf_remove_header failed");
3240
memcpy(p->payload, buffer, len);
3341
ESP_GOTO_ON_FALSE(netif->input(p, netif) == ERR_OK, ESP_FAIL, err, TAG, "failed to input packet to lwip");
34-
return;
42+
return ESP_NETIF_OPTIONAL_RETURN_CODE(ESP_OK);
3543
err:
3644
if (p) {
3745
pbuf_free(p);
3846
}
47+
return ESP_NETIF_OPTIONAL_RETURN_CODE(ret);
3948
}
4049

4150
static err_t tun_output(struct netif *netif, struct pbuf *p)

0 commit comments

Comments
 (0)