[PATCH] NIPQUAD macro broken on big endian

Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
07 Oct 1998 11:09:08 +0200


The NIPQUAD makro is broken on big endian machines. The argument is a
number in network byte order.

--- linux/include/linux/kernel.h.~1~ Wed Oct 7 11:06:36 1998
+++ linux/include/linux/kernel.h Wed Oct 7 11:08:43 1998
@@ -69,10 +69,10 @@
*/

#define NIPQUAD(addr) \
- (int)(((addr) >> 0) & 0xff), \
- (int)(((addr) >> 8) & 0xff), \
- (int)(((addr) >> 16) & 0xff), \
- (int)(((addr) >> 24) & 0xff)
+ (int)((ntohl(addr) >> 24) & 0xff), \
+ (int)((ntohl(addr) >> 16) & 0xff), \
+ (int)((ntohl(addr) >> 8) & 0xff), \
+ (int)((ntohl(addr) >> 0) & 0xff)

#endif /* __KERNEL__ */

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/