use of org.onosproject.lisp.msg.types.lcaf.LispTeRecord in project onos by opennetworkinglab.
the class LispExtensionMappingAddressInterpreter method mapMappingAddress.
@Override
public LispLcafAddress mapMappingAddress(ExtensionMappingAddress mappingAddress) {
ExtensionMappingAddressType type = mappingAddress.type();
if (type.equals(LIST_ADDRESS.type())) {
LispListAddress listAddress = (LispListAddress) mappingAddress;
LispAfiAddress ipv4 = mapping2afi(listAddress.getIpv4());
LispAfiAddress ipv6 = mapping2afi(listAddress.getIpv6());
if (ipv4 != null && ipv6 != null) {
return new LispListLcafAddress(ImmutableList.of(ipv4, ipv6));
} else {
return new LispListLcafAddress(ImmutableList.of());
}
}
if (type.equals(SEGMENT_ADDRESS.type())) {
LispSegmentAddress segmentAddress = (LispSegmentAddress) mappingAddress;
return new LispSegmentLcafAddress.SegmentAddressBuilder().withInstanceId(segmentAddress.getInstanceId()).withAddress(getAfiAddress(segmentAddress.getAddress())).build();
}
if (type.equals(AS_ADDRESS.type())) {
LispAsAddress asAddress = (LispAsAddress) mappingAddress;
return new LispAsLcafAddress.AsAddressBuilder().withAsNumber(asAddress.getAsNumber()).withAddress(getAfiAddress(asAddress.getAddress())).build();
}
if (type.equals(APPLICATION_DATA_ADDRESS.type())) {
LispAppDataAddress appDataAddress = (LispAppDataAddress) mappingAddress;
return new LispAppDataLcafAddress.AppDataAddressBuilder().withProtocol(appDataAddress.getProtocol()).withIpTos(appDataAddress.getIpTos()).withLocalPortLow(appDataAddress.getLocalPortLow()).withLocalPortHigh(appDataAddress.getLocalPortHigh()).withRemotePortLow(appDataAddress.getRemotePortLow()).withRemotePortHigh(appDataAddress.getRemotePortHigh()).withAddress(getAfiAddress(appDataAddress.getAddress())).build();
}
if (type.equals(GEO_COORDINATE_ADDRESS.type())) {
LispGcAddress gcAddress = (LispGcAddress) mappingAddress;
return new LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder().withIsNorth(gcAddress.isNorth()).withLatitudeDegree(gcAddress.getLatitudeDegree()).withLatitudeMinute(gcAddress.getLatitudeMinute()).withLatitudeSecond(gcAddress.getLatitudeSecond()).withIsEast(gcAddress.isEast()).withLongitudeDegree(gcAddress.getLongitudeDegree()).withLongitudeMinute(gcAddress.getLongitudeMinute()).withLongitudeSecond(gcAddress.getLongitudeSecond()).withAltitude(gcAddress.getAltitude()).withAddress(getAfiAddress(gcAddress.getAddress())).build();
}
if (type.equals(NAT_ADDRESS.type())) {
LispNatAddress natAddress = (LispNatAddress) mappingAddress;
List<LispAfiAddress> aas = Lists.newArrayList();
natAddress.getRtrRlocAddresses().forEach(rtr -> aas.add(getAfiAddress(rtr)));
return new LispNatLcafAddress.NatAddressBuilder().withMsUdpPortNumber(natAddress.getMsUdpPortNumber()).withEtrUdpPortNumber(natAddress.getEtrUdpPortNumber()).withMsRlocAddress(getAfiAddress(natAddress.getMsRlocAddress())).withGlobalEtrRlocAddress(getAfiAddress(natAddress.getGlobalEtrRlocAddress())).withPrivateEtrRlocAddress(getAfiAddress(natAddress.getPrivateEtrRlocAddress())).withRtrRlocAddresses(aas).build();
}
if (type.equals(NONCE_ADDRESS.type())) {
LispNonceAddress nonceAddress = (LispNonceAddress) mappingAddress;
return new LispNonceLcafAddress.NonceAddressBuilder().withNonce(nonceAddress.getNonce()).withAddress(getAfiAddress(nonceAddress.getAddress())).build();
}
if (type.equals(MULTICAST_ADDRESS.type())) {
LispMulticastAddress multicastAddress = (LispMulticastAddress) mappingAddress;
return new LispMulticastLcafAddress.MulticastAddressBuilder().withInstanceId(multicastAddress.getInstanceId()).withSrcAddress(getAfiAddress(multicastAddress.getSrcAddress())).withSrcMaskLength(multicastAddress.getSrcMaskLength()).withGrpAddress(getAfiAddress(multicastAddress.getGrpAddress())).withGrpMaskLength(multicastAddress.getGrpMaskLength()).build();
}
if (type.equals(TRAFFIC_ENGINEERING_ADDRESS.type())) {
LispTeAddress teAddress = (LispTeAddress) mappingAddress;
List<LispTeRecord> records = Lists.newArrayList();
teAddress.getTeRecords().forEach(record -> {
LispTeRecord teRecord = new LispTeRecord.TeRecordBuilder().withIsLookup(record.isLookup()).withIsRlocProbe(record.isRlocProbe()).withIsStrict(record.isStrict()).withRtrRlocAddress(getAfiAddress(record.getAddress())).build();
records.add(teRecord);
});
return new LispTeLcafAddress.TeAddressBuilder().withTeRecords(records).build();
}
if (type.equals(SOURCE_DEST_ADDRESS.type())) {
LispSrcDstAddress srcDstAddress = (LispSrcDstAddress) mappingAddress;
return new LispSourceDestLcafAddress.SourceDestAddressBuilder().withSrcPrefix(getAfiAddress(srcDstAddress.getSrcPrefix())).withSrcMaskLength(srcDstAddress.getSrcMaskLength()).withDstPrefix(getAfiAddress(srcDstAddress.getDstPrefix())).withDstMaskLength(srcDstAddress.getDstMaskLength()).build();
}
log.error("Unsupported extension mapping address type {}", mappingAddress.type());
return null;
}
use of org.onosproject.lisp.msg.types.lcaf.LispTeRecord in project onos by opennetworkinglab.
the class LispExtensionMappingAddressInterpreterTest method getLcafMappingAddress.
private LispLcafAddress getLcafMappingAddress(ExtensionMappingAddressType type) {
LispLcafAddress address = null;
LispAfiAddress ipv4Addr = new LispIpv4Address(IPV4_ADDRESS);
LispAfiAddress ipv6Addr = new LispIpv6Address(IPV6_ADDRESS);
if (type.equals(LIST_ADDRESS.type())) {
address = new LispListLcafAddress(ImmutableList.of(ipv4Addr, ipv6Addr));
}
if (type.equals(SEGMENT_ADDRESS.type())) {
address = new LispSegmentLcafAddress.SegmentAddressBuilder().withInstanceId(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(AS_ADDRESS.type())) {
address = new LispAsLcafAddress.AsAddressBuilder().withAsNumber(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(APPLICATION_DATA_ADDRESS.type())) {
address = new LispAppDataLcafAddress.AppDataAddressBuilder().withProtocol(UNIQUE_BYTE).withIpTos(UNIQUE_INT).withLocalPortLow(UNIQUE_SHORT).withLocalPortHigh(UNIQUE_SHORT).withRemotePortLow(UNIQUE_SHORT).withRemotePortHigh(UNIQUE_SHORT).withAddress(ipv4Addr).build();
}
if (type.equals(GEO_COORDINATE_ADDRESS.type())) {
address = new LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder().withIsNorth(UNIQUE_BOOLEAN).withLatitudeDegree(UNIQUE_SHORT).withLatitudeMinute(UNIQUE_BYTE).withLatitudeSecond(UNIQUE_BYTE).withIsEast(UNIQUE_BOOLEAN).withLongitudeDegree(UNIQUE_SHORT).withLongitudeMinute(UNIQUE_BYTE).withLongitudeSecond(UNIQUE_BYTE).withAltitude(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(NAT_ADDRESS.type())) {
address = new LispNatLcafAddress.NatAddressBuilder().withMsUdpPortNumber(UNIQUE_SHORT).withEtrUdpPortNumber(UNIQUE_SHORT).withGlobalEtrRlocAddress(ipv4Addr).withMsRlocAddress(ipv4Addr).withPrivateEtrRlocAddress(ipv4Addr).withRtrRlocAddresses(ImmutableList.of(ipv4Addr, ipv6Addr)).build();
}
if (type.equals(NONCE_ADDRESS.type())) {
address = new LispNonceLcafAddress.NonceAddressBuilder().withNonce(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(MULTICAST_ADDRESS.type())) {
address = new LispMulticastLcafAddress.MulticastAddressBuilder().withInstanceId(UNIQUE_INT).withSrcMaskLength(UNIQUE_BYTE).withSrcAddress(ipv4Addr).withGrpMaskLength(UNIQUE_BYTE).withGrpAddress(ipv4Addr).build();
}
if (type.equals(TRAFFIC_ENGINEERING_ADDRESS.type())) {
LispTeRecord tr = new LispTeRecord.TeRecordBuilder().withIsLookup(UNIQUE_BOOLEAN).withIsRlocProbe(UNIQUE_BOOLEAN).withIsStrict(UNIQUE_BOOLEAN).withRtrRlocAddress(ipv4Addr).build();
address = new LispTeLcafAddress.TeAddressBuilder().withTeRecords(ImmutableList.of(tr)).build();
}
if (type.equals(SOURCE_DEST_ADDRESS.type())) {
address = new LispSourceDestLcafAddress.SourceDestAddressBuilder().withSrcMaskLength(UNIQUE_BYTE).withSrcPrefix(ipv4Addr).withDstMaskLength(UNIQUE_BYTE).withDstPrefix(ipv4Addr).build();
}
return address;
}
use of org.onosproject.lisp.msg.types.lcaf.LispTeRecord in project onos by opennetworkinglab.
the class MappingEntryBuilderTest method getLcafAddress.
/**
* Obtains the LCAF address with respect to the LCAF type.
*
* @param type LCAF type
* @return LCAF address instance
*/
private LispLcafAddress getLcafAddress(LispCanonicalAddressFormatEnum type) {
List<LispAfiAddress> afiAddresses = ImmutableList.of(IPV4_ADDRESS_1, IPV6_ADDRESS);
switch(type) {
case LIST:
return new LispListLcafAddress(afiAddresses);
case SEGMENT:
return new LispSegmentLcafAddress.SegmentAddressBuilder().withIdMaskLength(UNIQUE_BYTE).withInstanceId(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
case AS:
return new LispAsLcafAddress.AsAddressBuilder().withAsNumber(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
case APPLICATION_DATA:
return new LispAppDataLcafAddress.AppDataAddressBuilder().withProtocol(UNIQUE_BYTE).withIpTos(UNIQUE_SHORT).withLocalPortLow(UNIQUE_SHORT).withLocalPortHigh(UNIQUE_SHORT).withRemotePortLow(UNIQUE_SHORT).withRemotePortHigh(UNIQUE_SHORT).withAddress(IPV4_ADDRESS_1).build();
case GEO_COORDINATE:
return new LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder().withIsNorth(UNIQUE_BOOLEAN).withLatitudeDegree(UNIQUE_SHORT).withLatitudeMinute(UNIQUE_BYTE).withLatitudeSecond(UNIQUE_BYTE).withIsEast(UNIQUE_BOOLEAN).withLongitudeDegree(UNIQUE_SHORT).withLongitudeMinute(UNIQUE_BYTE).withLongitudeSecond(UNIQUE_BYTE).withAltitude(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
case NAT:
return new LispNatLcafAddress.NatAddressBuilder().withLength(UNIQUE_SHORT).withMsUdpPortNumber(UNIQUE_SHORT).withEtrUdpPortNumber(UNIQUE_SHORT).withGlobalEtrRlocAddress(IPV4_ADDRESS_1).withMsRlocAddress(IPV4_ADDRESS_1).withPrivateEtrRlocAddress(IPV4_ADDRESS_1).withRtrRlocAddresses(afiAddresses).build();
case NONCE:
return new LispNonceLcafAddress.NonceAddressBuilder().withNonce(UNIQUE_INT).withAddress(IPV4_ADDRESS_1).build();
case MULTICAST:
return new LispMulticastLcafAddress.MulticastAddressBuilder().withInstanceId(UNIQUE_INT).withSrcMaskLength(UNIQUE_BYTE).withGrpMaskLength(UNIQUE_BYTE).withSrcAddress(IPV4_ADDRESS_1).withGrpAddress(IPV4_ADDRESS_1).build();
case TRAFFIC_ENGINEERING:
LispTeRecord.TeRecordBuilder recordBuilder1 = new LispTeRecord.TeRecordBuilder();
recordBuilder1.withIsLookup(UNIQUE_BOOLEAN);
recordBuilder1.withIsRlocProbe(UNIQUE_BOOLEAN);
recordBuilder1.withIsStrict(UNIQUE_BOOLEAN);
recordBuilder1.withRtrRlocAddress(IPV4_ADDRESS_1);
LispTeRecord record1 = recordBuilder1.build();
LispTeRecord.TeRecordBuilder recordBuilder2 = new LispTeRecord.TeRecordBuilder();
recordBuilder2.withIsLookup(UNIQUE_BOOLEAN);
recordBuilder2.withIsRlocProbe(UNIQUE_BOOLEAN);
recordBuilder2.withIsStrict(UNIQUE_BOOLEAN);
recordBuilder2.withRtrRlocAddress(IPV4_ADDRESS_2);
LispTeRecord record2 = recordBuilder2.build();
return new LispTeLcafAddress.TeAddressBuilder().withTeRecords(ImmutableList.of(record1, record2)).build();
case SOURCE_DEST:
return new LispSourceDestLcafAddress.SourceDestAddressBuilder().withReserved(UNIQUE_SHORT).withSrcMaskLength(UNIQUE_BYTE).withDstMaskLength(UNIQUE_BYTE).withSrcPrefix(IPV4_ADDRESS_1).withDstPrefix(IPV4_ADDRESS_2).build();
case UNKNOWN:
case UNSPECIFIED:
default:
return null;
}
}
Aggregations