use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAddressAndQuery.
// takes an address, packs it in a MapRegister, sends it, returns the
// MapReply
private MapReply registerAddressAndQuery(Eid eid) throws SocketTimeoutException {
mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
sleepForSeconds(1);
MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
LOG.trace("Sending Map-Register via socket: {}", mapRegister);
sendMapRegister(mapRegister);
MapNotify mapNotify = receiveMapNotify();
LOG.trace("Received Map-Notify via socket: {}", mapNotify);
assertEquals(8, mapNotify.getNonce().longValue());
// wait for the notifications to propagate
sleepForSeconds(1);
MapRequest mapRequest = MappingServiceIntegrationTestUtil.getDefaultMapRequestBuilder(eid).build();
sendMapRequest(mapRequest);
return receiveMapReply();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project lispflowmapping by opendaylight.
the class MapNotifySerializationTest method deserialize__SHA1.
@Test
public void deserialize__SHA1() throws Exception {
// LISP(Type = 4 Map-Notify, I=0
// Record Counter: 1
// Nonce: (something)
// Key ID: 0x0001
// AuthDataLength: 20 Data:
// b2:dd:1a:25:c0:60:b1:46:e8:dc:6d:a6:ae:2e:92:92:a6:ca:b7:9d
// EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
// No-Action
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
//
MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 01 FF BB " + "00 00 00 00 00 00 00 01 00 14 2c 61 b9 c9 9a 20 " + "ba d8 f5 40 d3 55 6f 5f 6e 5a b2 0a bf b5 00 00 " + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + "ff 00 00 05 00 01 c0 a8 88 0a"));
assertFalse(mn.isXtrSiteIdPresent());
assertEquals(1, mn.getMappingRecordItem().size());
assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
assertEquals(0x0001, mn.getKeyId().shortValue());
byte[] expectedAuthenticationData = { (byte) 0x2c, (byte) 0x61, (byte) 0xb9, (byte) 0xc9, (byte) 0x9a, (byte) 0x20, (byte) 0xba, (byte) 0xd8, (byte) 0xf5, (byte) 0x40, (byte) 0xd3, (byte) 0x55, (byte) 0x6f, (byte) 0x5f, (byte) 0x6e, (byte) 0x5a, (byte) 0xb2, (byte) 0x0a, (byte) 0xbf, (byte) 0xb5 };
ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify in project lispflowmapping by opendaylight.
the class MapNotifySerializationTest method deserialize__AllFields.
@Test
public void deserialize__AllFields() throws Exception {
// LISP(Type = 4 Map-Notify, I=1
// Record Counter: 1
// Nonce: (something)
// Key ID: 0x0000
// AuthDataLength: 00 Data:
// EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
// No-Action
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
// xTR-ID 1
// Site-ID 1
MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("48 00 00 01 FF BB " + "00 00 00 00 00 00 00 00 00 00 00 00 " + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + "ff 00 00 05 00 01 c0 a8 88 0a " + // xTR-ID
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 " + // Site-ID
"00 00 00 00 00 00 00 01 "));
assertTrue(mn.isXtrSiteIdPresent());
assertEquals(1, mn.getMappingRecordItem().size());
assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
assertEquals(0x0000, mn.getKeyId().shortValue());
byte[] expectedAuthenticationData = {};
ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify 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.params.xml.ns.yang.bgp.message.rev171207.Notify in project lispflowmapping by opendaylight.
the class MappingSystem method handleAddMappingNotifications.
private void handleAddMappingNotifications(MappingOrigin origin, Eid key, MappingData mappingData, MappingRecord oldMapping, MappingRecord newMapping, MappingChange changeType) {
// account policy as well
if (origin != MappingOrigin.Southbound || MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
notifyChange(key, mappingData.getRecord(), changeType);
Eid dstKey = key;
// for the checks that we do afterwards
if (key.getAddress() instanceof SourceDestKey) {
dstKey = SourceDestKeyHelper.getDstBinary(key);
}
// If the old mapping had a different EID than what was just added, notify those subscribers too
if (oldMapping != null && !oldMapping.getEid().equals(key) && !oldMapping.getEid().equals(dstKey)) {
notifyChange(oldMapping.getEid(), oldMapping, changeType);
}
// subscribers too
if (newMapping != null && !newMapping.getEid().equals(key) && !newMapping.getEid().equals(dstKey)) {
notifyChange(newMapping.getEid(), newMapping, changeType);
}
}
}
Aggregations