浏览代码

Merge pull request #703 from linux-on-ibm-z/udp_test_update_s390x

network order functionality changed based on endianess
Tom Denham 8 年之前
父节点
当前提交
40ad3622dc
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      pkg/ip/ipnet.go

+ 6 - 2
pkg/ip/ipnet.go

@@ -60,8 +60,12 @@ func (ip IP4) ToIP() net.IP {
 }
 
 func (ip IP4) NetworkOrder() uint32 {
-	a, b, c, d := byte(ip>>24), byte(ip>>16), byte(ip>>8), byte(ip)
-	return uint32(a) | (uint32(b) << 8) | (uint32(c) << 16) | (uint32(d) << 24)
+	if NativelyLittle() {
+		a, b, c, d := byte(ip>>24), byte(ip>>16), byte(ip>>8), byte(ip)
+		return uint32(a) | (uint32(b) << 8) | (uint32(c) << 16) | (uint32(d) << 24)
+	} else {
+		return uint32(ip)
+	}
 }
 
 func (ip IP4) String() string {