import org.junit.Test;
import org.opendaylight.lispflowmapping.implementation.lisp.exception.LispSerializationException;
+import org.opendaylight.lispflowmapping.implementation.serializer.MapRegisterSerializer.Length;
import org.opendaylight.lispflowmapping.implementation.util.LispAFIConvertor;
import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
import org.opendaylight.lispflowmapping.type.AddressFamilyNumberEnum;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispAFIAddress;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRegister;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord.Action;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecordBuilder;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.NoBuilder;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.locatorrecords.LocatorRecord;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.mapregisternotification.MapRegisterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.EidToLocatorRecord.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.MapRegister;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.eidtolocatorrecords.EidToLocatorRecord;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.eidtolocatorrecords.EidToLocatorRecordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.lispaddress.lispaddresscontainer.address.no.NoAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.locatorrecords.LocatorRecord;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.mapregisternotification.MapRegisterBuilder;
public class MapRegisterSerializationTest extends BaseTestCase {
mrBuilder.setKeyId((short) 0x0001);
mrBuilder.setWantMapNotify(true);
mrBuilder.setProxyMapReply(true);
+ mrBuilder.setXtrSiteIdPresent(true);
byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d,
(byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba,
(byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
mrBuilder.setAuthenticationData(authenticationData);
+ byte[] xtrId = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
+ mrBuilder.setXtrId(xtrId);
+ byte[] siteId = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
+ mrBuilder.setSiteId(siteId);
ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
- assertHexEquals((byte) 0x38, bb.get()); // Type + MSByte of reserved
+ assertHexEquals((byte) 0x3a, bb.get()); // Type + MSByte of reserved
assertEquals(1, bb.getShort()); // Rest of reserved + want map notify
assertEquals(2, bb.get()); // Record Count
assertEquals(6161616161L, bb.getLong()); // Nonce
bb.position(bb.position() + 12); /* EID in second record */
assertEquals(73, bb.getInt());
+ byte[] actualXtrId = new byte[Length.XTRID_SIZE];
+ bb.get(actualXtrId);
+ ArrayAssert.assertEquals(xtrId, actualXtrId);
+
+ byte[] actualSiteId = new byte[Length.SITEID_SIZE];
+ bb.get(actualSiteId);
+ ArrayAssert.assertEquals(siteId, actualSiteId);
+
assertEquals(bb.position(), bb.capacity());
}
mrBuilder.getEidToLocatorRecord().add(new EidToLocatorRecordBuilder().setLispAddressContainer(null).build());
mrBuilder.getEidToLocatorRecord().add(
new EidToLocatorRecordBuilder().setLispAddressContainer(
- LispAFIConvertor.toContainer(new NoBuilder().setAfi(AddressFamilyNumberEnum.NO_ADDRESS.getIanaCode()).build())).build());
+ LispAFIConvertor.toContainer(new NoAddressBuilder().setAfi(AddressFamilyNumberEnum.NO_ADDRESS.getIanaCode()).build())).build());
ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
bb.position(bb.position() + 16); // jump to first record prefix AFI
ArrayAssert.assertEquals(expectedAuthenticationData, mr.getAuthenticationData());
}
+ @Test
+ public void deserialize__serialize() throws Exception {
+ ByteBuffer bb = hexToByteBuffer("32 00 01 01 63 99 "
+ + "83 64 23 06 a8 be 00 01 00 14 b8 c2 a2 e1 dc 4a "
+ + "08 0c f6 01 b0 9d 70 5a d4 88 95 f8 73 dd 00 00 "
+ + "05 a0 01 20 10 00 00 00 40 03 00 00 02 20 00 0a "
+ + "00 00 00 01 00 01 c3 a8 c8 01 0a 32 ff 00 00 04 "
+ + "00 01 ac 10 01 02 15 1a 39 80 e3 35 e6 c4 49 a6 "
+ + "90 87 20 65 9a b7 00 00 00 00 00 00 00 00 ");
+ MapRegister mr = MapRegisterSerializer.getInstance().deserialize(bb);
+
+ assertTrue(mr.isXtrSiteIdPresent());
+
+ ArrayAssert.assertEquals(bb.array(), MapRegisterSerializer.getInstance().serialize(mr).array());
+ }
+
@Test
public void deserialize__MultipleRecords() throws Exception {
// LISP(Type = 3 Map-Register, P=1, M=1