lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] RAWSOCKETS_IN_LWIP


From: Sergio R. Caprile
Subject: Re: [lwip-users] RAWSOCKETS_IN_LWIP
Date: Wed, 02 Jul 2014 09:58:03 -0300
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Hi,
I think you have things a bit confusing here. Let me try to clarify:
* There si no data link layer in TCP/IP. TCP/IP can virtually use any
data link layer and so lwIP. The most common data link layer used for
TCP/IP is Ethernet.
** In linux, the OS owns the stack and the Ethernet chip, and you have
to ask permission to access the Ethernet layer and inject "raw frames"
* lwIP is not an operating system nor a kernel, it is a TCP/IP stack.
** Therefore, if you need to use Ethernet, you will use Ethernet, not
lwIP. You don't need to ask the OS permission to write to the Ethernet
chip, it is an embedded system and you own the Ethernet chip, you write
the driver and you write to the chip at will. This has nothing to do
with lwIP, except:
*** In case you need to use both your own stack for your own protocol
(which you refer to as "Application Layer" but in this scenario is a
layer-3 protocol) AND lwIP for TCP/IP; then YOU will modify the _netif_
code in YOUR driver and capture the proper Ethernet protocol-type and/or
IEEE802.3/SNAP, for example, in src/netif/ethernetif.c:

  switch (htons(ethhdr->type)) {

  /* IP or ARP packet? */

  case ETHTYPE_IP:

  case ETHTYPE_ARP:

#if PPPOE_SUPPORT

  /* PPPoE packet? */

  case ETHTYPE_PPPOEDISC:

  case ETHTYPE_PPPOE:

#endif /* PPPOE_SUPPORT */

    /* full packet send to tcpip_thread to process */

    if (netif->input(p, netif)!=ERR_OK)

     { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));

       pbuf_free(p);

       p = NULL;

     }

    break;


you will add something like:

  case ETHTYPE_myOWNLAYER3PROTOCOL:

    /* full packet send to mylayer3_thread to process */

    if (netif->mylayer3protocolinput(p, netif)!=ERR_OK)

     { LWIP_DEBUGF(NETIF_DEBUG, ("mylayer3protocol_input: PROTOCOLNAME input 
error\n"));

       pbuf_free(p);

       p = NULL;

     }

    break;

This is just an example, you will have your ethernetif.c equivalent in
your port for your particular hardware, adapted for your particular chip.
Regards




reply via email to

[Prev in Thread] Current Thread [Next in Thread]