mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-20 15:17:05 +08:00
PPP, CORE, now using const callbacks struct from lower level protocols
Saving some RAM by using callbacks struct in rodata for required callbacks called by PPP core to PPP low level protocols.
This commit is contained in:
@@ -303,19 +303,13 @@ struct ppp_addrs {
|
||||
/*
|
||||
* PPP interface control block.
|
||||
*/
|
||||
typedef int (*link_command_cb_fn)(void *pcb, u8_t command);
|
||||
typedef int (*link_write_cb_fn)(void *pcb, struct pbuf *p);
|
||||
typedef err_t (*link_netif_output_cb_fn)(void *pcb, struct pbuf *p, u_short protocol);
|
||||
|
||||
struct ppp_pcb_s {
|
||||
/* -- below are data that will NOT be cleared between two sessions */
|
||||
#if PPP_DEBUG
|
||||
u8_t num; /* Interface number - only useful for debugging */
|
||||
#endif /* PPP_DEBUG */
|
||||
ppp_settings settings;
|
||||
link_command_cb_fn link_command_cb;
|
||||
link_write_cb_fn link_write_cb;
|
||||
link_netif_output_cb_fn link_netif_output_cb;
|
||||
const struct link_callbacks *link_cb;
|
||||
void *link_ctx_cb;
|
||||
void (*link_status_cb)(ppp_pcb *pcb, int err_code, void *ctx); /* Status change callback */
|
||||
#if PPP_NOTIFY_PHASE
|
||||
|
||||
@@ -93,16 +93,6 @@
|
||||
*/
|
||||
#define PPP_LINK_ENABLED_NUMBER (!!PPPOS_SUPPORT+!!PPPOE_SUPPORT+!!PPPOL2TP_SUPPORT)
|
||||
|
||||
/*
|
||||
* Low-level links commands
|
||||
*/
|
||||
/* Start a connection (i.e. initiate discovery phase) */
|
||||
#define PPP_LINK_COMMAND_CONNECT 0
|
||||
/* End a connection (i.e. initiate disconnect phase) */
|
||||
#define PPP_LINK_COMMAND_DISCONNECT 1
|
||||
/* Free link connection */
|
||||
#define PPP_LINK_COMMAND_FREE 2
|
||||
|
||||
/*
|
||||
* Protocol field values.
|
||||
*/
|
||||
@@ -152,6 +142,23 @@
|
||||
#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* The following struct gives the addresses of procedures to call
|
||||
* for a particular lower link level protocol.
|
||||
*/
|
||||
struct link_callbacks {
|
||||
/* Start a connection (e.g. Initiate discovery phase) */
|
||||
err_t (*connect) (ppp_pcb *pcb, void *ctx);
|
||||
/* End a connection (i.e. initiate disconnect phase) */
|
||||
void (*disconnect) (ppp_pcb *pcb, void *ctx);
|
||||
/* Free lower protocol control block */
|
||||
err_t (*free) (ppp_pcb *pcb, void *ctx);
|
||||
/* Write a pbuf to a ppp link, only used from PPP functions to send PPP packets. */
|
||||
err_t (*write)(ppp_pcb *pcb, void *ctx, struct pbuf *p);
|
||||
/* Send a packet from lwIP core (IPv4 or IPv6) */
|
||||
err_t (*netif_output)(ppp_pcb *pcb, void *ctx, struct pbuf *p, u_short protocol);
|
||||
};
|
||||
|
||||
/*
|
||||
* What to do with network protocol (NP) packets.
|
||||
*/
|
||||
@@ -380,8 +387,8 @@ ppp_pcb *ppp_new(struct netif *pppif, ppp_link_status_cb_fn link_status_cb, void
|
||||
/* Set a PPP PCB to its initial state */
|
||||
void ppp_clear(ppp_pcb *pcb);
|
||||
|
||||
/* Set link callback function */
|
||||
void ppp_link_set_callbacks(ppp_pcb *pcb, link_command_cb_fn command, link_write_cb_fn write, link_netif_output_cb_fn netif_output, void *ctx);
|
||||
/* Set link callback functions */
|
||||
void ppp_link_set_callbacks(ppp_pcb *pcb, const struct link_callbacks *callbacks, void *ctx);
|
||||
|
||||
/* Initiate LCP open request */
|
||||
void ppp_start(ppp_pcb *pcb);
|
||||
|
||||
Reference in New Issue
Block a user