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");
}
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);
}
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());
}
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());
}
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();
}
Aggregations