[En-Nut-Discussion] UdpGetError() is only conditionally defined

Ole Reinhardt ole.reinhardt at embedded-it.de
Sun Feb 10 17:22:04 CET 2013


Hi Philipp and Harald,

> just found this in sys/socket.h:
> 
> #ifdef NUT_UDP_ICMP_SUPPORT
> extern int NutUdpSetSocketError(UDPSOCKET * sock, uint32_t remote_addr,
> uint16_t remote_port, uint16_t error);
> extern int NutUdpError(UDPSOCKET * sock, uint32_t * addr, uint16_t * port);
> #endif
> 
> Why is there an #ifdef with ICMP for these basic functions? 

The reason was quite simple:

I added ICMP support for UDP quite some time ago because I needed it for
a project.

But the UDP error support slightly modifies the behavior of the
NutUdpSendTo() and NutUdpReceiveFrom(). Both functions will return -1
without sending/receiving the packet if an error is outstanding, as long
as NUT_UDP_ICMP_SUPPORT is enabled.

I did not want to break existing code and therefor added conditional
compilation. This functionality is not enabled in the configurator by
default. So by default you'll get the standard functionality of
NutUdpSendTo() and NutUdpReceiveFrom()

> It is not present in the source, so the functions will always be
> compiled anyway.

It is available, but I forgot it at some places.

> Additionally, the doc still says "Todo: There is no similar call like
> NutTcpError() available for UDP."

Ok, that should be changed.


@Harald:

I would vote to make it a standard functionality and therefor would
remove the conditional compile. What do you think?

Bye,

Ole


More information about the En-Nut-Discussion mailing list