use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class MappingRecordSerializer method deserializeToBuilder.
public MappingRecordBuilder deserializeToBuilder(ByteBuffer buffer) {
MappingRecordBuilder builder = new MappingRecordBuilder();
builder.setRecordTtl(buffer.getInt());
final byte locatorCount = (byte) ByteUtil.getUnsignedByte(buffer);
final short maskLength = ((short) ByteUtil.getUnsignedByte(buffer));
final byte actionAndAuthoritative = buffer.get();
Action act = Action.forValue(actionAndAuthoritative >> 5);
if (act == null) {
act = Action.NoAction;
}
builder.setAction(act);
builder.setAuthoritative(ByteUtil.extractBit(actionAndAuthoritative, Flags.AUTHORITATIVE));
buffer.position(buffer.position() + Length.RESERVED);
builder.setMapVersion(buffer.getShort());
LispAddressSerializerContext ctx = new LispAddressSerializerContext(maskLength);
builder.setEid(LispAddressSerializer.getInstance().deserializeEid(buffer, ctx));
builder.setLocatorRecord(new ArrayList<LocatorRecord>());
for (int i = 0; i < locatorCount; i++) {
builder.getLocatorRecord().add(LocatorRecordSerializer.getInstance().deserialize(buffer));
}
return builder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class LispUtil method buildAddMappingInput.
// private static final Logger LOG = LoggerFactory.getLogger(LispUtil.class);
public static AddMappingInput buildAddMappingInput(Eid eid, List<LocatorRecord> locators) {
MappingRecordBuilder mrb = new MappingRecordBuilder();
mrb.setAction(Action.NoAction).setAuthoritative(true).setEid(eid).setLocatorRecord(locators).setMapVersion((short) 0).setRecordTtl(1440);
AddMappingInputBuilder mib = new AddMappingInputBuilder();
mib.setMappingRecord(mrb.build());
return mib.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class HostInformationManager method attemptToCreateMappingRecord.
private synchronized void attemptToCreateMappingRecord(String hostId) {
List<Rloc> rlocForMappingRecord = hostIdToRlocMapper.getRlocs(hostId);
PortUuidToPortDataMapper uuidToEidMapper = hostIdToPortDataMapper.getAllPortData(hostId);
if (rlocForMappingRecord == null || rlocForMappingRecord.isEmpty() || uuidToEidMapper == null) {
return;
}
Collection<PortData> allUnprocessedPorts = uuidToEidMapper.getAllUnprocessedPorts();
List<LocatorRecord> locators = LispAddressUtil.asLocatorRecords(rlocForMappingRecord);
allUnprocessedPorts.forEach(portData -> {
lfmDbService.addMapping(LispUtil.buildAddMappingInput(portData.getPortEid(), locators));
uuidToEidMapper.addPortDataToProcessed(portData);
});
uuidToEidMapper.clearAllUnprocessedData();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAddress.
/*
// This registers an IP with a MapRegister, then adds a password via the
// northbound REST API
// and checks that the password works
public void testPasswordExactMatch() throws Exception {
cleanUP();
String ipString = "10.0.0.1";
LispIpv4Address address = LispAddressUtil.asIPAfiAddress(ipString);
int mask = 32;
String pass = "pass";
URL url = createPutURL("key");
String jsonAuthData = createAuthKeyJSON(pass, address, mask);
LOG.trace("Sending this JSON to LISP server: \n" + jsonAuthData);
LOG.trace("Address: " + address);
byte[] expectedSha = new byte[] { (byte) 146, (byte) 234, (byte) 52, (byte) 247, (byte) 186, (byte) 232,
(byte) 31, (byte) 249, (byte) 87,
(byte) 73, (byte) 234, (byte) 54, (byte) 225, (byte) 160, (byte) 129, (byte) 251, (byte) 73, (byte) 53,
(byte) 196, (byte) 62 };
byte[] zeros = new byte[20];
callURL("PUT", "application/json", "text/plain", jsonAuthData, url);
// build a MapRegister
MapRegisterBuilder mapRegister = new MapRegisterBuilder();
mapRegister.setWantMapNotify(true);
mapRegister.setNonce((long) 8);
EidToLocatorRecordBuilder etlr = new EidToLocatorRecordBuilder();
etlr.setLispAddressContainer(LispAddressUtil.toContainer(address));
etlr.setMaskLength((short) mask);
etlr.setRecordTtl(254);
LocatorRecordBuilder record = new LocatorRecordBuilder();
record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
etlr.getLocatorRecord().add(record.build());
mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
mapRegister.setKeyId((short) 1); // LispKeyIDEnum.SHA1.getKeyID()
mapRegister.setAuthenticationData(zeros);
sendMapRegister(mapRegister.build());
assertNoPacketReceived(3000);
mapRegister.setAuthenticationData(expectedSha);
sendMapRegister(mapRegister.build());
assertMapNotifyReceived();
}
public void testPasswordMaskMatch() throws Exception {
cleanUP();
LispIpv4Address addressInRange = LispAddressUtil.asIPAfiAddress("10.20.30.40");
LispIpv4Address addressOutOfRange = LispAddressUtil.asIPAfiAddress("20.40.30.40");
LispIpv4Address range = LispAddressUtil.asIPAfiAddress("10.20.30.0");
int mask = 32;
String pass = "pass";
URL url = createPutURL("key");
String jsonAuthData = createAuthKeyJSON(pass, range, 8);
callURL("PUT", "application/json", "text/plain", jsonAuthData, url);
// build a MapRegister
MapRegisterBuilder mapRegister = new MapRegisterBuilder();
mapRegister.setWantMapNotify(true);
mapRegister.setNonce((long) 8);
EidToLocatorRecordBuilder etlr = new EidToLocatorRecordBuilder();
etlr.setLispAddressContainer(LispAddressUtil.toContainer(addressInRange));
etlr.setMaskLength((short) mask);
etlr.setRecordTtl(254);
LocatorRecordBuilder record = new LocatorRecordBuilder();
record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
record.setLispAddressContainer(LispAddressUtil.toContainer(locatorEid));
etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
etlr.getLocatorRecord().add(record.build());
mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
mapRegister.setKeyId((short) 1); // LispKeyIDEnum.SHA1.getKeyID()
mapRegister
.setAuthenticationData(new byte[] { -15, -52, 38, -94, 125, -111, -68, -79, 68, 6, 101, 45, -1, 47, -4,
-67, -113, 104, -110, -71 });
sendMapRegister(mapRegister.build());
assertMapNotifyReceived();
etlr.setLispAddressContainer(LispAddressUtil.toContainer(addressOutOfRange));
mapRegister
.setAuthenticationData(new byte[] { -54, 68, -58, -91, -23, 22, -88, -31, 113, 39, 115, 78, -68, -123,
-71, -14, -99, 67, -23, -73 });
sendMapRegister(mapRegister.build());
assertNoPacketReceived(3000);
}
*/
// takes an address, packs it in a MapRegister and sends it
private void registerAddress(Eid eid) throws SocketTimeoutException {
mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
sleepForSeconds(1);
MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
sendMapRegister(mapRegister);
MapNotify mapNotify = receiveMapNotify();
assertEquals(8, mapNotify.getNonce().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class MultiSiteScenario method provideLocatorRecord.
private LocatorRecord provideLocatorRecord(final Rloc rloc, final String rlocStr, final short weight, final short priority) {
final LocatorRecordBuilder locatorRecordBuilder = new LocatorRecordBuilder();
locatorRecordBuilder.setRloc(rloc);
locatorRecordBuilder.setLocatorId(rlocStr);
locatorRecordBuilder.setPriority(priority);
locatorRecordBuilder.setWeight(weight);
locatorRecordBuilder.setMulticastPriority(DEFAULT_MULTICAST_PRIORITY);
locatorRecordBuilder.setMulticastWeight(DEFAULT_MULTICAST_WEIGHT);
locatorRecordBuilder.setLocalLocator(DEFAULT_LOCAL_LOCATOR);
locatorRecordBuilder.setRlocProbed(DEFAULT_RLOC_PROBED);
locatorRecordBuilder.setRouted(DEFAULT_ROUTED);
return locatorRecordBuilder.build();
}
Aggregations