/[lwip]/lwip/src/netif/loopif.c
ViewVC logotype

Diff of /lwip/src/netif/loopif.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by likewise, Mon Jun 9 21:14:47 2003 UTC revision 1.8.2.1 by likewise, Fri Nov 14 09:42:51 2003 UTC
# Line 40  Line 40 
40  #include "lwip/tcp.h"  #include "lwip/tcp.h"
41  #include "lwip/ip.h"  #include "lwip/ip.h"
42    
43  /*-----------------------------------------------------------------------------------*/  static void
44    loopif_input( void * arg )
45    {
46            struct netif *netif = (struct netif *)( ((void **)arg)[ 0 ] );
47            struct pbuf *r = (struct pbuf *)( ((void **)arg)[ 1 ] );
48    
49            mem_free( arg );
50            netif -> input( r, netif );
51    }
52    
53  static err_t  static err_t
54  loopif_output(struct netif *netif, struct pbuf *p,  loopif_output(struct netif *netif, struct pbuf *p,
55         struct ip_addr *ipaddr)         struct ip_addr *ipaddr)
56  {  {
57    struct pbuf *q, *r;    struct pbuf *q, *r;
58    char *ptr;    char *ptr;
59      void **arg;
60    
61  #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP)  #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP)
62    tcpdump(p);    tcpdump(p);
# Line 60  loopif_output(struct netif *netif, struc Line 70  loopif_output(struct netif *netif, struc
70        memcpy(ptr, q->payload, q->len);        memcpy(ptr, q->payload, q->len);
71        ptr += q->len;        ptr += q->len;
72      }      }
73      netif->input(r, netif);  
74        arg = mem_malloc( sizeof( void *[2]));
75            if( NULL == arg ) {
76                    return ERR_MEM;
77            }
78            
79            arg[0] = netif;
80            arg[1] = r;
81            /**
82             * workaround (patch #1779) to try to prevent bug #2595:
83             * When connecting to "localhost" with the loopif interface,
84             * tcp_output doesn't get the opportunity to finnish sending the
85             * segment before tcp_process gets it, resulting in tcp_process
86             * referencing pcb->unacked-> which still is NULL.
87             *
88             * TODO: Is there still a race condition here? Leon
89             */
90            sys_timeout( 1, loopif_input, arg );
91            
92      return ERR_OK;          return ERR_OK;    
93    }    }
94    return ERR_MEM;    return ERR_MEM;
95  }  }
96  /*-----------------------------------------------------------------------------------*/  
97  err_t  err_t
98  loopif_init(struct netif *netif)  loopif_init(struct netif *netif)
99  {  {
100    netif->name[0] = 'l';    netif->name[0] = 'l';
101    netif->name[1] = 'o';    netif->name[1] = 'o';
102    #if 0 /** TODO: I think this should be enabled, or not? Leon */
103      netif->input = loopif_input;
104    #endif
105    netif->output = loopif_output;    netif->output = loopif_output;
106    return ERR_OK;    return ERR_OK;
107  }  }
108  /*-----------------------------------------------------------------------------------*/  
109    
110    
111    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.8.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26