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;
455
455
#define UTIL_H
456
456
457
457
#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)
458
461
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
460
466
#define ntohs (x ) htons(x)
461
467
468
+ // Host to Network long
462
469
#define htonl (x ) ( ((x)<<24 & 0xFF000000UL ) | \
463
470
((x)<< 8 & 0x00FF0000UL ) | \
464
471
((x)>> 8 & 0x0000FF00UL ) | \
465
472
((x)>>24 & 0x000000FFUL ) )
473
+
474
+ // Network to Host long
466
475
#define ntohl (x ) htonl(x)
467
476
468
477
#endif // !defined(htons)
You can’t perform that action at this time.
0 commit comments