use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispSrcDstAddressTest method setUp.
@Before
public void setUp() {
MappingAddress ma1 = MappingAddresses.ipv4MappingAddress(IP_ADDRESS_1);
address1 = new LispSrcDstAddress.Builder().withSrcMaskLength(MASK_LENGTH_1).withDstMaskLength(MASK_LENGTH_1).withSrcPrefix(ma1).withDstPrefix(ma1).build();
sameAsAddress1 = new LispSrcDstAddress.Builder().withSrcMaskLength(MASK_LENGTH_1).withDstMaskLength(MASK_LENGTH_1).withSrcPrefix(ma1).withDstPrefix(ma1).build();
MappingAddress ma2 = MappingAddresses.ipv4MappingAddress(IP_ADDRESS_2);
address2 = new LispSrcDstAddress.Builder().withSrcMaskLength(MASK_LENGTH_2).withDstMaskLength(MASK_LENGTH_2).withSrcPrefix(ma2).withDstPrefix(ma2).build();
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class LispSrcDstAddressTest method testConstruction.
@Test
public void testConstruction() {
LispSrcDstAddress address = address1;
MappingAddress ma = MappingAddresses.ipv4MappingAddress(IP_ADDRESS_1);
assertThat(address.getSrcMaskLength(), is(MASK_LENGTH_1));
assertThat(address.getDstMaskLength(), is(MASK_LENGTH_1));
assertThat(address.getSrcPrefix(), is(ma));
assertThat(address.getDstPrefix(), is(ma));
}
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 LispMulticastAddressCodec method decode.
@Override
public LispMulticastAddress 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();
byte srcMaskLength = (byte) nullIsIllegal(json.get(SRC_MASK_LENGTH), SRC_MASK_LENGTH + MISSING_MEMBER_MESSAGE).asInt();
byte grpMaskLength = (byte) nullIsIllegal(json.get(GRP_MASK_LENGTH), GRP_MASK_LENGTH + MISSING_MEMBER_MESSAGE).asInt();
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
ObjectNode srcAddressJson = get(json, SRC_ADDRESS);
MappingAddress srcAddress = null;
if (srcAddressJson != null) {
srcAddress = addressCodec.decode(srcAddressJson, context);
}
ObjectNode grpAddressJson = get(json, GRP_ADDRESS);
MappingAddress grpAddress = null;
if (grpAddressJson != null) {
grpAddress = addressCodec.decode(grpAddressJson, context);
}
return new LispMulticastAddress.Builder().withInstanceId(instanceId).withSrcMaskLength(srcMaskLength).withGrpMaskLength(grpMaskLength).withSrcAddress(srcAddress).withGrpAddress(grpAddress).build();
}
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