-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathofswitch.go
37 lines (30 loc) · 869 Bytes
/
ofswitch.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
package goof
import (
"encoding/binary"
"net"
"github.com/kopwei/goof/protocols/ofp10"
)
// DatapathID represents the datapath object
type DatapathID struct {
rawValue uint64
}
// GetRawValue is used to retrieve the raw value of the datapth
func (dpid *DatapathID) GetRawValue() uint64 {
return dpid.rawValue
}
// GetHwAddr is used to retrieve the mac addr of the datapath
func (dpid *DatapathID) GetHwAddr() net.HardwareAddr {
hardwareAddr := make([]byte, 8)
binary.BigEndian.PutUint64(hardwareAddr, dpid.rawValue)
return hardwareAddr
}
// OpenflowSwitch descibes the switch supports openflow
type OpenflowSwitch interface {
GetDatapathID() *DatapathID
DoesSupportOFVer(ofpversion uint8) bool
}
// NewSwitch generates a new switch object
func NewSwitch(tunnel *OfpMessageTunnel, msg *ofp10.OfpSwitchFeatureMsg) OpenflowSwitch {
// TODO
return nil
}