use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project netvirt by opendaylight.
the class VrfEntryListener method installIVpnLinkSwitchingFlows.
/*
* Installs the flows in FIB table that, for a given route, do the switching from one VPN to the other.
*/
private void installIVpnLinkSwitchingFlows(final InterVpnLinkDataComposite interVpnLink, final String vpnUuid, final VrfEntry vrfEntry, long vpnTag) {
Preconditions.checkNotNull(interVpnLink, "InterVpnLink cannot be null");
Preconditions.checkArgument(vrfEntry.getRoutePaths() != null && vrfEntry.getRoutePaths().size() == 1);
String destination = vrfEntry.getDestPrefix();
String nextHop = vrfEntry.getRoutePaths().get(0).getNexthopAddress();
String interVpnLinkName = interVpnLink.getInterVpnLinkName();
// using as metadata the LPortTag associated to that vpn in the inter-vpn-link.
if (interVpnLink.getState().or(State.Error) != State.Active) {
LOG.warn("Route to {} with nexthop={} cannot be installed because the interVpnLink {} is not active", destination, nextHop, interVpnLinkName);
return;
}
Optional<Long> optOtherEndpointLportTag = interVpnLink.getOtherEndpointLportTagByVpnName(vpnUuid);
if (!optOtherEndpointLportTag.isPresent()) {
LOG.warn("Could not find suitable LportTag for the endpoint opposite to vpn {} in interVpnLink {}", vpnUuid, interVpnLinkName);
return;
}
List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnUuid);
if (targetDpns.isEmpty()) {
LOG.warn("Could not find DPNs for endpoint opposite to vpn {} in interVpnLink {}", vpnUuid, interVpnLinkName);
return;
}
String[] values = destination.split("/");
String destPrefixIpAddress = values[0];
int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnTag), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(MatchEthernetType.IPV4);
if (prefixLength != 0) {
matches.add(new MatchIpv4Destination(destPrefixIpAddress, Integer.toString(prefixLength)));
}
List<Instruction> instructions = Arrays.asList(new InstructionWriteMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(optOtherEndpointLportTag.get().intValue(), ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()).buildInstruction(0), new InstructionGotoTable(NwConstants.L3_INTERFACE_TABLE).buildInstruction(1));
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
String flowRef = getInterVpnFibFlowRef(interVpnLinkName, destination, nextHop);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, COOKIE_VM_FIB_TABLE, matches, instructions);
LOG.trace("Installing flow in FIB table for vpn {} interVpnLink {} nextHop {} key {}", vpnUuid, interVpnLink.getInterVpnLinkName(), nextHop, flowRef);
for (BigInteger dpId : targetDpns) {
LOG.debug("Installing flow: VrfEntry=[prefix={} route-paths={}] dpn {} for InterVpnLink {} in FIB", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), dpId, interVpnLink.getInterVpnLinkName());
mdsalManager.installFlow(dpId, flowEntity);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project netvirt by opendaylight.
the class AclServiceUtils method buildMatchesForLPortTagAndConntrackClassifierType.
public static Collection<? extends MatchInfoBase> buildMatchesForLPortTagAndConntrackClassifierType(int lportTag, AclConntrackClassifierType conntrackClassifierType, Class<? extends ServiceModeBase> serviceMode) {
List<MatchInfoBase> matches = new ArrayList<>();
if (serviceMode != null && serviceMode.isAssignableFrom(ServiceModeEgress.class)) {
matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
matches.add(AclServiceUtils.buildAclConntrackClassifierTypeMatch(conntrackClassifierType));
} else {
// In case of ingress service mode, only metadata is used for
// matching both lportTag and conntrackClassifierType. Hence performing "or"
// operation on both lportTag and conntrackClassifierType metadata.
BigInteger metaData = MetaDataUtil.getLportTagMetaData(lportTag).or(MetaDataUtil.getAclConntrackClassifierTypeFromMetaData(conntrackClassifierType.getValue()));
BigInteger metaDataMask = MetaDataUtil.METADATA_MASK_LPORT_TAG.or(MetaDataUtil.METADATA_MASK_ACL_CONNTRACK_CLASSIFIER_TYPE);
matches.add(new MatchMetadata(metaData, metaDataMask));
}
return matches;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project openflowplugin by opendaylight.
the class MatchConvertorTest method testConversionWithMasks.
@Test
public void testConversionWithMasks() {
MatchBuilder builder = new MatchBuilder();
MetadataBuilder metadataBuilder = new MetadataBuilder();
metadataBuilder.setMetadata(new BigInteger("3"));
metadataBuilder.setMetadataMask(new BigInteger("15"));
builder.setMetadata(metadataBuilder.build());
EthernetMatchBuilder ethernetBuilder = new EthernetMatchBuilder();
EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
ethSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
ethSrcBuilder.setMask(new MacAddress("00:00:00:00:00:08"));
ethernetBuilder.setEthernetSource(ethSrcBuilder.build());
EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
ethDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
ethDstBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
ethernetBuilder.setEthernetDestination(ethDstBuilder.build());
builder.setEthernetMatch(ethernetBuilder.build());
VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
vlanIdBuilder.setVlanId(new VlanId(0));
vlanIdBuilder.setVlanIdPresent(true);
vlanBuilder.setVlanId(vlanIdBuilder.build());
builder.setVlanMatch(vlanBuilder.build());
ProtocolMatchFieldsBuilder protoBuilder = new ProtocolMatchFieldsBuilder();
PbbBuilder pbbBuilder = new PbbBuilder();
pbbBuilder.setPbbIsid(20L);
pbbBuilder.setPbbMask(8L);
protoBuilder.setPbb(pbbBuilder.build());
builder.setProtocolMatchFields(protoBuilder.build());
TunnelBuilder tunnelBuilder = new TunnelBuilder();
tunnelBuilder.setTunnelId(new BigInteger("21"));
tunnelBuilder.setTunnelMask(new BigInteger("14"));
builder.setTunnel(tunnelBuilder.build());
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.0/24"));
ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.0/8"));
builder.setLayer3Match(ipv4MatchBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 8, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, Metadata.class, true);
Assert.assertArrayEquals("Wrong metadata", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, ((MetadataCase) entry.getMatchEntryValue()).getMetadata().getMetadata());
Assert.assertArrayEquals("Wrong metadata mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 15 }, ((MetadataCase) entry.getMatchEntryValue()).getMetadata().getMask());
entry = entries.get(1);
checkEntryHeader(entry, EthDst.class, true);
Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:06"), ((EthDstCase) entry.getMatchEntryValue()).getEthDst().getMacAddress());
Assert.assertArrayEquals("Wrong eth dst mask", new byte[] { 0, 0, 0, 0, 0, 9 }, ((EthDstCase) entry.getMatchEntryValue()).getEthDst().getMask());
entry = entries.get(2);
checkEntryHeader(entry, EthSrc.class, true);
Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:05"), ((EthSrcCase) entry.getMatchEntryValue()).getEthSrc().getMacAddress());
Assert.assertArrayEquals("Wrong eth src mask", new byte[] { 0, 0, 0, 0, 0, 8 }, ((EthSrcCase) entry.getMatchEntryValue()).getEthSrc().getMask());
entry = entries.get(3);
checkEntryHeader(entry, VlanVid.class, true);
Assert.assertEquals("Wrong vlan id", 0, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue());
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
Assert.assertArrayEquals("Wrong vlanId mask", new byte[] { 16, 0 }, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getMask());
entry = entries.get(4);
checkEntryHeader(entry, Ipv4Src.class, true);
Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong ipv4 src mask", new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 }, ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getMask());
entry = entries.get(5);
checkEntryHeader(entry, Ipv4Dst.class, true);
Assert.assertEquals("Wrong ipv4 dst", "10.0.0.0", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong ipv4 dst mask", new byte[] { (byte) 255, 0, 0, 0 }, ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getMask());
entry = entries.get(6);
checkEntryHeader(entry, PbbIsid.class, true);
Assert.assertEquals("Wrong pbb isid", 20, ((PbbIsidCase) entry.getMatchEntryValue()).getPbbIsid().getIsid().intValue());
Assert.assertArrayEquals("Wrong pbb isid mask", new byte[] { 0, 0, 8 }, ((PbbIsidCase) entry.getMatchEntryValue()).getPbbIsid().getMask());
entry = entries.get(7);
checkEntryHeader(entry, TunnelId.class, true);
Assert.assertArrayEquals("Wrong tunnel id", new byte[] { 0, 0, 0, 0, 0, 0, 0, 21 }, ((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getTunnelId());
Assert.assertArrayEquals("Wrong tunnel id mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 14 }, ((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getMask());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project openflowplugin by opendaylight.
the class MatchConvertorTest method testConversion.
@Test
public void testConversion() {
MatchBuilder builder = new MatchBuilder();
builder.setInPort(new NodeConnectorId("openflow:42:1"));
builder.setInPhyPort(new NodeConnectorId("openflow:42:2"));
MetadataBuilder metadataBuilder = new MetadataBuilder();
metadataBuilder.setMetadata(new BigInteger("3"));
builder.setMetadata(metadataBuilder.build());
EthernetMatchBuilder ethernetBuilder = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(4L));
ethernetBuilder.setEthernetType(ethTypeBuilder.build());
EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
ethSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
ethernetBuilder.setEthernetSource(ethSrcBuilder.build());
EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
ethDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
ethernetBuilder.setEthernetDestination(ethDstBuilder.build());
builder.setEthernetMatch(ethernetBuilder.build());
VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
vlanIdBuilder.setVlanId(new VlanId(7));
vlanIdBuilder.setVlanIdPresent(true);
vlanBuilder.setVlanId(vlanIdBuilder.build());
vlanBuilder.setVlanPcp(new VlanPcp((short) 7));
builder.setVlanMatch(vlanBuilder.build());
IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
ipMatchBuilder.setIpDscp(new Dscp((short) 8));
ipMatchBuilder.setIpEcn((short) 9);
ipMatchBuilder.setIpProtocol((short) 10);
builder.setIpMatch(ipMatchBuilder.build());
TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
tcpMatchBuilder.setTcpSourcePort(new PortNumber(11));
tcpMatchBuilder.setTcpDestinationPort(new PortNumber(12));
builder.setLayer4Match(tcpMatchBuilder.build());
Icmpv4MatchBuilder icmpv4Builder = new Icmpv4MatchBuilder();
icmpv4Builder.setIcmpv4Type((short) 13);
icmpv4Builder.setIcmpv4Code((short) 14);
builder.setIcmpv4Match(icmpv4Builder.build());
Icmpv6MatchBuilder icmpv6Builder = new Icmpv6MatchBuilder();
icmpv6Builder.setIcmpv6Type((short) 15);
icmpv6Builder.setIcmpv6Code((short) 16);
builder.setIcmpv6Match(icmpv6Builder.build());
ProtocolMatchFieldsBuilder protoBuilder = new ProtocolMatchFieldsBuilder();
protoBuilder.setMplsLabel(17L);
protoBuilder.setMplsTc((short) 18);
protoBuilder.setMplsBos((short) 19);
PbbBuilder pbbBuilder = new PbbBuilder();
pbbBuilder.setPbbIsid(20L);
protoBuilder.setPbb(pbbBuilder.build());
builder.setProtocolMatchFields(protoBuilder.build());
TunnelBuilder tunnelBuilder = new TunnelBuilder();
tunnelBuilder.setTunnelId(new BigInteger("21"));
builder.setTunnel(tunnelBuilder.build());
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.1/32"));
ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.2/32"));
builder.setLayer3Match(ipv4MatchBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 24, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, InPort.class, false);
Assert.assertEquals("Wrong in port", 1, ((InPortCase) entry.getMatchEntryValue()).getInPort().getPortNumber().getValue().intValue());
entry = entries.get(1);
checkEntryHeader(entry, InPhyPort.class, false);
Assert.assertEquals("Wrong in phy port", 2, ((InPhyPortCase) entry.getMatchEntryValue()).getInPhyPort().getPortNumber().getValue().intValue());
entry = entries.get(2);
checkEntryHeader(entry, Metadata.class, false);
Assert.assertArrayEquals("Wrong metadata", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, ((MetadataCase) entry.getMatchEntryValue()).getMetadata().getMetadata());
entry = entries.get(3);
checkEntryHeader(entry, EthDst.class, false);
Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:06"), ((EthDstCase) entry.getMatchEntryValue()).getEthDst().getMacAddress());
entry = entries.get(4);
checkEntryHeader(entry, EthSrc.class, false);
Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:05"), ((EthSrcCase) entry.getMatchEntryValue()).getEthSrc().getMacAddress());
entry = entries.get(5);
checkEntryHeader(entry, EthType.class, false);
Assert.assertEquals("Wrong eth type", 4, ((EthTypeCase) entry.getMatchEntryValue()).getEthType().getEthType().getValue().intValue());
entry = entries.get(6);
checkEntryHeader(entry, VlanVid.class, false);
Assert.assertEquals("Wrong vlan id", 7, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue());
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
entry = entries.get(7);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
Assert.assertEquals("Wrong vlan pcp", 7, ((VlanPcpCase) entry.getMatchEntryValue()).getVlanPcp().getVlanPcp().intValue());
entry = entries.get(8);
checkEntryHeader(entry, IpDscp.class, false);
Assert.assertEquals("Wrong ip dscp", 8, ((IpDscpCase) entry.getMatchEntryValue()).getIpDscp().getDscp().getValue().intValue());
entry = entries.get(9);
checkEntryHeader(entry, IpEcn.class, false);
Assert.assertEquals("Wrong ip ecn", 9, ((IpEcnCase) entry.getMatchEntryValue()).getIpEcn().getEcn().intValue());
entry = entries.get(10);
checkEntryHeader(entry, IpProto.class, false);
Assert.assertEquals("Wrong ip proto", 10, ((IpProtoCase) entry.getMatchEntryValue()).getIpProto().getProtocolNumber().intValue());
entry = entries.get(11);
checkEntryHeader(entry, TcpSrc.class, false);
Assert.assertEquals("Wrong tcp src", 11, ((TcpSrcCase) entry.getMatchEntryValue()).getTcpSrc().getPort().getValue().intValue());
entry = entries.get(12);
checkEntryHeader(entry, TcpDst.class, false);
Assert.assertEquals("Wrong tcp dst", 12, ((TcpDstCase) entry.getMatchEntryValue()).getTcpDst().getPort().getValue().intValue());
entry = entries.get(13);
checkEntryHeader(entry, Icmpv4Type.class, false);
Assert.assertEquals("Wrong icmpv4 type", 13, ((Icmpv4TypeCase) entry.getMatchEntryValue()).getIcmpv4Type().getIcmpv4Type().intValue());
entry = entries.get(14);
checkEntryHeader(entry, Icmpv4Code.class, false);
Assert.assertEquals("Wrong icmpv4 code", 14, ((Icmpv4CodeCase) entry.getMatchEntryValue()).getIcmpv4Code().getIcmpv4Code().intValue());
entry = entries.get(15);
checkEntryHeader(entry, Icmpv6Type.class, false);
Assert.assertEquals("Wrong icmpv6 type", 15, ((Icmpv6TypeCase) entry.getMatchEntryValue()).getIcmpv6Type().getIcmpv6Type().intValue());
entry = entries.get(16);
checkEntryHeader(entry, Icmpv6Code.class, false);
Assert.assertEquals("Wrong icmpv6 code", 16, ((Icmpv6CodeCase) entry.getMatchEntryValue()).getIcmpv6Code().getIcmpv6Code().intValue());
entry = entries.get(17);
checkEntryHeader(entry, Ipv4Src.class, false);
Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
entry = entries.get(18);
checkEntryHeader(entry, Ipv4Dst.class, false);
Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
entry = entries.get(19);
checkEntryHeader(entry, MplsLabel.class, false);
Assert.assertEquals("Wrong mpls label", 17, ((MplsLabelCase) entry.getMatchEntryValue()).getMplsLabel().getMplsLabel().intValue());
entry = entries.get(20);
checkEntryHeader(entry, MplsBos.class, false);
Assert.assertEquals("Wrong mpls bos", true, ((MplsBosCase) entry.getMatchEntryValue()).getMplsBos().isBos());
entry = entries.get(21);
checkEntryHeader(entry, MplsTc.class, false);
Assert.assertEquals("Wrong mpls tc", 18, ((MplsTcCase) entry.getMatchEntryValue()).getMplsTc().getTc().intValue());
entry = entries.get(22);
checkEntryHeader(entry, PbbIsid.class, false);
Assert.assertEquals("Wrong pbb isid", 20, ((PbbIsidCase) entry.getMatchEntryValue()).getPbbIsid().getIsid().intValue());
entry = entries.get(23);
checkEntryHeader(entry, TunnelId.class, false);
Assert.assertArrayEquals("Wrong tunnel id", new byte[] { 0, 0, 0, 0, 0, 0, 0, 21 }, ((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getTunnelId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project openflowplugin by opendaylight.
the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures2.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyTableFeatures2() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0C 00 00 00 00 00 00 " + // length, tableId, padding
"00 B0 01 00 00 00 00 00 " + //
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + // name
"00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
"00 00 00 00 00 00 00 01 " + // metadata write
"00 00 00 00 00 00 00 02 " + // config
"00 00 00 00 " + // max entries
"00 00 00 2A " + //
"00 00 00 04 00 00 00 00 " + //
"00 01 00 04 00 00 00 00 " + //
"00 02 00 08 01 02 03 04 " + //
"00 03 00 07 05 06 07 00 " + //
"00 04 00 04 00 00 00 00 " + //
"00 05 00 04 00 00 00 00 " + //
"00 06 00 04 00 00 00 00 " + //
"00 07 00 04 00 00 00 00 " + //
"00 08 00 04 00 00 00 00 " + //
"00 0A 00 04 00 00 00 00 " + //
"00 0C 00 04 00 00 00 00 " + //
"00 0D 00 04 00 00 00 00 " + //
"00 0E 00 04 00 00 00 00 " + "00 0F 00 04 00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size());
TableFeatures feature = message.getTableFeatures().get(0);
Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, feature.getTableFeatureProperties().get(0).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, feature.getTableFeatureProperties().get(1).getType());
TableFeatureProperties property = feature.getTableFeatureProperties().get(2);
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, property.getType());
List<NextTableIds> tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
Assert.assertEquals("Wrong next table id size", 4, tableIds.size());
Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue());
property = feature.getTableFeatureProperties().get(3);
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, property.getType());
tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
Assert.assertEquals("Wrong next table id size", 3, tableIds.size());
Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, feature.getTableFeatureProperties().get(4).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, feature.getTableFeatureProperties().get(5).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, feature.getTableFeatureProperties().get(6).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, feature.getTableFeatureProperties().get(7).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, feature.getTableFeatureProperties().get(8).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, feature.getTableFeatureProperties().get(9).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, feature.getTableFeatureProperties().get(10).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, feature.getTableFeatureProperties().get(11).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, feature.getTableFeatureProperties().get(12).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, feature.getTableFeatureProperties().get(13).getType());
}
Aggregations