File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -455,14 +455,23 @@ extern W5100Class W5100;
455455#define UTIL_H
456456
457457#ifndef htons
458+ // The host order of the Arduino platform is little endian.
459+ // Sometimes it is desired to convert to big endian (or
460+ // network order)
458461
459- #define htons (x ) ( (((x)<<8 )&0xFF00 ) | (((x)>>8 )&0xFF ) )
462+ // Host to Network short
463+ #define htons (x ) ( (((x)&0xFF )<<8 ) | (((x)>>8 )&0xFF ) )
464+
465+ // Network to Host short
460466#define ntohs (x ) htons(x)
461467
468+ // Host to Network long
462469#define htonl (x ) ( ((x)<<24 & 0xFF000000UL ) | \
463470 ((x)<< 8 & 0x00FF0000UL ) | \
464471 ((x)>> 8 & 0x0000FF00UL ) | \
465472 ((x)>>24 & 0x000000FFUL ) )
473+
474+ // Network to Host long
466475#define ntohl (x ) htonl(x)
467476
468477#endif // !defined(htons)
You can’t perform that action at this time.
0 commit comments