[En-Nut-Discussion] RFC: Registering Protocols

Ole Reinhardt ole.reinhardt at embedded-it.de
Mon Aug 11 12:47:45 CEST 2008

Hi Harald,

> However, the IP protocols UDP and TCP should be optional, because some 
> applications may use one of them only. The decision can be based on 
> NutTcpCreateSocket() and NutUdpCreateSocket(). If any of these is called 
> for the first time, they will register the related protocol in the IP layer.
> The protocol switch in NutIpInput() will be partly (UDP, TCP, IGMP) 
> replaced by a loop through a linked list of registered protocols.

This sounds reasonable for me too. But I would implement it with a
static jump table.

E.g. you could define an array of callback function pointers that will
be NULL in case the protocol is not registered and point to the protocol
input function in case the protocol was first used anywhere in the code.

This kind of implementation avoids loping through the linked list and
the array will still be quite short as we don't have that much unused
protocols, right?



|                                                             |
| Embedded-IT          Hard- und Softwarelösungen             |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt at embedded-it.de |
| Germany              Web:         http://www.embedded-it.de |
|                      UstID / VAT:       DE198944716         |

More information about the En-Nut-Discussion mailing list