// Translate our match fields into openflow 1.3 match fields func (self *Flow) xlateMatch() openflow13.Match { ofMatch := openflow13.NewMatch() // Handle input poty if self.Match.InputPort != 0 { inportField := openflow13.NewInPortField(self.Match.InputPort) ofMatch.AddField(*inportField) } // Handle mac DA field if self.Match.MacDa != nil { if self.Match.MacDaMask != nil { macDaField := openflow13.NewEthDstField(*self.Match.MacDa, self.Match.MacDaMask) ofMatch.AddField(*macDaField) } else { macDaField := openflow13.NewEthDstField(*self.Match.MacDa, nil) ofMatch.AddField(*macDaField) } } // Handle MacSa field if self.Match.MacSa != nil { if self.Match.MacSaMask != nil { macSaField := openflow13.NewEthSrcField(*self.Match.MacSa, self.Match.MacSaMask) ofMatch.AddField(*macSaField) } else { macSaField := openflow13.NewEthSrcField(*self.Match.MacSa, nil) ofMatch.AddField(*macSaField) } } // Handle ethertype if self.Match.Ethertype != 0 { etypeField := openflow13.NewEthTypeField(self.Match.Ethertype) ofMatch.AddField(*etypeField) } // Handle Vlan id if self.Match.VlanId != 0 { if self.Match.VlanIdMask != nil { vidField := openflow13.NewVlanIdField(self.Match.VlanId, self.Match.VlanIdMask) ofMatch.AddField(*vidField) } else { vidField := openflow13.NewVlanIdField(self.Match.VlanId, nil) ofMatch.AddField(*vidField) } } // Handle MPLS Label -SRTE if self.Match.MplsLabel != 0 { mplsLabelField := openflow13.NewMplsLabelField(self.Match.MplsLabel) ofMatch.AddField(*mplsLabelField) } // Handle MPLS Bos -SRTE if self.Match.MplsBos != 0 { mplsBosField := openflow13.NewMplsBosField(self.Match.MplsBos) ofMatch.AddField(*mplsBosField) } // Handle ARP Oper type if self.Match.ArpOper != 0 { arpOperField := openflow13.NewArpOperField(self.Match.ArpOper) ofMatch.AddField(*arpOperField) } // Handle IP Dst if self.Match.IpDa != nil { if self.Match.IpDaMask != nil { ipDaField := openflow13.NewIpv4DstField(*self.Match.IpDa, self.Match.IpDaMask) ofMatch.AddField(*ipDaField) } else { ipDaField := openflow13.NewIpv4DstField(*self.Match.IpDa, nil) ofMatch.AddField(*ipDaField) } } // Handle IP Src if self.Match.IpSa != nil { if self.Match.IpSaMask != nil { ipSaField := openflow13.NewIpv4SrcField(*self.Match.IpSa, self.Match.IpSaMask) ofMatch.AddField(*ipSaField) } else { ipSaField := openflow13.NewIpv4SrcField(*self.Match.IpSa, nil) ofMatch.AddField(*ipSaField) } } // Handle IPv6 Dst if self.Match.Ipv6Da != nil { if self.Match.Ipv6DaMask != nil { ipv6DaField := openflow13.NewIpv6DstField(*self.Match.Ipv6Da, self.Match.Ipv6DaMask) ofMatch.AddField(*ipv6DaField) } else { ipv6DaField := openflow13.NewIpv6DstField(*self.Match.Ipv6Da, nil) ofMatch.AddField(*ipv6DaField) } } // Handle IPv6 Src if self.Match.Ipv6Sa != nil { if self.Match.Ipv6SaMask != nil { ipv6SaField := openflow13.NewIpv6SrcField(*self.Match.Ipv6Sa, self.Match.Ipv6SaMask) ofMatch.AddField(*ipv6SaField) } else { ipv6SaField := openflow13.NewIpv6SrcField(*self.Match.Ipv6Sa, nil) ofMatch.AddField(*ipv6SaField) } } // Handle IP protocol if self.Match.IpProto != 0 { protoField := openflow13.NewIpProtoField(self.Match.IpProto) ofMatch.AddField(*protoField) } // Handle port numbers if self.Match.IpProto == IP_PROTO_TCP && self.Match.TcpSrcPort != 0 { portField := openflow13.NewTcpSrcField(self.Match.TcpSrcPort) ofMatch.AddField(*portField) } if self.Match.IpProto == IP_PROTO_TCP && self.Match.TcpDstPort != 0 { portField := openflow13.NewTcpDstField(self.Match.TcpDstPort) ofMatch.AddField(*portField) } if self.Match.IpProto == IP_PROTO_UDP && self.Match.UdpSrcPort != 0 { portField := openflow13.NewUdpSrcField(self.Match.UdpSrcPort) ofMatch.AddField(*portField) } if self.Match.IpProto == IP_PROTO_UDP && self.Match.UdpDstPort != 0 { portField := openflow13.NewUdpDstField(self.Match.UdpDstPort) ofMatch.AddField(*portField) } // Handle tcp flags if self.Match.IpProto == IP_PROTO_TCP && self.Match.TcpFlags != nil { tcpFlagField := openflow13.NewTcpFlagsField(*self.Match.TcpFlags, self.Match.TcpFlagsMask) ofMatch.AddField(*tcpFlagField) } // Handle metadata if self.Match.Metadata != nil { if self.Match.MetadataMask != nil { metadataField := openflow13.NewMetadataField(*self.Match.Metadata, self.Match.MetadataMask) ofMatch.AddField(*metadataField) } else { metadataField := openflow13.NewMetadataField(*self.Match.Metadata, nil) ofMatch.AddField(*metadataField) } } // Handle Vxlan tunnel id if self.Match.TunnelId != 0 { tunnelIdField := openflow13.NewTunnelIdField(self.Match.TunnelId) ofMatch.AddField(*tunnelIdField) } return *ofMatch }
// Translate our match fields into openflow 1.3 match fields func (self *Flow) xlateMatch() openflow13.Match { ofMatch := openflow13.NewMatch() // Handle input poty if self.Match.InputPort != 0 { inportField := openflow13.NewInPortField(self.Match.InputPort) ofMatch.AddField(*inportField) } // Handle mac DA field if self.Match.MacDa != nil { if self.Match.MacDaMask != nil { macDaField := openflow13.NewEthDstField(*self.Match.MacDa, self.Match.MacDaMask) ofMatch.AddField(*macDaField) } else { macDaField := openflow13.NewEthDstField(*self.Match.MacDa, nil) ofMatch.AddField(*macDaField) } } // Handle MacSa field if self.Match.MacSa != nil { if self.Match.MacSaMask != nil { macSaField := openflow13.NewEthSrcField(*self.Match.MacSa, self.Match.MacSaMask) ofMatch.AddField(*macSaField) } else { macSaField := openflow13.NewEthSrcField(*self.Match.MacSa, nil) ofMatch.AddField(*macSaField) } } // Handle ethertype if self.Match.Ethertype != 0 { etypeField := openflow13.NewEthTypeField(self.Match.Ethertype) ofMatch.AddField(*etypeField) } // Handle Vlan id if self.Match.VlanId != 0 { vidField := openflow13.NewVlanIdField(self.Match.VlanId) ofMatch.AddField(*vidField) } // Handle IP Dst if self.Match.IpDa != nil { if self.Match.IpDaMask != nil { ipDaField := openflow13.NewIpv4DstField(*self.Match.IpDa, self.Match.IpDaMask) ofMatch.AddField(*ipDaField) } else { ipDaField := openflow13.NewIpv4DstField(*self.Match.IpDa, nil) ofMatch.AddField(*ipDaField) } } // Handle IP Src if self.Match.IpSa != nil { if self.Match.IpSaMask != nil { ipSaField := openflow13.NewIpv4SrcField(*self.Match.IpSa, self.Match.IpSaMask) ofMatch.AddField(*ipSaField) } else { ipSaField := openflow13.NewIpv4SrcField(*self.Match.IpSa, nil) ofMatch.AddField(*ipSaField) } } // Handle IP protocol if self.Match.IpProto != 0 { protoField := openflow13.NewIpProtoField(self.Match.IpProto) ofMatch.AddField(*protoField) } // Handle port numbers if self.Match.IpProto == IP_PROTO_TCP && self.Match.TcpSrcPort != 0 { portField := openflow13.NewTcpSrcField(self.Match.TcpSrcPort) ofMatch.AddField(*portField) } if self.Match.IpProto == IP_PROTO_TCP && self.Match.TcpDstPort != 0 { portField := openflow13.NewTcpDstField(self.Match.TcpDstPort) ofMatch.AddField(*portField) } if self.Match.IpProto == IP_PROTO_UDP && self.Match.UdpSrcPort != 0 { portField := openflow13.NewUdpSrcField(self.Match.UdpSrcPort) ofMatch.AddField(*portField) } if self.Match.IpProto == IP_PROTO_UDP && self.Match.UdpDstPort != 0 { portField := openflow13.NewUdpDstField(self.Match.UdpDstPort) ofMatch.AddField(*portField) } // Handle metadata if self.Match.Metadata != nil { if self.Match.MetadataMask != nil { metadataField := openflow13.NewMetadataField(*self.Match.Metadata, self.Match.MetadataMask) ofMatch.AddField(*metadataField) } else { metadataField := openflow13.NewMetadataField(*self.Match.Metadata, nil) ofMatch.AddField(*metadataField) } } // Handle Vxlan tunnel id if self.Match.TunnelId != 0 { tunnelIdField := openflow13.NewTunnelIdField(self.Match.TunnelId) ofMatch.AddField(*tunnelIdField) } return *ofMatch }
// Translate our match fields into openflow 1.3 match fields func (self *Flow) xlateMatch() openflow13.Match { ofMatch := openflow13.NewMatch() if self.Match.InputPort != 0 { inportField := openflow13.NewInPortField(self.Match.InputPort) ofMatch.AddField(*inportField) } if self.Match.MacDa != nil { if self.Match.MacDaMask != nil { macDaField := openflow13.NewEthDstField(*self.Match.MacDa, self.Match.MacDaMask) ofMatch.AddField(*macDaField) } else { macDaField := openflow13.NewEthDstField(*self.Match.MacDa, nil) ofMatch.AddField(*macDaField) } } if self.Match.MacSa != nil { if self.Match.MacSaMask != nil { macSaField := openflow13.NewEthSrcField(*self.Match.MacSa, self.Match.MacSaMask) ofMatch.AddField(*macSaField) } else { macSaField := openflow13.NewEthSrcField(*self.Match.MacSa, nil) ofMatch.AddField(*macSaField) } } if self.Match.Ethertype != 0 { etypeField := openflow13.NewEthTypeField(self.Match.Ethertype) ofMatch.AddField(*etypeField) } if self.Match.VlanId != 0 { vidField := openflow13.NewVlanIdField(self.Match.VlanId) ofMatch.AddField(*vidField) } if self.Match.IpDa != nil { if self.Match.IpDaMask != nil { ipDaField := openflow13.NewIpv4DstField(*self.Match.IpDa, self.Match.IpDaMask) ofMatch.AddField(*ipDaField) } else { ipDaField := openflow13.NewIpv4DstField(*self.Match.IpDa, nil) ofMatch.AddField(*ipDaField) } } if self.Match.IpSa != nil { if self.Match.IpSaMask != nil { ipSaField := openflow13.NewIpv4SrcField(*self.Match.IpSa, self.Match.IpSaMask) ofMatch.AddField(*ipSaField) } else { ipSaField := openflow13.NewIpv4SrcField(*self.Match.IpSa, nil) ofMatch.AddField(*ipSaField) } } if self.Match.Metadata != nil { if self.Match.MetadataMask != nil { metadataField := openflow13.NewMetadataField(*self.Match.Metadata, self.Match.MetadataMask) ofMatch.AddField(*metadataField) } else { metadataField := openflow13.NewMetadataField(*self.Match.Metadata, nil) ofMatch.AddField(*metadataField) } } if self.Match.TunnelId != 0 { tunnelIdField := openflow13.NewTunnelIdField(self.Match.TunnelId) ofMatch.AddField(*tunnelIdField) } return *ofMatch }