use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class AuthKeyDb method getAuthKeyLpm.
private MappingAuthkey getAuthKeyLpm(Eid prefix, ILispDAO db) {
short maskLength = MaskUtil.getMaskForAddress(prefix.getAddress());
while (maskLength >= 0) {
Eid key = MaskUtil.normalize(prefix, maskLength);
Object password = db.getSpecific(key, SubKeys.AUTH_KEY);
if (password != null && password instanceof MappingAuthkey) {
return (MappingAuthkey) password;
}
maskLength -= 1;
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class LispMapCacheStringifier method prettyPrintKeys.
@SuppressWarnings("unchecked")
public static String prettyPrintKeys(ILispDAO dao) {
final StringBuilder sb = new StringBuilder();
final IRowVisitor innerVisitor = (new IRowVisitor() {
public void visitRow(Object keyId, String valueKey, Object value) {
switch(valueKey) {
case SubKeys.AUTH_KEY:
String eid = LispAddressStringifier.getString((Eid) keyId);
sb.append(" ");
sb.append(eid);
int padLen = Math.max(2, Constants.INET6_ADDRSTRLEN - eid.length());
sb.append(Stringifier.getSpacesAsString(padLen));
MappingAuthkey authKey = (MappingAuthkey) value;
String hmac = LispKeyIDEnum.valueOf(authKey.getKeyType().shortValue()).getAuthenticationName();
sb.append(hmac);
sb.append(Stringifier.getSpacesAsString(Math.max(2, 22 - hmac.length())));
sb.append(authKey.getKeyString());
sb.append("\n");
break;
default:
break;
}
}
});
dao.getAll(new IRowVisitor() {
String lastKey = "";
public void visitRow(Object keyId, String valueKey, Object value) {
String key = keyId.getClass().getSimpleName() + "#" + keyId;
if (!lastKey.equals(key)) {
sb.append("Instance ID " + keyId + "\n");
sb.append(" -> EID HMAC Algorithm Shared Key\n");
}
if (valueKey.equals(SubKeys.VNI)) {
((ILispDAO) value).getAll(innerVisitor);
}
lastKey = key;
}
});
return sb.toString();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class MapServer method handleMapRegister.
@SuppressWarnings("unchecked")
public void handleMapRegister(MapRegister mapRegister) {
boolean mappingUpdated = false;
boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
MappingRecord oldMapping;
if (merge) {
if (!mapRegister.isXtrSiteIdPresent() || mapRegister.getXtrId() == null) {
LOG.error("Merge bit is set in Map-Register, but xTR-ID is not present. Will not merge.");
merge = false;
} else if (Arrays.equals(mapRegister.getXtrId().getValue(), ALL_ZEROES_XTR_ID)) {
LOG.warn("Merge bit is set in Map-Register, but xTR-ID is all zeroes.");
}
}
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
Eid eid = mapping.getEid();
MappingData mappingData = new MappingData(mapping, System.currentTimeMillis());
mappingData.setMergeEnabled(merge);
mappingData.setXtrId(mapRegister.getXtrId());
oldMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
mapService.addMapping(MappingOrigin.Southbound, eid, getSiteId(mapRegister), mappingData);
if (merge) {
MappingRecord newMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
if (MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
// If there is a SB mapping change with merge on, Map-Notify will be sent to ALL xTRs, not jus the
// one registering (merging is done in the MappingSystem code)
mappingUpdated = true;
}
}
}
if (BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
LOG.trace("MapRegister wants MapNotify");
MapNotifyBuilder builder = new MapNotifyBuilder();
List<TransportAddress> rlocs = null;
if (merge) {
Set<IpAddressBinary> notifyRlocs = new HashSet<IpAddressBinary>();
List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
MappingRecord currentRecord = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, mapping.getEid()));
mergedMappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
Set<IpAddressBinary> sourceRlocs = (Set<IpAddressBinary>) mapService.getData(MappingOrigin.Southbound, mapping.getEid(), SubKeys.SRC_RLOCS);
if (sourceRlocs != null) {
notifyRlocs.addAll(sourceRlocs);
}
}
MapNotifyBuilderHelper.setFromMapRegisterAndMappingRecordItems(builder, mapRegister, mergedMappings);
// send map-notify to merge group only when mapping record is changed
if (mappingUpdated) {
rlocs = getTransportAddresses(notifyRlocs);
}
} else {
MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
}
List<MappingRecordItem> mappings = builder.getMappingRecordItem();
if (mappings != null && mappings.get(0) != null && mappings.get(0).getMappingRecord() != null && mappings.get(0).getMappingRecord().getEid() != null) {
MappingAuthkey authkey = mapService.getAuthenticationKey(mappings.get(0).getMappingRecord().getEid());
if (authkey != null) {
builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(), authkey.getKeyString()));
}
}
notifyHandler.handleMapNotify(builder.build(), rlocs);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class DSBEInputUtil method toAuthenticationKey.
public static AuthenticationKey toAuthenticationKey(Eid key, MappingAuthkey authKey) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));
akb.setEid(key);
akb.setMappingAuthkey(authKey);
return akb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class RPCInputConvertorUtil method toAuthenticationKey.
private static AuthenticationKey toAuthenticationKey(Eid address, MappingAuthkey key) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(address)));
akb.setEid(address);
if (key != null) {
akb.setMappingAuthkey(key);
}
return akb.build();
}
Aggregations