PAP is now using pbuf instead of pcb->outpacket_buf

This commit is contained in:
Sylvain Rochet 2012-06-18 01:10:21 +02:00
parent 8641b8a36e
commit 22fad86453
4 changed files with 22 additions and 6 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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 */