Inject match entry deserializers into MatchDeserializer.
These deserializers will deserialize these match entries:
- ArpOp
- ArpSha
- ArpSpa
- ArpTha
- ArpTpa
- InPort
- InPhyPort
- EthSrc
- EthDst
- EthType
- Metadata
- VlanPcp
- VlanVid
- IpDscp
- IpEcn
- IpProto
- TcpSrc
- TcpDst
- UdpSrc
- UdpDst
- SctpSrc
- SctpDst
- Icmpv4Code
- Icmpv4Type
- Icmpv6Code
- Icmpv6Type
- Ipv4Source
- Ipv4Destination
- Ipv6Source
- Ipv6Destination
- Ipv6ExtHeader
- Ipv6Flabel
- Ipv6NdSll
- Ipv6NdTll
- Ipv6NdTarget
- MplsLabel
- MplsBos
- MplsTc
- PbbIsid
- TunnelId
- TcpFlags
Change-Id: Ic584d4610f2b2230542e449d3fae3f4affcc2756
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.tech>
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey;
import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MatchDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MatchDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MatchEntryDeserializer;
import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MatchEntryDeserializerRegistry;
import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpOpEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpSourceHardwareAddressEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpSourceTransportAddressEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpTargetHardwareAddressEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpTargetTransportAddressEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.EthernetDestinationEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.EthernetSourceEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.EthernetTypeEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv4CodeEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv4TypeEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv6CodeEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv6TypeEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.InPhyPortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.InPortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.IpDscpEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.IpEcnEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.IpProtoEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv4DestinationEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv4SourceEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6DestinationEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6ExtHeaderEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6FlabelEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6NdSllEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6NdTargetEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6NdTllEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6SourceEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MatchDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MetadataEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MplsBosEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MplsLabelEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MplsTcEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.PbbEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.SctpDestinationPortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.SctpSourcePortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TcpDestinationPortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TcpFlagsEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TcpSourcePortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TunnelIdEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.UdpDestinationPortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.UdpSourcePortEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.VlanPcpEntryDeserializer;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.match.VlanVidEntryDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
/**
// Inject new match entry serializers here using injector created by createInjector method
final Function<Integer, Function<Long, Function<Integer, Consumer<MatchEntryDeserializer>>>> injector =
createInjector(deserializer, EncodeConstants.OF13_VERSION_ID);
+
+
+ // Wrapped injector that uses OPENFLOW_BASIC_CLASS
+ final Function<Integer, Consumer<MatchEntryDeserializer>> basicInjector =
+ injector.apply(OxmMatchConstants.OPENFLOW_BASIC_CLASS).apply(null);
+
+ // Wrapped injector that uses EXPERIMENTER_CLASS
+ final Function<Long, Function<Integer, Consumer<MatchEntryDeserializer>>> experInjector =
+ injector.apply(OxmMatchConstants.EXPERIMENTER_CLASS);
+
+ basicInjector.apply(OxmMatchConstants.ARP_OP).accept(new ArpOpEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ARP_SHA).accept(new ArpSourceHardwareAddressEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ARP_THA).accept(new ArpTargetHardwareAddressEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ARP_SPA).accept(new ArpSourceTransportAddressEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ARP_TPA).accept(new ArpTargetTransportAddressEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IN_PORT).accept(new InPortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IN_PHY_PORT).accept(new InPhyPortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.METADATA).accept(new MetadataEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ETH_DST).accept(new EthernetDestinationEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ETH_SRC).accept(new EthernetSourceEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ETH_TYPE).accept(new EthernetTypeEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.VLAN_PCP).accept(new VlanPcpEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.VLAN_VID).accept(new VlanVidEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IP_DSCP).accept(new IpDscpEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IP_ECN).accept(new IpEcnEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IP_PROTO).accept(new IpProtoEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.TCP_SRC).accept(new TcpSourcePortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.TCP_DST).accept(new TcpDestinationPortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.UDP_SRC).accept(new UdpSourcePortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.UDP_DST).accept(new UdpDestinationPortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.SCTP_SRC).accept(new SctpSourcePortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.SCTP_DST).accept(new SctpDestinationPortEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ICMPV4_CODE).accept(new Icmpv4CodeEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ICMPV4_TYPE).accept(new Icmpv4TypeEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ICMPV6_CODE).accept(new Icmpv6CodeEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.ICMPV6_TYPE).accept(new Icmpv6TypeEntryDeserializer());
+ // TODO: How to differentiate between Ipv4 and Tunnel when both are serialized to same format?
+ basicInjector.apply(OxmMatchConstants.IPV4_SRC).accept(new Ipv4SourceEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV4_DST).accept(new Ipv4DestinationEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV6_SRC).accept(new Ipv6SourceEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV6_DST).accept(new Ipv6DestinationEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV6_EXTHDR).accept(new Ipv6ExtHeaderEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV6_FLABEL).accept(new Ipv6FlabelEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV6_ND_SLL).accept(new Ipv6NdSllEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV6_ND_TLL).accept(new Ipv6NdTllEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.IPV6_ND_TARGET).accept(new Ipv6NdTargetEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.MPLS_LABEL).accept(new MplsLabelEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.MPLS_BOS).accept(new MplsBosEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.MPLS_TC).accept(new MplsTcEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.PBB_ISID).accept(new PbbEntryDeserializer());
+ basicInjector.apply(OxmMatchConstants.TUNNEL_ID).accept(new TunnelIdEntryDeserializer());
+ experInjector.apply(EncodeConstants.ONF_EXPERIMENTER_ID).apply(EncodeConstants.ONFOXM_ET_TCP_FLAGS).accept(new TcpFlagsEntryDeserializer());
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+
+public class ArpOpEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final Layer3Match layer3Match = builder.getLayer3Match();
+ final int arpOp = message.readUnsignedShort();
+
+ if (Objects.isNull(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder()
+ .setArpOp(arpOp)
+ .build());
+ } else if (ArpMatch.class.isInstance(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
+ .setArpOp(arpOp)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+
+public class ArpSourceHardwareAddressEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Layer3Match layer3Match = builder.getLayer3Match();
+ final ArpSourceHardwareAddressBuilder arpBuilder = new ArpSourceHardwareAddressBuilder()
+ .setAddress(OxmDeserializerHelper.convertMacAddress(message));
+
+ if (hasMask) {
+ arpBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
+ }
+
+ if (Objects.isNull(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder()
+ .setArpSourceHardwareAddress(arpBuilder.build())
+ .build());
+ } else if (ArpMatch.class.isInstance(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
+ .setArpSourceHardwareAddress(arpBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+
+public class ArpSourceTransportAddressEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Layer3Match layer3Match = builder.getLayer3Match();
+ final Ipv4Prefix prefix = readPrefix(message, hasMask);
+
+ if (Objects.isNull(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder()
+ .setArpSourceTransportAddress(prefix)
+ .build());
+ } else if (ArpMatch.class.isInstance(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
+ .setArpSourceTransportAddress(prefix)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+
+public class ArpTargetHardwareAddressEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Layer3Match layer3Match = builder.getLayer3Match();
+ final ArpTargetHardwareAddressBuilder arpBuilder = new ArpTargetHardwareAddressBuilder()
+ .setAddress(OxmDeserializerHelper.convertMacAddress(message));
+
+ if (hasMask) {
+ arpBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
+ }
+
+ if (Objects.isNull(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder()
+ .setArpTargetHardwareAddress(arpBuilder.build())
+ .build());
+ } else if (ArpMatch.class.isInstance(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
+ .setArpTargetHardwareAddress(arpBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+
+public class ArpTargetTransportAddressEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Layer3Match layer3Match = builder.getLayer3Match();
+ final Ipv4Prefix prefix = readPrefix(message, hasMask);
+
+ if (Objects.isNull(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder()
+ .setArpTargetTransportAddress(prefix)
+ .build());
+ } else if (ArpMatch.class.isInstance(layer3Match)) {
+ builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
+ .setArpTargetTransportAddress(prefix)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+
+public class EthernetDestinationEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final EthernetMatch ethernetMatch = builder.getEthernetMatch();
+ final EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
+ ethernetDestinationBuilder.setAddress(OxmDeserializerHelper.convertMacAddress(message));
+
+ if (hasMask) {
+ ethernetDestinationBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
+ }
+
+ if (Objects.isNull(ethernetMatch)) {
+ builder.setEthernetMatch(new EthernetMatchBuilder()
+ .setEthernetDestination(ethernetDestinationBuilder.build())
+ .build());
+ } else if (Objects.isNull(ethernetMatch.getEthernetDestination())) {
+ builder.setEthernetMatch(new EthernetMatchBuilder(ethernetMatch)
+ .setEthernetDestination(ethernetDestinationBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "ethernetMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+
+public class EthernetSourceEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final EthernetMatch ethernetMatch = builder.getEthernetMatch();
+ final EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
+ ethernetSourceBuilder.setAddress(OxmDeserializerHelper.convertMacAddress(message));
+
+ if (hasMask) {
+ ethernetSourceBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
+ }
+
+ if (Objects.isNull(ethernetMatch)) {
+ builder.setEthernetMatch(new EthernetMatchBuilder()
+ .setEthernetSource(ethernetSourceBuilder.build())
+ .build());
+ } else if (Objects.isNull(ethernetMatch.getEthernetSource())) {
+ builder.setEthernetMatch(new EthernetMatchBuilder(ethernetMatch)
+ .setEthernetSource(ethernetSourceBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "ethernetMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+
+public class EthernetTypeEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final int type = message.readUnsignedShort();
+
+ if (Objects.isNull(builder.getEthernetMatch())) {
+ builder.setEthernetMatch(new EthernetMatchBuilder()
+ .setEthernetType(new EthernetTypeBuilder()
+ .setType(new EtherType(Long.valueOf(type)))
+ .build())
+ .build());
+ } else if (Objects.isNull(builder.getEthernetMatch().getEthernetType())) {
+ builder.setEthernetMatch(new EthernetMatchBuilder(builder.getEthernetMatch())
+ .setEthernetType(new EthernetTypeBuilder()
+ .setType(new EtherType(Long.valueOf(type)))
+ .build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "ethernetMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+
+public class Icmpv4CodeEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short code = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getIcmpv4Match())) {
+ builder.setIcmpv4Match(new Icmpv4MatchBuilder()
+ .setIcmpv4Code(code)
+ .build());
+ } else if (Objects.isNull(builder.getIcmpv4Match().getIcmpv4Code())) {
+ builder.setIcmpv4Match(new Icmpv4MatchBuilder(builder.getIcmpv4Match())
+ .setIcmpv4Code(code)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "icmpv4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
+
+public class Icmpv4TypeEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short type = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getIcmpv4Match())) {
+ builder.setIcmpv4Match(new Icmpv4MatchBuilder()
+ .setIcmpv4Type(type)
+ .build());
+ } else if (Objects.isNull(builder.getIcmpv4Match().getIcmpv4Type())) {
+ builder.setIcmpv4Match(new Icmpv4MatchBuilder(builder.getIcmpv4Match())
+ .setIcmpv4Type(type)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "icmpv4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+
+public class Icmpv6CodeEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short code = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getIcmpv6Match())) {
+ builder.setIcmpv6Match(new Icmpv6MatchBuilder()
+ .setIcmpv6Code(code)
+ .build());
+ } else if (Objects.isNull(builder.getIcmpv6Match().getIcmpv6Code())) {
+ builder.setIcmpv6Match(new Icmpv6MatchBuilder(builder.getIcmpv6Match())
+ .setIcmpv6Code(code)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "icmpv6Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
+
+public class Icmpv6TypeEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short type = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getIcmpv6Match())) {
+ builder.setIcmpv6Match(new Icmpv6MatchBuilder()
+ .setIcmpv6Type(type)
+ .build());
+ } else if (Objects.isNull(builder.getIcmpv6Match().getIcmpv6Type())) {
+ builder.setIcmpv6Match(new Icmpv6MatchBuilder(builder.getIcmpv6Match())
+ .setIcmpv6Type(type)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "icmpv6Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+
+public class InPhyPortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final long port = message.readUnsignedInt();
+
+ if (Objects.isNull(builder.getInPhyPort())) {
+ final String portName = OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, port);
+
+ // We do not assign datapath ID here, because we simply do not have it
+ builder.setInPhyPort(new NodeConnectorId(Objects.isNull(portName) ? String.valueOf(port) : portName));
+ } else {
+ throwErrorOnMalformed(builder, "inPhyPort");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+
+public class InPortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final long port = message.readUnsignedInt();
+
+ if (Objects.isNull(builder.getInPort())) {
+ final String portName = OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, port);
+
+ // We do not assign datapath ID here, because we simply do not have it
+ builder.setInPort(new NodeConnectorId(Objects.isNull(portName) ? String.valueOf(port) : portName));
+ } else {
+ throwErrorOnMalformed(builder, "inPort");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+
+public class IpDscpEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short dscp = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getIpMatch())) {
+ builder.setIpMatch(new IpMatchBuilder()
+ .setIpDscp(new Dscp(dscp))
+ .build());
+ } else if (Objects.isNull(builder.getIpMatch().getIpDscp())) {
+ builder.setIpMatch(new IpMatchBuilder(builder.getIpMatch())
+ .setIpDscp(new Dscp(dscp))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "ipMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+
+public class IpEcnEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short ecn = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getIpMatch())) {
+ builder.setIpMatch(new IpMatchBuilder()
+ .setIpEcn(ecn)
+ .build());
+ } else if (Objects.isNull(builder.getIpMatch().getIpEcn())) {
+ builder.setIpMatch(new IpMatchBuilder(builder.getIpMatch())
+ .setIpEcn(ecn)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "ipMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+
+public class IpProtoEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short proto = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getIpMatch())) {
+ builder.setIpMatch(new IpMatchBuilder()
+ .setIpProtocol(proto)
+ .build());
+ } else if (Objects.isNull(builder.getIpMatch().getIpProtocol())) {
+ builder.setIpMatch(new IpMatchBuilder(builder.getIpMatch())
+ .setIpProtocol(proto)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "ipMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv4DestinationEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Ipv4Address address = ByteBufUtils.readIetfIpv4Address(message);
+
+ if (hasMask) {
+ final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.GROUPS_IN_IPV4_ADDRESS);
+
+ if (IpConversionUtil.isArbitraryBitMask(mask)) {
+ setArbitraryMatch(builder, address, mask);
+ } else {
+ setPrefixMatch(builder, address, mask, hasMask);
+ }
+ } else {
+ setPrefixMatch(builder, address, null, hasMask);
+ }
+ }
+
+ private static void setPrefixMatch(final MatchBuilder builder, final Ipv4Address address,
+ final byte[] mask, final boolean hasMask) {
+ if (hasMask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Destination(IpConversionUtil.createPrefix(address, mask))
+ .build());
+ } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Destination(IpConversionUtil.createPrefix(address, mask))
+ .setIpv4Destination(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Destination())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ } else {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Destination(IpConversionUtil.createPrefix(address))
+ .build());
+ } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Destination(IpConversionUtil.createPrefix(address))
+ .setIpv4Source(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Source())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+ }
+
+ private static void setArbitraryMatch(final MatchBuilder builder, final Ipv4Address address,
+ final byte[] mask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder()
+ .setIpv4DestinationAddressNoMask(address)
+ .setIpv4DestinationArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
+ .build());
+ } else if (Ipv4MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
+ final Ipv4MatchArbitraryBitMask match = Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder()
+ .setIpv4DestinationAddressNoMask(address)
+ .setIpv4DestinationArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
+ .setIpv4SourceAddressNoMask(match.getIpv4SourceAddressNoMask())
+ .setIpv4SourceArbitraryBitmask(match.getIpv4SourceArbitraryBitmask())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv4SourceEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Ipv4Address address = ByteBufUtils.readIetfIpv4Address(message);
+
+ if (hasMask) {
+ final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.GROUPS_IN_IPV4_ADDRESS);
+
+ if (IpConversionUtil.isArbitraryBitMask(mask)) {
+ setArbitraryMatch(builder, address, mask);
+ } else {
+ setPrefixMatch(builder, address, mask, hasMask);
+ }
+ } else {
+ setPrefixMatch(builder, address, null, hasMask);
+ }
+ }
+
+ private static void setPrefixMatch(final MatchBuilder builder, final Ipv4Address address,
+ final byte[] mask, final boolean hasMask) {
+ if (hasMask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Source(IpConversionUtil.createPrefix(address, mask))
+ .build());
+ } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Source(IpConversionUtil.createPrefix(address, mask))
+ .setIpv4Destination(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Destination())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ } else {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Source(IpConversionUtil.createPrefix(address))
+ .build());
+ } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchBuilder()
+ .setIpv4Source(IpConversionUtil.createPrefix(address))
+ .setIpv4Destination(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Destination())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+ }
+
+ private static void setArbitraryMatch(final MatchBuilder builder, final Ipv4Address address,
+ final byte[] mask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder()
+ .setIpv4SourceAddressNoMask(address)
+ .setIpv4SourceArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
+ .build());
+ } else if (Ipv4MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
+ final Ipv4MatchArbitraryBitMask match = Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder()
+ .setIpv4SourceAddressNoMask(address)
+ .setIpv4SourceArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
+ .setIpv4DestinationAddressNoMask(match.getIpv4DestinationAddressNoMask())
+ .setIpv4DestinationArbitraryBitmask(match.getIpv4DestinationArbitraryBitmask())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv6DestinationEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Ipv6Address address = ByteBufUtils.readIetfIpv6Address(message);
+
+ if (hasMask) {
+ final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
+
+ if (IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
+ setArbitraryMatch(builder, address, mask);
+ } else {
+ setPrefixMatch(builder, address, mask, hasMask);
+ }
+ } else {
+ setPrefixMatch(builder, address, null, hasMask);
+ }
+ }
+
+ private static void setPrefixMatch(final MatchBuilder builder, final Ipv6Address address,
+ final byte[] mask, final boolean hasMask) {
+ if (hasMask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6Destination(IpConversionUtil.createPrefix(address, mask))
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
+ .setIpv6Destination(IpConversionUtil.createPrefix(address, mask))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ } else {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6Destination(IpConversionUtil.createPrefix(address))
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
+ .setIpv6Destination(IpConversionUtil.createPrefix(address))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+ }
+
+ private static void setArbitraryMatch(final MatchBuilder builder, final Ipv6Address address,
+ final byte[] mask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder()
+ .setIpv6DestinationAddressNoMask(address)
+ .setIpv6DestinationArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
+ .build());
+ } else if (Ipv6MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
+ final Ipv6MatchArbitraryBitMask match = Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder(match)
+ .setIpv6DestinationAddressNoMask(address)
+ .setIpv6DestinationArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv6ExtHeaderEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Ipv6ExtHeaderBuilder extHeaderBuilder = new Ipv6ExtHeaderBuilder()
+ .setIpv6Exthdr(message.readUnsignedShort());
+
+ if (hasMask) {
+ final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ extHeaderBuilder.setIpv6ExthdrMask(ByteUtil.bytesToUnsignedShort(mask));
+ }
+
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6ExtHeader(extHeaderBuilder.build())
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv6MatchBuilder(match)
+ .setIpv6ExtHeader(extHeaderBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv6FlabelEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Ipv6LabelBuilder ipv6labelBuilder = new Ipv6LabelBuilder()
+ .setIpv6Flabel(new Ipv6FlowLabel(message.readUnsignedInt()));
+
+ if (hasMask) {
+ final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+ ipv6labelBuilder.setFlabelMask(new Ipv6FlowLabel(ByteUtil.bytesToUnsignedInt(mask)));
+ }
+
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6Label(ipv6labelBuilder.build())
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv6MatchBuilder(match)
+ .setIpv6Label(ipv6labelBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv6NdSllEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final MacAddress address = OxmDeserializerHelper.convertMacAddress(message);
+
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6NdSll(address)
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv6MatchBuilder(match)
+ .setIpv6NdSll(address)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv6NdTargetEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final Ipv6Address address = ByteBufUtils.readIetfIpv6Address(message);
+
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6NdTarget(address)
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv6MatchBuilder(match)
+ .setIpv6NdTarget(address)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv6NdTllEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final MacAddress address = OxmDeserializerHelper.convertMacAddress(message);
+
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6NdTll(address)
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv6MatchBuilder(match)
+ .setIpv6NdTll(address)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class Ipv6SourceEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Ipv6Address address = ByteBufUtils.readIetfIpv6Address(message);
+
+ if (hasMask) {
+ final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
+
+ if (IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
+ setArbitraryMatch(builder, address, mask);
+ } else {
+ setPrefixMatch(builder, address, mask, hasMask);
+ }
+ } else {
+ setPrefixMatch(builder, address, null, hasMask);
+ }
+ }
+
+ private static void setPrefixMatch(final MatchBuilder builder, final Ipv6Address address,
+ final byte[] mask, final boolean hasMask) {
+ if (hasMask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6Source(IpConversionUtil.createPrefix(address, mask))
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
+ .setIpv6Source(IpConversionUtil.createPrefix(address, mask))
+ .setIpv6Destination(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6Destination())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ } else {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder()
+ .setIpv6Source(IpConversionUtil.createPrefix(address))
+ .build());
+ } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
+ .setIpv6Source(IpConversionUtil.createPrefix(address))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+ }
+
+ private static void setArbitraryMatch(final MatchBuilder builder, final Ipv6Address address,
+ final byte[] mask) {
+ if (Objects.isNull(builder.getLayer3Match())) {
+ builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder()
+ .setIpv6SourceAddressNoMask(address)
+ .setIpv6SourceArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
+ .build());
+ } else if (Ipv6MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
+ final Ipv6MatchArbitraryBitMask match = Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
+ builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder(match)
+ .setIpv6SourceAddressNoMask(address)
+ .setIpv6SourceArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer3Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.math.BigInteger;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
+
+public class MetadataEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final Metadata metadata = builder.getMetadata();
+ final MetadataBuilder metadataBuilder = new MetadataBuilder()
+ .setMetadata(BigInteger.valueOf(message.readLong()));
+
+ if (hasMask) {
+ metadataBuilder.setMetadataMask(BigInteger.valueOf(message.readLong()));
+ }
+
+ if (Objects.isNull(metadata)) {
+ builder.setMetadata(metadataBuilder.build());
+ } else {
+ throwErrorOnMalformed(builder, "metadata");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class MplsBosEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short mplsBos = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getProtocolMatchFields())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
+ .setMplsBos(mplsBos)
+ .build());
+ } else if (Objects.isNull(builder.getProtocolMatchFields().getMplsBos())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields())
+ .setMplsBos(mplsBos)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "protocolMatchFields");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class MplsLabelEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final long mplsLabel = message.readUnsignedInt();
+
+ if (Objects.isNull(builder.getProtocolMatchFields())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
+ .setMplsLabel(mplsLabel)
+ .build());
+ } else if (Objects.isNull(builder.getProtocolMatchFields().getMplsLabel())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields())
+ .setMplsLabel(mplsLabel)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "protocolMatchFields");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class MplsTcEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short mplsTc = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getProtocolMatchFields())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
+ .setMplsTc(mplsTc)
+ .build());
+ } else if (Objects.isNull(builder.getProtocolMatchFields().getMplsTc())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields())
+ .setMplsTc(mplsTc)
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "protocolMatchFields");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class PbbEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final long pbb = message.readUnsignedMedium();
+ final PbbBuilder pbbBuilder = new PbbBuilder()
+ .setPbbIsid(pbb);
+
+ if (hasMask) {
+ pbbBuilder.setPbbMask((long) message.readUnsignedMedium());
+ }
+
+ if (Objects.isNull(builder.getProtocolMatchFields())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
+ .setPbb(pbbBuilder.build())
+ .build());
+ } else if (Objects.isNull(builder.getProtocolMatchFields().getPbb())) {
+ builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields())
+ .setPbb(pbbBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "protocolMatchFields");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
+
+public class SctpDestinationPortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final int port = message.readUnsignedShort();
+
+ if (Objects.isNull(builder.getLayer4Match())) {
+ builder.setLayer4Match(new SctpMatchBuilder()
+ .setSctpDestinationPort(new PortNumber(port))
+ .build());
+ } else if (SctpMatch.class.isInstance(builder.getLayer4Match())) {
+ builder.setLayer4Match(new SctpMatchBuilder(SctpMatch.class.cast(builder.getLayer4Match()))
+ .setSctpDestinationPort(new PortNumber(port))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
+
+public class SctpSourcePortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final int port = message.readUnsignedShort();
+
+ if (Objects.isNull(builder.getLayer4Match())) {
+ builder.setLayer4Match(new SctpMatchBuilder()
+ .setSctpSourcePort(new PortNumber(port))
+ .build());
+ } else if (SctpMatch.class.isInstance(builder.getLayer4Match())) {
+ builder.setLayer4Match(new SctpMatchBuilder(SctpMatch.class.cast(builder.getLayer4Match()))
+ .setSctpSourcePort(new PortNumber(port))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+
+public class TcpDestinationPortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final int port = message.readUnsignedShort();
+
+ if (Objects.isNull(builder.getLayer4Match())) {
+ builder.setLayer4Match(new TcpMatchBuilder()
+ .setTcpDestinationPort(new PortNumber(port))
+ .build());
+ } else if (TcpMatch.class.isInstance(builder.getLayer4Match())) {
+ builder.setLayer4Match(new TcpMatchBuilder(TcpMatch.class.cast(builder.getLayer4Match()))
+ .setTcpDestinationPort(new PortNumber(port))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.util.Objects;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class TcpFlagsEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ message.readUnsignedInt(); // Just skip experimenter ID for now, not used
+
+ final TcpFlagsMatchBuilder tcpFlagsBuilder = new TcpFlagsMatchBuilder()
+ .setTcpFlags(message.readUnsignedShort());
+
+ if (hasMask) {
+ tcpFlagsBuilder.setTcpFlagsMask(message.readUnsignedShort());
+ }
+
+ if (Objects.isNull(builder.getTcpFlagsMatch())) {
+ builder.setTcpFlagsMatch(tcpFlagsBuilder.build());
+ } else {
+ throwErrorOnMalformed(builder, "tcpFlagsMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+
+public class TcpSourcePortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final int port = message.readUnsignedShort();
+
+ if (Objects.isNull(builder.getLayer4Match())) {
+ builder.setLayer4Match(new TcpMatchBuilder()
+ .setTcpSourcePort(new PortNumber(port))
+ .build());
+ } else if (TcpMatch.class.isInstance(builder.getLayer4Match())) {
+ builder.setLayer4Match(new TcpMatchBuilder(TcpMatch.class.cast(builder.getLayer4Match()))
+ .setTcpSourcePort(new PortNumber(port))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import java.math.BigInteger;
+import java.util.Objects;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
+
+import io.netty.buffer.ByteBuf;
+
+public class TunnelIdEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+
+ final TunnelBuilder tunnelBuilder = new TunnelBuilder()
+ .setTunnelId(BigInteger.valueOf(message.readLong()));
+
+ if (hasMask) {
+ tunnelBuilder.setTunnelMask(BigInteger.valueOf(message.readLong()));
+ }
+
+ if (Objects.isNull(builder.getTunnel())) {
+ builder.setTunnel(tunnelBuilder.build());
+ } else {
+ throwErrorOnMalformed(builder, "tunnel");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+
+public class UdpDestinationPortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final int port = message.readUnsignedShort();
+
+ if (Objects.isNull(builder.getLayer4Match())) {
+ builder.setLayer4Match(new UdpMatchBuilder()
+ .setUdpDestinationPort(new PortNumber(port))
+ .build());
+ } else if (UdpMatch.class.isInstance(builder.getLayer4Match())) {
+ builder.setLayer4Match(new UdpMatchBuilder(UdpMatch.class.cast(builder.getLayer4Match()))
+ .setUdpDestinationPort(new PortNumber(port))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+
+public class UdpSourcePortEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final int port = message.readUnsignedShort();
+
+ if (Objects.isNull(builder.getLayer4Match())) {
+ builder.setLayer4Match(new UdpMatchBuilder()
+ .setUdpSourcePort(new PortNumber(port))
+ .build());
+ } else if (UdpMatch.class.isInstance(builder.getLayer4Match())) {
+ builder.setLayer4Match(new UdpMatchBuilder(UdpMatch.class.cast(builder.getLayer4Match()))
+ .setUdpSourcePort(new PortNumber(port))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "layer4Match");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+
+public class VlanPcpEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ processHeader(message);
+ final short pcp = message.readUnsignedByte();
+
+ if (Objects.isNull(builder.getVlanMatch())) {
+ builder.setVlanMatch(new VlanMatchBuilder()
+ .setVlanPcp(new VlanPcp(pcp))
+ .build());
+ } else if (Objects.nonNull(builder.getVlanMatch().getVlanPcp())) {
+ builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch())
+ .setVlanPcp(new VlanPcp(pcp))
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "vlanMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+
+public class VlanVidEntryDeserializer extends AbstractMatchEntryDeserializer {
+
+ @Override
+ public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
+ final boolean hasMask = processHeader(message);
+ final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+ final int vlanVidValue = message.readUnsignedShort();
+
+ if (hasMask) {
+ message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); // Skip mask
+ vlanIdBuilder
+ .setVlanId(new VlanId(0))
+ .setVlanIdPresent(true);
+ } else {
+ final boolean vidPresent = (vlanVidValue & (1 << 12)) != 0;
+
+ vlanIdBuilder
+ .setVlanId(new VlanId((vidPresent ? vlanVidValue & ((1 << 12) - 1) : vlanVidValue)))
+ .setVlanIdPresent(vidPresent);
+ }
+
+ if (Objects.isNull(builder.getVlanMatch())) {
+ builder.setVlanMatch(new VlanMatchBuilder()
+ .setVlanId(vlanIdBuilder.build())
+ .build());
+ } else if (Objects.nonNull(builder.getVlanMatch().getVlanId())) {
+ builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch())
+ .setVlanId(vlanIdBuilder.build())
+ .build());
+ } else {
+ throwErrorOnMalformed(builder, "vlanMatch");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+
+public class ArpOpEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int arpOp = 10;
+
+ writeHeader(in, false);
+ in.writeShort(arpOp);
+
+ assertEquals(arpOp, ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpOp().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ARP_OP;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+
+public class ArpSourceHardwareAddressEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final MacAddress arpSourceHardwareAddress = new MacAddress("00:01:02:03:04:05");
+ final MacAddress arpSourceHardwareAddressMask = new MacAddress("00:00:00:00:00:00");
+
+ writeHeader(in, false);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddress));
+
+ assertEquals(arpSourceHardwareAddress.getValue(),
+ ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceHardwareAddress().getAddress().getValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddress));
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddressMask));
+
+ final ArpSourceHardwareAddress desAddress =
+ ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceHardwareAddress();
+ assertEquals(arpSourceHardwareAddress.getValue(), desAddress.getAddress().getValue());
+ assertEquals(arpSourceHardwareAddressMask.getValue(), desAddress.getMask().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ARP_SHA;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.MAC_ADDRESS_LENGTH;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.util.Iterator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+
+public class ArpSourceTransportAddressEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final Ipv4Prefix arpSourceTransportAddress = new Ipv4Prefix("192.168.0.0/24");
+ final Ipv4Prefix arpSourceTransportAddressNoMask = new Ipv4Prefix("192.168.0.0/32");
+
+ writeHeader(in, false);
+ Iterator<String> addressParts = IpConversionUtil.splitToParts(arpSourceTransportAddressNoMask);
+ in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
+
+ assertEquals(arpSourceTransportAddressNoMask.getValue(),
+ ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceTransportAddress().getValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ addressParts = IpConversionUtil.splitToParts(arpSourceTransportAddress);
+ in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
+ in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
+
+ final Ipv4Prefix desAddress =
+ ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceTransportAddress();
+ assertEquals(arpSourceTransportAddress.getValue(), desAddress.getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ARP_SPA;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_INT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+
+public class ArpTargetHardwareAddressEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final MacAddress arpTargetHardwareAddress = new MacAddress("00:01:02:03:04:05");
+ final MacAddress arpTargetHardwareAddressMask = new MacAddress("00:00:00:00:00:00");
+
+ writeHeader(in, false);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpTargetHardwareAddress));
+
+ assertEquals(arpTargetHardwareAddress.getValue(),
+ ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpTargetHardwareAddress().getAddress().getValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpTargetHardwareAddress));
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpTargetHardwareAddressMask));
+
+ final ArpTargetHardwareAddress desAddress =
+ ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpTargetHardwareAddress();
+ assertEquals(arpTargetHardwareAddress.getValue(), desAddress.getAddress().getValue());
+ assertEquals(arpTargetHardwareAddressMask.getValue(), desAddress.getMask().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ARP_THA;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.MAC_ADDRESS_LENGTH;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
+
+public class EthernetDestinationEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final MacAddress ethernetDestinationAddress = new MacAddress("00:01:02:03:04:05");
+ final MacAddress ethernetDestinationAddressMask = new MacAddress("00:00:00:00:00:00");
+
+ writeHeader(in, false);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddress));
+
+ assertEquals(ethernetDestinationAddress.getValue(), deserialize(in).getEthernetMatch().getEthernetDestination().getAddress().getValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddress));
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddressMask));
+
+ final EthernetDestination desAddress = deserialize(in).getEthernetMatch().getEthernetDestination();
+ assertEquals(ethernetDestinationAddress.getValue(), desAddress.getAddress().getValue());
+ assertEquals(ethernetDestinationAddressMask.getValue(), desAddress.getMask().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ETH_DST;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.MAC_ADDRESS_LENGTH;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
+
+public class EthernetSourceEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final MacAddress ethernetSourceAddress = new MacAddress("00:01:02:03:04:05");
+ final MacAddress ethernetSourceAddressMask = new MacAddress("00:00:00:00:00:00");
+
+ writeHeader(in, false);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddress));
+
+ assertEquals(ethernetSourceAddress.getValue(), deserialize(in).getEthernetMatch().getEthernetSource().getAddress().getValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddress));
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddressMask));
+
+ final EthernetSource desAddress = deserialize(in).getEthernetMatch().getEthernetSource();
+ assertEquals(ethernetSourceAddress.getValue(), desAddress.getAddress().getValue());
+ assertEquals(ethernetSourceAddressMask.getValue(), desAddress.getMask().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ETH_SRC;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.MAC_ADDRESS_LENGTH;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class EthernetTypeEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int ethType = 0x800;
+
+ writeHeader(in, false);
+ in.writeShort(ethType);
+
+ assertEquals(Long.valueOf(ethType), deserialize(in).getEthernetMatch().getEthernetType().getType().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ETH_TYPE;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class Icmpv4CodeEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short code = 7;
+
+ writeHeader(in, false);
+ in.writeByte(code);
+
+ assertEquals(code, deserialize(in).getIcmpv4Match().getIcmpv4Code().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ICMPV4_CODE;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class Icmpv4TypeEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short type = 7;
+
+ writeHeader(in, false);
+ in.writeByte(type);
+
+ assertEquals(type, deserialize(in).getIcmpv4Match().getIcmpv4Type().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ICMPV4_TYPE;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class Icmpv6CodeEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short code = 7;
+
+ writeHeader(in, false);
+ in.writeByte(code);
+
+ assertEquals(code, deserialize(in).getIcmpv6Match().getIcmpv6Code().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ICMPV6_CODE;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class Icmpv6TypeEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short type = 7;
+
+ writeHeader(in, false);
+ in.writeByte(type);
+
+ assertEquals(type, deserialize(in).getIcmpv6Match().getIcmpv6Type().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ICMPV6_TYPE;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+
+public class InPhyPortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = -6;
+
+ writeHeader(in, false);
+ in.writeInt(port);
+
+ assertEquals(OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID,
+ BinContent.intToUnsignedLong(port)), deserialize(in).getInPhyPort().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IN_PHY_PORT;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_INT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+
+public class InPortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = -6;
+
+ writeHeader(in, false);
+ in.writeInt(port);
+
+ assertEquals(OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID,
+ BinContent.intToUnsignedLong(port)), deserialize(in).getInPort().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IN_PORT;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_INT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class IpDscpEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short ipDscp = 7;
+
+ writeHeader(in, false);
+ in.writeByte(ipDscp);
+
+ assertEquals(ipDscp, deserialize(in).getIpMatch().getIpDscp().getValue().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IP_DSCP;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class IpEcnEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short ipEcn = 7;
+
+ writeHeader(in, false);
+ in.writeByte(ipEcn);
+
+ assertEquals(ipEcn, deserialize(in).getIpMatch().getIpEcn().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IP_ECN;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class IpProtoEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short ipProto = 7;
+
+ writeHeader(in, false);
+ in.writeByte(ipProto);
+
+ assertEquals(ipProto, deserialize(in).getIpMatch().getIpProtocol().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IP_PROTO;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Iterator;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+
+public class Ipv4DestinationEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final Ipv4Prefix address = new Ipv4Prefix("192.168.72.0/24");
+ final Iterator<String> addressParts = IpConversionUtil.splitToParts(address);
+
+ writeHeader(in, true);
+ in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
+ in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
+
+ final Ipv4Match match = Ipv4Match.class.cast(deserialize(in).getLayer3Match());
+
+ assertEquals(address.getValue(), match.getIpv4Destination().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV4_DST;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.GROUPS_IN_IPV4_ADDRESS;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Iterator;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+
+public class Ipv4SourceEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final Ipv4Prefix address = new Ipv4Prefix("192.168.72.0/24");
+ final Iterator<String> addressParts = IpConversionUtil.splitToParts(address);
+
+ writeHeader(in, true);
+ in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
+ in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
+
+ final Ipv4Match match = Ipv4Match.class.cast(deserialize(in).getLayer3Match());
+
+ assertEquals(address.getValue(), match.getIpv4Source().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV4_SRC;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.GROUPS_IN_IPV4_ADDRESS;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+
+public class Ipv6DestinationEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final Ipv6Prefix address = new Ipv6Prefix("fe80::200:f8ff:fe21:67cf/30");
+
+ writeHeader(in, true);
+ in.writeBytes(IetfInetUtil.INSTANCE.ipv6AddressBytes(IpConversionUtil.extractIpv6Address(address)));
+ in.writeBytes(IpConversionUtil.convertIpv6PrefixToByteArray(IpConversionUtil.extractIpv6Prefix(address)));
+
+ final Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+
+ assertEquals(address.getValue(), match.getIpv6Destination().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV6_DST;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+
+public class Ipv6ExtHeaderEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int extHeader = 10;
+ final int extHeaderMask = 8;
+
+ writeHeader(in, false);
+ in.writeShort(extHeader);
+
+ Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+ assertEquals(extHeader, match.getIpv6ExtHeader().getIpv6Exthdr().intValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeShort(extHeader);
+ in.writeShort(extHeaderMask);
+
+ match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+ assertEquals(extHeader, match.getIpv6ExtHeader().getIpv6Exthdr().intValue());
+ assertEquals(extHeaderMask, match.getIpv6ExtHeader().getIpv6ExthdrMask().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV6_EXTHDR;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+
+public class Ipv6FlabelEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int flowLabel = 10;
+ final int flowLabelMask = 8;
+
+ writeHeader(in, false);
+ in.writeInt(flowLabel);
+
+ Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+ assertEquals(flowLabel, match.getIpv6Label().getIpv6Flabel().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeInt(flowLabel);
+ in.writeInt(flowLabelMask);
+
+ match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+ assertEquals(flowLabel, match.getIpv6Label().getIpv6Flabel().getValue().intValue());
+ assertEquals(flowLabelMask, match.getIpv6Label().getFlabelMask().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV6_FLABEL;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_INT_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+
+public class Ipv6NdSllEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final MacAddress address = new MacAddress("00:01:02:03:04:05");
+
+ writeHeader(in, false);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(address));
+
+ Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+ assertEquals(address.getValue(), match.getIpv6NdSll().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV6_ND_SLL;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.MAC_ADDRESS_LENGTH;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class Ipv6NdTargetEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final Ipv6Address address = new Ipv6Address("2001:db8::");
+
+ writeHeader(in, false);
+ in.writeBytes(IetfInetUtil.INSTANCE.ipv6AddressBytes(address));
+
+ Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+ assertArrayEquals(
+ IetfInetUtil.INSTANCE.ipv6AddressBytes(address),
+ IetfInetUtil.INSTANCE.ipv6AddressBytes(match.getIpv6NdTarget()));
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV6_ND_TARGET;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+
+public class Ipv6NdTllEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final MacAddress address = new MacAddress("00:01:02:03:04:05");
+
+ writeHeader(in, false);
+ in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(address));
+
+ Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+ assertEquals(address.getValue(), match.getIpv6NdTll().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV6_ND_TLL;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.MAC_ADDRESS_LENGTH;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+
+public class Ipv6SourceEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final Ipv6Prefix address = new Ipv6Prefix("fe80::200:f8ff:fe21:67cf/30");
+
+ writeHeader(in, true);
+ in.writeBytes(IetfInetUtil.INSTANCE.ipv6AddressBytes(IpConversionUtil.extractIpv6Address(address)));
+ in.writeBytes(IpConversionUtil.convertIpv6PrefixToByteArray(IpConversionUtil.extractIpv6Prefix(address)));
+
+ final Ipv6Match match = Ipv6Match.class.cast(deserialize(in).getLayer3Match());
+
+ assertEquals(address.getValue(), match.getIpv6Source().getValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.IPV6_SRC;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import java.math.BigInteger;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
+
+public class MetadataEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final BigInteger metadata = BigInteger.valueOf(20);
+ final BigInteger metadataMask = BigInteger.valueOf(30);
+
+ writeHeader(in, false);
+ in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, getValueLength()));
+
+ assertEquals(metadata, deserialize(in).getMetadata().getMetadata());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, getValueLength()));
+ in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadataMask, getValueLength()));
+
+ final Metadata desMetadata = deserialize(in).getMetadata();
+ assertEquals(metadata, desMetadata.getMetadata());
+ assertEquals(metadataMask, desMetadata.getMetadataMask());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.METADATA;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_LONG_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class MplsBosEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short mplsBos = 6;
+
+ writeHeader(in, false);
+ in.writeByte(mplsBos);
+
+ ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
+ assertEquals(mplsBos, match.getMplsBos().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.MPLS_BOS;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class MplsLabelEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int mplsLabel = 10;
+
+ writeHeader(in, false);
+ in.writeInt(mplsLabel);
+
+ ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
+ assertEquals(mplsLabel, match.getMplsLabel().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.MPLS_LABEL;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_INT_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class MplsTcEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short mplsTc = 6;
+
+ writeHeader(in, false);
+ in.writeByte(mplsTc);
+
+ ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
+ assertEquals(mplsTc, match.getMplsTc().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.MPLS_TC;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class PbbEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final long pbb = 6;
+ final long pbbMask = 5;
+
+ writeHeader(in, false);
+ in.writeMedium((int) pbb);
+
+ ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
+ assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeMedium((int) pbb);
+ in.writeMedium((int) pbbMask);
+
+ match = deserialize(in).getProtocolMatchFields();
+ assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
+ assertEquals(pbbMask, match.getPbb().getPbbMask().longValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.PBB_ISID;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_3_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
+
+public class SctpDestinationPortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = 22;
+
+ writeHeader(in, false);
+ in.writeShort(port);
+
+ assertEquals(port, SctpMatch.class.cast(deserialize(in).getLayer4Match()).getSctpDestinationPort().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.SCTP_DST;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
+
+public class SctpSourcePortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = 22;
+
+ writeHeader(in, false);
+ in.writeShort(port);
+
+ assertEquals(port, SctpMatch.class.cast(deserialize(in).getLayer4Match()).getSctpSourcePort().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.SCTP_SRC;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+
+public class TcpDestinationPortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = 22;
+
+ writeHeader(in, false);
+ in.writeShort(port);
+
+ assertEquals(port, TcpMatch.class.cast(deserialize(in).getLayer4Match()).getTcpDestinationPort().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.TCP_DST;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class TcpFlagsEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int tcpFlags = 6;
+ final int tcpFlagsMask = 5;
+
+ writeHeader(in, false);
+ in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID);
+ in.writeShort(tcpFlags);
+
+ TcpFlagsMatch match = deserialize(in).getTcpFlagsMatch();
+ assertEquals(tcpFlags, match.getTcpFlags().intValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID);
+ in.writeShort(tcpFlags);
+ in.writeShort(tcpFlagsMask);
+
+ match = deserialize(in).getTcpFlagsMatch();
+ assertEquals(tcpFlags, match.getTcpFlags().intValue());
+ assertEquals(tcpFlagsMask, match.getTcpFlagsMask().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.EXPERIMENTER_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return EncodeConstants.ONFOXM_ET_TCP_FLAGS;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+
+public class TcpSourcePortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = 22;
+
+ writeHeader(in, false);
+ in.writeShort(port);
+
+ assertEquals(port, TcpMatch.class.cast(deserialize(in).getLayer4Match()).getTcpSourcePort().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.TCP_SRC;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+public class TunnelIdEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final long tunnelId = 6;
+ final long tunnelIdMask = 5;
+
+ writeHeader(in, false);
+ in.writeLong(tunnelId);
+
+ Tunnel match = deserialize(in).getTunnel();
+ assertEquals(tunnelId, match.getTunnelId().longValue());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeLong(tunnelId);
+ in.writeLong(tunnelIdMask);
+
+ match = deserialize(in).getTunnel();
+ assertEquals(tunnelId, match.getTunnelId().longValue());
+ assertEquals(tunnelIdMask, match.getTunnelMask().longValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.TUNNEL_ID;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_LONG_IN_BYTES;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+
+public class UdpDestinationPortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = 22;
+
+ writeHeader(in, false);
+ in.writeShort(port);
+
+ assertEquals(port, UdpMatch.class.cast(deserialize(in).getLayer4Match()).getUdpDestinationPort().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.UDP_DST;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+
+public class UdpSourcePortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int port = 22;
+
+ writeHeader(in, false);
+ in.writeShort(port);
+
+ assertEquals(port, UdpMatch.class.cast(deserialize(in).getLayer4Match()).getUdpSourcePort().getValue().intValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.UDP_SRC;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+
+public class VlanPcpEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final short vlanPcp = 7;
+
+ writeHeader(in, false);
+ in.writeByte(vlanPcp);
+
+ assertEquals(vlanPcp, deserialize(in).getVlanMatch().getVlanPcp().getValue().shortValue());
+ assertEquals(0, in.readableBytes());
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.VLAN_PCP;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
+
+public class VlanVidEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
+
+ @Test
+ public void deserializeEntry() throws Exception {
+ final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
+ final int vlanVid = 8;
+ final byte[] vlanMask = new byte[] { 16, 0 };
+
+ writeHeader(in, false);
+ in.writeShort(vlanVid | (1 << 12));
+
+ VlanMatch vlanMatch = deserialize(in).getVlanMatch();
+ assertEquals(vlanVid, vlanMatch.getVlanId().getVlanId().getValue().intValue());
+ assertTrue(vlanMatch.getVlanId().isVlanIdPresent());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, true);
+ in.writeShort(vlanVid);
+ in.writeBytes(vlanMask);
+
+ vlanMatch = deserialize(in).getVlanMatch();
+ assertEquals(0, vlanMatch.getVlanId().getVlanId().getValue().intValue());
+ assertTrue(vlanMatch.getVlanId().isVlanIdPresent());
+ assertEquals(0, in.readableBytes());
+
+ writeHeader(in, false);
+ in.writeShort(vlanVid);
+
+ vlanMatch = deserialize(in).getVlanMatch();
+ assertEquals(vlanVid, vlanMatch.getVlanId().getVlanId().getValue().intValue());
+ assertFalse(vlanMatch.getVlanId().isVlanIdPresent());
+
+ }
+
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
+ }
+
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.VLAN_VID;
+ }
+
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}