use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispNatAddressTest method testConstruction.
@Test
public void testConstruction() {
LispNatAddress address = address1;
MappingAddress ma = MappingAddresses.ipv4MappingAddress(IP_ADDRESS_1);
assertThat(address.getMsUdpPortNumber(), is(MS_UDP_PORT_NUMBER));
assertThat(address.getEtrUdpPortNumber(), is(ETR_UDP_PORT_NUMBER));
assertThat(address.getGlobalEtrRlocAddress(), is(ma));
assertThat(address.getMsRlocAddress(), is(ma));
assertThat(address.getPrivateEtrRlocAddress(), is(ma));
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispSegmentAddressTest method setUp.
@Before
public void setUp() {
MappingAddress ma1 = MappingAddresses.ipv4MappingAddress(IP_ADDRESS_1);
address1 = new LispSegmentAddress.Builder().withInstanceId(INSTANCE_ID_1).withAddress(ma1).build();
sameAsAddress1 = new LispSegmentAddress.Builder().withInstanceId(INSTANCE_ID_1).withAddress(ma1).build();
MappingAddress ma2 = MappingAddresses.ipv4MappingAddress(IP_ADDRESS_2);
address2 = new LispSegmentAddress.Builder().withInstanceId(INSTANCE_ID_2).withAddress(ma2).build();
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispAsAddressCodec method encode.
@Override
public ObjectNode encode(LispAsAddress address, CodecContext context) {
checkNotNull(address, "LispAsAddress cannot be null");
final ObjectNode result = context.mapper().createObjectNode().put(AS_NUMBER, address.getAsNumber());
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 LispListAddressCodec method encode.
@Override
public ObjectNode encode(LispListAddress address, CodecContext context) {
checkNotNull(address, "LispListAddress cannot be null");
final ObjectNode result = context.mapper().createObjectNode();
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
if (address.getIpv4() != null) {
ObjectNode ipv4Node = addressCodec.encode(address.getIpv4(), context);
result.set(IPV4, ipv4Node);
}
if (address.getIpv6() != null) {
ObjectNode ipv6Node = addressCodec.encode(address.getIpv6(), context);
result.set(IPV6, ipv6Node);
}
if (address.getIpv4() == null && address.getIpv6() == null) {
log.error("Either IPv4 or IPv6 address should be specified.");
}
return result;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispNatAddressCodec method decode.
@Override
public LispNatAddress decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
short msUdpPortNumber = (short) json.get(MS_UDP_PORT_NUMBER).asInt();
short etrUdpPortNumber = (short) json.get(ETR_UDP_PORT_NUMBER).asInt();
ObjectNode globalEtrRlocJson = get(json, GLOBAL_ETR_RLOC_ADDRESS);
ObjectNode msRlocJson = get(json, MS_RLOC_ADDRESS);
ObjectNode privateEtrRlocJson = get(json, PRIVATE_ETR_RLOC_ADDRESS);
JsonNode rtrRlocJson = json.get(RTR_RLOC_ADDRESSES);
MappingAddress globalEtrRlocAddress = null;
MappingAddress msRlocAddress = null;
MappingAddress privateEtrRlocAddress = null;
List<MappingAddress> rtrRlocAddresses = Lists.newArrayList();
if (globalEtrRlocJson != null) {
globalEtrRlocAddress = addressCodec.decode(globalEtrRlocJson, context);
}
if (msRlocJson != null) {
msRlocAddress = addressCodec.decode(msRlocJson, context);
}
if (privateEtrRlocJson != null) {
privateEtrRlocAddress = addressCodec.decode(privateEtrRlocJson, context);
}
if (rtrRlocJson != null) {
IntStream.range(0, rtrRlocJson.size()).forEach(i -> rtrRlocAddresses.add(addressCodec.decode(get(rtrRlocJson, i), context)));
}
return new LispNatAddress.Builder().withMsUdpPortNumber(msUdpPortNumber).withEtrUdpPortNumber(etrUdpPortNumber).withGlobalEtrRlocAddress(globalEtrRlocAddress).withMsRlocAddress(msRlocAddress).withPrivateEtrRlocAddress(privateEtrRlocAddress).withRtrRlocAddresses(rtrRlocAddresses).build();
}
Aggregations