forked from klauspost/oui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.go
34 lines (30 loc) · 908 Bytes
/
entry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package oui
import (
"strings"
)
//go:generate: ffjson -nodecoder $(GOFILE)
// A database Entry the represents the data in the oui database.
// Local and Multicast
type Entry struct {
Manufacturer string `json:"manufacturer"`
Address []string `json:"address"`
Prefix HardwareAddr `json:"prefix"`
Country string `json:"country,omitempty"`
Local bool `json:"local,omitempty"`
Multicast bool `json:"multicast,omitempty"`
}
// Returns a formatted string representation of the entry
func (e Entry) String() string {
t := []string{"Prefix: " + e.Prefix.String(), "Manufacturer: " + e.Manufacturer}
if len(e.Address) > 0 {
a := strings.Join(e.Address, "\n\t")
t = append(t, "Address:", "\t"+a)
}
if e.Local {
t = append(t, "* Locally Administered")
}
if e.Multicast {
t = append(t, "* Multicast")
}
return strings.Join(t, "\n")
}