use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.
the class MapNotifySerializationTest method serialize__NoAuthenticationData.
@Test
public void serialize__NoAuthenticationData() throws Exception {
MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).setRecordTtl(55).build()).build());
ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
// jump to AuthenticationDataLength
bb.position(bb.position() + 14);
assertEquals(0, bb.getShort());
assertEquals(55, bb.getInt());
mnBuilder.setAuthenticationData(null);
bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
// jump to AuthenticationDataLength
bb.position(bb.position() + 14);
assertEquals(0, bb.getShort());
assertEquals(55, bb.getInt());
mnBuilder.setAuthenticationData(new byte[0]);
bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
// jump to AuthenticationDataLength
bb.position(bb.position() + 14);
assertEquals(0, bb.getShort());
assertEquals(55, bb.getInt());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.
the class MapRegisterSerializationTest method serialize__NoAuthenticationData.
@Test
public void serialize__NoAuthenticationData() throws Exception {
MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setRecordTtl(55).setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build()).build());
// mrBuilder.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(1)).setRecordTtl(55));
ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
// jump to AuthenticationDataLength
bb.position(bb.position() + 14);
assertEquals(0, bb.getShort());
assertEquals(55, bb.getInt());
mrBuilder.setAuthenticationData(null);
bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
// jump to AuthenticationDataLength
bb.position(bb.position() + 14);
assertEquals(0, bb.getShort());
assertEquals(55, bb.getInt());
mrBuilder.setAuthenticationData(new byte[0]);
bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
// jump to AuthenticationDataLength
bb.position(bb.position() + 14);
assertEquals(0, bb.getShort());
assertEquals(55, bb.getInt());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.
the class MapRegisterSerializationTest method serialize__Fields.
@Test
public void serialize__Fields() throws Exception {
MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32"));
mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
mrBuilder.setNonce(6161616161L);
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);
XtrId xtrId = new 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);
SiteId siteId = new 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());
// Type + MSByte of reserved
assertHexEquals((byte) 0x3a, bb.get());
// Rest of reserved + want map notify
assertEquals(1, bb.getShort());
// Record Count
assertEquals(2, bb.get());
// Nonce
assertEquals(6161616161L, bb.getLong());
// Key ID
assertHexEquals((short) 0x0001, bb.getShort());
assertEquals(authenticationData.length, bb.getShort());
byte[] actualAuthenticationData = new byte[20];
bb.get(actualAuthenticationData);
ArrayAssert.assertEquals(authenticationData, actualAuthenticationData);
// EID in first record
bb.position(bb.position() + 12);
assertEquals(0x1, bb.getInt());
// EID in second record
bb.position(bb.position() + 12);
assertEquals(73, bb.getInt());
byte[] actualXtrId = new byte[Length.XTRID_SIZE];
bb.get(actualXtrId);
ArrayAssert.assertEquals(xtrId.getValue(), actualXtrId);
byte[] actualSiteId = new byte[Length.SITEID_SIZE];
bb.get(actualSiteId);
ArrayAssert.assertEquals(siteId.getValue(), actualSiteId);
assertEquals(bb.position(), bb.capacity());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.
the class MapReplySerializationTest method serialize__SomeFlags.
@Test
public void serialize__SomeFlags() throws Exception {
MapReplyBuilder mr = new MapReplyBuilder();
mr.setMappingRecordItem(new ArrayList<MappingRecordItem>());
MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
mr.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
mr.setProbe(true);
mr.setEchoNonceEnabled(false);
ByteBuffer packet = MapReplySerializer.getInstance().serialize(mr.build());
byte firstByte = packet.get(0);
assertHexEquals((byte) 0x28, firstByte);
mr.setProbe(false);
mr.setEchoNonceEnabled(true);
packet = MapReplySerializer.getInstance().serialize(mr.build());
firstByte = packet.get(0);
assertHexEquals((byte) 0x24, firstByte);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder in project lispflowmapping by opendaylight.
the class MapReplySerializationTest method serialize__EidRecordNullActionShouldTranslateToDefault.
@Test
public void serialize__EidRecordNullActionShouldTranslateToDefault() throws Exception {
MapReplyBuilder mrBuilder = new MapReplyBuilder();
mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
recordBuilder.setAction(null);
mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
ByteBuffer packet = MapReplySerializer.getInstance().serialize(mrBuilder.build());
packet.position(18);
// MapReplyAction.NoAction
assertHexEquals((byte) 0x00, packet.get());
}
Aggregations