From 0e246fb02d714bacd787f880c7ab50ded9033592 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Wed, 14 Dec 2016 09:23:19 +0100 Subject: [PATCH] Add Match entry deserializers 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 --- .../MatchDeserializerInjector.java | 96 ++++++++++++++++++ .../match/ArpOpEntryDeserializer.java | 39 ++++++++ ...ourceHardwareAddressEntryDeserializer.java | 46 +++++++++ ...urceTransportAddressEntryDeserializer.java | 40 ++++++++ ...argetHardwareAddressEntryDeserializer.java | 46 +++++++++ ...rgetTransportAddressEntryDeserializer.java | 40 ++++++++ .../EthernetDestinationEntryDeserializer.java | 45 +++++++++ .../EthernetSourceEntryDeserializer.java | 45 +++++++++ .../match/EthernetTypeEntryDeserializer.java | 42 ++++++++ .../match/Icmpv4CodeEntryDeserializer.java | 36 +++++++ .../match/Icmpv4TypeEntryDeserializer.java | 36 +++++++ .../match/Icmpv6CodeEntryDeserializer.java | 36 +++++++ .../match/Icmpv6TypeEntryDeserializer.java | 36 +++++++ .../match/InPhyPortEntryDeserializer.java | 35 +++++++ .../match/InPortEntryDeserializer.java | 35 +++++++ .../match/IpDscpEntryDeserializer.java | 37 +++++++ .../match/IpEcnEntryDeserializer.java | 36 +++++++ .../match/IpProtoEntryDeserializer.java | 36 +++++++ .../Ipv4DestinationEntryDeserializer.java | 97 +++++++++++++++++++ .../match/Ipv4SourceEntryDeserializer.java | 97 +++++++++++++++++++ .../Ipv6DestinationEntryDeserializer.java | 93 ++++++++++++++++++ .../match/Ipv6ExtHeaderEntryDeserializer.java | 56 +++++++++++ .../match/Ipv6FlabelEntryDeserializer.java | 52 ++++++++++ .../match/Ipv6NdSllEntryDeserializer.java | 43 ++++++++ .../match/Ipv6NdTargetEntryDeserializer.java | 43 ++++++++ .../match/Ipv6NdTllEntryDeserializer.java | 43 ++++++++ .../match/Ipv6SourceEntryDeserializer.java | 94 ++++++++++++++++++ .../match/MetadataEntryDeserializer.java | 38 ++++++++ .../match/MplsBosEntryDeserializer.java | 38 ++++++++ .../match/MplsLabelEntryDeserializer.java | 38 ++++++++ .../match/MplsTcEntryDeserializer.java | 38 ++++++++ .../match/PbbEntryDeserializer.java | 45 +++++++++ .../SctpDestinationPortEntryDeserializer.java | 38 ++++++++ .../SctpSourcePortEntryDeserializer.java | 38 ++++++++ .../TcpDestinationPortEntryDeserializer.java | 38 ++++++++ .../match/TcpFlagsEntryDeserializer.java | 39 ++++++++ .../match/TcpSourcePortEntryDeserializer.java | 38 ++++++++ .../match/TunnelIdEntryDeserializer.java | 39 ++++++++ .../UdpDestinationPortEntryDeserializer.java | 38 ++++++++ .../match/UdpSourcePortEntryDeserializer.java | 38 ++++++++ .../match/VlanPcpEntryDeserializer.java | 37 +++++++ .../match/VlanVidEntryDeserializer.java | 53 ++++++++++ .../match/ArpOpEntryDeserializerTest.java | 48 +++++++++ ...eHardwareAddressEntryDeserializerTest.java | 63 ++++++++++++ ...TransportAddressEntryDeserializerTest.java | 67 +++++++++++++ ...tHardwareAddressEntryDeserializerTest.java | 63 ++++++++++++ ...ernetDestinationEntryDeserializerTest.java | 60 ++++++++++++ .../EthernetSourceEntryDeserializerTest.java | 60 ++++++++++++ .../EthernetTypeEntryDeserializerTest.java | 47 +++++++++ .../Icmpv4CodeEntryDeserializerTest.java | 47 +++++++++ .../Icmpv4TypeEntryDeserializerTest.java | 47 +++++++++ .../Icmpv6CodeEntryDeserializerTest.java | 47 +++++++++ .../Icmpv6TypeEntryDeserializerTest.java | 47 +++++++++ .../match/InPhyPortEntryDeserializerTest.java | 50 ++++++++++ .../match/InPortEntryDeserializerTest.java | 50 ++++++++++ .../match/IpDscpEntryDeserializerTest.java | 47 +++++++++ .../match/IpEcnEntryDeserializerTest.java | 47 +++++++++ .../match/IpProtoEntryDeserializerTest.java | 47 +++++++++ .../Ipv4DestinationEntryDeserializerTest.java | 60 ++++++++++++ .../Ipv4SourceEntryDeserializerTest.java | 60 ++++++++++++ .../Ipv6DestinationEntryDeserializerTest.java | 55 +++++++++++ .../Ipv6ExtHeaderEntryDeserializerTest.java | 60 ++++++++++++ .../Ipv6FlabelEntryDeserializerTest.java | 60 ++++++++++++ .../match/Ipv6NdSllEntryDeserializerTest.java | 52 ++++++++++ .../Ipv6NdTargetEntryDeserializerTest.java | 56 +++++++++++ .../match/Ipv6NdTllEntryDeserializerTest.java | 52 ++++++++++ .../Ipv6SourceEntryDeserializerTest.java | 55 +++++++++++ .../match/MetadataEntryDeserializerTest.java | 61 ++++++++++++ .../match/MplsBosEntryDeserializerTest.java | 51 ++++++++++ .../match/MplsLabelEntryDeserializerTest.java | 51 ++++++++++ .../match/MplsTcEntryDeserializerTest.java | 51 ++++++++++ .../match/PbbEntryDeserializerTest.java | 61 ++++++++++++ ...pDestinationPortEntryDeserializerTest.java | 48 +++++++++ .../SctpSourcePortEntryDeserializerTest.java | 48 +++++++++ ...pDestinationPortEntryDeserializerTest.java | 48 +++++++++ .../match/TcpFlagsEntryDeserializerTest.java | 63 ++++++++++++ .../TcpSourcePortEntryDeserializerTest.java | 48 +++++++++ .../match/TunnelIdEntryDeserializerTest.java | 61 ++++++++++++ ...pDestinationPortEntryDeserializerTest.java | 48 +++++++++ .../UdpSourcePortEntryDeserializerTest.java | 48 +++++++++ .../match/VlanPcpEntryDeserializerTest.java | 47 +++++++++ .../match/VlanVidEntryDeserializerTest.java | 70 +++++++++++++ 82 files changed, 4124 insertions(+) create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetTransportAddressEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializer.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializer.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializerTest.java create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializerTest.java diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java index 0c40d095d1..082e299737 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/MatchDeserializerInjector.java @@ -17,9 +17,53 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; 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; /** @@ -45,6 +89,58 @@ public class MatchDeserializerInjector { // Inject new match entry serializers here using injector created by createInjector method final Function>>> injector = createInjector(deserializer, EncodeConstants.OF13_VERSION_ID); + + + // Wrapped injector that uses OPENFLOW_BASIC_CLASS + final Function> basicInjector = + injector.apply(OxmMatchConstants.OPENFLOW_BASIC_CLASS).apply(null); + + // Wrapped injector that uses EXPERIMENTER_CLASS + final Function>> 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()); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializer.java new file mode 100644 index 0000000000..f4f91476bf --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializer.java @@ -0,0 +1,39 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializer.java new file mode 100644 index 0000000000..76afbbd402 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializer.java @@ -0,0 +1,46 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializer.java new file mode 100644 index 0000000000..6be18e0524 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializer.java @@ -0,0 +1,40 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializer.java new file mode 100644 index 0000000000..bb59ef2d25 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializer.java @@ -0,0 +1,46 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetTransportAddressEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetTransportAddressEntryDeserializer.java new file mode 100644 index 0000000000..314e4b3b2c --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetTransportAddressEntryDeserializer.java @@ -0,0 +1,40 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializer.java new file mode 100644 index 0000000000..3708534c19 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializer.java @@ -0,0 +1,45 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializer.java new file mode 100644 index 0000000000..7a538b69e1 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializer.java @@ -0,0 +1,45 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializer.java new file mode 100644 index 0000000000..2511c47216 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializer.java @@ -0,0 +1,42 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializer.java new file mode 100644 index 0000000000..58d1c157b7 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializer.java @@ -0,0 +1,36 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializer.java new file mode 100644 index 0000000000..73c3a636e0 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializer.java @@ -0,0 +1,36 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializer.java new file mode 100644 index 0000000000..3f36e4f443 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializer.java @@ -0,0 +1,36 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializer.java new file mode 100644 index 0000000000..5f8afa71d0 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializer.java @@ -0,0 +1,36 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializer.java new file mode 100644 index 0000000000..42f399165b --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializer.java @@ -0,0 +1,35 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializer.java new file mode 100644 index 0000000000..1f7e3ace22 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializer.java @@ -0,0 +1,35 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializer.java new file mode 100644 index 0000000000..9944449aff --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializer.java @@ -0,0 +1,37 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializer.java new file mode 100644 index 0000000000..797ce95f40 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializer.java @@ -0,0 +1,36 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializer.java new file mode 100644 index 0000000000..f506620127 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializer.java @@ -0,0 +1,36 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializer.java new file mode 100644 index 0000000000..572965019b --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializer.java @@ -0,0 +1,97 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializer.java new file mode 100644 index 0000000000..80552328b3 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializer.java @@ -0,0 +1,97 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializer.java new file mode 100644 index 0000000000..aed993fadc --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializer.java @@ -0,0 +1,93 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializer.java new file mode 100644 index 0000000000..0890d50911 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializer.java @@ -0,0 +1,56 @@ +/* + * 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"); + } + + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializer.java new file mode 100644 index 0000000000..58a3f2d3c3 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializer.java @@ -0,0 +1,52 @@ +/* + * 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"); + } + + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializer.java new file mode 100644 index 0000000000..acd9a43968 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializer.java @@ -0,0 +1,43 @@ +/* + * 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"); + } + + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializer.java new file mode 100644 index 0000000000..fd406b348c --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializer.java @@ -0,0 +1,43 @@ +/* + * 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"); + } + + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializer.java new file mode 100644 index 0000000000..7a5445441f --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializer.java @@ -0,0 +1,43 @@ +/* + * 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"); + } + + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializer.java new file mode 100644 index 0000000000..b988e7f121 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializer.java @@ -0,0 +1,94 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializer.java new file mode 100644 index 0000000000..04f585f3db --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializer.java new file mode 100644 index 0000000000..06d590ddaa --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializer.java new file mode 100644 index 0000000000..c71ae84139 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializer.java new file mode 100644 index 0000000000..5836cf9fa3 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializer.java new file mode 100644 index 0000000000..1d59140b9a --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializer.java @@ -0,0 +1,45 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializer.java new file mode 100644 index 0000000000..1995043276 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializer.java new file mode 100644 index 0000000000..8204c5959d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializer.java new file mode 100644 index 0000000000..5a1afead44 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializer.java new file mode 100644 index 0000000000..1144adda58 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializer.java @@ -0,0 +1,39 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializer.java new file mode 100644 index 0000000000..0f7fb97dd8 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializer.java new file mode 100644 index 0000000000..8c61e8de3d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializer.java @@ -0,0 +1,39 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializer.java new file mode 100644 index 0000000000..4c58d228cc --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializer.java new file mode 100644 index 0000000000..adc55a6f58 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializer.java @@ -0,0 +1,38 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializer.java new file mode 100644 index 0000000000..b728803b6d --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializer.java @@ -0,0 +1,37 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializer.java new file mode 100644 index 0000000000..a9f62c4111 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializer.java @@ -0,0 +1,53 @@ +/* + * 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"); + } + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializerTest.java new file mode 100644 index 0000000000..4334b58020 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializerTest.java @@ -0,0 +1,48 @@ +/* + * 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 diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializerTest.java new file mode 100644 index 0000000000..fa8f87d2a1 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializerTest.java @@ -0,0 +1,63 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializerTest.java new file mode 100644 index 0000000000..dc83ae1f3b --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializerTest.java @@ -0,0 +1,67 @@ +/* + * 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 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializerTest.java new file mode 100644 index 0000000000..36ec142209 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializerTest.java @@ -0,0 +1,63 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializerTest.java new file mode 100644 index 0000000000..41da2f7ced --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializerTest.java @@ -0,0 +1,60 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializerTest.java new file mode 100644 index 0000000000..30c2534e6a --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializerTest.java @@ -0,0 +1,60 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java new file mode 100644 index 0000000000..ede1cf769e --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializerTest.java new file mode 100644 index 0000000000..f3665573a0 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializerTest.java new file mode 100644 index 0000000000..5064722756 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializerTest.java new file mode 100644 index 0000000000..513c795190 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializerTest.java new file mode 100644 index 0000000000..768f97eb18 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializerTest.java new file mode 100644 index 0000000000..65f85eac6f --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializerTest.java @@ -0,0 +1,50 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializerTest.java new file mode 100644 index 0000000000..d28c2daa64 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializerTest.java @@ -0,0 +1,50 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializerTest.java new file mode 100644 index 0000000000..4bf225e286 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializerTest.java new file mode 100644 index 0000000000..86fbb64367 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializerTest.java new file mode 100644 index 0000000000..2d470b269d --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializerTest.java new file mode 100644 index 0000000000..907a05a27f --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializerTest.java @@ -0,0 +1,60 @@ +/* + * 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 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializerTest.java new file mode 100644 index 0000000000..aa7cfb8598 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializerTest.java @@ -0,0 +1,60 @@ +/* + * 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 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializerTest.java new file mode 100644 index 0000000000..5be5a28524 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializerTest.java @@ -0,0 +1,55 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializerTest.java new file mode 100644 index 0000000000..e513893f04 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializerTest.java @@ -0,0 +1,60 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializerTest.java new file mode 100644 index 0000000000..32150659ae --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializerTest.java @@ -0,0 +1,60 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializerTest.java new file mode 100644 index 0000000000..4c4489820c --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializerTest.java @@ -0,0 +1,52 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializerTest.java new file mode 100644 index 0000000000..8c65891ba0 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializerTest.java @@ -0,0 +1,56 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializerTest.java new file mode 100644 index 0000000000..c6785a4ec8 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializerTest.java @@ -0,0 +1,52 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializerTest.java new file mode 100644 index 0000000000..46a3951bb1 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializerTest.java @@ -0,0 +1,55 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java new file mode 100644 index 0000000000..d65aa98c33 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializerTest.java @@ -0,0 +1,61 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializerTest.java new file mode 100644 index 0000000000..23eba5bd04 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializerTest.java @@ -0,0 +1,51 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializerTest.java new file mode 100644 index 0000000000..25767acf97 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializerTest.java @@ -0,0 +1,51 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializerTest.java new file mode 100644 index 0000000000..4ce947718f --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializerTest.java @@ -0,0 +1,51 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializerTest.java new file mode 100644 index 0000000000..d149c97f81 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializerTest.java @@ -0,0 +1,61 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializerTest.java new file mode 100644 index 0000000000..e2df9f5dc2 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializerTest.java @@ -0,0 +1,48 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializerTest.java new file mode 100644 index 0000000000..b4681511e9 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializerTest.java @@ -0,0 +1,48 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializerTest.java new file mode 100644 index 0000000000..97521b9227 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializerTest.java @@ -0,0 +1,48 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java new file mode 100644 index 0000000000..020f30525a --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpFlagsEntryDeserializerTest.java @@ -0,0 +1,63 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializerTest.java new file mode 100644 index 0000000000..fbb4bf16cd --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializerTest.java @@ -0,0 +1,48 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java new file mode 100644 index 0000000000..37264c4173 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java @@ -0,0 +1,61 @@ +/* + * 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; + } + +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializerTest.java new file mode 100644 index 0000000000..5120b6499f --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializerTest.java @@ -0,0 +1,48 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializerTest.java new file mode 100644 index 0000000000..c323e92041 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializerTest.java @@ -0,0 +1,48 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializerTest.java new file mode 100644 index 0000000000..bbbee15d9e --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializerTest.java @@ -0,0 +1,47 @@ +/* + * 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; + } +} diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializerTest.java new file mode 100644 index 0000000000..ba1d95e7ba --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializerTest.java @@ -0,0 +1,70 @@ +/* + * 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; + } +} -- 2.36.6