This is mostly a matter of moving some files, changing package names, changing some imports, and changing some type references. We duplicate the odd constant & global var, and the intmac/macint functions, since neither 'router' or 'mesh' nor, really,' common' are a natural home for them.
46 lines
831 B
Go
46 lines
831 B
Go
package router
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/weaveworks/weave/mesh"
|
|
)
|
|
|
|
type NetworkRouterStatus struct {
|
|
*mesh.Status
|
|
Interface string
|
|
CaptureStats map[string]int
|
|
MACs []MACStatus
|
|
}
|
|
|
|
type MACStatus struct {
|
|
Mac string
|
|
Name string
|
|
NickName string
|
|
LastSeen time.Time
|
|
}
|
|
|
|
func NewNetworkRouterStatus(router *NetworkRouter) *NetworkRouterStatus {
|
|
return &NetworkRouterStatus{
|
|
mesh.NewStatus(router.Router),
|
|
router.Bridge.String(),
|
|
router.Bridge.Stats(),
|
|
NewMACStatusSlice(router.Macs)}
|
|
}
|
|
|
|
func NewMACStatusSlice(cache *MacCache) []MACStatus {
|
|
cache.RLock()
|
|
defer cache.RUnlock()
|
|
|
|
var slice []MACStatus
|
|
for key, entry := range cache.table {
|
|
slice = append(slice, MACStatus{
|
|
intmac(key).String(),
|
|
entry.peer.Name.String(),
|
|
entry.peer.NickName,
|
|
entry.lastSeen})
|
|
}
|
|
|
|
return slice
|
|
}
|