static
#endif
void ethernetif_input(void * pvParameters)
{
  struct netif      *netif = (struct netif *)pvParameters;
  struct pbuf       *p;

#ifdef FREERTOS_USED
  for( ;; )
  {
    do
    {
#endif
      /* move received packet into a new pbuf */
      p = low_level_input( netif );
      if( p == NULL )
      {
#ifdef FREERTOS_USED
        /* No packet could be read.  Wait a for an interrupt to tell us
        there is more data available. */
        vMACBWaitForInput(100);
      }
    }while( p == NULL );
#else
        return;
      }
#endif

    if( ERR_OK != netif->input( p, netif ) )
    {
      pbuf_free(p);
      p = NULL;
    }
#ifdef FREERTOS_USED
  }
Ejemplo n.º 2
0
/*!
 *  \brief Manage the Ethernet packets, if any received process them
 *  After processing any packets, manage the lwIP timers
 */
void ethernet_task(void)
{
	/* Check once to see if packet is ready before managing the timers */
	if(vMACBWaitForInput(1))
	{
		// Process received packet
		ethernetif_input(&MACB_if);
	}
	/* Manages all the timers lwIP requires in standalone mode */
	manage_timers();
}
Ejemplo n.º 3
0
void ethernetif_input( void * pvParameters )
{
struct ethernetif   *ethernetif;
struct eth_hdr      *ethhdr;
struct pbuf         *p;

  ( void ) pvParameters;

  for( ;; )  {
   
    ethernetif = xNetIf->state;
    do
    {
      ethernetif = xNetIf->state;

      /* move received packet into a new pbuf */
      p = low_level_input( xNetIf );

      if( p == NULL )
      {
        /* No packet could be read.  Wait a for an interrupt to tell us
        there is more data available. */
        vMACBWaitForInput(100);
      }

    } while( p == NULL );

    /* points to packet payload, which starts with an Ethernet header */
    ethhdr = p->payload;
  
    #if LINK_STATS
      lwip_stats.link.recv++;
    #endif /* LINK_STATS */
  
    ethhdr = p->payload;
  
    switch( htons( ethhdr->type ) )
    {
      /* IP packet? */
      case ETHTYPE_IP:
        /* update ARP table */
        etharp_ip_input( xNetIf, p );
  
        /* skip Ethernet header */
        pbuf_header( p, (s16_t)-sizeof(struct eth_hdr) );
  
        /* pass to network layer */
        xNetIf->input( p, xNetIf );
        break;
  
      case ETHTYPE_ARP:
        /* pass p to ARP module */
        etharp_arp_input( xNetIf, ethernetif->ethaddr, p );
        break;
  
      default:
        pbuf_free( p );
        p = NULL;
        break;
    }
  }
}