Search in sources :

Example 96 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.

the class TunnelIpv4SourceEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final Match ipv4match = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Source(new Ipv4Prefix("10.0.2.0/24")).build()).build();
    assertMatch(ipv4match, 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 ipv4matchNoMask = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Source(new Ipv4Prefix("10.0.0.0/32")).build()).build();
    assertMatch(ipv4matchNoMask, false, (out) -> {
        byte[] address = new byte[4];
        out.readBytes(address);
        assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
    });
}
Also used : TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) 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) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 97 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.

the class OxmArpShaSerializerTest method testSerializeWithoutMask.

/**
 * Test correct serialization.
 */
@Test
public void testSerializeWithoutMask() {
    MatchEntryBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);
    checkHeader(buffer, false);
    byte[] address = new byte[6];
    buffer.readBytes(address);
    Assert.assertArrayEquals("Wrong address", new byte[] { 0, 1, 2, 3, 4, 5 }, address);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}
Also used : MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 98 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.

the class OxmArpThaSerializerTest method testSerializeWithMask.

/**
 * Test correct serialization.
 */
@Test
public void testSerializeWithMask() {
    MatchEntryBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A");
    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);
    checkHeader(buffer, true);
    byte[] address = new byte[6];
    buffer.readBytes(address);
    Assert.assertArrayEquals("Wrong address", new byte[] { 0, 1, 2, 3, 4, 10 }, address);
    byte[] tmp = new byte[6];
    buffer.readBytes(tmp);
    Assert.assertArrayEquals("Wrong mask", new byte[] { 15, 15, 0, 0, 10, 10 }, tmp);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}
Also used : MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 99 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.

the class OxmEthDstSerializerTest method testSerializeWithoutMask.

/**
 * Test correct serialization.
 */
@Test
public void testSerializeWithoutMask() {
    MatchEntryBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05");
    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);
    checkHeader(buffer, false);
    byte[] address = new byte[6];
    buffer.readBytes(address);
    Assert.assertArrayEquals("Wrong address", new byte[] { 0, 1, 2, 3, 4, 5 }, address);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}
Also used : MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 100 with Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.

the class OxmIpv4SrcSerializerTest method testSerializeWithoutMask.

/**
 * Test correct serialization.
 */
@Test
public void testSerializeWithoutMask() {
    MatchEntryBuilder builder = prepareMatchEntry(false, "10.0.0.1");
    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);
    checkHeader(buffer, false);
    byte[] address = new byte[4];
    buffer.readBytes(address);
    Assert.assertArrayEquals("Wrong address", new byte[] { 10, 0, 0, 1 }, address);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}
Also used : MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)209 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)90 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)79 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)77 ArrayList (java.util.ArrayList)67 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)66 ByteBuf (io.netty.buffer.ByteBuf)57 InetAddress (java.net.InetAddress)57 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)55 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)52 BigInteger (java.math.BigInteger)41 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)41 Inet6Address (java.net.Inet6Address)39 KeyValueAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress)39 Inet4Address (java.net.Inet4Address)36 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)29 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)28 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)27 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)26 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25