use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispSrcDstAddressCodec method encode.
@Override
public ObjectNode encode(LispSrcDstAddress address, CodecContext context) {
checkNotNull(address, "LispSrcDstAddress cannot be null");
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
final ObjectNode result = context.mapper().createObjectNode().put(SRC_MASK_LENGTH, address.getSrcMaskLength()).put(DST_MASK_LENGTH, address.getDstMaskLength());
if (address.getSrcPrefix() != null) {
ObjectNode srcPrefix = addressCodec.encode(address.getSrcPrefix(), context);
result.set(SRC_PREFIX, srcPrefix);
}
if (address.getDstPrefix() != null) {
ObjectNode dstPrefix = addressCodec.encode(address.getDstPrefix(), context);
result.set(DST_PREFIX, dstPrefix);
}
return result;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispTeRecordCodec method encode.
@Override
public ObjectNode encode(LispTeAddress.TeRecord record, CodecContext context) {
checkNotNull(record, "LispTeRecord cannot be null");
final ObjectNode result = context.mapper().createObjectNode().put(LOOKUP, record.isLookup()).put(RLOC_PROBE, record.isRlocProbe()).put(STRICT, record.isStrict());
if (record.getAddress() != null) {
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
ObjectNode address = addressCodec.encode(record.getAddress(), context);
result.set(ADDRESS, address);
}
return result;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispTeRecordCodec method decode.
@Override
public LispTeAddress.TeRecord decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
boolean isLookup = nullIsIllegal(json.get(LOOKUP), LOOKUP + MISSING_MEMBER_MESSAGE).asBoolean();
boolean isRlocProbe = nullIsIllegal(json.get(RLOC_PROBE), RLOC_PROBE + MISSING_MEMBER_MESSAGE).asBoolean();
boolean isStrict = nullIsIllegal(json.get(STRICT), STRICT + MISSING_MEMBER_MESSAGE).asBoolean();
ObjectNode addressJson = get(json, ADDRESS);
MappingAddress mappingAddress = null;
if (addressJson != null) {
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
mappingAddress = addressCodec.decode(addressJson, context);
}
return new LispTeAddress.TeRecord.Builder().withIsLookup(isLookup).withIsRlocProbe(isRlocProbe).withIsStrict(isStrict).withRtrRlocAddress(mappingAddress).build();
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class MappingEntryBuilder method buildTreatments.
/**
* Builds a collection of mapping treatments.
*
* @param record LISP map record
* @return a collection of mapping treatments
*/
private List<MappingTreatment> buildTreatments(LispMapRecord record) {
List<LispLocator> locators = record.getLocators();
List<MappingTreatment> treatments = Lists.newArrayList();
for (LispLocator locator : locators) {
MappingTreatment.Builder builder = DefaultMappingTreatment.builder();
LispAfiAddress address = locator.getLocatorAfi();
final MappingAddress mappingAddress = getAddress(deviceService, deviceId, address);
if (mappingAddress != null) {
builder.withAddress(mappingAddress);
}
builder.setUnicastWeight(locator.getWeight()).setUnicastPriority(locator.getPriority()).setMulticastWeight(locator.getMulticastWeight()).setMulticastPriority(locator.getMulticastPriority());
// TODO: need to convert specific properties to
// abstracted extension properties
treatments.add(builder.build());
}
return treatments;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class DefaultMappingTreatmentTest method testIllegalUnicastTypeConstruction.
/**
* Tests illegal unicast type instruction construction.
*/
@Test(expected = IllegalArgumentException.class)
public void testIllegalUnicastTypeConstruction() {
IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
DefaultMappingTreatment.builder().withAddress(address).setUnicastPriority(10).setUnicastWeight(10).setUnicastPriority(20).build();
}
Aggregations