Search in sources :

Example 6 with MappingAddress

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));
}
Also used : MappingAddress(org.onosproject.mapping.addresses.MappingAddress) Test(org.junit.Test)

Example 7 with MappingAddress

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();
}
Also used : MappingAddress(org.onosproject.mapping.addresses.MappingAddress) Before(org.junit.Before)

Example 8 with MappingAddress

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MappingAddress(org.onosproject.mapping.addresses.MappingAddress)

Example 9 with MappingAddress

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MappingAddress(org.onosproject.mapping.addresses.MappingAddress)

Example 10 with MappingAddress

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();
}
Also used : MappingAddress(org.onosproject.mapping.addresses.MappingAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) LispNatAddress(org.onosproject.drivers.lisp.extensions.LispNatAddress) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

MappingAddress (org.onosproject.mapping.addresses.MappingAddress)66 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)34 Test (org.junit.Test)26 Before (org.junit.Before)11 DefaultMappingTreatment (org.onosproject.mapping.DefaultMappingTreatment)7 MappingTreatment (org.onosproject.mapping.MappingTreatment)7 MappingAddressJsonMatcher.matchesMappingAddress (org.onosproject.mapping.codec.MappingAddressJsonMatcher.matchesMappingAddress)7 IpPrefix (org.onlab.packet.IpPrefix)6 MappingInstruction (org.onosproject.mapping.instructions.MappingInstruction)6 DefaultMappingKey (org.onosproject.mapping.DefaultMappingKey)5 MappingKey (org.onosproject.mapping.MappingKey)5 DefaultMappingValue (org.onosproject.mapping.DefaultMappingValue)4 MappingValue (org.onosproject.mapping.MappingValue)4 MappingAction (org.onosproject.mapping.actions.MappingAction)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 EqualsTester (com.google.common.testing.EqualsTester)2 LispNatAddress (org.onosproject.drivers.lisp.extensions.LispNatAddress)2 LispTeRecord (org.onosproject.lisp.msg.types.lcaf.LispTeRecord)2 DefaultMapping (org.onosproject.mapping.DefaultMapping)2