-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice.go
67 lines (57 loc) · 1.21 KB
/
device.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package mxio
import "C"
import "net"
type DeviceType C.int
const (
E4000_SERIES = DeviceType(1)
E2000_SERIES = DeviceType(2)
E4200_SERIES = DeviceType(4)
E1200_SERIES = DeviceType(8)
W5000_SERIES = DeviceType(16)
E1500_SERIES = DeviceType(64)
IOPac8000_SERIES = DeviceType(128)
AOPC_SERVER = DeviceType(256)
ALL_DEVICES = DeviceType(511)
)
type lan uint8
const (
Lan0 = lan(0)
Lan1 = lan(1)
)
func (l lan) String() string {
switch l {
case Lan0:
return "Lan0"
case Lan1:
return "Lan1"
default:
return "Unknown"
}
}
// Device describes a device that could be on the network.
type Device struct {
// This is the ID of the device.
ID deviceid
// The is the IP of the first network port on the device
IP net.IP
// This is the MAC address of the frist network port.
MAC net.HardwareAddr
// IP of the second network port.
IP1 net.IP
// MAC address of the second network port.
MAC1 net.HardwareAddr
// Which lan port is in use. These can be the valus Lan0 or Lan1
LanUse lan
}
func (d Device) LanIP() net.IP {
if d.LanUse == Lan0 {
return d.IP
}
return d.IP1
}
func (d Device) LanMAC() net.HardwareAddr {
if d.LanUse == Lan0 {
return d.MAC
}
return d.MAC1
}