use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationData in project lispflowmapping by opendaylight.
the class ApplicationDataSerializerTest method deserialize__Simple.
@Test
public void deserialize__Simple() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"04 20 00 0E " + // IPTOS & protocol
"AA BB CC DD " + // local port range
"A6 A1 A6 A2 " + // remote port range
"FF DD FF DE " + "00 01 11 22 33 44"), // AFI=1, IP=0x11223344
null);
assertEquals(ApplicationDataLcaf.class, address.getAddressType());
ApplicationData appAddress = (ApplicationData) address.getAddress();
assertEquals("17.34.51.68", String.valueOf(appAddress.getApplicationData().getAddress().getValue()));
assertEquals(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }), appAddress.getApplicationData().getIpTos().intValue());
assertEquals((byte) 0xDD, appAddress.getApplicationData().getProtocol().byteValue());
assertEquals((short) 0xA6A1, appAddress.getApplicationData().getLocalPortLow().getValue().shortValue());
assertEquals((short) 0xA6A2, appAddress.getApplicationData().getLocalPortHigh().getValue().shortValue());
assertEquals((short) 0xFFDD, appAddress.getApplicationData().getRemotePortLow().getValue().shortValue());
assertEquals((short) 0xFFDE, appAddress.getApplicationData().getRemotePortHigh().getValue().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationData in project lispflowmapping by opendaylight.
the class ApplicationDataSerializer method serializeData.
@Override
protected void serializeData(ByteBuffer buffer, LispAddress lispAddress) {
ApplicationData appData = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData) lispAddress.getAddress()).getApplicationData();
buffer.put(ByteUtil.partialIntToByteArray(NumberUtil.asInt(appData.getIpTos()), Length.TOC));
buffer.put((byte) NumberUtil.asShort(appData.getProtocol()));
if (appData.getLocalPortLow() != null) {
buffer.putShort(NumberUtil.asShort(appData.getLocalPortLow().getValue().shortValue()));
} else {
buffer.putShort((short) 0);
}
if (appData.getLocalPortHigh() != null) {
buffer.putShort(NumberUtil.asShort(appData.getLocalPortHigh().getValue().shortValue()));
} else {
buffer.putShort((short) 0);
}
if (appData.getRemotePortLow() != null) {
buffer.putShort(NumberUtil.asShort(appData.getRemotePortLow().getValue().shortValue()));
} else {
buffer.putShort((short) 0);
}
if (appData.getRemotePortHigh() != null) {
buffer.putShort(NumberUtil.asShort(appData.getRemotePortHigh().getValue().shortValue()));
} else {
buffer.putShort((short) 0);
}
SimpleAddressSerializer.getInstance().serialize(buffer, appData.getAddress());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationData in project lispflowmapping by opendaylight.
the class LispNotificationHelperTest method getTransportAddressFromRlocTest_withApplicationDataIpv4PrefixAddress.
/**
* Tests {@link LispNotificationHelper#getTransportAddressFromRloc} method with ApplicationData type address.
*/
@Test(expected = NullPointerException.class)
public void getTransportAddressFromRlocTest_withApplicationDataIpv4PrefixAddress() {
final TransportAddress result = new TransportAddressBuilder().build();
assertEquals(result, LispNotificationHelper.getTransportAddressFromRloc(RLOC_APPLICATION_DATA_IPV6_PREFIX));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationData in project lispflowmapping by opendaylight.
the class LispNotificationHelperTest method getTransportAddressFromRlocTest_withApplicationDataIpv6Address.
/**
* Tests {@link LispNotificationHelper#getTransportAddressFromRloc} method with ApplicationData type Ipv6 address.
*/
@Test
public void getTransportAddressFromRlocTest_withApplicationDataIpv6Address() {
final TransportAddress result = new TransportAddressBuilder().setIpAddress(new IpAddressBinary(ADDRESS_IPV6_BINARY)).setPort(new PortNumber(PORT)).build();
assertEquals(result, LispNotificationHelper.getTransportAddressFromRloc(RLOC_APPLICATION_DATA_IPV6));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.application.data.ApplicationData in project lispflowmapping by opendaylight.
the class LispNotificationHelperTest method getTransportAddressFromRlocTest_withApplicationDataIpv4Address.
/**
* Tests {@link LispNotificationHelper#getTransportAddressFromRloc} method with ApplicationData type Ipv4 address.
*/
@Test
public void getTransportAddressFromRlocTest_withApplicationDataIpv4Address() {
final TransportAddress result = new TransportAddressBuilder().setIpAddress(new IpAddressBinary(ADDRESS_IPV4_BINARY)).setPort(new PortNumber(PORT)).build();
assertEquals(result, LispNotificationHelper.getTransportAddressFromRloc(RLOC_APPLICATION_DATA_IPV4));
}
Aggregations