[ONOS-4718] Add LISP Canonical Address Format Enum and Address class

Change-Id: Ife7f0b98207424b1ce1df390d73b72eb7b5890fe
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispCanonicalAddressFormatEnum.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispCanonicalAddressFormatEnum.java
new file mode 100644
index 0000000..6ad3cdb
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispCanonicalAddressFormatEnum.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2016-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.msg.types;
+
+/**
+ * LISP Canonical Address Format (LCAF) Enumeration class.
+ *
+ * LCAF defines a canonical address format encoding used in LISP control message
+ * and in the encoding of lookup keys for the LISP Mapping Database System.
+ *
+ * LCAF is defined in draft-ietf-lisp-lcaf-13
+ * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-13
+ */
+public enum LispCanonicalAddressFormatEnum {
+    LIST(1),                    // AFI LIST Type
+    SEGMENT(2),                 // Instance ID Type
+    AS(3),                      // AS Number Type
+    APPLICATION_DATA(4),        // Application Data Type
+    NAT(7),                     // NAT Traversal Type
+    MULTICAST(9),               // Multi-cast Info Type
+    SECURITY(11),               // Security Key Type
+    SOURCE_DEST(12),            // Source/Dest Key Type
+    TRAFFIC_ENGINEERING(10),    // Explicit Locator Path Type
+    UNKNOWN(-1);                // Unknown Type
+
+    private byte lispCode;
+
+    /**
+     * Private constructor which avoid instantiating object externally.
+     *
+     * @param lispCode lisp code value
+     */
+    LispCanonicalAddressFormatEnum(int lispCode) {
+        this.lispCode = (byte) lispCode;
+    }
+
+    /**
+     * Obtains lisp code value.
+     *
+     * @return lisp code value
+     */
+    public byte getLispCode() {
+        return lispCode;
+    }
+
+    /**
+     * Obtains the LCAF enum using given lisp code.
+     *
+     * @param lispCode lisp code
+     * @return LCAP enum
+     */
+    public static LispCanonicalAddressFormatEnum valueOf(int lispCode) {
+        for (LispCanonicalAddressFormatEnum val : values()) {
+            if (val.getLispCode() == lispCode) {
+                return val;
+            }
+        }
+        return UNKNOWN;
+    }
+}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispLcafAddress.java
new file mode 100644
index 0000000..2490ac57
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispLcafAddress.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2016-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.msg.types;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * LISP Canonical Address Formatted address class.
+ */
+public class LispLcafAddress extends LispAfiAddress {
+
+    protected final LispCanonicalAddressFormatEnum lcafType;
+    protected final byte value;
+
+    /**
+     * Initializes LCAF address.
+     *
+     * @param lcafType LCAF type
+     * @param value LCAF value
+     */
+    protected LispLcafAddress(LispCanonicalAddressFormatEnum lcafType, byte value) {
+        super(AddressFamilyIdentifierEnum.LCAF);
+        this.lcafType = lcafType;
+        this.value = value;
+    }
+
+    /**
+     * Obtains LCAF type.
+     *
+     * @return LCAF type
+     */
+    public LispCanonicalAddressFormatEnum getType() {
+        return lcafType;
+    }
+
+    /**
+     * Obtains LCAF value.
+     *
+     * @return LCAF value
+     */
+    public byte getValue() {
+        return value;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((lcafType == null) ? 0 : lcafType.hashCode());
+        result = prime * result + value;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj instanceof LispLcafAddress) {
+            final LispLcafAddress other = (LispLcafAddress) obj;
+            return Objects.equals(this.lcafType, other.lcafType) &&
+                    Objects.equals(this.value, other.value);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this)
+                .add("lcafType", lcafType)
+                .add("lcafValue", value)
+                .toString();
+    }
+}