use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispSegmentAddressCodec method decode.
@Override
public LispSegmentAddress decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
int instanceId = nullIsIllegal(json.get(INSTANCE_ID), INSTANCE_ID + MISSING_MEMBER_MESSAGE).asInt();
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 LispSegmentAddress.Builder().withInstanceId(instanceId).withAddress(mappingAddress).build();
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispSrcDstAddressCodec method decode.
@Override
public LispSrcDstAddress decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
byte srcMaskLength = (byte) nullIsIllegal(json.get(SRC_MASK_LENGTH), SRC_MASK_LENGTH + MISSING_MEMBER_MESSAGE).asInt();
byte dstMaskLength = (byte) nullIsIllegal(json.get(DST_MASK_LENGTH), DST_MASK_LENGTH + MISSING_MEMBER_MESSAGE).asInt();
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
ObjectNode srcPrefixJson = get(json, SRC_PREFIX);
MappingAddress srcPrefix = null;
ObjectNode dstPrefixJson = get(json, DST_PREFIX);
MappingAddress dstPrefix = null;
if (srcPrefixJson != null) {
srcPrefix = addressCodec.decode(srcPrefixJson, context);
}
if (dstPrefixJson != null) {
dstPrefix = addressCodec.decode(dstPrefixJson, context);
}
return new LispSrcDstAddress.Builder().withSrcMaskLength(srcMaskLength).withDstMaskLength(dstMaskLength).withSrcPrefix(srcPrefix).withDstPrefix(dstPrefix).build();
}
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();
}
Aggregations