mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-12-08 23:03:46 +00:00
103 lines
2.6 KiB
Diff
103 lines
2.6 KiB
Diff
|
diff --git a/pkg/netlink/netlink_linux.go b/pkg/netlink/netlink_linux.go
|
||
|
index 6de293d..77a411b 100644
|
||
|
--- a/pkg/netlink/netlink_linux.go
|
||
|
+++ b/pkg/netlink/netlink_linux.go
|
||
|
@@ -5,7 +5,6 @@ package netlink
|
||
|
import (
|
||
|
"encoding/binary"
|
||
|
"fmt"
|
||
|
- "math/rand"
|
||
|
"net"
|
||
|
"syscall"
|
||
|
"unsafe"
|
||
|
@@ -871,21 +870,3 @@ func AddToBridge(iface, master *net.Interface) error {
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
-
|
||
|
-func setBridgeMacAddress(s int, name string) error {
|
||
|
- ifr := ifreqHwaddr{}
|
||
|
- ifr.IfruHwaddr.Family = syscall.ARPHRD_ETHER
|
||
|
- copy(ifr.IfrnName[:], name)
|
||
|
-
|
||
|
- for i := 0; i < 6; i++ {
|
||
|
- ifr.IfruHwaddr.Data[i] = int8(rand.Intn(255))
|
||
|
- }
|
||
|
-
|
||
|
- ifr.IfruHwaddr.Data[0] &^= 0x1 // clear multicast bit
|
||
|
- ifr.IfruHwaddr.Data[0] |= 0x2 // set local assignment bit (IEEE802)
|
||
|
-
|
||
|
- if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), syscall.SIOCSIFHWADDR, uintptr(unsafe.Pointer(&ifr))); err != 0 {
|
||
|
- return err
|
||
|
- }
|
||
|
- return nil
|
||
|
-}
|
||
|
diff --git a/pkg/netlink/setbridgemacaddress_amd64.go b/pkg/netlink/setbridgemacaddress_amd64.go
|
||
|
new file mode 100644
|
||
|
index 0000000..f6e799e
|
||
|
--- /dev/null
|
||
|
+++ b/pkg/netlink/setbridgemacaddress_amd64.go
|
||
|
@@ -0,0 +1,27 @@
|
||
|
+// +build amd64
|
||
|
+
|
||
|
+package netlink
|
||
|
+
|
||
|
+import (
|
||
|
+ "math/rand"
|
||
|
+ "syscall"
|
||
|
+ "unsafe"
|
||
|
+)
|
||
|
+
|
||
|
+func setBridgeMacAddress(s int, name string) error {
|
||
|
+ ifr := ifreqHwaddr{}
|
||
|
+ ifr.IfruHwaddr.Family = syscall.ARPHRD_ETHER
|
||
|
+ copy(ifr.IfrnName[:], name)
|
||
|
+
|
||
|
+ for i := 0; i < 6; i++ {
|
||
|
+ ifr.IfruHwaddr.Data[i] = int8(rand.Intn(255))
|
||
|
+ }
|
||
|
+
|
||
|
+ ifr.IfruHwaddr.Data[0] &^= 0x1 // clear multicast bit
|
||
|
+ ifr.IfruHwaddr.Data[0] |= 0x2 // set local assignment bit (IEEE802)
|
||
|
+
|
||
|
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), syscall.SIOCSIFHWADDR, uintptr(unsafe.Pointer(&ifr))); err != 0 {
|
||
|
+ return err
|
||
|
+ }
|
||
|
+ return nil
|
||
|
+}
|
||
|
\ No newline at end of file
|
||
|
diff --git a/pkg/netlink/setbridgemacaddress_arm.go b/pkg/netlink/setbridgemacaddress_arm.go
|
||
|
new file mode 100644
|
||
|
index 0000000..a5e59c5
|
||
|
--- /dev/null
|
||
|
+++ b/pkg/netlink/setbridgemacaddress_arm.go
|
||
|
@@ -0,0 +1,27 @@
|
||
|
+// +build arm
|
||
|
+
|
||
|
+package netlink
|
||
|
+
|
||
|
+import (
|
||
|
+ "math/rand"
|
||
|
+ "syscall"
|
||
|
+ "unsafe"
|
||
|
+)
|
||
|
+
|
||
|
+func setBridgeMacAddress(s int, name string) error {
|
||
|
+ ifr := ifreqHwaddr{}
|
||
|
+ ifr.IfruHwaddr.Family = syscall.ARPHRD_ETHER
|
||
|
+ copy(ifr.IfrnName[:], name)
|
||
|
+
|
||
|
+ for i := 0; i < 6; i++ {
|
||
|
+ ifr.IfruHwaddr.Data[i] = uint8(rand.Intn(128))
|
||
|
+ }
|
||
|
+
|
||
|
+ ifr.IfruHwaddr.Data[0] &^= 0x1 // clear multicast bit
|
||
|
+ ifr.IfruHwaddr.Data[0] |= 0x2 // set local assignment bit (IEEE802)
|
||
|
+
|
||
|
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), syscall.SIOCSIFHWADDR, uintptr(unsafe.Pointer(&ifr))); err != 0 {
|
||
|
+ return err
|
||
|
+ }
|
||
|
+ return nil
|
||
|
+}
|
||
|
\ No newline at end of file
|