Search in sources :

Example 1 with ApplicationDataBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method testRecievingNonProxyOnXtrPort.

public void testRecievingNonProxyOnXtrPort() throws SocketTimeoutException, SocketException, Throwable {
    cleanUP();
    configLispPlugin.shouldListenOnXtrPort(true);
    notificationCalled = false;
    final String eid = "10.10.10.10/32";
    String rloc = "127.0.0.3";
    int port = LispMessage.XTR_PORT_NUM;
    RlocBuilder rb = new RlocBuilder();
    rb.setAddressType(ApplicationDataLcaf.class);
    rb.setVirtualNetworkId(null);
    rb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(new ApplicationDataBuilder().setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(rloc)))).setLocalPortLow(new PortNumber(port)).build()).build());
    Rloc adLcaf = rb.build();
    final MapRequest mapRequest = createNonProxyMapRequest(eid, adLcaf);
    ((LispMappingService) lms).getNotificationService().registerNotificationListener(new XtrRequestMappingListener() {

        @Override
        public void onXtrRequestMapping(XtrRequestMapping notification) {
            assertEquals(((Ipv4Prefix) mapRequest.getEidItem().get(0).getEid().getAddress()).getIpv4Prefix().getValue(), eid);
            notificationCalled = true;
            LOG.warn("notification arrived");
        }
    });
    sendMapRequest(mapRequest, port);
    for (int i = 0; i < MAX_NOTIFICATION_RETRYS; i++) {
        if (notificationCalled) {
            return;
        } else {
            LOG.warn("notification hasn't arrived, sleeping...");
            Thread.sleep(500);
        }
    }
    fail("Notification hasn't arrived");
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) ApplicationDataBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) XtrRequestMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrRequestMapping) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 2 with ApplicationDataBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method testNonProxyOtherPort.

public void testNonProxyOtherPort() throws SocketTimeoutException, SocketException {
    cleanUP();
    String rloc = "127.0.0.3";
    int port = 4350;
    RlocBuilder rb = new RlocBuilder();
    rb.setAddressType(ApplicationDataLcaf.class);
    rb.setVirtualNetworkId(null);
    rb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(new ApplicationDataBuilder().setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(rloc)))).setLocalPortLow(new PortNumber(port)).build()).build());
    Rloc adLcaf = rb.build();
    LOG.info("testNonProxyOtherPort:" + LispAddressStringifier.getString(adLcaf));
    sendProxyMapRequest(rloc, port, adLcaf);
}
Also used : ApplicationDataBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 3 with ApplicationDataBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method registerAndQuery__ApplicationData.

