Implementing relatively large projects in C can often be quite messy, but when the project is done by one person, consistent coding-styles and design principals can be achieved.
Throughout the code some main design principals are followed:
This kind of modularity becomes very important when dealing with plugins as described in chapter 8. Plugins are code that is loaded at runtime to extend a program.
The OLSR daemon implementation is illustrated in figure 5.1. The different entities are explained briefly here. They will be reviewed in detail in later sections.
The entity to which a received message is sent, is responsible for updating the information repositories needed if the information is considered fresh enough and has not already been processed.
Parse functions for messages are registered with the packet parser at run-time.
In these tables the information needed to at minimum describe the current state of the network, and this nodes immediate links, is kept. The various packet parsing functions both update these tables and relies on information in these tables to be able to process the messages. The forwarding functionality in particular, relies on the duplicate table which is a cache of all recent processed and/or forwarded packets.
All these tables are regularly timed out. This means that entries no longer considered valid are removed. Whenever these databases are updated in a way that changes the understanding of the network topology, the routes are recalculated.
The scheduler runs in a thread of its own and shared memory is protected using a mutex so that the packet creation entity does not have to consider synchronization and memory-protection.
Andreas 2004-07-29