From 02598d1e917d0de0b67017b19c019e30d1b6b7a4 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Tue, 10 Mar 2015 23:51:32 +0100 Subject: [PATCH] PPP, PPPoS, moved pcomp and accomp only used by PPPoS to PPPoS --- src/include/netif/ppp/ppp.h | 3 +-- src/include/netif/ppp/ppp_impl.h | 4 ++-- src/include/netif/ppp/pppos.h | 4 +++- src/netif/ppp/ppp.c | 9 ++------- src/netif/ppp/pppos.c | 17 +++++++++++------ 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index 698a3e29..b5bb8836 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -328,8 +328,6 @@ struct ppp_pcb_s { u8_t err_code; /* Code indicating why interface is down. */ /* flags */ - unsigned int pcomp :1; /* Does peer accept protocol compression? */ - unsigned int accomp :1; /* Does peer accept addr/ctl compression? */ #if PPP_IPV4_SUPPORT unsigned int ipcp_is_open :1; /* haven't called np_finished() */ unsigned int ipcp_is_up :1; /* have called ipcp_up() */ @@ -347,6 +345,7 @@ struct ppp_pcb_s { unsigned int :2; /* 2 bit of padding */ #endif /* PPP_IPV6_SUPPORT */ unsigned int lcp_echo_timer_running :1; /* set if a timer is running */ + unsigned int :2; /* 2 bits of padding to round out to 8 bits */ u32_t last_xmit; /* Time of last transmission. */ diff --git a/src/include/netif/ppp/ppp_impl.h b/src/include/netif/ppp/ppp_impl.h index 48885ee5..b9437603 100644 --- a/src/include/netif/ppp/ppp_impl.h +++ b/src/include/netif/ppp/ppp_impl.h @@ -156,9 +156,9 @@ struct link_callbacks { /* 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); + void (*send_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp); /* confire the receive-side characteristics of the PPP interface */ - void (*recv_config)(ppp_pcb *pcb, void *ctx, u32_t accm); + void (*recv_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp); #if VJ_SUPPORT /* configure TCP header compression */ void (*vj_config)(ppp_pcb *pcb, void *ctx, int vjcomp, int cidcomp, int maxcid); diff --git a/src/include/netif/ppp/pppos.h b/src/include/netif/ppp/pppos.h index 1c962e05..f6747da0 100644 --- a/src/include/netif/ppp/pppos.h +++ b/src/include/netif/ppp/pppos.h @@ -78,12 +78,14 @@ struct pppos_pcb_s { /* flags */ unsigned int open :1; /* Set if PPPoS is open */ + unsigned int pcomp :1; /* Does peer accept protocol compression? */ + unsigned int accomp :1; /* Does peer accept addr/ctl compression? */ #if VJ_SUPPORT unsigned int vj_enabled :1; /* Flag indicating VJ compression enabled. */ #else unsigned int :1; /* 1 bit of padding */ #endif /* VJ_SUPPORT */ - unsigned int :6; /* 6 bits of padding to round out to 8 bits */ + unsigned int :4; /* 4 bits of padding to round out to 8 bits */ /* PPPoS rx */ ext_accm in_accm; /* Async-Ctl-Char-Map for input. */ diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 703f86f5..2b152e85 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -827,13 +827,10 @@ void new_phase(ppp_pcb *pcb, int p) { */ int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) { LWIP_UNUSED_ARG(mtu); - /* pcb->mtu = mtu; -- set correctly with netif_set_mtu */ - pcb->pcomp = pcomp; - pcb->accomp = accomp; if (pcb->link_cb->send_config) { - pcb->link_cb->send_config(pcb, pcb->link_ctx_cb, accm); + pcb->link_cb->send_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp); } PPPDEBUG(LOG_INFO, ("ppp_send_config[%d]\n", pcb->netif->num) ); @@ -845,12 +842,10 @@ int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) { * the ppp interface. */ int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp) { - LWIP_UNUSED_ARG(accomp); - LWIP_UNUSED_ARG(pcomp); LWIP_UNUSED_ARG(mru); if (pcb->link_cb->recv_config) { - pcb->link_cb->recv_config(pcb, pcb->link_ctx_cb, accm); + pcb->link_cb->recv_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp); } PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]\n", pcb->netif->num)); diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 0d98e002..09c75637 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -59,8 +59,8 @@ static err_t pppos_listen(ppp_pcb *ppp, void *ctx, struct ppp_addrs *addrs); #endif /* PPP_SERVER */ 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); +static void pppos_send_config(ppp_pcb *ppp, void *ctx, u32_t accm, int pcomp, int accomp); +static void pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm, int pcomp, int accomp); static err_t 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); @@ -328,13 +328,13 @@ pppos_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *pb, u_short protocol) } ppp->last_xmit = sys_jiffies(); - if (!ppp->accomp) { + if (!pppos->accomp) { fcs_out = PPP_FCS(fcs_out, PPP_ALLSTATIONS); tail = pppos_append(PPP_ALLSTATIONS, tail, &pppos->out_accm); fcs_out = PPP_FCS(fcs_out, PPP_UI); tail = pppos_append(PPP_UI, tail, &pppos->out_accm); } - if (!ppp->pcomp || protocol > 0xFF) { + if (!pppos->pcomp || protocol > 0xFF) { c = (protocol >> 8) & 0xFF; fcs_out = PPP_FCS(fcs_out, c); tail = pppos_append(c, tail, &pppos->out_accm); @@ -787,12 +787,15 @@ drop: #endif /* PPP_INPROC_MULTITHREADED */ static void -pppos_send_config(ppp_pcb *ppp, void *ctx, u32_t accm) +pppos_send_config(ppp_pcb *ppp, void *ctx, u32_t accm, int pcomp, int accomp) { int i; pppos_pcb *pppos = (pppos_pcb *)ctx; LWIP_UNUSED_ARG(ppp); + pppos->pcomp = pcomp; + pppos->accomp = accomp; + /* 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); @@ -804,12 +807,14 @@ pppos_send_config(ppp_pcb *ppp, void *ctx, u32_t accm) } static void -pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm) +pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm, int pcomp, int accomp) { int i; pppos_pcb *pppos = (pppos_pcb *)ctx; PPPOS_DECL_PROTECT(lev); LWIP_UNUSED_ARG(ppp); + LWIP_UNUSED_ARG(pcomp); + LWIP_UNUSED_ARG(accomp); /* Load the ACCM bits for the 32 control codes. */ PPPOS_PROTECT(lev);