mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-04 21:44:38 +08: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);
|
void (*vj_config)(ppp_pcb *pcb, void *ctx, int vjcomp, int cidcomp, int maxcid);
|
||||||
/* Get and set parameters for the given connection. */
|
/* Get and set parameters for the given connection. */
|
||||||
int (*ioctl)(ppp_pcb *pcb, void *ctx, int cmd, void *arg);
|
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. */
|
/* 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);
|
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 /* PPPOS_H */
|
||||||
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
|
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
|
||||||
|
@ -691,26 +691,8 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
|||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: should we write protent to do that ? */
|
|
||||||
|
|
||||||
switch(protocol) {
|
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 */
|
case PPP_IP: /* Internet Protocol */
|
||||||
PPPDEBUG(LOG_INFO, ("ppp_input[%d]: ip in pbuf len=%d\n", pcb->num, pb->len));
|
PPPDEBUG(LOG_INFO, ("ppp_input[%d]: ip in pbuf len=%d\n", pcb->num, pb->len));
|
||||||
ip_input(pb, pcb->netif);
|
ip_input(pb, pcb->netif);
|
||||||
@ -724,9 +706,14 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
|||||||
#endif /* PPP_IPV6_SUPPORT */
|
#endif /* PPP_IPV6_SUPPORT */
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
const struct protent *protp;
|
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.
|
* Upcall the proper protocol input routine.
|
||||||
*/
|
*/
|
||||||
|
@ -157,6 +157,7 @@ static const struct link_callbacks pppoe_callbacks = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ static const struct link_callbacks pppol2tp_callbacks = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
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);
|
static int pppos_ioctl(ppp_pcb *pcb, void *ctx, int cmd, void *arg);
|
||||||
#if VJ_SUPPORT
|
#if VJ_SUPPORT
|
||||||
static void pppos_vjc_config(ppp_pcb *ppp, void *ctx, int vjcomp, int cidcomp, int maxcid);
|
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 */
|
#endif /* VJ_SUPPORT */
|
||||||
|
|
||||||
/* Prototypes for procedures local to this file. */
|
/* Prototypes for procedures local to this file. */
|
||||||
@ -117,7 +118,12 @@ static const struct link_callbacks pppos_callbacks = {
|
|||||||
#else /* VJ_SUPPORT */
|
#else /* VJ_SUPPORT */
|
||||||
NULL,
|
NULL,
|
||||||
#endif /* VJ_SUPPORT */
|
#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
|
/* 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));
|
ppp->num, vjcomp, cidcomp, maxcid));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
err_t pppos_netif_input(ppp_pcb *ppp, void *ctx, struct pbuf *p, u16_t protocol) {
|
||||||
pppos_vjc_comp(pppos_pcb *pppos, struct pbuf *pb)
|
|
||||||
{
|
|
||||||
ppp_pcb *ppp = pppos->ppp;
|
|
||||||
int ret;
|
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;
|
||||||
|
|
||||||
/*
|
switch(protocol) {
|
||||||
* Clip off the VJ header and prepend the rebuilt TCP/IP header and
|
case PPP_VJC_COMP: /* VJ compressed TCP */
|
||||||
* pass the result to IP.
|
if (!ppp->vj_enabled) {
|
||||||
*/
|
break;
|
||||||
ret = vj_uncompress_tcp(&pb, &pppos->vj_comp);
|
}
|
||||||
if (ret >= 0) {
|
/*
|
||||||
ip_input(pb, ppp->netif);
|
* Clip off the VJ header and prepend the rebuilt TCP/IP header and
|
||||||
return ret;
|
* 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. */
|
return ERR_VAL;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
#endif /* VJ_SUPPORT */
|
#endif /* VJ_SUPPORT */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user