use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4 in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createL4TCPMatch.
private static MatchBuilder createL4TCPMatch() {
final MatchBuilder match = new MatchBuilder();
final EthernetMatchBuilder eth = new EthernetMatchBuilder();
final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
// ipv4 version
final IpMatchBuilder ipmatch = new IpMatchBuilder();
ipmatch.setIpProtocol((short) 6);
match.setIpMatch(ipmatch.build());
final PortNumber srcport = new PortNumber(1213);
final PortNumber dstport = new PortNumber(646);
// tcp match
final TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
tcpmatch.setTcpSourcePort(srcport);
tcpmatch.setTcpDestinationPort(dstport);
match.setLayer4Match(tcpmatch.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4 in project openflowplugin by opendaylight.
the class MatchDeserializerInjector method injectDeserializers.
/**
* Injects deserializers into provided
* {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider}.
*
* @param provider OpenflowJava deserializer extension provider
*/
static void injectDeserializers(final DeserializerExtensionProvider provider) {
for (MatchPath path : MatchPath.values()) {
final MatchDeserializer deserializer = new MatchDeserializer(path);
provider.registerDeserializer(new MessageCodeMatchKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_LENGTH, Match.class, path), deserializer);
// Inject new match entry serializers here using injector created by createInjector method
final Function<Integer, Function<Long, Function<Integer, Consumer<MatchEntryDeserializer>>>> injector = createInjector(deserializer, EncodeConstants.OF13_VERSION_ID);
// Wrapped injector that uses OPENFLOW_BASIC_CLASS
final Function<Integer, Consumer<MatchEntryDeserializer>> basicInjector = injector.apply(OxmMatchConstants.OPENFLOW_BASIC_CLASS).apply(null);
// Wrapped injector that uses EXPERIMENTER_CLASS
final Function<Long, Function<Integer, Consumer<MatchEntryDeserializer>>> experInjector = injector.apply(OxmMatchConstants.EXPERIMENTER_CLASS);
basicInjector.apply(OxmMatchConstants.ARP_OP).accept(new ArpOpEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ARP_SHA).accept(new ArpSourceHardwareAddressEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ARP_THA).accept(new ArpTargetHardwareAddressEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ARP_SPA).accept(new ArpSourceTransportAddressEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ARP_TPA).accept(new ArpTargetTransportAddressEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IN_PORT).accept(new InPortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IN_PHY_PORT).accept(new InPhyPortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.METADATA).accept(new MetadataEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ETH_DST).accept(new EthernetDestinationEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ETH_SRC).accept(new EthernetSourceEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ETH_TYPE).accept(new EthernetTypeEntryDeserializer());
basicInjector.apply(OxmMatchConstants.VLAN_PCP).accept(new VlanPcpEntryDeserializer());
basicInjector.apply(OxmMatchConstants.VLAN_VID).accept(new VlanVidEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IP_DSCP).accept(new IpDscpEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IP_ECN).accept(new IpEcnEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IP_PROTO).accept(new IpProtoEntryDeserializer());
basicInjector.apply(OxmMatchConstants.TCP_SRC).accept(new TcpSourcePortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.TCP_DST).accept(new TcpDestinationPortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.UDP_SRC).accept(new UdpSourcePortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.UDP_DST).accept(new UdpDestinationPortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.SCTP_SRC).accept(new SctpSourcePortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.SCTP_DST).accept(new SctpDestinationPortEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ICMPV4_CODE).accept(new Icmpv4CodeEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ICMPV4_TYPE).accept(new Icmpv4TypeEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ICMPV6_CODE).accept(new Icmpv6CodeEntryDeserializer());
basicInjector.apply(OxmMatchConstants.ICMPV6_TYPE).accept(new Icmpv6TypeEntryDeserializer());
// TODO: How to differentiate between Ipv4 and Tunnel when both are serialized to same format?
basicInjector.apply(OxmMatchConstants.IPV4_SRC).accept(new Ipv4SourceEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV4_DST).accept(new Ipv4DestinationEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV6_SRC).accept(new Ipv6SourceEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV6_DST).accept(new Ipv6DestinationEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV6_EXTHDR).accept(new Ipv6ExtHeaderEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV6_FLABEL).accept(new Ipv6FlabelEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV6_ND_SLL).accept(new Ipv6NdSllEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV6_ND_TLL).accept(new Ipv6NdTllEntryDeserializer());
basicInjector.apply(OxmMatchConstants.IPV6_ND_TARGET).accept(new Ipv6NdTargetEntryDeserializer());
basicInjector.apply(OxmMatchConstants.MPLS_LABEL).accept(new MplsLabelEntryDeserializer());
basicInjector.apply(OxmMatchConstants.MPLS_BOS).accept(new MplsBosEntryDeserializer());
basicInjector.apply(OxmMatchConstants.MPLS_TC).accept(new MplsTcEntryDeserializer());
basicInjector.apply(OxmMatchConstants.PBB_ISID).accept(new PbbEntryDeserializer());
basicInjector.apply(OxmMatchConstants.TUNNEL_ID).accept(new TunnelIdEntryDeserializer());
experInjector.apply(EncodeConstants.ONF_EXPERIMENTER_ID).apply(EncodeConstants.ONFOXM_ET_TCP_FLAGS).accept(new TcpFlagsEntryDeserializer());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4 in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithSrcCidrMaskAndDstArbitraryBitMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithSrcCidrMaskAndDstArbitraryBitMask() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
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.Metadata.class);
entriesBuilder.setHasMask(true);
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Src.class);
entriesBuilder.setHasMask(true);
final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
ipv4SrcBuilder.setMask(new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Dst.class);
entriesBuilder.setHasMask(true);
final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
ipv4AddressBuilder.setMask(new byte[] { (byte) 255, 0, (byte) 240, 0 });
ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
entries.add(entriesBuilder.build());
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();
final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1", ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1", ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4 in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithSrcArbitraryBitMaskAndDstCidrMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithSrcArbitraryBitMaskAndDstCidrMask() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
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.Metadata.class);
entriesBuilder.setHasMask(true);
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Src.class);
entriesBuilder.setHasMask(true);
final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
ipv4SrcBuilder.setMask(new byte[] { (byte) 255, (byte) 0, (byte) 255, 0 });
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Dst.class);
entriesBuilder.setHasMask(true);
final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
ipv4AddressBuilder.setMask(new byte[] { (byte) 255, (byte) 255, (byte) 240, 0 });
ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
entries.add(entriesBuilder.build());
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();
final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1", ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1", ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4 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());
}
Aggregations