diff --git a/experimental/libbox/link_flags_linux.go b/experimental/libbox/link_flags_linux.go new file mode 100644 index 00000000..aa9ad46d --- /dev/null +++ b/experimental/libbox/link_flags_linux.go @@ -0,0 +1,30 @@ +package libbox + +import ( + "net" + "syscall" +) + +// copied from net.linkFlags +func linkFlags(rawFlags uint32) net.Flags { + var f net.Flags + if rawFlags&syscall.IFF_UP != 0 { + f |= net.FlagUp + } + if rawFlags&syscall.IFF_RUNNING != 0 { + f |= net.FlagRunning + } + if rawFlags&syscall.IFF_BROADCAST != 0 { + f |= net.FlagBroadcast + } + if rawFlags&syscall.IFF_LOOPBACK != 0 { + f |= net.FlagLoopback + } + if rawFlags&syscall.IFF_POINTOPOINT != 0 { + f |= net.FlagPointToPoint + } + if rawFlags&syscall.IFF_MULTICAST != 0 { + f |= net.FlagMulticast + } + return f +} diff --git a/experimental/libbox/link_flags_stub.go b/experimental/libbox/link_flags_stub.go new file mode 100644 index 00000000..306754f3 --- /dev/null +++ b/experimental/libbox/link_flags_stub.go @@ -0,0 +1,11 @@ +//go:build !linux + +package libbox + +import ( + "net" +) + +func linkFlags(rawFlags uint32) net.Flags { + panic("stub!") +} diff --git a/experimental/libbox/platform.go b/experimental/libbox/platform.go index 4078140f..e2bf8e8e 100644 --- a/experimental/libbox/platform.go +++ b/experimental/libbox/platform.go @@ -38,6 +38,7 @@ type NetworkInterface struct { MTU int32 Name string Addresses StringIterator + Flags int32 } type WIFIState struct { diff --git a/experimental/libbox/service.go b/experimental/libbox/service.go index 7e2e1414..53ca168c 100644 --- a/experimental/libbox/service.go +++ b/experimental/libbox/service.go @@ -181,6 +181,7 @@ func (w *platformInterfaceWrapper) Interfaces() ([]control.Interface, error) { MTU: int(netInterface.MTU), Name: netInterface.Name, Addresses: common.Map(iteratorToArray[string](netInterface.Addresses), netip.MustParsePrefix), + Flags: linkFlags(uint32(netInterface.Flags)), }) } return interfaces, nil