use of org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress in project onos by opennetworkinglab.
the class LispExtensionMappingAddressInterpreter method mapLcafAddress.
@Override
public ExtensionMappingAddress mapLcafAddress(LispLcafAddress lcafAddress) {
switch(lcafAddress.getType()) {
case LIST:
LispListLcafAddress lcafListAddress = (LispListLcafAddress) lcafAddress;
MappingAddress ipv4Ma = afi2mapping(lcafListAddress.getAddresses().get(0));
MappingAddress ipv6Ma = afi2mapping(lcafListAddress.getAddresses().get(1));
return new LispListAddress.Builder().withIpv4(ipv4Ma).withIpv6(ipv6Ma).build();
case SEGMENT:
LispSegmentLcafAddress segmentLcafAddress = (LispSegmentLcafAddress) lcafAddress;
return new LispSegmentAddress.Builder().withInstanceId(segmentLcafAddress.getInstanceId()).withAddress(getMappingAddress(segmentLcafAddress.getAddress())).build();
case AS:
LispAsLcafAddress asLcafAddress = (LispAsLcafAddress) lcafAddress;
return new org.onosproject.drivers.lisp.extensions.LispAsAddress.Builder().withAsNumber(asLcafAddress.getAsNumber()).withAddress(getMappingAddress(asLcafAddress.getAddress())).build();
case APPLICATION_DATA:
LispAppDataLcafAddress appLcafAddress = (LispAppDataLcafAddress) lcafAddress;
return new LispAppDataAddress.Builder().withProtocol(appLcafAddress.getProtocol()).withIpTos(appLcafAddress.getIpTos()).withLocalPortLow(appLcafAddress.getLocalPortLow()).withLocalPortHigh(appLcafAddress.getLocalPortHigh()).withRemotePortLow(appLcafAddress.getRemotePortLow()).withRemotePortHigh(appLcafAddress.getRemotePortHigh()).withAddress(getMappingAddress(appLcafAddress.getAddress())).build();
case GEO_COORDINATE:
LispGeoCoordinateLcafAddress gcLcafAddress = (LispGeoCoordinateLcafAddress) lcafAddress;
return new LispGcAddress.Builder().withIsNorth(gcLcafAddress.isNorth()).withLatitudeDegree(gcLcafAddress.getLatitudeDegree()).withLatitudeMinute(gcLcafAddress.getLatitudeMinute()).withLatitudeSecond(gcLcafAddress.getLatitudeSecond()).withIsEast(gcLcafAddress.isEast()).withLongitudeDegree(gcLcafAddress.getLongitudeDegree()).withLongitudeMinute(gcLcafAddress.getLongitudeMinute()).withLongitudeSecond(gcLcafAddress.getLongitudeSecond()).withAltitude(gcLcafAddress.getAltitude()).withAddress(getMappingAddress(gcLcafAddress.getAddress())).build();
case NAT:
LispNatLcafAddress natLcafAddress = (LispNatLcafAddress) lcafAddress;
List<MappingAddress> mas = Lists.newArrayList();
natLcafAddress.getRtrRlocAddresses().forEach(rtr -> mas.add(getMappingAddress(rtr)));
return new LispNatAddress.Builder().withMsUdpPortNumber(natLcafAddress.getMsUdpPortNumber()).withEtrUdpPortNumber(natLcafAddress.getEtrUdpPortNumber()).withMsRlocAddress(getMappingAddress(natLcafAddress.getMsRlocAddress())).withGlobalEtrRlocAddress(getMappingAddress(natLcafAddress.getGlobalEtrRlocAddress())).withPrivateEtrRlocAddress(getMappingAddress(natLcafAddress.getPrivateEtrRlocAddress())).withRtrRlocAddresses(mas).build();
case NONCE:
LispNonceLcafAddress nonceLcafAddress = (LispNonceLcafAddress) lcafAddress;
return new LispNonceAddress.Builder().withNonce(nonceLcafAddress.getNonce()).withAddress(getMappingAddress(nonceLcafAddress.getAddress())).build();
case MULTICAST:
LispMulticastLcafAddress multiLcafAddress = (LispMulticastLcafAddress) lcafAddress;
return new LispMulticastAddress.Builder().withInstanceId(multiLcafAddress.getInstanceId()).withSrcAddress(getMappingAddress(multiLcafAddress.getSrcAddress())).withSrcMaskLength(multiLcafAddress.getSrcMaskLength()).withGrpAddress(getMappingAddress(multiLcafAddress.getGrpAddress())).withGrpMaskLength(multiLcafAddress.getGrpMaskLength()).build();
case TRAFFIC_ENGINEERING:
LispTeLcafAddress teLcafAddress = (LispTeLcafAddress) lcafAddress;
List<LispTeAddress.TeRecord> records = Lists.newArrayList();
teLcafAddress.getTeRecords().forEach(record -> {
LispTeAddress.TeRecord teRecord = new LispTeAddress.TeRecord.Builder().withIsLookup(record.isLookup()).withIsRlocProbe(record.isRlocProbe()).withIsStrict(record.isStrict()).withRtrRlocAddress(getMappingAddress(record.getRtrRlocAddress())).build();
records.add(teRecord);
});
return new LispTeAddress.Builder().withTeRecords(records).build();
case SECURITY:
// TODO: need to implement security type later
log.warn("security type will be implemented later");
return null;
case SOURCE_DEST:
LispSourceDestLcafAddress srcDstLcafAddress = (LispSourceDestLcafAddress) lcafAddress;
return new LispSrcDstAddress.Builder().withSrcPrefix(getMappingAddress(srcDstLcafAddress.getSrcPrefix())).withSrcMaskLength(srcDstLcafAddress.getSrcMaskLength()).withDstPrefix(getMappingAddress(srcDstLcafAddress.getDstPrefix())).withDstMaskLength(srcDstLcafAddress.getDstMaskLength()).build();
case UNSPECIFIED:
case UNKNOWN:
default:
log.error("Unsupported LCAF type {}", lcafAddress.getType());
return null;
}
}
Aggregations