diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 2757087b..33e4d466 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -1146,6 +1146,11 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg) return PPPERR_PARAM; } +int ppp_write_pbuf(ppp_pcb *pcb, struct pbuf *p) { + ppp_write(pcb, p->payload, p->len); + pbuf_free(p); +} + /* * Write n characters to a ppp link. * RETURN: >= 0 Number of characters written diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index 1593c63f..513b3f47 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -285,7 +285,7 @@ struct ppp_pcb_s { struct vjcompress vj_comp; /* Van Jacobson compression header. */ #endif /* PPPOS_SUPPORT && VJ_SUPPORT */ - struct netif netif; + struct netif netif; /* PPP interface */ struct ppp_addrs addrs; diff --git a/src/netif/ppp/ppp_impl.h b/src/netif/ppp/ppp_impl.h index 53160c4a..23126cdf 100644 --- a/src/netif/ppp/ppp_impl.h +++ b/src/netif/ppp/ppp_impl.h @@ -377,6 +377,7 @@ struct pppd_stats { /* function called by pppoe.c */ void ppp_input(ppp_pcb *pcb, struct pbuf *pb); +int ppp_write_pbuf(ppp_pcb *pcb, struct pbuf *p); /* function called by all PPP subsystems to send packets */ int ppp_write(ppp_pcb *pcb, const u_char *s, int n); diff --git a/src/netif/ppp/upap.c b/src/netif/ppp/upap.c index 6417d422..2df9ce3b 100644 --- a/src/netif/ppp/upap.c +++ b/src/netif/ppp/upap.c @@ -520,13 +520,17 @@ static void upap_rauthnak(ppp_pcb *pcb, u_char *inp, int id, int len) { * upap_sauthreq - Send an Authenticate-Request. */ static void upap_sauthreq(ppp_pcb *pcb) { + struct pbuf *p; u_char *outp; int outlen; outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) + pcb->upap.us_userlen + pcb->upap.us_passwdlen; - outp = pcb->outpacket_buf; - + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PBUF_RAM); + if(NULL == p) + return; + + outp = p->payload; MAKEHEADER(outp, PPP_PAP); PUTCHAR(UPAP_AUTHREQ, outp); @@ -538,7 +542,7 @@ static void upap_sauthreq(ppp_pcb *pcb) { PUTCHAR(pcb->upap.us_passwdlen, outp); MEMCPY(outp, pcb->upap.us_passwd, pcb->upap.us_passwdlen); - ppp_write(pcb, pcb->outpacket_buf, outlen + PPP_HDRLEN); + ppp_write_pbuf(pcb, p); TIMEOUT(upap_timeout, pcb, pcb->upap.us_timeouttime); ++pcb->upap.us_transmits; @@ -550,11 +554,16 @@ static void upap_sauthreq(ppp_pcb *pcb) { * upap_sresp - Send a response (ack or nak). */ static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msglen) { + struct pbuf *p; u_char *outp; int outlen; outlen = UPAP_HEADERLEN + sizeof (u_char) + msglen; - outp = pcb->outpacket_buf; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PBUF_RAM); + if(NULL == p) + return; + + outp = p->payload; MAKEHEADER(outp, PPP_PAP); PUTCHAR(code, outp); @@ -562,7 +571,8 @@ static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msgl PUTSHORT(outlen, outp); PUTCHAR(msglen, outp); MEMCPY(outp, msg, msglen); - ppp_write(pcb, pcb->outpacket_buf, outlen + PPP_HDRLEN); + + ppp_write_pbuf(pcb, p); } #endif /* UNUSED */