use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class MatchV10ResponseConvertorTest method testTcpMatch.
/**
* TCP match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
*/
@Test
public void testTcpMatch() {
// TP_SRC, TP_DST are wildcarded.
// NW_PROTO is not wildcarded but null.
Long dlType = 0x800L;
FlowWildcardsV10 wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, true, true);
MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
MatchV10 match = builder.build();
BigInteger dpid = BigInteger.valueOf(12345L);
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
datapathIdConvertorData.setDatapathId(dpid);
Match salMatch = convert(match, datapathIdConvertorData).build();
EthernetMatch etherMatch = salMatch.getEthernetMatch();
Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
// Specify TCP protocol.
Short ipProto = 6;
match = builder.setNwProto(ipProto).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
IpMatch ipMatch = salMatch.getIpMatch();
Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
// TP_SRC is not wildcarded but null.
wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, true, false);
match = builder.setWildcards(wc).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
// Specify TCP source port.
Integer srcPort = 60000;
match = builder.setTpSrc(srcPort).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();
Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
Assert.assertEquals("Wrong TCP src", srcPort, tcpMatch.getTcpSourcePort().getValue());
Assert.assertEquals("Wrong TCP dst", null, tcpMatch.getTcpDestinationPort());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
// TP_DST is not wildcarded but null.
wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, false, false);
match = builder.setWildcards(wc).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
tcpMatch = (TcpMatch) salMatch.getLayer4Match();
Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
Assert.assertEquals("Wrong TCP src", srcPort, tcpMatch.getTcpSourcePort().getValue());
Assert.assertEquals("Wrong TCP dst", null, tcpMatch.getTcpDestinationPort());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
// Specify TCP destination port only.
Integer dstPort = 6653;
match = builder.setTpSrc(null).setTpDst(dstPort).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
tcpMatch = (TcpMatch) salMatch.getLayer4Match();
Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
Assert.assertEquals("Wrong TCP src", null, tcpMatch.getTcpSourcePort());
Assert.assertEquals("Wrong TCP dst", dstPort, tcpMatch.getTcpDestinationPort().getValue());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
// Specify both source and destination port.
srcPort = 32767;
dstPort = 9999;
match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
tcpMatch = (TcpMatch) salMatch.getLayer4Match();
Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
Assert.assertEquals("Wrong TCP src", srcPort, tcpMatch.getTcpSourcePort().getValue());
Assert.assertEquals("Wrong TCP dst", dstPort, tcpMatch.getTcpDestinationPort().getValue());
Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class MultipartMatchFieldSerializerInjector method injectSerializers.
/**
* Injects multipart match field serializers into provided
* {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider}.
*
* @param provider OpenflowJava serializer extension provider
*/
static void injectSerializers(final SerializerExtensionProvider provider) {
// Inject new message serializers here using injector created by createInjector method
final Function<Class<? extends MatchField>, Consumer<OFSerializer<SetFieldMatch>>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID);
injector.apply(ArpOp.class).accept(new ArpOpMatchFieldSerializer());
injector.apply(ArpSha.class).accept(new ArpShaMatchFieldSerializer());
injector.apply(ArpSpa.class).accept(new ArpSpaMatchFieldSerializer());
injector.apply(ArpTha.class).accept(new ArpThaMatchFieldSerializer());
injector.apply(ArpTpa.class).accept(new ArpTpaMatchFieldSerializer());
injector.apply(EthDst.class).accept(new EthDstMatchFieldSerializer());
injector.apply(EthSrc.class).accept(new EthSrcMatchFieldSerializer());
injector.apply(EthType.class).accept(new EthTypeMatchFieldSerializer());
injector.apply(Icmpv4Code.class).accept(new Icmpv4CodeMatchFieldSerializer());
injector.apply(Icmpv4Type.class).accept(new Icmpv4TypeMatchFieldSerializer());
injector.apply(Icmpv6Code.class).accept(new Icmpv6CodeMatchFieldSerializer());
injector.apply(Icmpv6Type.class).accept(new Icmpv6TypeMatchFieldSerializer());
injector.apply(InPhyPort.class).accept(new InPhyPortMatchFieldSerializer());
injector.apply(InPort.class).accept(new InPortMatchFieldSerializer());
injector.apply(IpDscp.class).accept(new IpDscpMatchFieldSerializer());
injector.apply(IpEcn.class).accept(new IpEcnMatchFieldSerializer());
injector.apply(IpProto.class).accept(new IpProtoMatchFieldSerializer());
injector.apply(Ipv4Dst.class).accept(new Ipv4DstMatchFieldSerializer());
injector.apply(Ipv4Src.class).accept(new Ipv4SrcMatchFieldSerializer());
injector.apply(Ipv6Dst.class).accept(new Ipv6DstMatchFieldSerializer());
injector.apply(Ipv6Exthdr.class).accept(new Ipv6ExtHdrMatchFieldSerializer());
injector.apply(Ipv6Flabel.class).accept(new Ipv6FlabelMatchFieldSerializer());
injector.apply(Ipv6NdSll.class).accept(new Ipv6NdSllMatchFieldSerializer());
injector.apply(Ipv6NdTarget.class).accept(new Ipv6NdTargetMatchFieldSerializer());
injector.apply(Ipv6NdTll.class).accept(new Ipv6NdTllMatchFieldSerializer());
injector.apply(Ipv6Src.class).accept(new Ipv6SrcMatchFieldSerializer());
injector.apply(Metadata.class).accept(new MetadataMatchFieldSerializer());
injector.apply(MplsBos.class).accept(new MplsBosMatchFieldSerializer());
injector.apply(MplsLabel.class).accept(new MplsLabelMatchFieldSerializer());
injector.apply(MplsTc.class).accept(new MplsTcMatchFieldSerializer());
injector.apply(PbbIsid.class).accept(new PbbIsidMatchFieldSerializer());
injector.apply(SctpDst.class).accept(new SctpDstMatchFieldSerializer());
injector.apply(SctpSrc.class).accept(new SctpSrcMatchFieldSerializer());
injector.apply(TcpDst.class).accept(new TcpDstMatchFieldSerializer());
injector.apply(TcpFlags.class).accept(new TcpFlagsMatchFieldSerializer());
injector.apply(TcpSrc.class).accept(new TcpSrcMatchFieldSerializer());
injector.apply(TunnelId.class).accept(new TunnelIdMatchFieldSerializer());
// TODO: Finish implementation of Tunnel Ipv4 src and dst
injector.apply(TunnelIpv4Dst.class).accept(new Ipv4DstMatchFieldSerializer());
injector.apply(TunnelIpv4Src.class).accept(new Ipv4SrcMatchFieldSerializer());
injector.apply(UdpDst.class).accept(new UdpDstMatchFieldSerializer());
injector.apply(UdpSrc.class).accept(new UdpSrcMatchFieldSerializer());
injector.apply(VlanPcp.class).accept(new VlanPcpMatchFieldSerializer());
injector.apply(VlanVid.class).accept(new VlanVidMatchFieldSerializer());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class RegMoveConvertor method convert.
@Override
public Action convert(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
Preconditions.checkArgument(nxActionArg instanceof NxActionRegMoveGrouping);
NxActionRegMoveGrouping nxAction = (NxActionRegMoveGrouping) nxActionArg;
Dst dst = nxAction.getNxRegMove().getDst();
Src src = nxAction.getNxRegMove().getSrc();
final ActionRegMoveBuilder actionRegMoveBuilder = new ActionRegMoveBuilder();
NxActionRegMoveBuilder nxActionRegMove = new NxActionRegMoveBuilder();
nxActionRegMove.setDst(resolveDst(dst.getDstChoice()));
nxActionRegMove.setDstOfs(dst.getStart());
nxActionRegMove.setSrc(resolveSrc(src.getSrcChoice()));
nxActionRegMove.setSrcOfs(src.getStart());
nxActionRegMove.setNBits(dst.getEnd() - dst.getStart() + 1);
actionRegMoveBuilder.setNxActionRegMove(nxActionRegMove.build());
return ActionUtil.createAction(actionRegMoveBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class OF10MatchDeserializerTest method test2.
/**
* Testing correct deserialization of ofp_match.
*/
@Test
public void test2() {
ByteBuf message = BufferHelper.buildBuffer("00 3F FF FF 00 20 AA BB CC DD EE FF " + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 " + "50 50 20 20");
// skip XID
message.skipBytes(4);
MatchV10 match = matchDeserializer.deserialize(message);
Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true), match.getWildcards());
Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());
Assert.assertEquals("Wrong dstMask", 0, match.getNwDstMask().shortValue());
Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());
Assert.assertEquals("Wrong dl-src", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlSrc());
Assert.assertEquals("Wrong dl-dst", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlDst());
Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());
Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());
Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());
Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());
Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());
Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());
Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());
Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class OF10MatchDeserializerTest method test.
/**
* Testing correct deserialization of ofp_match.
*/
@Test
public void test() {
ByteBuf message = BufferHelper.buildBuffer("00 24 08 91 00 20 AA BB CC DD EE FF " + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 " + "50 50 20 20");
// skip XID
message.skipBytes(4);
MatchV10 match = matchDeserializer.deserialize(message);
Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, false), match.getWildcards());
Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
Assert.assertEquals("Wrong dstMask", 16, match.getNwDstMask().shortValue());
Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());
Assert.assertEquals("Wrong dl-src", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlSrc());
Assert.assertEquals("Wrong dl-dst", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlDst());
Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());
Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());
Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());
Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());
Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());
Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());
Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());
Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
}
Aggregations