mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-06 02:27:15 +00:00
merged ppp_write and ppp_write_pbuf
This commit is contained in:
parent
bda73b1bc9
commit
9b7860d6ec
@ -244,7 +244,7 @@ static void chap_timeout(void *arg) {
|
||||
if(NULL == p)
|
||||
return;
|
||||
MEMCPY(p->payload, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen);
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
++pcb->chap_server.challenge_xmits;
|
||||
pcb->chap_server.flags |= TIMEOUT_PENDING;
|
||||
TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time);
|
||||
@ -347,7 +347,7 @@ static void chap_handle_response(ppp_pcb *pcb, int id,
|
||||
outp[3] = len;
|
||||
if (mlen > 0)
|
||||
memcpy(outp + CHAP_HDRLEN, pcb->chap_server.message, mlen);
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
|
||||
if (pcb->chap_server.flags & CHALLENGE_VALID) {
|
||||
pcb->chap_server.flags &= ~CHALLENGE_VALID;
|
||||
@ -473,7 +473,7 @@ static void chap_respond(ppp_pcb *pcb, int id,
|
||||
outp[3] = len;
|
||||
|
||||
pbuf_realloc(p, PPP_HDRLEN + len);
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
|
||||
static void chap_handle_status(ppp_pcb *pcb, int code, int id,
|
||||
|
@ -279,7 +279,7 @@ eap_state *esp;
|
||||
PUTCHAR(pcb->eap.es_server.ea_id, outp);
|
||||
PUTSHORT(EAP_HEADERLEN, outp);
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
|
||||
pcb->eap.es_server.ea_state = eapBadAuth;
|
||||
auth_peer_fail(pcb, PPP_EAP);
|
||||
@ -310,7 +310,7 @@ eap_state *esp;
|
||||
PUTCHAR(pcb->eap.es_server.ea_id, outp);
|
||||
PUTSHORT(EAP_HEADERLEN, outp);
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
|
||||
auth_peer_success(pcb, PPP_EAP, 0,
|
||||
pcb->eap.es_server.ea_peer, pcb->eap.es_server.ea_peerlen);
|
||||
@ -881,7 +881,7 @@ eap_state *esp;
|
||||
PUTSHORT(outlen, lenloc);
|
||||
|
||||
pbuf_realloc(p, outlen + PPP_HDRLEN);
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
|
||||
pcb->eap.es_server.ea_requests++;
|
||||
|
||||
@ -1076,7 +1076,7 @@ static void eap_send_response(ppp_pcb *pcb, u_char id, u_char typenum, u_char *s
|
||||
MEMCPY(outp, str, lenstr);
|
||||
}
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1109,7 +1109,7 @@ static void eap_chap_response(ppp_pcb *pcb, u_char id, u_char *hash, char *name,
|
||||
MEMCPY(outp, name, namelen);
|
||||
}
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
|
||||
#ifdef USE_SRP
|
||||
@ -1148,7 +1148,7 @@ int lenstr;
|
||||
MEMCPY(outp, str, lenstr);
|
||||
}
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1185,7 +1185,7 @@ u_char *str;
|
||||
PUTLONG(flags, outp);
|
||||
MEMCPY(outp, str, SHA_DIGESTSIZE);
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
#endif /* USE_SRP */
|
||||
|
||||
@ -1210,7 +1210,7 @@ static void eap_send_nak(ppp_pcb *pcb, u_char id, u_char type) {
|
||||
PUTCHAR(EAPT_NAK, outp);
|
||||
PUTCHAR(type, outp);
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
|
||||
#ifdef USE_SRP
|
||||
|
@ -732,7 +732,7 @@ static void fsm_sconfreq(fsm *f, int retransmit) {
|
||||
PUTSHORT(cilen + HEADERLEN, outp);
|
||||
|
||||
pbuf_realloc(p, cilen + HEADERLEN + PPP_HDRLEN);
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
|
||||
/* start the retransmit timer */
|
||||
--f->retransmits;
|
||||
@ -767,7 +767,7 @@ void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen) {
|
||||
PUTCHAR(code, outp);
|
||||
PUTCHAR(id, outp);
|
||||
PUTSHORT(outlen, outp);
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
@ -212,7 +212,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u_short prot
|
||||
#if PPPOE_SUPPORT
|
||||
static err_t ppp_netif_output_over_ethernet(ppp_pcb *pcb, struct pbuf *p, u_short protocol);
|
||||
/* function called by ppp_write() */
|
||||
static int ppp_write_over_ethernet(ppp_pcb *pcb, const u_char *s, int n);
|
||||
static int ppp_write_over_ethernet(ppp_pcb *pcb, struct pbuf *p);
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
static void ppp_destroy(ppp_pcb *pcb);
|
||||
@ -1173,20 +1173,15 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg)
|
||||
return PPPERR_PARAM;
|
||||
}
|
||||
|
||||
/* FIXME: improve that */
|
||||
int ppp_write_pbuf(ppp_pcb *pcb, struct pbuf *p) {
|
||||
int ret = ppp_write(pcb, p->payload, p->len);
|
||||
pbuf_free(p);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write n characters to a ppp link.
|
||||
* Write a pbuf to a ppp link.
|
||||
* RETURN: >= 0 Number of characters written
|
||||
* -1 Failed to write to device
|
||||
*/
|
||||
int ppp_write(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
int ppp_write(ppp_pcb *pcb, struct pbuf *p) {
|
||||
#if PPPOS_SUPPORT
|
||||
u_char *s = p->payload;
|
||||
int n = p->len;
|
||||
u_char c;
|
||||
u_int fcs_out;
|
||||
struct pbuf *head, *tail;
|
||||
@ -1194,7 +1189,7 @@ int ppp_write(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
if(pcb->ethif) {
|
||||
return ppp_write_over_ethernet(pcb, s, n);
|
||||
return ppp_write_over_ethernet(pcb, p);
|
||||
}
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
@ -1204,6 +1199,7 @@ int ppp_write(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
LINK_STATS_INC(link.memerr);
|
||||
LINK_STATS_INC(link.proterr);
|
||||
snmp_inc_ifoutdiscards(&pcb->netif);
|
||||
pbuf_free(p);
|
||||
return PPPERR_ALLOC;
|
||||
}
|
||||
|
||||
@ -1245,6 +1241,7 @@ int ppp_write(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
LINK_STATS_INC(link.memerr);
|
||||
LINK_STATS_INC(link.proterr);
|
||||
snmp_inc_ifoutdiscards(&pcb->netif);
|
||||
pbuf_free(p);
|
||||
return PPPERR_ALLOC;
|
||||
}
|
||||
|
||||
@ -1253,11 +1250,14 @@ int ppp_write(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
pppos_put(pcb, head);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
pbuf_free(p);
|
||||
return PPPERR_NONE;
|
||||
}
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
static int ppp_write_over_ethernet(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
static int ppp_write_over_ethernet(ppp_pcb *pcb, struct pbuf *p) {
|
||||
u_char *s = p->payload;
|
||||
int n = p->len;
|
||||
struct pbuf *pb;
|
||||
|
||||
/* skip address & flags */
|
||||
@ -1270,6 +1270,7 @@ static int ppp_write_over_ethernet(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
LINK_STATS_INC(link.memerr);
|
||||
LINK_STATS_INC(link.proterr);
|
||||
snmp_inc_ifoutdiscards(&pcb->netif);
|
||||
pbuf_free(p);
|
||||
return PPPERR_ALLOC;
|
||||
}
|
||||
|
||||
@ -1282,6 +1283,7 @@ static int ppp_write_over_ethernet(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
if(pppoe_xmit(pcb->pppoe_sc, pb) != ERR_OK) {
|
||||
LINK_STATS_INC(link.err);
|
||||
snmp_inc_ifoutdiscards(&pcb->netif);
|
||||
pbuf_free(p);
|
||||
return PPPERR_DEVICE;
|
||||
}
|
||||
|
||||
@ -1292,6 +1294,7 @@ static int ppp_write_over_ethernet(ppp_pcb *pcb, const u_char *s, int n) {
|
||||
snmp_add_ifoutoctets(&pcb->netif, (u16_t)n);
|
||||
snmp_inc_ifoutucastpkts(&pcb->netif);
|
||||
LINK_STATS_INC(link.xmit);
|
||||
pbuf_free(p);
|
||||
return PPPERR_NONE;
|
||||
}
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
@ -383,9 +383,8 @@ 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);
|
||||
int ppp_write(ppp_pcb *pcb, struct pbuf *p);
|
||||
|
||||
/* functions called by auth.c link_terminated() */
|
||||
void ppp_link_down(ppp_pcb *pcb);
|
||||
|
@ -546,7 +546,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_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
|
||||
TIMEOUT(upap_timeout, pcb, pcb->upap.us_timeouttime);
|
||||
++pcb->upap.us_transmits;
|
||||
@ -576,7 +576,7 @@ static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msgl
|
||||
PUTCHAR(msglen, outp);
|
||||
MEMCPY(outp, msg, msglen);
|
||||
|
||||
ppp_write_pbuf(pcb, p);
|
||||
ppp_write(pcb, p);
|
||||
}
|
||||
#endif /* UNUSED */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user