@@ -157,7 +157,7 @@ static void netif_deinit(esp_netif_t *netif)
157
157
}
158
158
}
159
159
160
- static esp_netif_t * netif_init (eppp_type_t role )
160
+ static esp_netif_t * netif_init (eppp_type_t role , eppp_config_t * eppp_config )
161
161
{
162
162
if (s_eppp_netif_count > 9 ) { // Limit to max 10 netifs, since we use "EPPPx" as the unique key (where x is 0-9)
163
163
ESP_LOGE (TAG , "Cannot create more than 10 instances" );
@@ -217,10 +217,13 @@ static esp_netif_t *netif_init(eppp_type_t role)
217
217
char if_key [] = "EPPP0" ; // netif key needs to be unique
218
218
if_key [sizeof (if_key ) - 2 /* 2 = two chars before the terminator */ ] += s_eppp_netif_count ++ ;
219
219
base_netif_cfg .if_key = if_key ;
220
- if (role == EPPP_CLIENT ) {
221
- base_netif_cfg .if_desc = "pppos_client" ;
220
+ if (eppp_config -> ppp . netif_description ) {
221
+ base_netif_cfg .if_desc = eppp_config -> ppp . netif_description ;
222
222
} else {
223
- base_netif_cfg .if_desc = "pppos_server" ;
223
+ base_netif_cfg .if_desc = role == EPPP_CLIENT ? "pppos_client" : "pppos_server" ;
224
+ }
225
+ if (eppp_config -> ppp .netif_prio ) {
226
+ base_netif_cfg .route_prio = eppp_config -> ppp .netif_prio ;
224
227
}
225
228
esp_netif_config_t netif_ppp_config = { .base = & base_netif_cfg ,
226
229
.driver = ppp_driver_cfg ,
@@ -703,7 +706,12 @@ void eppp_deinit(esp_netif_t *netif)
703
706
704
707
esp_netif_t * eppp_init (eppp_type_t role , eppp_config_t * config )
705
708
{
706
- esp_netif_t * netif = netif_init (role );
709
+ if (config == NULL || (role != EPPP_SERVER && role != EPPP_CLIENT )) {
710
+ ESP_LOGE (TAG , "Invalid configuration or role" );
711
+ return NULL ;
712
+ }
713
+
714
+ esp_netif_t * netif = netif_init (role , config );
707
715
if (!netif ) {
708
716
ESP_LOGE (TAG , "Failed to initialize PPP netif" );
709
717
remove_handlers ();
@@ -730,6 +738,10 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
730
738
731
739
esp_netif_t * eppp_open (eppp_type_t role , eppp_config_t * config , int connect_timeout_ms )
732
740
{
741
+ if (config == NULL || (role != EPPP_SERVER && role != EPPP_CLIENT )) {
742
+ ESP_LOGE (TAG , "Invalid configuration or role" );
743
+ return NULL ;
744
+ }
733
745
#if CONFIG_EPPP_LINK_DEVICE_UART
734
746
if (config -> transport != EPPP_TRANSPORT_UART ) {
735
747
ESP_LOGE (TAG , "Invalid transport: UART device must be enabled in Kconfig" );
0 commit comments