Closed VojislavM closed 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.
Thanks for the advice. MCU has little endian. I wrote my functions for ntohs, htons, and htonl.
I have a problem with:
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?