Search in sources :

Example 16 with TransportAddressBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.

the class LispSouthboundRpcTest method sendMapRegisterTest_inputNotNull.

/**
 * Tests {@link LispSouthboundRPC#sendMapRegister} method.
 */
@Test
public void sendMapRegisterTest_inputNotNull() throws ExecutionException, InterruptedException {
    final MapRegister mapRegister = getDefaultMapRegisterBuilder().build();
    final TransportAddress transportAddress = new TransportAddressBuilder().build();
    final SendMapRegisterInput sendMapRegisterInputMock = Mockito.mock(SendMapRegisterInput.class);
    Mockito.when(sendMapRegisterInputMock.getTransportAddress()).thenReturn(transportAddress);
    Mockito.when(sendMapRegisterInputMock.getMapRegister()).thenReturn(mapRegister);
    assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.sendMapRegister(sendMapRegisterInputMock).get().isSuccessful());
    Mockito.verify(lispSouthboundPlugin).handleSerializedLispBuffer(transportAddress, MapRegisterSerializer.getInstance().serialize(mapRegister), MessageType.MapRegister);
}
Also used : TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) SendMapRegisterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRegisterInput) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegister) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder) Test(org.junit.Test)

Example 17 with TransportAddressBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.

the class LispSouthboundHandler method handleMapRequest.

@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapRequest(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
    try {
        MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer, sourceAddress);
        InetAddress finalSourceAddress = MapRequestUtil.selectItrRloc(request);
        if (finalSourceAddress == null) {
            throw new LispMalformedPacketException("Couldn't deserialize Map-Request, no ITR Rloc found!");
        }
        RequestMappingBuilder requestMappingBuilder = new RequestMappingBuilder();
        requestMappingBuilder.setMapRequest(LispNotificationHelper.convertMapRequest(request));
        TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
        transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(finalSourceAddress));
        transportAddressBuilder.setPort(new PortNumber(port));
        requestMappingBuilder.setTransportAddress(transportAddressBuilder.build());
        lispSbPlugin.sendNotificationIfPossible(requestMappingBuilder.build());
    } catch (RuntimeException re) {
        throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len=" + inBuffer.capacity() + ")", re);
    } catch (InterruptedException e) {
        LOG.warn("Notification publication interrupted!");
    }
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) RequestMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMappingBuilder) LispMalformedPacketException(org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) InetAddress(java.net.InetAddress) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)

Example 18 with TransportAddressBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.

the class LispSouthboundHandler method handleMapReply.

@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapReply(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
    try {
        MapReply mapReply = MapReplySerializer.getInstance().deserialize(inBuffer);
        GotMapReplyBuilder gotMapReplyBuilder = new GotMapReplyBuilder();
        gotMapReplyBuilder.setMapReply(LispNotificationHelper.convertMapReply(mapReply));
        TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
        transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(sourceAddress));
        transportAddressBuilder.setPort(new PortNumber(port));
        gotMapReplyBuilder.setTransportAddress(transportAddressBuilder.build());
        lispSbPlugin.sendNotificationIfPossible(gotMapReplyBuilder.build());
    } catch (RuntimeException re) {
        throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len=" + inBuffer.capacity() + ")", re);
    } catch (InterruptedException e) {
        LOG.warn("Notification publication interrupted!");
    }
}
Also used : MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) LispMalformedPacketException(org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException) GotMapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReplyBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)

Example 19 with TransportAddressBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.

the class MapServer method getTransportAddresses.

private static List<TransportAddress> getTransportAddresses(Set<IpAddressBinary> addresses) {
    List<TransportAddress> rlocs = new ArrayList<TransportAddress>();
    for (IpAddressBinary address : addresses) {
        TransportAddressBuilder tab = new TransportAddressBuilder();
        tab.setIpAddress(address);
        tab.setPort(new PortNumber(LispMessage.PORT_NUM));
        rlocs.add(tab.build());
    }
    return rlocs;
}
Also used : IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) ArrayList(java.util.ArrayList) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)

Example 20 with TransportAddressBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder in project lispflowmapping by opendaylight.

the class LispNotificationHelper method getTransportAddressFromRloc.

public static TransportAddress getTransportAddressFromRloc(Rloc rloc) {
    TransportAddressBuilder tab = new TransportAddressBuilder();
    Address address = rloc.getAddress();
    // object, yey!
    if (address instanceof Ipv4) {
        String ipv4 = ((Ipv4) address).getIpv4().getValue();
        tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ipv4).getAddress()));
        tab.setPort(new PortNumber(LispMessage.PORT_NUM));
    } else if (address instanceof Ipv6) {
        String ipv6 = ((Ipv6) address).getIpv6().getValue();
        tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ipv6).getAddress()));
        tab.setPort(new PortNumber(LispMessage.PORT_NUM));
    } else if (address instanceof Ipv4Binary) {
        Ipv4AddressBinary ipv6 = ((Ipv4Binary) address).getIpv4Binary();
        tab.setIpAddress(new IpAddressBinary(ipv6));
        tab.setPort(new PortNumber(LispMessage.PORT_NUM));
    } else if (address instanceof Ipv6Binary) {
        Ipv6AddressBinary ipv6 = ((Ipv6Binary) address).getIpv6Binary();
        tab.setIpAddress(new IpAddressBinary(ipv6));
        tab.setPort(new PortNumber(LispMessage.PORT_NUM));
    } else if (address instanceof KeyValueAddress) {
        SimpleAddress sa = ((KeyValueAddress) address).getKeyValueAddress().getValue();
        if (sa.getDistinguishedNameType() != null) {
            final Iterator<String> it = COLON_SPLITTER.split(sa.getDistinguishedNameType().getValue()).iterator();
            String ip = it.next();
            int port = Integer.valueOf(it.next());
            tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ip).getAddress()));
            tab.setPort(new PortNumber(port));
        }
    } else if (address instanceof DistinguishedName) {
        DistinguishedName dname = (DistinguishedName) address;
        final Iterator<String> it = COLON_SPLITTER.split(dname.getDistinguishedName().getValue()).iterator();
        String ip = it.next();
        int port = Integer.valueOf(it.next());
        tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ip).getAddress()));
        tab.setPort(new PortNumber(port));
    } else if (address instanceof ApplicationData) {
        ApplicationData appData = (ApplicationData) address;
        tab.setIpAddress(getIpAddressBinary(appData.getApplicationData().getAddress().getIpAddress()));
        tab.setPort(new PortNumber(appData.getApplicationData().getLocalPortLow()));
    }
    return tab.build();
}
Also used : Ipv6AddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv6AddressBinary) Ipv4AddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary) TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) InetAddress(java.net.InetAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) 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) Ipv6(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6) DistinguishedName(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.DistinguishedName) Ipv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4) ApplicationData(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData) Ipv4Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary) IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) KeyValueAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress) Iterator(java.util.Iterator) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Ipv6Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary)

Aggregations

TransportAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)22 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)17 TransportAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress)17 Test (org.junit.Test)13 IpAddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary)10 LispMalformedPacketException (org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException)5 InetAddress (java.net.InetAddress)3 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)2 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)1 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)1 ApplicationData (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData)1 DistinguishedName (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.DistinguishedName)1 Ipv4 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4)1 Ipv6 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6)1