mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
esp_netif: Extend PPP netif API to control connection failure
This commit is contained in:
parent
ef75b5a188
commit
2f6c60573e
@ -38,6 +38,11 @@ typedef struct esp_netif_ppp_config {
|
||||
*/
|
||||
#define NETIF_PP_PHASE_OFFSET (0x100)
|
||||
|
||||
/** @brief event id offset for internal errors
|
||||
*
|
||||
*/
|
||||
#define NETIF_PPP_INTERNAL_ERR_OFFSET (0x200)
|
||||
|
||||
/** @brief event ids for different PPP related events
|
||||
*
|
||||
*/
|
||||
@ -68,6 +73,7 @@ typedef enum {
|
||||
NETIF_PPP_PHASE_RUNNING = NETIF_PP_PHASE_OFFSET + 10,
|
||||
NETIF_PPP_PHASE_TERMINATE = NETIF_PP_PHASE_OFFSET + 11,
|
||||
NETIF_PPP_PHASE_DISCONNECT = NETIF_PP_PHASE_OFFSET + 12,
|
||||
NETIF_PPP_CONNECT_FAILED = NETIF_PPP_INTERNAL_ERR_OFFSET + 0,
|
||||
} esp_netif_ppp_status_event_t;
|
||||
|
||||
/** @brief definitions of different authorisation types
|
||||
@ -89,7 +95,8 @@ typedef enum {
|
||||
* @param[in] user User name
|
||||
* @param[in] passwd Password
|
||||
*
|
||||
* @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP
|
||||
* @return ESP_OK on success,
|
||||
* ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null
|
||||
*/
|
||||
esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t authtype, const char *user, const char *passwd);
|
||||
|
||||
@ -98,10 +105,20 @@ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t autht
|
||||
* @param[in] esp_netif Handle to esp-netif instance
|
||||
* @param[in] config Pointer to PPP netif configuration structure
|
||||
*
|
||||
* @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not PPP
|
||||
* @return ESP_OK on success,
|
||||
* ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null
|
||||
*/
|
||||
esp_err_t esp_netif_ppp_set_params(esp_netif_t *netif, const esp_netif_ppp_config_t *config);
|
||||
|
||||
/** @brief Gets parameters configured in the supplied esp-netif.
|
||||
*
|
||||
* @param[in] esp_netif Handle to esp-netif instance
|
||||
* @param[out] config Pointer to PPP netif configuration structure
|
||||
*
|
||||
* @return ESP_OK on success,
|
||||
* ESP_ERR_ESP_NETIF_INVALID_PARAMS if the supplied netif is not of PPP type, or netif is null
|
||||
*/
|
||||
esp_err_t esp_netif_ppp_get_params(esp_netif_t *netif, esp_netif_ppp_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -786,7 +786,7 @@ esp_err_t esp_netif_start(esp_netif_t *esp_netif)
|
||||
if (_IS_NETIF_POINT2POINT_TYPE(esp_netif, PPP_LWIP_NETIF)) {
|
||||
#if CONFIG_PPP_SUPPORT
|
||||
// No need to start PPP interface in lwip thread
|
||||
esp_err_t ret = esp_netif_start_ppp(esp_netif->related_data);
|
||||
esp_err_t ret = esp_netif_start_ppp(esp_netif);
|
||||
if (ret == ESP_OK) {
|
||||
esp_netif_update_default_netif(esp_netif, ESP_NETIF_STARTED);
|
||||
}
|
||||
|
@ -296,8 +296,9 @@ netif_related_data_t * esp_netif_new_ppp(esp_netif_t *esp_netif, const esp_netif
|
||||
return (netif_related_data_t *)ppp_obj;
|
||||
}
|
||||
|
||||
esp_err_t esp_netif_start_ppp(netif_related_data_t *netif_related)
|
||||
esp_err_t esp_netif_start_ppp(esp_netif_t *esp_netif)
|
||||
{
|
||||
netif_related_data_t *netif_related = esp_netif->related_data;
|
||||
lwip_peer2peer_ctx_t *ppp_ctx = (lwip_peer2peer_ctx_t *)netif_related;
|
||||
assert(ppp_ctx->base.netif_type == PPP_LWIP_NETIF);
|
||||
|
||||
@ -305,6 +306,9 @@ esp_err_t esp_netif_start_ppp(netif_related_data_t *netif_related)
|
||||
esp_err_t err = pppapi_connect(ppp_ctx->ppp, 0);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: PPP connection cannot be started", __func__);
|
||||
if (ppp_ctx->ppp_error_event_enabled) {
|
||||
esp_event_post(NETIF_PPP_STATUS, NETIF_PPP_CONNECT_FAILED, esp_netif, sizeof(esp_netif), 0);
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
@ -349,4 +353,12 @@ esp_err_t esp_netif_ppp_set_params(esp_netif_t *netif, const esp_netif_ppp_confi
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_netif_ppp_get_params(esp_netif_t *netif, esp_netif_ppp_config_t *config)
|
||||
{
|
||||
struct lwip_peer2peer_ctx *obj = (struct lwip_peer2peer_ctx *)netif->related_data;
|
||||
config->ppp_phase_event_enabled = obj->ppp_phase_event_enabled;
|
||||
config->ppp_error_event_enabled = obj->ppp_error_event_enabled;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP_NETIF_TCPIP_LWIP */
|
||||
|
@ -32,12 +32,12 @@ netif_related_data_t * esp_netif_new_ppp(esp_netif_t *esp_netif, const esp_netif
|
||||
/**
|
||||
* @brief Creates new PPP related structure
|
||||
*
|
||||
* @param[in] netif_related pointer to internal ppp context instance
|
||||
* @param[in] esp_netif pointer esp-netif instance
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_netif_start_ppp(netif_related_data_t *netif_related);
|
||||
esp_err_t esp_netif_start_ppp(esp_netif_t *esp_netif);
|
||||
|
||||
/**
|
||||
* @brief Data path API to input incoming packets to PPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user