contiki-os/contiki — pull request #46 by adamdunkels (2012-11-27 14:16:06+00:00)
Title: Thingsquare IPv6/RPL updates

This is a pretty large pull request that includes a whole bunch of updates, fixes, and rewrites from the internal Thingsquare Contiki repository. The pull request is divided into a number of individual commits to make it easier to follow.

This pull request includes:

* Rewrite of the IPv6 route management code

The IPv6 route management code in Contiki was really tricky to understand and maintain. The code was included in the catch-all file uip-ds6.c, where it was integrated with a number of other IPv6 table-handling functions, such as neighbor table and network interface management. At the time uip-ds6.c was written, it was done this way for code footprint efficiency, but as a consequence the code has become really difficult to understand. This rewrite is the first in a series of rewrites of this file: neighbor management needs to be easier to understand too.

This rewrite breaks out routing table management in a separate file, uip-ds6-route.[ch], which uses the Contiki LIST() and MEMB() mechanisms to maintain a list of IPv6 routes. While this adds some two bytes of RAM to each routing table entry, the code becomes *much* easier to understand. This also introduces an "API" change (if you can say that the old uip-ds6.c routing management mechanism had an API...), as code that wants to read the routing table now explicitly must ask for the head of the list with uip_ds6_route_list_head().

The rewrite also adds a new feature: route entry callbacks that allows an application to get a callback whenever a new route is added or an old is deleted. This also goes for default routes. This can be used to e.g. have an LED indicate if a node is connected to the network or not (e.g. if it has been given a default route).

* RPL fixes

Up/down fix: this critical fix to RPL allows it to route packets both up and down a large network (the code previously did not set the up and down flags in the RPL extension header correctly, which caused packets to be dropped along the route).

Root version inference: this critical change allows RPL root to learn the current DAG version from a network where every node has infinite rank. This is needed if the root node has disappeared and the network has gone into an infinite rank state, and the root reappears, possibly rebooted. Without this change, the network may end up in a state where the RPL root has a lower version number than the (now failed) network, and is unable to repair it, which leads to a complete failure of the network.

There are also a number of added configuration options that are needed to be tweaked when running RPL in larger networks, as well as code style fixes.

* Miscellaneous updates

uip-split configuration: allows the threshold of where to start splitting TCP segments to be configurable.

IPv4/IPv6 functions: allows IP address functions for handing IPv4 address to be used even if the stack is configured for IPv6 networking, and vice versa.

simple-udp update: a new function for sending packets to specified UDP ports.

Code style fixes.