func NewFlowRemoved() *FlowRemoved { f := new(FlowRemoved) f.Header = ofpxx.NewOfp10Header() f.Match = *NewMatch() f.pad = make([]byte, 1) f.pad2 = make([]byte, 2) return f }
func NewSetConfig() *SwitchConfig { c := new(SwitchConfig) c.Header = ofpxx.NewOfp10Header() c.Header.Type = Type_SetConfig c.Flags = 0 c.MissSendLen = 0 return c }
func NewPacketIn() *PacketIn { p := new(PacketIn) p.Header = ofpxx.NewOfp10Header() p.Header.Type = Type_PacketIn p.BufferId = 0xffffffff p.InPort = P_NONE p.Reason = 0 return p }
// FeaturesReply constructor func NewFeaturesReply() *SwitchFeatures { res := new(SwitchFeatures) res.Header = ofpxx.NewOfp10Header() res.Header.Type = Type_FeaturesReply res.DPID = make([]byte, 8) res.pad = make([]byte, 3) res.Ports = make([]PhyPort, 0) return res }
func NewPacketOut() *PacketOut { p := new(PacketOut) p.Header = ofpxx.NewOfp10Header() p.Header.Type = Type_PacketOut p.BufferId = 0xffffffff p.InPort = P_NONE p.ActionsLen = 0 p.Actions = make([]Action, 0) return p }
func NewFlowMod() *FlowMod { f := new(FlowMod) f.Header = ofpxx.NewOfp10Header() f.Header.Type = Type_FlowMod f.Match = *NewMatch() // Add a generator for f.Cookie here f.Cookie = 0 f.Command = FC_ADD f.IdleTimeout = 0 f.HardTimeout = 0 // Add a priority gen here f.Priority = 1000 f.BufferId = 0xffffffff f.OutPort = P_NONE f.Flags = 0 f.Actions = make([]Action, 0) return f }
func NewPortStatus() *PortStatus { p := new(PortStatus) p.Header = ofpxx.NewOfp10Header() p.pad = make([]byte, 7) return p }
// Echo request/reply messages can be sent from either the // switch or the controller, and must return an echo reply. They // can be used to indicate the latency, bandwidth, and/or // liveness of a controller-switch connection. func NewEchoReply() *ofpxx.Header { h := ofpxx.NewOfp10Header() h.Type = Type_EchoReply return &h }
// Echo request/reply messages can be sent from either the // switch or the controller, and must return an echo reply. They // can be used to indicate the latency, bandwidth, and/or // liveness of a controller-switch connection. func NewEchoRequest() *ofpxx.Header { h := ofpxx.NewOfp10Header() h.Type = Type_EchoRequest return &h }
// FeaturesRequest constructor func NewFeaturesRequest() *ofpxx.Header { req := ofpxx.NewOfp10Header() req.Type = Type_FeaturesRequest return &req }
func (f *FlowMod) UnmarshalJSON(b []byte) error { type act struct { Type string Value string } type tmp struct { Match *Match Actions []act } s := tmp{} f.Header = ofpxx.NewOfp10Header() f.Header.Type = Type_FlowMod f.Match = *NewMatch() f.Cookie = 0 f.Command = FC_ADD f.IdleTimeout = 0 f.HardTimeout = 0 f.Priority = 1000 f.BufferId = 0xffffffff f.OutPort = P_NONE f.Flags = FC_ADD f.Actions = make([]Action, 0) if err := json.Unmarshal(b, &s); err != nil { return err } if s.Match != nil { f.Match = *s.Match } // f.Match.Wildcards = FW_ALL ^ FW_DL_SRC ^ FW_DL_DST if f.Match.InPort != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_IN_PORT } if f.Match.DLSrc.String() != "00:00:00:00:00:00" { f.Match.Wildcards = f.Match.Wildcards ^ FW_DL_SRC } if f.Match.DLDst.String() != "00:00:00:00:00:00" { f.Match.Wildcards = f.Match.Wildcards ^ FW_DL_DST } if f.Match.DLVLAN != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_DL_VLAN } if f.Match.DLVLANPcp != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_DL_VLAN_PCP } if f.Match.DLType != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_DL_TYPE } if f.Match.NWTos != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_NW_TOS } if f.Match.NWProto != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_NW_PROTO } if f.Match.NWSrc.String() != "0.0.0.0" { f.Match.Wildcards = f.Match.Wildcards ^ FW_NW_SRC_MASK } if f.Match.NWDst.String() != "0.0.0.0" { f.Match.Wildcards = f.Match.Wildcards ^ FW_NW_DST_MASK } if f.Match.TPSrc != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_TP_SRC } if f.Match.TPDst != 0 { f.Match.Wildcards = f.Match.Wildcards ^ FW_TP_DST } strPorts := map[string]uint16{ "P_MAX": P_MAX, "P_IN_PORT": P_IN_PORT, "P_TABLE": P_TABLE, "P_NORMAL": P_NORMAL, "P_FLOOD": P_FLOOD, "P_ALL": P_ALL, "P_CONTROLLER": P_CONTROLLER, "P_LOCAL": P_LOCAL, "P_NONE": P_NONE, } for _, a := range s.Actions { switch a.Type { case "OFPAT_OUTPUT": v, found := strPorts[a.Value] if !found { i, err := strconv.Atoi(a.Value) if err != nil { return err } v = uint16(i) } f.AddAction(NewActionOutput(v)) } } return nil }
func NewConfigRequest() *ofpxx.Header { h := ofpxx.NewOfp10Header() h.Type = Type_GetConfigRequest return &h }