mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-04 21:44:38 +08:00
PPP, using err_t return code instead of PPPERR_
Standardised PPP API to follow lwIP already used return codes. PPPERR_ are now used only on link status callback.
This commit is contained in:
parent
0a761d238a
commit
6b4db944dd
@ -249,7 +249,7 @@ pppapi_do_ppp_open(struct pppapi_msg_msg *msg)
|
|||||||
* Call ppp_open() in a thread-safe way by running that function inside the
|
* Call ppp_open() in a thread-safe way by running that function inside the
|
||||||
* tcpip_thread context.
|
* tcpip_thread context.
|
||||||
*/
|
*/
|
||||||
int
|
err_t
|
||||||
pppapi_open(ppp_pcb *pcb, u16_t holdoff)
|
pppapi_open(ppp_pcb *pcb, u16_t holdoff)
|
||||||
{
|
{
|
||||||
struct pppapi_msg msg;
|
struct pppapi_msg msg;
|
||||||
@ -275,7 +275,7 @@ pppapi_do_ppp_close(struct pppapi_msg_msg *msg)
|
|||||||
* Call ppp_close() in a thread-safe way by running that function inside the
|
* Call ppp_close() in a thread-safe way by running that function inside the
|
||||||
* tcpip_thread context.
|
* tcpip_thread context.
|
||||||
*/
|
*/
|
||||||
int
|
err_t
|
||||||
pppapi_close(ppp_pcb *pcb)
|
pppapi_close(ppp_pcb *pcb)
|
||||||
{
|
{
|
||||||
struct pppapi_msg msg;
|
struct pppapi_msg msg;
|
||||||
@ -324,7 +324,7 @@ pppapi_do_ppp_free(struct pppapi_msg_msg *msg)
|
|||||||
* Call ppp_free() in a thread-safe way by running that function inside the
|
* Call ppp_free() in a thread-safe way by running that function inside the
|
||||||
* tcpip_thread context.
|
* tcpip_thread context.
|
||||||
*/
|
*/
|
||||||
int
|
err_t
|
||||||
pppapi_free(ppp_pcb *pcb)
|
pppapi_free(ppp_pcb *pcb)
|
||||||
{
|
{
|
||||||
struct pppapi_msg msg;
|
struct pppapi_msg msg;
|
||||||
|
@ -44,7 +44,7 @@ struct pppapi_msg_msg {
|
|||||||
#if !LWIP_TCPIP_CORE_LOCKING
|
#if !LWIP_TCPIP_CORE_LOCKING
|
||||||
sys_sem_t sem;
|
sys_sem_t sem;
|
||||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||||
int err;
|
err_t err;
|
||||||
ppp_pcb *ppp;
|
ppp_pcb *ppp;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
@ -133,10 +133,10 @@ ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_add
|
|||||||
u8_t *secret, u8_t secret_len,
|
u8_t *secret, u8_t secret_len,
|
||||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||||
#endif /* PPPOL2TP_SUPPORT */
|
#endif /* PPPOL2TP_SUPPORT */
|
||||||
int pppapi_open(ppp_pcb *pcb, u16_t holdoff);
|
err_t pppapi_open(ppp_pcb *pcb, u16_t holdoff);
|
||||||
int pppapi_close(ppp_pcb *pcb);
|
err_t pppapi_close(ppp_pcb *pcb);
|
||||||
void pppapi_sighup(ppp_pcb *pcb);
|
void pppapi_sighup(ppp_pcb *pcb);
|
||||||
int pppapi_free(ppp_pcb *pcb);
|
err_t pppapi_free(ppp_pcb *pcb);
|
||||||
err_t pppapi_ioctl(ppp_pcb *pcb, int cmd, void *arg);
|
err_t pppapi_ioctl(ppp_pcb *pcb, int cmd, void *arg);
|
||||||
#if LWIP_NETIF_STATUS_CALLBACK
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
void pppapi_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback);
|
void pppapi_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback);
|
||||||
|
@ -464,14 +464,14 @@ void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_p
|
|||||||
* Holdoff is the time to wait (in seconds) before initiating
|
* Holdoff is the time to wait (in seconds) before initiating
|
||||||
* the connection.
|
* the connection.
|
||||||
*/
|
*/
|
||||||
int ppp_open(ppp_pcb *pcb, u16_t holdoff);
|
err_t ppp_open(ppp_pcb *pcb, u16_t holdoff);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initiate the end of a PPP connection.
|
* Initiate the end of a PPP connection.
|
||||||
* Any outstanding packets in the queues are dropped.
|
* Any outstanding packets in the queues are dropped.
|
||||||
* Return 0 on success, an error code on failure.
|
* Return 0 on success, an error code on failure.
|
||||||
*/
|
*/
|
||||||
int ppp_close(ppp_pcb *pcb);
|
err_t ppp_close(ppp_pcb *pcb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Indicate to the PPP stack that the line has disconnected.
|
* Indicate to the PPP stack that the line has disconnected.
|
||||||
@ -488,7 +488,7 @@ void ppp_sighup(ppp_pcb *pcb);
|
|||||||
*
|
*
|
||||||
* Return 0 on success, an error code on failure.
|
* Return 0 on success, an error code on failure.
|
||||||
*/
|
*/
|
||||||
int ppp_free(ppp_pcb *pcb);
|
err_t ppp_free(ppp_pcb *pcb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get and set parameters for the given connection.
|
* Get and set parameters for the given connection.
|
||||||
|
@ -250,9 +250,9 @@ void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_p
|
|||||||
* Holdoff is the time to wait (in seconds) before initiating
|
* Holdoff is the time to wait (in seconds) before initiating
|
||||||
* the connection.
|
* the connection.
|
||||||
*/
|
*/
|
||||||
int ppp_open(ppp_pcb *pcb, u16_t holdoff) {
|
err_t ppp_open(ppp_pcb *pcb, u16_t holdoff) {
|
||||||
if (pcb->phase != PPP_PHASE_DEAD) {
|
if (pcb->phase != PPP_PHASE_DEAD) {
|
||||||
return PPPERR_PARAM;
|
return ERR_ALREADY;
|
||||||
}
|
}
|
||||||
|
|
||||||
PPPDEBUG(LOG_DEBUG, ("ppp_open() called, holdoff=%d\n", holdoff));
|
PPPDEBUG(LOG_DEBUG, ("ppp_open() called, holdoff=%d\n", holdoff));
|
||||||
@ -263,7 +263,7 @@ int ppp_open(ppp_pcb *pcb, u16_t holdoff) {
|
|||||||
|
|
||||||
new_phase(pcb, PPP_PHASE_HOLDOFF);
|
new_phase(pcb, PPP_PHASE_HOLDOFF);
|
||||||
sys_timeout((u32_t)(holdoff*1000), ppp_do_open, pcb);
|
sys_timeout((u32_t)(holdoff*1000), ppp_do_open, pcb);
|
||||||
return PPPERR_NONE;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -271,7 +271,7 @@ int ppp_open(ppp_pcb *pcb, u16_t holdoff) {
|
|||||||
* Any outstanding packets in the queues are dropped.
|
* Any outstanding packets in the queues are dropped.
|
||||||
* Return 0 on success, an error code on failure.
|
* Return 0 on success, an error code on failure.
|
||||||
*/
|
*/
|
||||||
int
|
err_t
|
||||||
ppp_close(ppp_pcb *pcb)
|
ppp_close(ppp_pcb *pcb)
|
||||||
{
|
{
|
||||||
pcb->err_code = PPPERR_USER;
|
pcb->err_code = PPPERR_USER;
|
||||||
@ -279,14 +279,14 @@ ppp_close(ppp_pcb *pcb)
|
|||||||
/* dead phase, nothing to do, call the status callback to be consistent */
|
/* dead phase, nothing to do, call the status callback to be consistent */
|
||||||
if (pcb->phase == PPP_PHASE_DEAD) {
|
if (pcb->phase == PPP_PHASE_DEAD) {
|
||||||
pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
|
pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
|
||||||
return PPPERR_NONE;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* holdoff phase, cancel the reconnection and call the status callback */
|
/* holdoff phase, cancel the reconnection and call the status callback */
|
||||||
if (pcb->phase == PPP_PHASE_HOLDOFF) {
|
if (pcb->phase == PPP_PHASE_HOLDOFF) {
|
||||||
sys_untimeout(ppp_do_open, pcb);
|
sys_untimeout(ppp_do_open, pcb);
|
||||||
pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
|
pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
|
||||||
return PPPERR_NONE;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
PPPDEBUG(LOG_DEBUG, ("ppp_close() called\n"));
|
PPPDEBUG(LOG_DEBUG, ("ppp_close() called\n"));
|
||||||
@ -296,7 +296,7 @@ ppp_close(ppp_pcb *pcb)
|
|||||||
/* LCP close request, this will leave us at PPP_PHASE_DEAD. */
|
/* LCP close request, this will leave us at PPP_PHASE_DEAD. */
|
||||||
lcp_close(pcb, "User request");
|
lcp_close(pcb, "User request");
|
||||||
|
|
||||||
return PPPERR_NONE;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called when carrier is lost on the PPP channel. */
|
/* This function is called when carrier is lost on the PPP channel. */
|
||||||
@ -319,10 +319,10 @@ ppp_sighup(ppp_pcb *pcb)
|
|||||||
*
|
*
|
||||||
* Return 0 on success, an error code on failure.
|
* Return 0 on success, an error code on failure.
|
||||||
*/
|
*/
|
||||||
int ppp_free(ppp_pcb *pcb) {
|
err_t ppp_free(ppp_pcb *pcb) {
|
||||||
int err;
|
int err;
|
||||||
if (pcb->phase != PPP_PHASE_DEAD) {
|
if (pcb->phase != PPP_PHASE_DEAD) {
|
||||||
return PPPERR_PARAM;
|
return ERR_CONN;
|
||||||
}
|
}
|
||||||
|
|
||||||
PPPDEBUG(LOG_DEBUG, ("ppp_free: unit %d\n", pcb->num));
|
PPPDEBUG(LOG_DEBUG, ("ppp_free: unit %d\n", pcb->num));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user