Search in sources :

Example 1 with Ipv4PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.

the class MaskUtilTest method normalizeTest_withIpv4PrefixBinary_withMask.

/**
 * Tests {@link MaskUtil#normalize(Eid eid, short mask)} method with Ipv4PrefixBinary.
 */
@Test
public void normalizeTest_withIpv4PrefixBinary_withMask() throws UnknownHostException {
    // input ip: 255.255.255.255, mask: 20
    final Eid result = MaskUtil.normalize(EID_IPV4_PREFIX_BINARY, (short) 20);
    final Ipv4PrefixBinary resultPrefix = (Ipv4PrefixBinary) result.getAddress();
    // expected result
    assertArrayEquals(ipv4ExpectedByteAddress, resultPrefix.getIpv4AddressBinary().getValue());
    assertEquals((short) 20, (short) resultPrefix.getIpv4MaskLength());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) Test(org.junit.Test)

Example 2 with Ipv4PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.

the class MaskUtilTest method normalizeTest_withIpv4PrefixBinary.

/**
 * Tests {@link MaskUtil#normalize(Eid eid)} method with Ipv4PrefixBinary.
 */
@Test
public void normalizeTest_withIpv4PrefixBinary() throws UnknownHostException {
    // input ip: 255.255.255.255, mask: 20
    final Eid result = MaskUtil.normalize(EID_IPV4_PREFIX_BINARY);
    final Ipv4PrefixBinary resultPrefix = (Ipv4PrefixBinary) result.getAddress();
    // expected result
    final byte[] expectedResult = Inet4Address.getByName("255.255.240.0").getAddress();
    assertArrayEquals(expectedResult, resultPrefix.getIpv4AddressBinary().getValue());
    assertEquals((short) 20, (short) resultPrefix.getIpv4MaskLength());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) Test(org.junit.Test)

Example 3 with Ipv4PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.

the class MapReplySerializationTest method deserialize__MultipleRecordsWithoutRLOCs.

@Test
public void deserialize__MultipleRecordsWithoutRLOCs() throws Exception {
    MapReply mr = MapReplySerializer.getInstance().deserialize(hexToByteBuffer("20 00 00 02 00 00 " + "00 00 00 00 00 00 00 00 00 01 00 20 00 00 00 00 " + "00 01 01 02 03 04 00 00 00 00 00 10 30 00 00 02 00 01 04 03 00 00"));
    assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
    // XXX Why here normalized and other cases not normalized?
    assertArrayEquals(new byte[] { 4, 3, 0, 0 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
    assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().isAuthoritative());
    assertEquals(true, mr.getMappingRecordItem().get(1).getMappingRecord().isAuthoritative());
    assertEquals(Action.NoAction, mr.getMappingRecordItem().get(0).getMappingRecord().getAction());
    assertEquals(Action.NativelyForward, mr.getMappingRecordItem().get(1).getMappingRecord().getAction());
    assertEquals(0, mr.getMappingRecordItem().get(0).getMappingRecord().getMapVersion().shortValue());
    assertEquals(2, mr.getMappingRecordItem().get(1).getMappingRecord().getMapVersion().shortValue());
    assertEquals(32, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()));
    assertEquals(16, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()));
    assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getRecordTtl().byteValue());
    assertEquals(0, mr.getMappingRecordItem().get(1).getMappingRecord().getRecordTtl().byteValue());
}
Also used : Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) Test(org.junit.Test)

Example 4 with Ipv4PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.

the class LispAddressUtil method toEid.

public static Eid toEid(Ipv4PrefixBinary prefix, InstanceIdType vni) {
    EidBuilder builder = new EidBuilder();
    builder.setAddressType(Ipv4PrefixBinaryAfi.class);
    builder.setVirtualNetworkId(vni);
    builder.setAddress((Address) prefix);
    return builder.build();
}
Also used : EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)

Example 5 with Ipv4PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.

the class LispAddressUtil method convertToBinary.

private static Ipv4PrefixBinary convertToBinary(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix prefix) {
    Ipv4PrefixBinaryBuilder pb = new Ipv4PrefixBinaryBuilder();
    byte[] address = InetAddresses.forString(MaskUtil.getAddressStringForIpv4Prefix(prefix)).getAddress();
    pb.setIpv4AddressBinary(new Ipv4AddressBinary(address));
    pb.setIpv4MaskLength(MaskUtil.getMaskForAddress(prefix));
    return pb.build();
}
Also used : Ipv4AddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary) Ipv4PrefixBinaryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder)

Aggregations

Ipv4PrefixBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary)14 Ipv6PrefixBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary)8 Test (org.junit.Test)5 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 InetAddress (java.net.InetAddress)4 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)4 Inet4Address (java.net.Inet4Address)3 Inet6Address (java.net.Inet6Address)3 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 Ipv4Binary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary)3 Ipv6Binary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary)3 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)3 UnknownHostException (java.net.UnknownHostException)2 InstanceId (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.InstanceId)2 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix)2 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix)2 Ipv4AddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary)2 Ipv4PrefixBinaryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder)2 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)2 InetSocketAddress (java.net.InetSocketAddress)1