From a83fb308360fff6d69083ebf1924774fc1cdc996 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 23 Jun 2012 13:07:43 +0200 Subject: [PATCH] fixed PPPoS multithread support --- src/netif/ppp/ppp.c | 18 ++++++++++++++---- src/netif/ppp/ppp.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 5793bf87..620dbedb 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -845,7 +845,7 @@ ppp_input_thread(void *arg) { int count; ppp_pcb_rx *pcrx = arg; - ppp_pcb *pcb = (ppp_pcb*)pcrx->pcb; + ppp_pcb *pcb = pcrx->pcb; while (pcb->phase != PHASE_DEAD) { count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE); @@ -1363,6 +1363,12 @@ pppos_input(ppp_pcb *pcb, u_char* data, int len) } #endif +#if PPP_INPROC_MULTITHREADED +struct ppp_tcpip_callback_header { + ppp_pcb *pcb; +}; +#endif /* PPP_INPROC_MULTITHREADED */ + /** * Process a received octet string. */ @@ -1416,6 +1422,7 @@ pppos_input_proc(ppp_pcb_rx *pcrx, u_char *s, int l) struct pbuf *inp; #if PPP_INPROC_MULTITHREADED struct pbuf *head; + struct ppp_tcpip_callback_header *cbhead; #endif /* PPP_INPROC_MULTITHREADED */ /* Trim off the checksum. */ if(pcrx->in_tail->len > 2) { @@ -1440,9 +1447,10 @@ pppos_input_proc(ppp_pcb_rx *pcrx, u_char *s, int l) pcrx->in_head = NULL; pcrx->in_tail = NULL; #if PPP_INPROC_MULTITHREADED - head = pbuf_alloc(PBUF_RAW, sizeof(void*), PBUF_POOL); + head = pbuf_alloc(PBUF_RAW, sizeof(struct ppp_tcpip_callback_header), PBUF_POOL); if(NULL != head) { - MEMCPY(head->payload, pcb, sizeof(void*)); + cbhead = (struct ppp_tcpip_callback_header*)head->payload; + cbhead->pcb = pcb; pbuf_chain(head, inp); if(tcpip_callback_with_block(pppos_input_callback, head, 0) != ERR_OK) { PPPDEBUG(LOG_ERR, ("pppos_input_proc[%d]: tcpip_callback() failed, dropping packet\n", pcb->num)); @@ -1584,10 +1592,12 @@ pppos_input_proc(ppp_pcb_rx *pcrx, u_char *s, int l) */ static void pppos_input_callback(void *arg) { struct pbuf *hd, *pl; + struct ppp_tcpip_callback_header *cbhead; ppp_pcb *pcb; hd = (struct pbuf *)arg; - pcb = (ppp_pcb *)hd->payload; + cbhead = (struct ppp_tcpip_callback_header *)hd->payload; + pcb = cbhead->pcb; pl = hd->next; pbuf_free(hd); diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index d9191be1..50ab2d1e 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -466,7 +466,7 @@ int ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg); #if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD /* * PPP over Serial: this is the input function to be called for received data. - * If PPP_INPROC_OWNTHREAD==1, a seperate input thread using the blocking + * If PPP_INPROC_OWNTHREAD==1, a separate input thread using the blocking * sio_read() is used, so this is deactivated. */ void pppos_input(ppp_pcb *pcb, u_char* data, int len);