mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-12-08 23:03:46 +00:00
118 lines
3.2 KiB
Diff
118 lines
3.2 KiB
Diff
From 7348f406a6de412ef070d5e384e35a31e355564d Mon Sep 17 00:00:00 2001
|
|
From: Kevin Mihelich <kevin@archlinuxarm.org>
|
|
Date: Wed, 7 May 2014 15:47:33 -0600
|
|
Subject: [PATCH 3/3] setBridgeMacAddress ARM support
|
|
|
|
---
|
|
pkg/netlink/netlink_linux.go | 19 -------------------
|
|
pkg/netlink/setbridgemacaddress_amd64.go | 27 +++++++++++++++++++++++++++
|
|
pkg/netlink/setbridgemacaddress_arm.go | 27 +++++++++++++++++++++++++++
|
|
3 files changed, 54 insertions(+), 19 deletions(-)
|
|
create mode 100644 pkg/netlink/setbridgemacaddress_amd64.go
|
|
create mode 100644 pkg/netlink/setbridgemacaddress_arm.go
|
|
|
|
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
|
|
--
|
|
1.9.0
|
|
|