We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 481f960 + 5509403 commit 7c32bbeCopy full SHA for 7c32bbe
src/utility/w5100.h
@@ -455,14 +455,23 @@ extern W5100Class W5100;
455
#define UTIL_H
456
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)
461
-#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
466
#define ntohs(x) htons(x)
467
468
+// Host to Network long
469
#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
470
((x)<< 8 & 0x00FF0000UL) | \
471
((x)>> 8 & 0x0000FF00UL) | \
472
((x)>>24 & 0x000000FFUL) )
473
474
+// Network to Host long
475
#define ntohl(x) htonl(x)
476
477
#endif // !defined(htons)
0 commit comments