use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp in project openflowplugin by opendaylight.
the class IpDscpEntryDeserializer method deserializeEntry.
@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", "ipDscp");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp in project openflowplugin by opendaylight.
the class OF13MatchSerializer02Test method test.
/**
* Testing serialization of match.
*/
@Test
public void test() {
MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(InPort.class);
entryBuilder.setHasMask(false);
InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
InPortBuilder inPortBuilder = new InPortBuilder();
inPortBuilder.setPortNumber(new PortNumber(42L));
inPortCaseBuilder.setInPort(inPortBuilder.build());
entryBuilder.setMatchEntryValue(inPortCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(InPhyPort.class);
entryBuilder.setHasMask(false);
InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
inPhyPortBuilder.setPortNumber(new PortNumber(43L));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entryBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Metadata.class);
entryBuilder.setHasMask(true);
MetadataCaseBuilder metaCaseBuilder = new MetadataCaseBuilder();
MetadataBuilder metadataBuilder = new MetadataBuilder();
metadataBuilder.setMetadata(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 });
metadataBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 });
metaCaseBuilder.setMetadata(metadataBuilder.build());
entryBuilder.setMatchEntryValue(metaCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(EthDst.class);
entryBuilder.setHasMask(true);
EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
EthDstBuilder ethDstBuilder = new EthDstBuilder();
ethDstBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06"));
ethDstBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 5 });
ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
entryBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(EthSrc.class);
entryBuilder.setHasMask(true);
EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
ethSrcBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08"));
ethSrcBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 2 });
ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
entryBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(EthType.class);
entryBuilder.setHasMask(false);
EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();
EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();
ethTypeBuilder.setEthType(new EtherType(46));
ethTypeCaseBuilder.setEthType(ethTypeBuilder.build());
entryBuilder.setMatchEntryValue(ethTypeCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(VlanVid.class);
entryBuilder.setHasMask(true);
final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
vlanVidBuilder.setVlanVid(45);
vlanVidBuilder.setCfiBit(true);
vlanVidBuilder.setMask(new byte[] { 0, 9 });
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
entryBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(VlanPcp.class);
entryBuilder.setHasMask(false);
VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();
VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();
vlanPcpBuilder.setVlanPcp((short) 14);
vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());
entryBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(IpDscp.class);
entryBuilder.setHasMask(false);
IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();
IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();
ipDscpBuilder.setDscp(new Dscp((short) 48));
ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());
entryBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(IpEcn.class);
entryBuilder.setHasMask(false);
IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
ipEcnBuilder.setEcn((short) 49);
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entryBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(IpProto.class);
entryBuilder.setHasMask(false);
IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();
IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();
ipProtoBuilder.setProtocolNumber((short) 50);
ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build());
entryBuilder.setMatchEntryValue(ipProtoCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv4Src.class);
entryBuilder.setHasMask(true);
Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));
ipv4SrcBuilder.setMask(new byte[] { 0, 0, 0, 14 });
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
entryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv4Dst.class);
entryBuilder.setHasMask(true);
Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));
ipv4DstBuilder.setMask(new byte[] { 0, 0, 0, 15 });
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
entryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(TcpSrc.class);
entryBuilder.setHasMask(false);
TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6653));
tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
entryBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(TcpDst.class);
entryBuilder.setHasMask(false);
TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6654));
tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
entryBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(UdpSrc.class);
entryBuilder.setHasMask(false);
UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6655));
udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
entryBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(UdpDst.class);
entryBuilder.setHasMask(false);
UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6656));
udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
entryBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(SctpSrc.class);
entryBuilder.setHasMask(false);
SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();
SctpSrcBuilder sctpSrcBuilder = new SctpSrcBuilder();
sctpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6657));
sctpSrcCaseBuilder.setSctpSrc(sctpSrcBuilder.build());
entryBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(SctpDst.class);
entryBuilder.setHasMask(false);
SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();
SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();
sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6658));
sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());
entryBuilder.setMatchEntryValue(sctpDstCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Icmpv4Type.class);
entryBuilder.setHasMask(false);
Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
icmpv4TypeBuilder.setIcmpv4Type((short) 51);
icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
entryBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Icmpv4Code.class);
entryBuilder.setHasMask(false);
Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
icmpv4CodeBuilder.setIcmpv4Code((short) 52);
icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
entryBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(ArpOp.class);
entryBuilder.setHasMask(false);
ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();
ArpOpBuilder arpOpBuilder = new ArpOpBuilder();
arpOpBuilder.setOpCode(53);
arpOpCaseBuilder.setArpOp(arpOpBuilder.build());
entryBuilder.setMatchEntryValue(arpOpCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(ArpSpa.class);
entryBuilder.setHasMask(true);
ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));
arpSpaBuilder.setMask(new byte[] { 0, 0, 0, 16 });
arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
entryBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(ArpTpa.class);
entryBuilder.setHasMask(true);
ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.5"));
arpTpaBuilder.setMask(new byte[] { 0, 0, 0, 17 });
arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
entryBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(ArpSha.class);
entryBuilder.setHasMask(true);
ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
arpShaBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05"));
arpShaBuilder.setMask(new byte[] { 0, 0, 4, 0, 0, 6 });
arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
entryBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(ArpTha.class);
entryBuilder.setHasMask(true);
ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));
arpThaBuilder.setMask(new byte[] { 0, 0, 6, 0, 0, 4 });
arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
entryBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6Src.class);
entryBuilder.setHasMask(true);
Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
ipv6SrcBuilder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1"));
ipv6SrcBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 });
ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
entryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6Dst.class);
entryBuilder.setHasMask(true);
Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
ipv6DstBuilder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1"));
ipv6DstBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 });
ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
entryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6Flabel.class);
entryBuilder.setHasMask(false);
Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L));
ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
entryBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Icmpv6Type.class);
entryBuilder.setHasMask(false);
Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
icmpv6TypeBuilder.setIcmpv6Type((short) 59);
icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
entryBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Icmpv6Code.class);
entryBuilder.setHasMask(false);
Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
icmpv6CodeBuilder.setIcmpv6Code((short) 60);
icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
entryBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6NdTarget.class);
entryBuilder.setHasMask(false);
Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1"));
ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
entryBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6NdSll.class);
entryBuilder.setHasMask(false);
Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();
Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();
ipv6NdSllBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06"));
ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());
entryBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6NdTll.class);
entryBuilder.setHasMask(false);
Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();
Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();
ipv6NdTllBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08"));
ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());
entryBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(MplsLabel.class);
entryBuilder.setHasMask(false);
MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();
MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();
mplsLabelBuilder.setMplsLabel(61L);
mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build());
entryBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(MplsTc.class);
entryBuilder.setHasMask(false);
MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();
MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();
mplsTcBuilder.setTc((short) 62);
mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build());
entryBuilder.setMatchEntryValue(mplsTcCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(MplsBos.class);
entryBuilder.setHasMask(false);
MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();
MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();
mplsBosBuilder.setBos(true);
mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());
entryBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(PbbIsid.class);
entryBuilder.setHasMask(true);
PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();
PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();
pbbIsidBuilder.setIsid(64L);
pbbIsidBuilder.setMask(new byte[] { 0, 1, 2 });
pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());
entryBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(TunnelId.class);
entryBuilder.setHasMask(true);
TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
tunnelIdBuilder.setTunnelId(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 });
tunnelIdBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 });
tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
entryBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
entries.add(entryBuilder.build());
entryBuilder = new MatchEntryBuilder();
entryBuilder.setOxmClass(OpenflowBasicClass.class);
entryBuilder.setOxmMatchField(Ipv6Exthdr.class);
entryBuilder.setHasMask(true);
Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();
Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();
ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));
ipv6ExthdrBuilder.setMask(new byte[] { 0, 2 });
ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());
entryBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());
entries.add(entryBuilder.build());
builder.setMatchEntry(entries);
Match match = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
matchSerializer.serialize(match, out);
Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong match length", 424, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 5, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 1L, out.readLong());
Assert.assertEquals("Wrong match entry mask", 2L, out.readLong());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte());
byte[] array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 1, 0, 3, 0, 0, 6 }, array);
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 5 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 9, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte());
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 4, 0, 2, 0, 0, 8 }, array);
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 2 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 10, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 46, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 13, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 4141, out.readUnsignedShort());
array = new byte[2];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 9 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 16, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 48, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 18, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 49, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 20, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 50, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 23, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte());
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 1 }, array);
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 14 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 25, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte());
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 2 }, array);
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 15 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 26, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 6653, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 28, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 6654, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 30, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 6655, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 32, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 6656, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 34, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 6657, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 36, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 6658, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 38, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 51, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 40, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 52, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 42, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 53, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 45, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte());
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 4 }, array);
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 16 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 47, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte());
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 5 }, array);
array = new byte[4];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 17 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 49, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte());
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 1, 2, 3, 4, 5 }, array);
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 4, 0, 0, 6 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 51, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte());
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 3 }, array);
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 6, 0, 0, 4 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 53, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte());
array = new byte[16];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array);
array = new byte[16];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 55, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte());
array = new byte[16];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, array);
array = new byte[16];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 56, out.readUnsignedByte());
// 8, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 59, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 60, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 60, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 62, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte());
array = new byte[16];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte());
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 1, 0, 3, 0, 0, 6 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 66, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte());
array = new byte[6];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 4, 0, 2, 0, 0, 8 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 68, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 61, out.readUnsignedInt());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 70, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 62, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 72, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 75, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 64, out.readUnsignedMedium());
array = new byte[3];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 1, 2 }, array);
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 77, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 1L, out.readLong());
Assert.assertEquals("Wrong match entry mask", 2L, out.readLong());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & hasMask", 79, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 358, out.readUnsignedShort());
array = new byte[2];
out.readBytes(array);
Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 2 }, array);
Assert.assertTrue("Wrong padding", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp in project openflowplugin by opendaylight.
the class MeterMessageDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
// Message type
buffer.writeByte(TYPE);
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.writeInt(XID);
buffer.writeShort(COMMAND.getIntValue());
buffer.writeShort(ByteBufUtils.fillBitMask(0, IS_KBPS, IS_PKTPS, IS_BURST, IS_STATS));
buffer.writeInt(ID);
// Drop band
buffer.writeShort(1);
buffer.writeInt(DROP_RATE);
buffer.writeInt(DROP_BURST);
buffer.writeZero(PADDING_IN_METER_BAND_DROP_HEADER);
// Dscp remark band
buffer.writeShort(2);
buffer.writeInt(DSCP_RATE);
buffer.writeInt(DSCP_BURST);
buffer.writeByte(DSCP_PREC);
buffer.writeZero(PADDING_IN_METER_BAND_DSCP_HEADER);
final MeterMessage message = (MeterMessage) getFactory().deserialize(buffer, EncodeConstants.OF13_VERSION_ID);
assertEquals(message.getXid().intValue(), XID);
assertEquals(message.getCommand().getIntValue(), COMMAND.getIntValue());
assertEquals(message.getFlags().isMeterBurst(), IS_BURST);
assertEquals(message.getFlags().isMeterKbps(), IS_KBPS);
assertEquals(message.getFlags().isMeterPktps(), IS_PKTPS);
assertEquals(message.getFlags().isMeterStats(), IS_STATS);
assertEquals(message.getMeterId().getValue().intValue(), ID);
final List<MeterBandHeader> meterBandHeader = message.getMeterBandHeaders().getMeterBandHeader();
assertEquals(meterBandHeader.size(), 2);
// Drop band
final MeterBandHeader dropHeader = meterBandHeader.get(0);
assertEquals(Drop.class, dropHeader.getBandType().getImplementedInterface());
assertTrue(dropHeader.getMeterBandTypes().getFlags().isOfpmbtDrop());
final Drop drop = Drop.class.cast(dropHeader.getBandType());
assertEquals(DROP_RATE, drop.getDropRate().intValue());
assertEquals(DROP_BURST, drop.getDropBurstSize().intValue());
// Dscp band
final MeterBandHeader dscpHeader = meterBandHeader.get(1);
assertEquals(DscpRemark.class, dscpHeader.getBandType().getImplementedInterface());
assertTrue(dscpHeader.getMeterBandTypes().getFlags().isOfpmbtDscpRemark());
final DscpRemark dscpRemark = DscpRemark.class.cast(dscpHeader.getBandType());
assertEquals(DSCP_RATE, dscpRemark.getDscpRemarkRate().intValue());
assertEquals(DSCP_BURST, dscpRemark.getDscpRemarkBurstSize().intValue());
assertEquals(buffer.readableBytes(), 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryNoMasks.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryNoMasks() {
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort.class);
entriesBuilder.setHasMask(false);
final InPortCaseBuilder caseBuilder = new InPortCaseBuilder();
final InPortBuilder portBuilder = new InPortBuilder();
portBuilder.setPortNumber(new PortNumber(1L));
caseBuilder.setInPort(portBuilder.build());
entriesBuilder.setMatchEntryValue(caseBuilder.build());
entries.add(entriesBuilder.build());
final InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort.class);
entriesBuilder.setHasMask(false);
final InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
inPhyPortBuilder.setPortNumber(new PortNumber(2L));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
entriesBuilder.setHasMask(false);
final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();
metadataBuilder.setMetadata(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 });
metadataCaseBuilder.setMetadata(metadataBuilder.build());
entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthDst.class);
entriesBuilder.setHasMask(false);
final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
final EthDstBuilder ethDstBuilder = new EthDstBuilder();
ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));
ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthSrc.class);
entriesBuilder.setHasMask(false);
final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));
ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthType.class);
entriesBuilder.setHasMask(false);
final EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();
final EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();
ethTypeBuilder.setEthType(new EtherType(3));
ethTypeCaseBuilder.setEthType(ethTypeBuilder.build());
entriesBuilder.setMatchEntryValue(ethTypeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(VlanVid.class);
final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
entriesBuilder.setHasMask(false);
final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
vlanVidBuilder.setVlanVid(4);
vlanVidBuilder.setCfiBit(true);
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
entriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(VlanPcp.class);
final VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();
entriesBuilder.setHasMask(false);
final VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();
vlanPcpBuilder.setVlanPcp((short) 5);
vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());
entriesBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpDscp.class);
entriesBuilder.setHasMask(false);
final IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();
final IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();
ipDscpBuilder.setDscp(new Dscp((short) 6));
ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());
entriesBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpEcn.class);
entriesBuilder.setHasMask(false);
final IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
final IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
ipEcnBuilder.setEcn((short) 7);
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpProto.class);
final IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();
entriesBuilder.setHasMask(false);
final IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();
ipProtoBuilder.setProtocolNumber((short) 8);
ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build());
entriesBuilder.setMatchEntryValue(ipProtoCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Src.class);
entriesBuilder.setHasMask(false);
final Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();
final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));
ipv4AddressBuilder.setIpv4Src(ipv4SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4AddressBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Dst.class);
entriesBuilder.setHasMask(false);
final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
final Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TcpSrc.class);
entriesBuilder.setHasMask(false);
final TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
final TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(9));
tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
entriesBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TcpDst.class);
entriesBuilder.setHasMask(false);
final TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
final TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(10));
tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
entriesBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv4Type.class);
entriesBuilder.setHasMask(false);
final Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
final Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
icmpv4TypeBuilder.setIcmpv4Type((short) 15);
icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv4Code.class);
entriesBuilder.setHasMask(false);
final Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
final Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
icmpv4CodeBuilder.setIcmpv4Code((short) 16);
icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv6Type.class);
entriesBuilder.setHasMask(false);
final Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
final Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
icmpv6TypeBuilder.setIcmpv6Type((short) 19);
icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Icmpv6Code.class);
entriesBuilder.setHasMask(false);
final Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
final Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
icmpv6CodeBuilder.setIcmpv6Code((short) 20);
icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
entriesBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(MplsLabel.class);
entriesBuilder.setHasMask(false);
final MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();
final MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();
mplsLabelBuilder.setMplsLabel(21L);
mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build());
entriesBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(MplsTc.class);
entriesBuilder.setHasMask(false);
final MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();
final MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();
mplsTcBuilder.setTc((short) 22);
mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build());
entriesBuilder.setMatchEntryValue(mplsTcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(MplsBos.class);
entriesBuilder.setHasMask(false);
final MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();
final MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();
mplsBosBuilder.setBos(true);
mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());
entriesBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(PbbIsid.class);
entriesBuilder.setHasMask(false);
final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();
final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();
pbbIsidBuilder.setIsid(23L);
pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());
entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TunnelId.class);
entriesBuilder.setHasMask(false);
final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
tunnelIdBuilder.setTunnelId(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
entries.add(entriesBuilder.build());
final MatchBuilder builder = new MatchBuilder();
builder.setMatchEntry(entries);
final Match match = builder.build();
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatch = convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();
Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue());
Assert.assertEquals("Wrong in phy port", "openflow:42:2", builtMatch.getInPhyPort().getValue());
Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }), builtMatch.getMetadata().getMetadata());
Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress());
Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress());
Assert.assertEquals("Wrong eth type", 3, builtMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());
Assert.assertEquals("Wrong vlan pcp", 5, builtMatch.getVlanMatch().getVlanPcp().getValue().intValue());
Assert.assertEquals("Wrong ip dscp", 6, builtMatch.getIpMatch().getIpDscp().getValue().intValue());
Assert.assertEquals("Wrong ip ecn", 7, builtMatch.getIpMatch().getIpEcn().intValue());
Assert.assertEquals("Wrong ip proto", null, builtMatch.getIpMatch().getIpProto());
Assert.assertEquals("Wrong ip protocol", 8, builtMatch.getIpMatch().getIpProtocol().intValue());
final TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();
Assert.assertEquals("Wrong tcp src port", 9, tcpMatch.getTcpSourcePort().getValue().intValue());
Assert.assertEquals("Wrong tcp dst port", 10, tcpMatch.getTcpDestinationPort().getValue().intValue());
Assert.assertEquals("Wrong icmpv4 type", 15, builtMatch.getIcmpv4Match().getIcmpv4Type().intValue());
Assert.assertEquals("Wrong icmpv4 code", 16, builtMatch.getIcmpv4Match().getIcmpv4Code().intValue());
Assert.assertEquals("Wrong icmpv6 type", 19, builtMatch.getIcmpv6Match().getIcmpv6Type().intValue());
Assert.assertEquals("Wrong icmpv6 code", 20, builtMatch.getIcmpv6Match().getIcmpv6Code().intValue());
final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/32", ipv4Match.getIpv4Source().getValue());
Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/32", ipv4Match.getIpv4Destination().getValue());
Assert.assertEquals("Wrong mpls label", 21, builtMatch.getProtocolMatchFields().getMplsLabel().intValue());
Assert.assertEquals("Wrong mpls bos", 1, builtMatch.getProtocolMatchFields().getMplsBos().intValue());
Assert.assertEquals("Wrong mpls tc", 22, builtMatch.getProtocolMatchFields().getMplsTc().intValue());
Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());
Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }), builtMatch.getTunnel().getTunnelId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.Dscp in project openflowplugin by opendaylight.
the class MatchV10ResponseConvertorTest method testIcmpv4Match.
/**
* ICMPv4 match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
*/
@Test
public void testIcmpv4Match() {
// NW_PROTO, TP_SRC, TP_DST are wildcarded.
Long dlType = 0x800L;
FlowWildcardsV10 wc = new FlowWildcardsV10(true, true, false, true, true, true, true, 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());
// NW_PROTO is not wildcarded but null.
wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, true, true);
match = builder.setWildcards(wc).build();
salMatch = convert(match, datapathIdConvertorData).build();
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 ICMPv4 protocol.
Short ipProto = 1;
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 ICMPv4 type.
Short icmpType = 10;
match = builder.setTpSrc(icmpType.intValue()).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
Icmpv4Match icmpv4Match = salMatch.getIcmpv4Match();
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 type", icmpType, icmpv4Match.getIcmpv4Type());
Assert.assertEquals("Wrong ICMPv4 code", null, icmpv4Match.getIcmpv4Code());
// 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();
icmpv4Match = salMatch.getIcmpv4Match();
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 type", icmpType, icmpv4Match.getIcmpv4Type());
Assert.assertEquals("Wrong ICMPv4 code", null, icmpv4Match.getIcmpv4Code());
// Specify ICMPv4 code only.
Short icmpCode = 33;
match = builder.setTpSrc(null).setTpDst(icmpCode.intValue()).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
icmpv4Match = salMatch.getIcmpv4Match();
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 type", null, icmpv4Match.getIcmpv4Type());
Assert.assertEquals("Wrong ICMPv4 code", icmpCode, icmpv4Match.getIcmpv4Code());
// Specify both ICMPv4 type and code.
icmpType = 0;
icmpCode = 8;
match = builder.setTpSrc(icmpType.intValue()).setTpDst(icmpCode.intValue()).build();
salMatch = convert(match, datapathIdConvertorData).build();
etherMatch = salMatch.getEthernetMatch();
ipMatch = salMatch.getIpMatch();
icmpv4Match = salMatch.getIcmpv4Match();
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 type", icmpType, icmpv4Match.getIcmpv4Type());
Assert.assertEquals("Wrong ICMPv4 code", icmpCode, icmpv4Match.getIcmpv4Code());
}
Aggregations