Search in sources :

Example 86 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method asEid.

/**
 * Tests {@link LispAddressUtil#asEid(SimpleAddress, InstanceIdType)} method.
 */
@Test
public void asEid() {
    final Eid eid = LispAddressUtil.asEid(SIMPLE_ADDRESS_IPV4_TEST, INSTANCE_ID_TYPE_TEST);
    assertNotNull(eid);
    assertEquals(Ipv4BinaryAfi.class, eid.getAddressType());
    final Ipv4Binary address = (Ipv4Binary) eid.getAddress();
    assertArrayEquals(InetAddresses.forString(SIMPLE_ADDRESS_IPV4_TEST.getIpAddress().getIpv4Address().getValue()).getAddress(), address.getIpv4Binary().getValue());
    assertEquals(INSTANCE_ID_TYPE_TEST, eid.getVirtualNetworkId());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Ipv4Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary) Test(org.junit.Test)

Example 87 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method addressFromIpPrefix_ipv4.

/**
 * Tests {@link LispAddressUtil#addressFromIpPrefix(IpPrefix)} and {@link
 * LispAddressUtil#addressTypeFromIpPrefix(IpPrefix)}
 * methods with ipv4 address.
 */
@Test
public void addressFromIpPrefix_ipv4() {
    IpPrefix ipv4Prefix = new IpPrefix(new Ipv4Prefix(IPV4_ADDRESS_PREFIX_VALUE_TEST));
    final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpPrefix(ipv4Prefix);
    assertEquals(Ipv4PrefixAfi.class, addressClass);
    final Address address = LispAddressUtil.addressFromIpPrefix(ipv4Prefix);
    assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix);
    assertEquals(IPV4_ADDRESS_PREFIX_VALUE_TEST, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) address).getIpv4Prefix().getValue());
}
Also used : InetAddress(java.net.InetAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) LispAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress) NoAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress) Inet4Address(java.net.Inet4Address) Inet6Address(java.net.Inet6Address) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) KeyValueAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Test(org.junit.Test)

Example 88 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method addressFromServicePathTest_withServicePath.

/**
 * Test {@link LispAddressUtil#addressFromServicePath(ServicePath)} method with concrete servicePath.
 */
@Test
public void addressFromServicePathTest_withServicePath() {
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePathBuilder servicePathBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePathBuilder();
    servicePathBuilder.setServiceIndex(SERVICE_INDEX_TEST);
    servicePathBuilder.setServicePathId(new ServicePathIdType(DUMMY_SERVICE_PATH_ID_TYPE));
    ServicePath expectedAddress = servicePathBuilder.build();
    final Address testedAddress = LispAddressUtil.addressFromServicePath(expectedAddress);
    assertTrue(testedAddress instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath);
    assertEquals(expectedAddress, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath) testedAddress).getServicePath());
}
Also used : InetAddress(java.net.InetAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) LispAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress) NoAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress) Inet4Address(java.net.Inet4Address) Inet6Address(java.net.Inet6Address) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) KeyValueAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress) ServicePathIdType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.ServicePathIdType) ServicePath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePath) Test(org.junit.Test)

Example 89 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class MapRequestSerializer method serialize.

public ByteBuffer serialize(MapRequest mapRequest) {
    int size = Length.HEADER_SIZE;
    if (mapRequest.getSourceEid() != null && mapRequest.getSourceEid().getEid() != null) {
        size += LispAddressSerializer.getInstance().getAddressSize(mapRequest.getSourceEid().getEid());
    } else {
        size += 2;
    }
    if (mapRequest.getItrRloc() != null) {
        for (ItrRloc address : mapRequest.getItrRloc()) {
            size += LispAddressSerializer.getInstance().getAddressSize(address.getRloc());
        }
    }
    if (mapRequest.getEidItem() != null) {
        for (EidItem record : mapRequest.getEidItem()) {
            size += 2 + LispAddressSerializer.getInstance().getAddressSize(record.getEid());
        }
    }
    ByteBuffer requestBuffer = ByteBuffer.allocate(size);
    requestBuffer.put((byte) ((byte) (MessageType.MapRequest.getIntValue() << 4) | ByteUtil.boolToBit(BooleanUtils.isTrue(mapRequest.isAuthoritative()), Flags.AUTHORITATIVE) | ByteUtil.boolToBit(BooleanUtils.isTrue(mapRequest.isMapDataPresent()), Flags.MAP_DATA_PRESENT) | ByteUtil.boolToBit(BooleanUtils.isTrue(mapRequest.isProbe()), Flags.PROBE) | ByteUtil.boolToBit(BooleanUtils.isTrue(mapRequest.isSmr()), Flags.SMR)));
    requestBuffer.put((byte) (ByteUtil.boolToBit(BooleanUtils.isTrue(mapRequest.isPitr()), Flags.PITR) | ByteUtil.boolToBit(BooleanUtils.isTrue(mapRequest.isSmrInvoked()), Flags.SMR_INVOKED)));
    if (mapRequest.getItrRloc() != null) {
        int irc = mapRequest.getItrRloc().size();
        if (irc > 0) {
            irc--;
        }
        requestBuffer.put((byte) (irc));
    } else {
        requestBuffer.put((byte) 0);
    }
    if (mapRequest.getEidItem() != null) {
        requestBuffer.put((byte) mapRequest.getEidItem().size());
    } else {
        requestBuffer.put((byte) 0);
    }
    requestBuffer.putLong(NumberUtil.asLong(mapRequest.getNonce()));
    if (mapRequest.getSourceEid() != null && mapRequest.getSourceEid().getEid() != null) {
        LispAddressSerializer.getInstance().serialize(requestBuffer, mapRequest.getSourceEid().getEid());
    } else {
        requestBuffer.putShort((short) 0);
    }
    if (mapRequest.getItrRloc() != null) {
        for (ItrRloc address : mapRequest.getItrRloc()) {
            LispAddressSerializer.getInstance().serialize(requestBuffer, address.getRloc());
        }
    }
    if (mapRequest.getEidItem() != null) {
        for (EidItem record : mapRequest.getEidItem()) {
            requestBuffer.put((byte) 0);
            requestBuffer.put((byte) MaskUtil.getMaskForAddress(record.getEid().getAddress()));
            LispAddressSerializer.getInstance().serialize(requestBuffer, record.getEid());
        }
    }
    if (mapRequest.getMapReply() != null) {
        ByteBuffer replyBuffer = ByteBuffer.allocate(MappingRecordSerializer.getInstance().getSerializationSize(mapRequest.getMapReply().getMappingRecord()));
        MappingRecordSerializer.getInstance().serialize(replyBuffer, mapRequest.getMapReply().getMappingRecord());
        ByteBuffer combinedBuffer = ByteBuffer.allocate(requestBuffer.capacity() + replyBuffer.capacity());
        combinedBuffer.put(requestBuffer.array());
        combinedBuffer.put(replyBuffer.array());
        return combinedBuffer;
    }
    return requestBuffer;
}
Also used : ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) EidItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem) ByteBuffer(java.nio.ByteBuffer)

Example 90 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class AfiListSerializer method getLcafLength.

@Override
protected short getLcafLength(LispAddress lispAddress) {
    short totalSize = 0;
    AfiList afiList = (((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiList) lispAddress.getAddress()).getAfiList());
    for (SimpleAddress address : afiList.getAddressList()) {
        totalSize += SimpleAddressSerializer.getInstance().getAddressSize(address);
    }
    return totalSize;
}
Also used : AfiList(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiList) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

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