Search in sources :

Example 71 with Ipv4Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project openflowplugin by opendaylight.

the class BulkOMaticUtils method getMatch.

public static Match getMatch(final int sourceIp) {
    Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build();
    MatchBuilder matchBuilder = new MatchBuilder();
    matchBuilder.setLayer3Match(ipv4Match);
    EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
    EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
    ethTypeBuilder.setType(new EtherType(2048L));
    ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
    matchBuilder.setEthernetMatch(ethMatchBuilder.build());
    return matchBuilder.build();
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 72 with Ipv4Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project openflowplugin by opendaylight.

the class ArpSourceTransportAddressEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final Ipv4Prefix arpSourceTransportAddress = new Ipv4Prefix("192.168.0.0/24");
    final Ipv4Prefix arpSourceTransportAddressNoMask = new Ipv4Prefix("192.168.0.0/32");
    writeHeader(in, false);
    Iterator<String> addressParts = IpConversionUtil.splitToParts(arpSourceTransportAddressNoMask);
    in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
    assertEquals(arpSourceTransportAddressNoMask.getValue(), ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceTransportAddress().getValue());
    assertEquals(0, in.readableBytes());
    writeHeader(in, true);
    addressParts = IpConversionUtil.splitToParts(arpSourceTransportAddress);
    in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
    in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
    final Ipv4Prefix desAddress = ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceTransportAddress();
    assertEquals(arpSourceTransportAddress.getValue(), desAddress.getValue());
    assertEquals(0, in.readableBytes());
}
Also used : ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) ByteBuf(io.netty.buffer.ByteBuf) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 73 with Ipv4Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project openflowplugin by opendaylight.

the class OFPluginFlowTest method createMatch1.

private static MatchBuilder createMatch1() {
    MatchBuilder match = new MatchBuilder();
    Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
    Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
    ipv4Match.setIpv4Destination(prefix);
    Ipv4Match i4m = ipv4Match.build();
    match.setLayer3Match(i4m);
    EthernetMatchBuilder eth = new EthernetMatchBuilder();
    EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
    ethTypeBuilder.setType(new EtherType(0x0800L));
    eth.setEthernetType(ethTypeBuilder.build());
    match.setEthernetMatch(eth.build());
    return match;
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 74 with Ipv4Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project openflowplugin by opendaylight.

the class MatchConvertorTest method testArpMatchConversionWithMasks.

@Test
public void testArpMatchConversionWithMasks() {
    ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
    /* Use canonnical prefixes !!! */
    arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/8"));
    arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/31"));
    ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();
    srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
    srcHwBuilder.setMask(new MacAddress("00:00:00:00:00:08"));
    arpBuilder.setArpSourceHardwareAddress(srcHwBuilder.build());
    ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
    dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
    dstHwBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
    arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
    MatchBuilder builder = new MatchBuilder();
    builder.setLayer3Match(arpBuilder.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", 4, entries.size());
    MatchEntry entry = entries.get(0);
    entry = entries.get(0);
    checkEntryHeader(entry, ArpSpa.class, true);
    Assert.assertEquals("Wrong arp spa", "10.0.0.0", ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getIpv4Address().getValue());
    Assert.assertArrayEquals("Wrong arp spa mask", new byte[] { (byte) 255, 0, 0, 0 }, ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getMask());
    entry = entries.get(1);
    checkEntryHeader(entry, ArpTpa.class, true);
    Assert.assertEquals("Wrong arp tpa", "10.0.0.4", ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getIpv4Address().getValue());
    Assert.assertArrayEquals("Wrong arp tpa mask", new byte[] { (byte) 255, (byte) 255, (byte) 255, (byte) 254 }, ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getMask());
    entry = entries.get(2);
    checkEntryHeader(entry, ArpSha.class, true);
    Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:05", ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMacAddress().getValue());
    Assert.assertArrayEquals("Wrong arp sha mask", new byte[] { 0, 0, 0, 0, 0, 8 }, ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMask());
    entry = entries.get(3);
    checkEntryHeader(entry, ArpTha.class, true);
    Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:06", ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMacAddress().getValue());
    Assert.assertArrayEquals("Wrong arp tha mask", new byte[] { 0, 0, 0, 0, 0, 9 }, ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMask());
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) ArpThaCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCase) ArpSpaCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCase) ArpShaCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCase) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) ArpSourceHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder) ArpTpaCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCase) ArpTargetHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder) List(java.util.List) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Icmpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder) TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) VlanMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) Icmpv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder) SctpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder) UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Test(org.junit.Test)

Example 75 with Ipv4Prefix

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project lispflowmapping by opendaylight.

the class LispSimpleAddressStringifierTest method getStringTest_asIpv4Prefix.

/**
 * Tests {@link LispSimpleAddressStringifier#getString} with Ipv4Prefix.
 */
@Test
public void getStringTest_asIpv4Prefix() {
    SimpleAddress simpleAddress = new SimpleAddress(IPV4_PREFIX);
    String result = LispSimpleAddressStringifier.getString(simpleAddress);
    assertEquals(IPV4_PREFIX.getIpv4Prefix().getValue(), result);
}
Also used : SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Test(org.junit.Test)

Aggregations

Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)152 Test (org.junit.Test)88 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)40 ArrayList (java.util.ArrayList)37 ByteBuf (io.netty.buffer.ByteBuf)36 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)33 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)33 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)33 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)22 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)20 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)20 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)18 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)18 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)16 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)15 SetNwSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder)14 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)14 EthernetTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder)14 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)13 SetNwDstActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder)12