PPP, CORE, new callbacks, send_config, recv_config, vj_config

Removed some calls from PPP core to PPPoS low level protocols,
the const struct allows us to have more and more callbacks
without using more RAM.
This commit is contained in:
Sylvain Rochet 2015-02-19 23:47:10 +01:00
parent 985de035bc
commit b92fe3eecb
6 changed files with 49 additions and 46 deletions

View File

@ -157,6 +157,12 @@ struct link_callbacks {
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);
/* configure the transmit-side characteristics of the PPP interface */
void (*send_config)(ppp_pcb *pcb, void *ctx, u32_t accm);
/* confire the receive-side characteristics of the PPP interface */
void (*recv_config)(ppp_pcb *pcb, void *ctx, u32_t accm);
/* configure TCP header compression */
void (*vj_config)(ppp_pcb *pcb, void *ctx, int vjcomp, int cidcomp, int maxcid);
};
/*

View File

@ -102,10 +102,7 @@ void pppos_input(ppp_pcb *ppp, u_char* data, int len);
*
* You may use them if you REALLY know what you are doing.
*/
void pppos_accm_out_config(pppos_pcb *pppos, u32_t accm);
void pppos_accm_in_config(pppos_pcb *pppos, u32_t accm);
sio_fd_t pppos_get_fd(pppos_pcb *pppos);
void pppos_vjc_config(pppos_pcb *pppos, int vjcomp, int cidcomp, int maxcid);
int pppos_vjc_comp(pppos_pcb *pppos, struct pbuf *pb);
int pppos_vjc_uncomp(pppos_pcb *pppos, struct pbuf *pb);

View File

