Search in sources :

Example 16 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class ArpSourceHardwareAddressEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final MacAddress address = new MacAddress("00:01:02:03:04:05");
    final MacAddress mask = new MacAddress("00:00:00:00:00:00");
    final Match arpShaMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceHardwareAddress(new ArpSourceHardwareAddressBuilder().setAddress(address).setMask(mask).build()).build()).build();
    assertMatch(arpShaMatch, true, (out) -> {
        byte[] addressBytes = new byte[6];
        out.readBytes(addressBytes);
        assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
        byte[] maskBytes = new byte[6];
        out.readBytes(maskBytes);
        assertEquals(new MacAddress(ByteBufUtils.macAddressToString(maskBytes)).getValue(), mask.getValue());
    });
    final Match arpShaMatchNoMask = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceHardwareAddress(new ArpSourceHardwareAddressBuilder().setAddress(address).build()).build()).build();
    assertMatch(arpShaMatchNoMask, false, (out) -> {
        byte[] addressBytes = new byte[6];
        out.readBytes(addressBytes);
        assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
    });
}
Also used : ArpSourceHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) 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.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 17 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class ArpTargetHardwareAddressEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final MacAddress address = new MacAddress("00:01:02:03:04:05");
    final MacAddress mask = new MacAddress("00:00:00:00:00:00");
    final Match arpShaMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().setAddress(address).setMask(mask).build()).build()).build();
    assertMatch(arpShaMatch, true, (out) -> {
        byte[] addressBytes = new byte[6];
        out.readBytes(addressBytes);
        assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
        byte[] maskBytes = new byte[6];
        out.readBytes(maskBytes);
        assertEquals(new MacAddress(ByteBufUtils.macAddressToString(maskBytes)).getValue(), mask.getValue());
    });
    final Match arpShaMatchNoMask = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().setAddress(address).build()).build()).build();
    assertMatch(arpShaMatchNoMask, false, (out) -> {
        byte[] addressBytes = new byte[6];
        out.readBytes(addressBytes);
        assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
    });
}
Also used : ArpTargetHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) 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.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 18 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class ArpOpEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    processHeader(message);
    final Layer3Match layer3Match = builder.getLayer3Match();
    final int arpOp = message.readUnsignedShort();
    if (Objects.isNull(layer3Match)) {
        builder.setLayer3Match(new ArpMatchBuilder().setArpOp(arpOp).build());
    } else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpOp())) {
        builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpOp(arpOp).build());
    } else {
        throwErrorOnMalformed(builder, "layer3Match", "arpOp");
    }
}
Also used : Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)

Example 19 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class ArpTargetTransportAddressEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final Layer3Match layer3Match = builder.getLayer3Match();
    final Ipv4Prefix prefix = readPrefix(message, hasMask);
    if (Objects.isNull(layer3Match)) {
        builder.setLayer3Match(new ArpMatchBuilder().setArpTargetTransportAddress(prefix).build());
    } else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpTargetTransportAddress())) {
        builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpTargetTransportAddress(prefix).build());
    } else {
        throwErrorOnMalformed(builder, "layer3Match", "arpTargetTransportAddress");
    }
}
Also used : Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) 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)

Example 20 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class ArpTargetTransportAddressEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final Match arpSpaMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpTargetTransportAddress(new Ipv4Prefix("10.0.2.0/24")).build()).build();
    assertMatch(arpSpaMatch, true, (out) -> {
        byte[] address = new byte[4];
        out.readBytes(address);
        assertArrayEquals(address, new byte[] { 10, 0, 2, 0 });
        byte[] mask = new byte[4];
        out.readBytes(mask);
        assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
    });
    final Match arpSpaMatchNoMask = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.0/32")).build()).build();
    assertMatch(arpSpaMatchNoMask, false, (out) -> {
        byte[] address = new byte[4];
        out.readBytes(address);
        assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
    });
}
Also used : MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Aggregations

ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)21 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)15 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)11 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)9 Test (org.junit.Test)8 ArpSourceHardwareAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder)8 ArpTargetHardwareAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder)8 ArpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)6 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)5 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)5 Layer3Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match)5 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)5 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)5 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)5 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)4 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)4 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)4 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)4 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)4 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)4