public void registerAndQuery__ApplicationData() throws SocketTimeoutException {
    cleanUP();
    String ipString = "1.2.3.4";
    short protocol = 1;
    int ipTOs = 2;
    int localPortLow = 3;
    int localPortHigh = 4;
    int remotePortLow = 4;
    int remotePortHigh = 5;
    ApplicationDataBuilder builder = new ApplicationDataBuilder();
    builder.setIpTos(ipTOs);
    builder.setProtocol(protocol);
    builder.setLocalPortLow(new PortNumber(localPortLow));
    builder.setLocalPortHigh(new PortNumber(localPortHigh));
    builder.setRemotePortLow(new PortNumber(remotePortLow));
    builder.setRemotePortHigh(new PortNumber(remotePortHigh));
    builder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
    EidBuilder eb = new EidBuilder();
    eb.setAddressType(ApplicationDataLcaf.class);
    eb.setVirtualNetworkId(null);
    eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(builder.build()).build());
    Eid addressToSend = eb.build();
    MapReply reply = registerAddressAndQuery(addressToSend);
    Eid receivedAddress = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
    assertEquals(ApplicationDataLcaf.class, receivedAddress.getAddressType());
    ApplicationData receivedApplicationDataAddress = (ApplicationData) receivedAddress.getAddress();
    assertEquals(protocol, receivedApplicationDataAddress.getApplicationData().getProtocol().intValue());
    assertEquals(ipTOs, receivedApplicationDataAddress.getApplicationData().getIpTos().intValue());
    assertEquals(localPortLow, receivedApplicationDataAddress.getApplicationData().getLocalPortLow().getValue().intValue());
    assertEquals(localPortHigh, receivedApplicationDataAddress.getApplicationData().getLocalPortHigh().getValue().intValue());
    assertEquals(remotePortLow, receivedApplicationDataAddress.getApplicationData().getRemotePortLow().getValue().intValue());
    assertEquals(remotePortHigh, receivedApplicationDataAddress.getApplicationData().getRemotePortHigh().getValue().intValue());
    SimpleAddress ipAddressReceived = receivedApplicationDataAddress.getApplicationData().getAddress();
    assertEquals(ipString, ipAddressReceived.getIpAddress().getIpv4Address().getValue());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ApplicationDataBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) ApplicationData(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 4 with ApplicationDataBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder in project lispflowmapping by opendaylight.

the class ApplicationDataSerializerTest method serialize__Simple.

@Test
public void serialize__Simple() throws Exception {
    ApplicationDataBuilder addressBuilder = new ApplicationDataBuilder();
    addressBuilder.setIpTos(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }));
    addressBuilder.setProtocol((short) 0xDD);
    addressBuilder.setLocalPortLow(new PortNumber(0xA6A1));
    addressBuilder.setLocalPortHigh(new PortNumber(0xA6A2));
    addressBuilder.setRemotePortLow(new PortNumber(0xFFDD));
    addressBuilder.setRemotePortHigh(new PortNumber(0xFFDE));
    addressBuilder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address("17.34.51.68"))));
    EidBuilder eb = new EidBuilder();
    eb.setAddressType(ApplicationDataLcaf.class);
    eb.setVirtualNetworkId(null);
    eb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(addressBuilder.build()).build());
    ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eb.build()));
    LispAddressSerializer.getInstance().serialize(buf, eb.build());
    ByteBuffer expectedBuf = hexToByteBuffer(// 
    "40 03 00 00 " + // 
    "04 00 00 12 " + // IPTOS & protocol
    "AA BB CC DD " + // local port range
    "A6 A1 A6 A2 " + // remote port range
    "FF DD FF DE " + // AFI=1, IP=0x11223344
    "00 01 11 22 33 44");
    ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
Also used : ApplicationDataBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder) ByteBuffer(java.nio.ByteBuffer) EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 5 with ApplicationDataBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder in project lispflowmapping by opendaylight.

the class ApplicationDataSerializer method deserializeData.

private Address deserializeData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
    ApplicationDataBuilder builder = new ApplicationDataBuilder();
    byte[] rawIPTos = new byte[3];
    buffer.get(rawIPTos);
    builder.setIpTos(ByteUtil.getPartialInt(rawIPTos));
    builder.setProtocol((short) ByteUtil.getUnsignedByte(buffer));
    builder.setLocalPortLow(new PortNumber(ByteUtil.asUnsignedShort(buffer.getShort())));
    builder.setLocalPortHigh(new PortNumber(ByteUtil.asUnsignedShort(buffer.getShort())));
    builder.setRemotePortLow(new PortNumber(ByteUtil.asUnsignedShort(buffer.getShort())));
    builder.setRemotePortHigh(new PortNumber(ByteUtil.asUnsignedShort(buffer.getShort())));
    SimpleAddress address = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx);
    builder.setAddress(address);
    return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder().setApplicationData(builder.build()).build();
}
Also used : ApplicationDataBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Aggregations

PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)5 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)5 ApplicationDataBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationDataBuilder)5 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)2 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)2 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)2 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)2 RlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder)2 ByteBuffer (java.nio.ByteBuffer)1 Test (org.junit.Test)1 ApplicationData (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData)1 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)1 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)1 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)1 XtrRequestMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrRequestMapping)1 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)1 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)1