@ -872,11 +872,9 @@ int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) {
pcb->pcomp = pcomp;
pcb->accomp = accomp;
#if PPPOS_SUPPORT
pppos_accm_out_config((pppos_pcb*)pcb->link_ctx_cb, accm);
#else /* PPPOS_SUPPORT */
LWIP_UNUSED_ARG(accm);
#endif /* PPPOS_SUPPORT */
if (pcb->link_cb->send_config) {
pcb->link_cb->send_config(pcb, pcb->link_ctx_cb, accm);
}
PPPDEBUG(LOG_INFO, ("ppp_send_config[%d]\n", pcb->num) );
return 0;
@ -891,11 +889,9 @@ int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp) {
LWIP_UNUSED_ARG(pcomp);
LWIP_UNUSED_ARG(mru);
#if PPPOS_SUPPORT
pppos_accm_in_config((pppos_pcb*)pcb->link_ctx_cb, accm);
#else /* PPPOS_SUPPORT */
LWIP_UNUSED_ARG(accm);
#endif /* PPPOS_SUPPORT */
if (pcb->link_cb->recv_config) {
pcb->link_cb->recv_config(pcb, pcb->link_ctx_cb, accm);
}
PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]\n", pcb->num));
return 0;
@ -1128,14 +1124,9 @@ int cifproxyarp(ppp_pcb *pcb, u32_t his_adr) {
* sifvjcomp - config tcp header compression
*/
int sifvjcomp(ppp_pcb *pcb, int vjcomp, int cidcomp, int maxcid) {
#if VJ_SUPPORT
pppos_vjc_config((pppos_pcb*)pcb->link_ctx_cb, vjcomp, cidcomp, maxcid);
#else /* VJ_SUPPORT */
LWIP_UNUSED_ARG(pcb);
LWIP_UNUSED_ARG(vjcomp);
LWIP_UNUSED_ARG(cidcomp);
LWIP_UNUSED_ARG(maxcid);
#endif /* VJ_SUPPORT */
if (pcb->link_cb->vj_config) {
pcb->link_cb->vj_config(pcb, pcb->link_ctx_cb, vjcomp, cidcomp, maxcid);
}
return 0;
}

View File

@ -153,7 +153,10 @@ static const struct link_callbacks pppoe_callbacks = {
pppoe_disconnect,
pppoe_destroy,
pppoe_link_write_callback,
pppoe_link_netif_output_callback
pppoe_link_netif_output_callback,
NULL,
NULL,
NULL
};
/*

View File

@ -102,7 +102,10 @@ static const struct link_callbacks pppol2tp_callbacks = {
pppol2tp_disconnect,
pppol2tp_destroy,
pppol2tp_link_write_callback,
pppol2tp_link_netif_output_callback
pppol2tp_link_netif_output_callback,
NULL,
NULL,
NULL
};

View File

@ -87,6 +87,11 @@ static err_t pppos_link_netif_output_callback(ppp_pcb *ppp, void *ctx, struct pb
static err_t pppos_connect(ppp_pcb *ppp, void *ctx);
static void pppos_disconnect(ppp_pcb *ppp, void *ctx);
static err_t pppos_destroy(ppp_pcb *ppp, void *ctx);
static void pppos_send_config(ppp_pcb *ppp, void *ctx, u32_t accm);
static void pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm);
#if VJ_SUPPORT
static void pppos_vjc_config(ppp_pcb *ppp, void *ctx, int vjcomp, int cidcomp, int maxcid);
#endif /* VJ_SUPPORT */
/* Prototypes for procedures local to this file. */
#if PPP_INPROC_MULTITHREADED
@ -103,7 +108,14 @@ static const struct link_callbacks pppos_callbacks = {
pppos_disconnect,
pppos_destroy,
pppos_link_write_callback,
pppos_link_netif_output_callback
pppos_link_netif_output_callback,
pppos_send_config,
pppos_recv_config,
#if VJ_SUPPORT
pppos_vjc_config
#else /* VJ_SUPPORT */
NULL
#endif /* VJ_SUPPORT */
};
/* PPP's Asynchronous-Control-Character-Map. The mask array is used
@ -760,34 +772,30 @@ drop:
}
#endif /* PPP_INPROC_MULTITHREADED */
void
pppos_accm_out_config(pppos_pcb *pppos, u32_t accm)
static void
pppos_send_config(ppp_pcb *ppp, void *ctx, u32_t accm)
{
int i;
if (!pppos_exist(pppos)) {
return;
}
pppos_pcb *pppos = (pppos_pcb *)ctx;
LWIP_UNUSED_ARG(ppp);
/* Load the ACCM bits for the 32 control codes. */
for (i = 0; i < 32/8; i++) {
pppos->out_accm[i] = (u_char)((accm >> (8 * i)) & 0xFF);
}
PPPDEBUG(LOG_INFO, ("pppos_accm_out_config[%d]: in_accm=%X %X %X %X\n",
PPPDEBUG(LOG_INFO, ("pppos_send_config[%d]: in_accm=%X %X %X %X\n",
pppos->ppp->num,
pppos->out_accm[0], pppos->out_accm[1], pppos->out_accm[2], pppos->out_accm[3]));
}
void
pppos_accm_in_config(pppos_pcb *pppos, u32_t accm)
static void
pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm)
{
int i;
pppos_pcb *pppos = (pppos_pcb *)ctx;
SYS_ARCH_DECL_PROTECT(lev);
if (!pppos_exist(pppos)) {
return;
}
LWIP_UNUSED_ARG(ppp);
/* Load the ACCM bits for the 32 control codes. */
SYS_ARCH_PROTECT(lev);
@ -796,7 +804,7 @@ pppos_accm_in_config(pppos_pcb *pppos, u32_t accm)
}
SYS_ARCH_UNPROTECT(lev);
PPPDEBUG(LOG_INFO, ("pppos_accm_in_config[%d]: in_accm=%X %X %X %X\n",
PPPDEBUG(LOG_INFO, ("pppos_recv_config[%d]: in_accm=%X %X %X %X\n",
pppos->ppp->num,
pppos->in_accm[0], pppos->in_accm[1], pppos->in_accm[2], pppos->in_accm[3]));
}
@ -811,16 +819,11 @@ pppos_get_fd(pppos_pcb *pppos)
}
#if VJ_SUPPORT
void
pppos_vjc_config(pppos_pcb *pppos, int vjcomp, int cidcomp, int maxcid)
static void
pppos_vjc_config(ppp_pcb *ppp, void *ctx, int vjcomp, int cidcomp, int maxcid)
{
ppp_pcb *ppp;
pppos_pcb *pppos = (pppos_pcb *)ctx;
if (!pppos_exist(pppos)) {
return;
}
ppp = pppos->ppp;
ppp->vj_enabled = vjcomp;
pppos->vj_comp.compressSlot = cidcomp;
pppos->vj_comp.maxSlotIndex = maxcid;