IP Stack Hardware Abstraction

The most important component of the TCP/IP stack is the hardware abstraction layer.  Without it, there is simply no way to communicate with the network.  As I’m still unsure about which hardware to use on the long run and being a good software architect, I created a hardware abstraction layer which is pretty simple to understand.  We need to initialize the hardware and to be able send/receive packets, and if somewhat possible keep track of some statistics.  All of these are grouped in the netif.h and netif.c files.  Like lwIP I created a structure (netif_t) that describes a network interface, via pointer functions the real implementation can be delegated to the hardware driver(s) to be provided for each ethernet chip/module.  Also I took over lwIP’s support for multiple network interfaces.  Adding all this together delivers me the following structure which describes pretty good a network interface:

These functions can be called externally to initialize/use the interface(s):

For example to initialize the ENC28j60 (hardware implementation follows later) you would call the following:

The complete code for the netif can be found here:

netif.h (7.1 KiB)

netif.c (3.9 KiB)


Tagged , , , . Bookmark the permalink.

2 Responses to IP Stack Hardware Abstraction

  1. Andrew Eliasz says:

    Not sure if there is an answer for this …
    I want to use lwip on an ARM Cortex spansion board with two ethernet interfaces. Is it possible to do this using lwIP and is there an example I can use to get me started please.

    • PatrickPatrick says:

      lwip is universal, you’ll need to develop a driver for the board you want to use or find one…

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Anti Spam by WP-SpamShield