use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispListAddressCodec method decode.
@Override
public LispListAddress decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
ObjectNode ipv4Json = get(json, IPV4);
ObjectNode ipv6Json = get(json, IPV6);
MappingAddress ipv4Address = null;
MappingAddress ipv6Address = null;
if (ipv4Json != null) {
ipv4Address = addressCodec.decode(ipv4Json, context);
}
if (ipv6Json != null) {
ipv6Address = addressCodec.decode(ipv6Json, context);
}
if (ipv4Json == null && ipv6Json == null) {
log.error("Either IPv4 or IPv6 address should be specified.");
}
return new LispListAddress.Builder().withIpv4(ipv4Address).withIpv6(ipv6Address).build();
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispMulticastAddressCodec method encode.
@Override
public ObjectNode encode(LispMulticastAddress address, CodecContext context) {
checkNotNull(address, "LispMulticastAddress cannot be null");
final ObjectNode result = context.mapper().createObjectNode().put(INSTANCE_ID, address.getInstanceId()).put(SRC_MASK_LENGTH, address.getSrcMaskLength()).put(GRP_MASK_LENGTH, address.getGrpMaskLength());
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
if (address.getSrcAddress() != null) {
ObjectNode srcAddressNode = addressCodec.encode(address.getSrcAddress(), context);
result.set(SRC_ADDRESS, srcAddressNode);
}
if (address.getGrpAddress() != null) {
ObjectNode grpAddressNode = addressCodec.encode(address.getGrpAddress(), context);
result.set(GRP_ADDRESS, grpAddressNode);
}
return result;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispNatAddressCodec method encode.
@Override
public ObjectNode encode(LispNatAddress address, CodecContext context) {
checkNotNull(address, "LispListAddress cannot be null");
final ObjectNode result = context.mapper().createObjectNode().put(MS_UDP_PORT_NUMBER, address.getMsUdpPortNumber()).put(ETR_UDP_PORT_NUMBER, address.getEtrUdpPortNumber());
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
if (address.getGlobalEtrRlocAddress() != null) {
ObjectNode globalEtrRlocNode = addressCodec.encode(address.getGlobalEtrRlocAddress(), context);
result.set(GLOBAL_ETR_RLOC_ADDRESS, globalEtrRlocNode);
}
if (address.getMsRlocAddress() != null) {
ObjectNode msRlocNode = addressCodec.encode(address.getMsRlocAddress(), context);
result.set(MS_RLOC_ADDRESS, msRlocNode);
}
if (address.getPrivateEtrRlocAddress() != null) {
ObjectNode privateEtrRlocNode = addressCodec.encode(address.getPrivateEtrRlocAddress(), context);
result.set(PRIVATE_ETR_RLOC_ADDRESS, privateEtrRlocNode);
}
final ArrayNode jsonRtrRlocNodes = result.putArray(RTR_RLOC_ADDRESSES);
if (address.getRtrRlocAddresses() != null) {
for (final MappingAddress mappingAddress : address.getRtrRlocAddresses()) {
jsonRtrRlocNodes.add(addressCodec.encode(mappingAddress, context));
}
}
return result;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispNonceAddressCodec method encode.
@Override
public ObjectNode encode(LispNonceAddress address, CodecContext context) {
checkNotNull(address, "LispListAddress cannot be null");
final ObjectNode result = context.mapper().createObjectNode().put(NONCE, address.getNonce());
if (address.getAddress() != null) {
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
ObjectNode addressNode = addressCodec.encode(address.getAddress(), context);
result.set(ADDRESS, addressNode);
}
return result;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispNonceAddressCodec method decode.
@Override
public LispNonceAddress decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
int nonce = nullIsIllegal(json.get(NONCE), NONCE + 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 LispNonceAddress.Builder().withNonce(nonce).withAddress(mappingAddress).build();
}
Aggregations