Skip to content

Commit

Permalink
Merge pull request #578 from david-cermak/fix/eppp_netif_config
Browse files Browse the repository at this point in the history
[eppp]: Make some common esp_netif options configurable
  • Loading branch information
david-cermak authored May 28, 2024
2 parents fcb6080 + d96f45a commit 39dfe26
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/eppp__build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Build
strategy:
matrix:
idf_ver: ["latest"]
idf_ver: ["latest", "release-v5.3"]
test: [ { app: host, path: "examples/host" }, { app: slave, path: "examples/slave" }, { app: test_app, path: "test/test_app" }]
runs-on: ubuntu-20.04
container: espressif/idf:${{ matrix.idf_ver }}
Expand All @@ -23,6 +23,6 @@ jobs:
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }}
shell: bash
run: |
${IDF_PATH}/install.sh --enable-pytest
. ${IDF_PATH}/export.sh
pip install idf-component-manager idf-build-apps --upgrade
python ./ci/build_apps.py ./components/eppp_link/${{matrix.test.path}} -vv --preserve-all
2 changes: 1 addition & 1 deletion components/eppp_link/.cz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ commitizen:
bump_message: 'bump(eppp): $current_version -> $new_version'
pre_bump_hooks: python ../../ci/changelog.py eppp_link
tag_format: eppp-v$version
version: 0.1.0
version: 0.1.1
version_files:
- idf_component.yml
6 changes: 6 additions & 0 deletions components/eppp_link/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.1.1](https://github.com/espressif/esp-protocols/commits/eppp-v0.1.1)

### Bug Fixes

- Make some common netif options configurable ([7829e8f](https://github.com/espressif/esp-protocols/commit/7829e8f))

## [0.1.0](https://github.com/espressif/esp-protocols/commits/eppp-v0.1.0)

### Features
Expand Down
22 changes: 17 additions & 5 deletions components/eppp_link/eppp_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static void netif_deinit(esp_netif_t *netif)
}
}

static esp_netif_t *netif_init(eppp_type_t role)
static esp_netif_t *netif_init(eppp_type_t role, eppp_config_t *eppp_config)
{
if (s_eppp_netif_count > 9) { // Limit to max 10 netifs, since we use "EPPPx" as the unique key (where x is 0-9)
ESP_LOGE(TAG, "Cannot create more than 10 instances");
Expand Down Expand Up @@ -217,10 +217,13 @@ static esp_netif_t *netif_init(eppp_type_t role)
char if_key[] = "EPPP0"; // netif key needs to be unique
if_key[sizeof(if_key) - 2 /* 2 = two chars before the terminator */ ] += s_eppp_netif_count++;
base_netif_cfg.if_key = if_key;
if (role == EPPP_CLIENT) {
base_netif_cfg.if_desc = "pppos_client";
if (eppp_config->ppp.netif_description) {
base_netif_cfg.if_desc = eppp_config->ppp.netif_description;
} else {
base_netif_cfg.if_desc = "pppos_server";
base_netif_cfg.if_desc = role == EPPP_CLIENT ? "pppos_client" : "pppos_server";
}
if (eppp_config->ppp.netif_prio) {
base_netif_cfg.route_prio = eppp_config->ppp.netif_prio;
}
esp_netif_config_t netif_ppp_config = { .base = &base_netif_cfg,
.driver = ppp_driver_cfg,
Expand Down Expand Up @@ -703,7 +706,12 @@ void eppp_deinit(esp_netif_t *netif)

esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
{
esp_netif_t *netif = netif_init(role);
if (config == NULL || (role != EPPP_SERVER && role != EPPP_CLIENT)) {
ESP_LOGE(TAG, "Invalid configuration or role");
return NULL;
}

esp_netif_t *netif = netif_init(role, config);
if (!netif) {
ESP_LOGE(TAG, "Failed to initialize PPP netif");
remove_handlers();
Expand All @@ -730,6 +738,10 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)

esp_netif_t *eppp_open(eppp_type_t role, eppp_config_t *config, int connect_timeout_ms)
{
if (config == NULL || (role != EPPP_SERVER && role != EPPP_CLIENT)) {
ESP_LOGE(TAG, "Invalid configuration or role");
return NULL;
}
#if CONFIG_EPPP_LINK_DEVICE_UART
if (config->transport != EPPP_TRANSPORT_UART) {
ESP_LOGE(TAG, "Invalid transport: UART device must be enabled in Kconfig");
Expand Down
2 changes: 1 addition & 1 deletion components/eppp_link/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 0.1.0
version: 0.1.1
url: https://github.com/espressif/esp-protocols/tree/master/components/eppp_link
description: The component provides a general purpose PPP connectivity, typically used as WiFi-PPP router
dependencies:
Expand Down
4 changes: 4 additions & 0 deletions components/eppp_link/include/eppp_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
. ppp = { \
.our_ip4_addr = { .addr = our_ip }, \
.their_ip4_addr = { .addr = their_ip }, \
.netif_prio = 0, \
.netif_description = NULL, \
} \
}

Expand Down Expand Up @@ -88,6 +90,8 @@ typedef struct eppp_config_t {
struct eppp_config_pppos_s {
esp_ip4_addr_t our_ip4_addr;
esp_ip4_addr_t their_ip4_addr;
int netif_prio;
const char *netif_description;
} ppp;

} eppp_config_t;
Expand Down

0 comments on commit 39dfe26

Please sign in to comment.