mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
PPP, PPPoS, moved VJ protocol handler to PPPoS
New callback, netif input, allow low level drivers to extend ppp_input call, moved PPPoS VJ support to pppos.c.
This commit is contained in:
parent
759d11ce1a
commit
29f3f2e1d8
@ -165,6 +165,8 @@ struct link_callbacks {
|
||||
void (*vj_config)(ppp_pcb *pcb, void *ctx, int vjcomp, int cidcomp, int maxcid);
|
||||
/* Get and set parameters for the given connection. */
|
||||
int (*ioctl)(ppp_pcb *pcb, void *ctx, int cmd, void *arg);
|
||||
/* Pass the processed input packet to the appropriate handler. */
|
||||
err_t (*netif_input)(ppp_pcb *pcb, void *ctx, struct pbuf *p, u16_t protocol);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -96,14 +96,5 @@ ppp_pcb *pppos_create(struct netif *pppif, sio_fd_t fd,
|
||||
/* PPP over Serial: this is the input function to be called for received data. */
|
||||
void pppos_input(ppp_pcb *ppp, u_char* data, int len);
|
||||
|
||||
|
||||
/*
|
||||
* Functions called from PPP CORE
|
||||
*
|
||||
* You may use them if you REALLY know what you are doing.
|
||||
*/
|
||||
int pppos_vjc_comp(pppos_pcb *pppos, struct pbuf *pb);
|
||||
int pppos_vjc_uncomp(pppos_pcb *pppos, struct pbuf *pb);
|
||||
|
||||
#endif /* PPPOS_H */
|
||||
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
|
||||
|
@ -691,26 +691,8 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
goto drop;
|
||||
}
|
||||
|
||||
/* FIXME: should we write protent to do that ? */
|
||||
|
||||
switch(protocol) {
|
||||
|
||||
#if VJ_SUPPORT
|
||||
case PPP_VJC_COMP: /* VJ compressed TCP */
|
||||
/* VJ is only enabled on PPPoS interfaces */
|
||||
if (pcb->vj_enabled && pppos_vjc_comp((pppos_pcb*)pcb->link_ctx_cb, pb) >= 0) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case PPP_VJC_UNCOMP: /* VJ uncompressed TCP */
|
||||
/* VJ is only enabled on PPPoS interfaces */
|
||||
if (pcb->vj_enabled && pppos_vjc_uncomp((pppos_pcb*)pcb->link_ctx_cb, pb) >= 0) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
case PPP_IP: /* Internet Protocol */
|
||||
PPPDEBUG(LOG_INFO, ("ppp_input[%d]: ip in pbuf len=%d\n", pcb->num, pb->len));
|
||||
ip_input(pb, pcb->netif);
|
||||
@ -724,9 +706,14 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
|
||||
default: {
|
||||
|
||||
int i;
|
||||
const struct protent *protp;
|
||||
|
||||
/* If callback set, try to pass the input packet to low level protocol */
|
||||
if (pcb->link_cb->netif_input && pcb->link_cb->netif_input(pcb, pcb->link_ctx_cb, pb, protocol) == ERR_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Upcall the proper protocol input routine.
|
||||
*/
|
||||
|
@ -157,6 +157,7 @@ static const struct link_callbacks pppoe_callbacks = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -106,6 +106,7 @@ static const struct link_callbacks pppol2tp_callbacks = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -92,6 +92,7 @@ static void pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm);
|
||||
static int pppos_ioctl(ppp_pcb *pcb, void *ctx, int cmd, void *arg);
|
||||
#if VJ_SUPPORT
|
||||
static void pppos_vjc_config(ppp_pcb *ppp, void *ctx, int vjcomp, int cidcomp, int maxcid);
|
||||
err_t pppos_netif_input(ppp_pcb *ppp, void *ctx, struct pbuf *p, u16_t protocol);
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
/* Prototypes for procedures local to this file. */
|
||||
@ -117,7 +118,12 @@ static const struct link_callbacks pppos_callbacks = {
|
||||
#else /* VJ_SUPPORT */
|
||||
NULL,
|
||||
#endif /* VJ_SUPPORT */
|
||||
pppos_ioctl
|
||||
pppos_ioctl,
|
||||
#if VJ_SUPPORT
|
||||
pppos_netif_input
|
||||
#else /* VJ_SUPPORT */
|
||||
NULL
|
||||
#endif /* VJ_SUPPORT */
|
||||
};
|
||||
|
||||
/* PPP's Asynchronous-Control-Character-Map. The mask array is used
|
||||
@ -845,48 +851,52 @@ pppos_vjc_config(ppp_pcb *ppp, void *ctx, int vjcomp, int cidcomp, int maxcid)
|
||||
ppp->num, vjcomp, cidcomp, maxcid));
|
||||
}
|
||||
|
||||
int
|
||||
pppos_vjc_comp(pppos_pcb *pppos, struct pbuf *pb)
|
||||
{
|
||||
ppp_pcb *ppp = pppos->ppp;
|
||||
err_t pppos_netif_input(ppp_pcb *ppp, void *ctx, struct pbuf *p, u16_t protocol) {
|
||||
int ret;
|
||||
PPPDEBUG(LOG_INFO, ("pppos_vjc_comp[%d]: vj_comp in pbuf len=%d\n", ppp->num, pb->len));
|
||||
pppos_pcb *pppos = (pppos_pcb *)ctx;
|
||||
|
||||
/*
|
||||
* Clip off the VJ header and prepend the rebuilt TCP/IP header and
|
||||
* pass the result to IP.
|
||||
*/
|
||||
ret = vj_uncompress_tcp(&pb, &pppos->vj_comp);
|
||||
if (ret >= 0) {
|
||||
ip_input(pb, ppp->netif);
|
||||
return ret;
|
||||
switch(protocol) {
|
||||
case PPP_VJC_COMP: /* VJ compressed TCP */
|
||||
if (!ppp->vj_enabled) {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Clip off the VJ header and prepend the rebuilt TCP/IP header and
|
||||
* pass the result to IP.
|
||||
*/
|
||||
PPPDEBUG(LOG_INFO, ("pppos_vjc_comp[%d]: vj_comp in pbuf len=%d\n", ppp->num, p->len));
|
||||
ret = vj_uncompress_tcp(&p, &pppos->vj_comp);
|
||||
if (ret >= 0) {
|
||||
ip_input(p, pppos->ppp->netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
/* Something's wrong so drop it. */
|
||||
PPPDEBUG(LOG_WARNING, ("pppos_vjc_comp[%d]: Dropping VJ compressed\n", ppp->num));
|
||||
break;
|
||||
|
||||
case PPP_VJC_UNCOMP: /* VJ uncompressed TCP */
|
||||
if (!ppp->vj_enabled) {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Process the TCP/IP header for VJ header compression and then pass
|
||||
* the packet to IP.
|
||||
*/
|
||||
PPPDEBUG(LOG_INFO, ("pppos_vjc_uncomp[%d]: vj_un in pbuf len=%d\n", ppp->num, p->len));
|
||||
ret = vj_uncompress_uncomp(p, &pppos->vj_comp);
|
||||
if (ret >= 0) {
|
||||
ip_input(p, pppos->ppp->netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
/* Something's wrong so drop it. */
|
||||
PPPDEBUG(LOG_WARNING, ("pppos_vjc_uncomp[%d]: Dropping VJ uncompressed\n", ppp->num));
|
||||
break;
|
||||
|
||||
/* Pass the packet to other handlers */
|
||||
default: ;
|
||||
}
|
||||
|
||||
/* Something's wrong so drop it. */
|
||||
PPPDEBUG(LOG_WARNING, ("pppos_vjc_comp[%d]: Dropping VJ compressed\n", ppp->num));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
pppos_vjc_uncomp(pppos_pcb *pppos, struct pbuf *pb)
|
||||
{
|
||||
ppp_pcb *ppp = pppos->ppp;
|
||||
int ret;
|
||||
PPPDEBUG(LOG_INFO, ("pppos_vjc_uncomp[%d]: vj_un in pbuf len=%d\n", ppp->num, pb->len));
|
||||
|
||||
/*
|
||||
* Process the TCP/IP header for VJ header compression and then pass
|
||||
* the packet to IP.
|
||||
*/
|
||||
ret = vj_uncompress_uncomp(pb, &pppos->vj_comp);
|
||||
if (ret >= 0) {
|
||||
ip_input(pb, ppp->netif);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Something's wrong so drop it. */
|
||||
PPPDEBUG(LOG_WARNING, ("pppos_vjc_uncomp[%d]: Dropping VJ uncompressed\n", ppp->num));
|
||||
return -1;
|
||||
return ERR_VAL;
|
||||
}
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user