IRNAS / koruza-driver

OpenWrt support for KORUZA devices via uBus
GNU General Public License v3.0
1 stars 3 forks source link

arpa/inet.h in message.c #2

Closed VojislavM closed 8 years ago

VojislavM commented 8 years ago

I have a problem with:

#include <arpa/inet.h>

functions ntohs, htons, and htonl are used in message.c, and I can`t comple them with GCC for microcontroler. Do you have expirience with this? I will try to find a way to include arpa/inet.h. If this does not work, do you think we could change those functions?

kostko commented 8 years ago

These functions convert between network byte order (big endian) and host byte order (ntoh means network-to-host while hton means host-to-network; s means short or 16 bits and l means long or 32 bits). All fields in our protocol are encoded as big endian.

If your target CPU is also big endian, you can just make an ifdef for your architecture where these functions are defined as just returning the result unchanged. In case your target CPU is little endian, you need to do the actual conversion.

VojislavM commented 8 years ago

Thanks for the advice. MCU has little endian. I wrote my functions for ntohs, htons, and htonl.