Fandom

lwIP Wiki

Using lwIP in a project

91pages on
this wiki
Add New Page
Talk1 Share

WORK IN PROGRESS. This is only a draft! PLEASE, help me to write this text :)


Using lwIP in a project is quite simple. These are the basic steps you need to follow:

  1. Download the library from the main site or from the CVS repository, choosing the right version for you (I recommend the last development version for testing or the last stable version for a real project) [insert links]
  1. Copy the “src” folder in you main project folder and rename it “lwIP”
  1. Copy the “/lwIP/include/opt.h” in “/lwIP/” and rename it “lwipopts.h”. Clean this file removing all the sentinels, #include, #ifdef - #else - #endif. At the end, what we do is using the original file (which contains all the possible configuration values) to extract all the name of the #define labels we can change. This step could be long, but it is useful to avoid conflicts between different versions of the lwIP library and the lwipopts.h file. (In fact from one release to another the labels could be renamed). [explain what to change for some typical application]
  1. Include in the project some files related to you architecture: [maybe other files..]
    - “cc.h” [explain]
    - “sys_arch.c” and “sys_arch.h” (if you use an OS) [explain]
    - your specific version of “ethernetif.c”[explain]
  1. For start using the libray you can use this simple code: [improve to work with or without an OS]
#include "lwip/tcpip.h"
#include "lwip/ip.h"
#include "arch/ethernetif.h"

struct netif my_netif;

void init_ethernet(
{

      /* Network interface variables */

      struct ip_addr ipaddr, netmask, gw;





      /* Set network address variables */

      IP4_ADDR(&gw, 192,168,0,1);                   //ip address of the gateway

      IP4_ADDR(&ipaddr, 192,168,0,2);             //ip address of your device

      IP4_ADDR(&netmask, 255,255,255,0);      //netmask

      tcpip_init(NULL, NULL);                            //call this routine if you use an OS 

      netif_add(&my_netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input);

      netif_set_default(&my_netif);

      netif_set_up(&my_netif);

}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.