From 246334bb48830c9e37b79cb6bcfcf12e36cba648 Mon Sep 17 00:00:00 2001 From: Jian Li Date: Fri, 31 Mar 2017 00:37:01 +0900 Subject: [PATCH] Add ExtensionAddressInterpreter with ExtensionMappingAddressCodec Change-Id: I30e663581ff392b3adf0e366cb7984fc66d34d0b --- .../ExtensionMappingAddressCodec.java | 49 +++++++++++++++++ protocols/lisp/api/BUCK | 1 + protocols/lisp/api/pom.xml | 5 ++ .../ExtensionMappingAddressInterpreter.java | 52 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/addresses/ExtensionMappingAddressCodec.java create mode 100644 protocols/lisp/api/src/main/java/org/onosproject/lisp/ctl/ExtensionMappingAddressInterpreter.java diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/addresses/ExtensionMappingAddressCodec.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/addresses/ExtensionMappingAddressCodec.java new file mode 100644 index 0000000000..342a94558a --- /dev/null +++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/addresses/ExtensionMappingAddressCodec.java @@ -0,0 +1,49 @@ +/* + * Copyright 2017-present Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.mapping.addresses; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.onosproject.codec.CodecContext; +import org.onosproject.net.driver.HandlerBehaviour; + +/** + * Interface for encode and decode extension mapping address. + */ +public interface ExtensionMappingAddressCodec extends HandlerBehaviour { + + /** + * Encodes an extension mapping address to an JSON object. + * + * @param extensionMappingAddress extension mapping address + * @param context encoding context + * @return JSON object + */ + default ObjectNode encode(ExtensionMappingAddress extensionMappingAddress, + CodecContext context) { + return null; + } + + /** + * Decodes a JSON object to an extension mapping address. + * + * @param objectNode JSON object + * @param context decoding context + * @return extension mapping address + */ + default ExtensionMappingAddress decode(ObjectNode objectNode, CodecContext context) { + return null; + } +} diff --git a/protocols/lisp/api/BUCK b/protocols/lisp/api/BUCK index 7e70e4e63b..8481517683 100644 --- a/protocols/lisp/api/BUCK +++ b/protocols/lisp/api/BUCK @@ -2,6 +2,7 @@ COMPILE_DEPS = [ '//lib:CORE_DEPS', '//lib:netty-transport', '//protocols/lisp/msg:onos-protocols-lisp-msg', + '//apps/mappingmanagement/api:onos-apps-mappingmanagement-api', ] osgi_jar_with_tests ( diff --git a/protocols/lisp/api/pom.xml b/protocols/lisp/api/pom.xml index 6bd81ffcc4..574bfe3ef2 100644 --- a/protocols/lisp/api/pom.xml +++ b/protocols/lisp/api/pom.xml @@ -44,6 +44,11 @@ onos-lisp-msg ${project.version} + + org.onosproject + onos-mapping-api + ${project.version} + diff --git a/protocols/lisp/api/src/main/java/org/onosproject/lisp/ctl/ExtensionMappingAddressInterpreter.java b/protocols/lisp/api/src/main/java/org/onosproject/lisp/ctl/ExtensionMappingAddressInterpreter.java new file mode 100644 index 0000000000..44e749f0a8 --- /dev/null +++ b/protocols/lisp/api/src/main/java/org/onosproject/lisp/ctl/ExtensionMappingAddressInterpreter.java @@ -0,0 +1,52 @@ +/* + * Copyright 2017-present Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.lisp.ctl; + +import org.onosproject.lisp.msg.types.lcaf.LispLcafAddress; +import org.onosproject.mapping.addresses.ExtensionMappingAddress; +import org.onosproject.mapping.addresses.ExtensionMappingAddressCodec; +import org.onosproject.mapping.addresses.ExtensionMappingAddressType; + +/** + * Interprets extension addresses and converts them to/from LISP objects. + */ +public interface ExtensionMappingAddressInterpreter extends ExtensionMappingAddressCodec { + + /** + * Returns true if the given extension mapping address is supported by this + * driver. + * + * @param extensionMappingAddressType extension mapping address type + * @return true if the address is supported, otherwise false + */ + boolean supported(ExtensionMappingAddressType extensionMappingAddressType); + + /** + * Maps an extension mapping address to a LCAF address. + * + * @param mappingAddress extension mapping address + * @return LISP LCAF address + */ + LispLcafAddress mapMappingAddress(ExtensionMappingAddress mappingAddress); + + /** + * Maps a LCAF address to an extension mapping address. + * + * @param lcafAddress LCAF address + * @return extension mapping address + */ + ExtensionMappingAddress mapLcafAddress(LispLcafAddress lcafAddress); +}