mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-21 23:56:59 +08:00
PPP, added PPP notify phase support
PPP notify phase support, using compile-time PPP_NOTIFY_PHASE macro.
This can be used for example to set a LED pattern depending on the
current phase of the PPP session.
Callback example:
static void ppp_notify_phase_cb(ppp_pcb *pcb, u8_t phase, void *ctx) {
switch(phase) {
case PPP_PHASE_DEAD: /* Kept off */
case PPP_PHASE_MASTER:
/* LED Off */
break;
case PPP_PHASE_INITIALIZE: /* Session opened */
/* LED FastBlink */
break;
case PPP_PHASE_RUNNING: /* Session running */
/* LED On */
break;
default:
/* LED SlowBlink */
}
}
This commit is contained in:
@@ -61,6 +61,23 @@
|
||||
#define PPP_HDRLEN 4 /* octets for standard ppp header */
|
||||
#define PPP_FCSLEN 2 /* octets for FCS */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PPP_PHASE_DEAD 0
|
||||
#define PPP_PHASE_INITIALIZE 1
|
||||
#define PPP_PHASE_SERIALCONN 2
|
||||
#define PPP_PHASE_DORMANT 3
|
||||
#define PPP_PHASE_ESTABLISH 4
|
||||
#define PPP_PHASE_AUTHENTICATE 5
|
||||
#define PPP_PHASE_CALLBACK 6
|
||||
#define PPP_PHASE_NETWORK 7
|
||||
#define PPP_PHASE_RUNNING 8
|
||||
#define PPP_PHASE_TERMINATE 9
|
||||
#define PPP_PHASE_DISCONNECT 10
|
||||
#define PPP_PHASE_HOLDOFF 11
|
||||
#define PPP_PHASE_MASTER 12
|
||||
|
||||
/* Error codes. */
|
||||
#define PPPERR_NONE 0 /* No error. */
|
||||
#define PPPERR_PARAM 1 /* Invalid parameter. */
|
||||
@@ -299,7 +316,10 @@ struct ppp_pcb_s {
|
||||
pppol2tp_pcb *l2tp_pcb;
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
void (*link_status_cb)(ppp_pcb *pcb, int err_code, void *ctx); /* Status change callback */
|
||||
void *link_status_ctx; /* Status change callback optional pointer */
|
||||
#if PPP_NOTIFY_PHASE
|
||||
void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase, void *ctx); /* Notify phase callback */
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
void *ctx_cb; /* Callbacks optional pointer */
|
||||
struct netif netif; /* PPP interface */
|
||||
|
||||
/* -- below are data that will be cleared between two sessions */
|
||||
@@ -451,6 +471,17 @@ void ppp_set_default(ppp_pcb *pcb);
|
||||
|
||||
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd);
|
||||
|
||||
#if PPP_NOTIFY_PHASE
|
||||
/*
|
||||
* Set a PPP notify phase callback.
|
||||
*
|
||||
* This can be used for example to set a LED pattern depending on the
|
||||
* current phase of the PPP session.
|
||||
*/
|
||||
typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx);
|
||||
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
|
||||
/* Link status callback function prototype */
|
||||
typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
|
||||
|
||||
@@ -463,7 +494,7 @@ typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
|
||||
*
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
int ppp_over_serial_create(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx);
|
||||
int ppp_over_serial_create(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
@@ -473,7 +504,7 @@ int ppp_over_serial_create(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
int ppp_over_ethernet_create(ppp_pcb *pcb, struct netif *ethif, const char *service_name, const char *concentrator_name,
|
||||
ppp_link_status_cb_fn link_status_cb, void *link_status_ctx);
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
#if PPPOL2TP_SUPPORT
|
||||
@@ -482,7 +513,7 @@ int ppp_over_ethernet_create(ppp_pcb *pcb, struct netif *ethif, const char *serv
|
||||
*/
|
||||
int ppp_over_l2tp_create(ppp_pcb *pcb, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
|
||||
u8_t *secret, u8_t secret_len,
|
||||
ppp_link_status_cb_fn link_status_cb, void *link_status_ctx);
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
|
||||
/*
|
||||
|
||||
@@ -346,23 +346,6 @@ extern const struct protent* const protocols[];
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PHASE_DEAD 0
|
||||
#define PHASE_INITIALIZE 1
|
||||
#define PHASE_SERIALCONN 2
|
||||
#define PHASE_DORMANT 3
|
||||
#define PHASE_ESTABLISH 4
|
||||
#define PHASE_AUTHENTICATE 5
|
||||
#define PHASE_CALLBACK 6
|
||||
#define PHASE_NETWORK 7
|
||||
#define PHASE_RUNNING 8
|
||||
#define PHASE_TERMINATE 9
|
||||
#define PHASE_DISCONNECT 10
|
||||
#define PHASE_HOLDOFF 11
|
||||
#define PHASE_MASTER 12
|
||||
|
||||
/* Supported CHAP protocols */
|
||||
#if CHAP_SUPPORT
|
||||
#include "chap-new.h"
|
||||
|
||||
Reference in New Issue
Block a user