From 50336aaedd6f2b857e3bd7cb49da142cb50f6261 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 14 Mar 2015 01:03:58 +0100 Subject: [PATCH] PPP, ppp->last_xmit is only used in PPPoS, moved to PPPoS Only PPPoS need to keep track of last transmitted packet for HDLC flag, removed from PPPoE and PPPoL2TP and moved to PPPoS. --- src/include/netif/ppp/ppp.h | 2 -- src/include/netif/ppp/pppos.h | 3 ++- src/netif/ppp/pppoe.c | 4 ---- src/netif/ppp/pppol2tp.c | 4 ---- src/netif/ppp/pppos.c | 10 +++++----- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index b5bb8836..7d9ef2bd 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -347,8 +347,6 @@ struct ppp_pcb_s { 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. */ - /* auth data */ #if PPP_SERVER char peer_authname[MAXNAMELEN + 1]; /* The name by which the peer authenticated itself to us. */ diff --git a/src/include/netif/ppp/pppos.h b/src/include/netif/ppp/pppos.h index cfb43801..cddb5437 100644 --- a/src/include/netif/ppp/pppos.h +++ b/src/include/netif/ppp/pppos.h @@ -71,9 +71,10 @@ struct pppos_pcb_s { /* -- below are data that will be cleared between two sessions * - * out_accm must be the first member of cleared members, because it is + * last_xmit must be the first member of cleared members, because it is * used to know which part must not be cleared. */ + u32_t last_xmit; /* Time of last transmission. */ ext_accm out_accm; /* Async-Ctl-Char-Map for output. */ /* flags */ diff --git a/src/netif/ppp/pppoe.c b/src/netif/ppp/pppoe.c index f601b9d0..4e000791 100644 --- a/src/netif/ppp/pppoe.c +++ b/src/netif/ppp/pppoe.c @@ -232,8 +232,6 @@ static err_t pppoe_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) { tot_len = ph->tot_len; #endif /* LWIP_SNMP */ - ppp->last_xmit = sys_jiffies(); - ret = pppoe_xmit(sc, ph); if (ret != ERR_OK) { LINK_STATS_INC(link.err); @@ -268,8 +266,6 @@ static err_t pppoe_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_short pbuf_header(pb, -(s16_t)PPPOE_HEADERLEN); - ppp->last_xmit = sys_jiffies(); - pl = (u8_t*)pb->payload; PUTSHORT(protocol, pl); diff --git a/src/netif/ppp/pppol2tp.c b/src/netif/ppp/pppol2tp.c index 8e37bc48..bff272eb 100644 --- a/src/netif/ppp/pppol2tp.c +++ b/src/netif/ppp/pppol2tp.c @@ -234,8 +234,6 @@ static err_t pppol2tp_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) { tot_len = ph->tot_len; #endif /* LWIP_SNMP */ - ppp->last_xmit = sys_jiffies(); - ret = pppol2tp_xmit(l2tp, ph); if (ret != ERR_OK) { LINK_STATS_INC(link.err); @@ -270,8 +268,6 @@ static err_t pppol2tp_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_sh pbuf_header(pb, -(s16_t)PPPOL2TP_OUTPUT_DATA_HEADER_LEN); - ppp->last_xmit = sys_jiffies(); - pl = (u8_t*)pb->payload; PUTSHORT(protocol, pl); diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 19dee39f..8ba90d7b 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -238,7 +238,7 @@ pppos_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) /* If the link has been idle, we'll send a fresh flag character to * flush any noise. */ err = ERR_OK; - if ((sys_jiffies() - ppp->last_xmit) >= PPP_MAXIDLEFLAG) { + if ((sys_jiffies() - pppos->last_xmit) >= PPP_MAXIDLEFLAG) { err = pppos_output_append(pppos, err, nb, PPP_FLAG, 0); } @@ -321,7 +321,7 @@ pppos_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *pb, u_short protocol) /* If the link has been idle, we'll send a fresh flag character to * flush any noise. */ err = ERR_OK; - if ((sys_jiffies() - ppp->last_xmit) >= PPP_MAXIDLEFLAG) { + if ((sys_jiffies() - pppos->last_xmit) >= PPP_MAXIDLEFLAG) { err = pppos_output_append(pppos, err, nb, PPP_FLAG, 0); } @@ -384,7 +384,7 @@ pppos_connect(ppp_pcb *ppp, void *ctx) ppp_clear(ppp); /* reset PPPoS control block to its initial state */ - memset(&pppos->out_accm, 0, sizeof(pppos_pcb) - ( (char*)&((pppos_pcb*)0)->out_accm - (char*)0 ) ); + memset(&pppos->last_xmit, 0, sizeof(pppos_pcb) - ( (char*)&((pppos_pcb*)0)->last_xmit - (char*)0 ) ); #if PPP_IPV4_SUPPORT && VJ_SUPPORT vj_compress_init(&pppos->vj_comp); @@ -974,7 +974,7 @@ pppos_output_last(pppos_pcb *pppos, err_t err, struct pbuf *nb) } } - ppp->last_xmit = sys_jiffies(); + pppos->last_xmit = sys_jiffies(); snmp_add_ifoutoctets(ppp->netif, nb->tot_len); snmp_inc_ifoutucastpkts(ppp->netif); LINK_STATS_INC(link.xmit); @@ -982,7 +982,7 @@ pppos_output_last(pppos_pcb *pppos, err_t err, struct pbuf *nb) return ERR_OK; failed: - ppp->last_xmit = 0; /* prepend PPP_FLAG to next packet */ + pppos->last_xmit = 0; /* prepend PPP_FLAG to next packet */ LINK_STATS_INC(link.err); LINK_STATS_INC(link.drop); snmp_inc_ifoutdiscards(ppp->netif);