diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java index 6a0492fef4..b6cfa7195c 100644 --- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java +++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java @@ -30,6 +30,7 @@ public enum LispCanonicalAddressFormatEnum { AS(3), // AS Number Type APPLICATION_DATA(4), // Application Data Type NAT(7), // NAT Traversal Type + NONCE(8), // Nonce Locator Type MULTICAST(9), // Multi-cast Info Type TRAFFIC_ENGINEERING(10), // Explicit Locator Path Type SECURITY(11), // Security Key Type diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java index 5aff3b9200..920d356400 100644 --- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java +++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java @@ -33,6 +33,7 @@ import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.LIST; import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.MULTICAST; import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.NAT; +import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.NONCE; import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.SEGMENT; import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.SOURCE_DEST; import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.TRAFFIC_ENGINEERING; @@ -412,6 +413,10 @@ public class LispLcafAddress extends LispAfiAddress { return new LispSegmentLcafAddress.SegmentLcafAddressReader().readFrom(byteBuf); } + if (lcafType == NONCE.getLispCode()) { + return new LispNonceLcafAddress.NonceLcafAddressReader().readFrom(byteBuf); + } + if (lcafType == MULTICAST.getLispCode()) { return new LispMulticastLcafAddress.MulticastLcafAddressReader().readFrom(byteBuf); } @@ -456,6 +461,10 @@ public class LispLcafAddress extends LispAfiAddress { new LispSegmentLcafAddress.SegmentLcafAddressWriter().writeTo(byteBuf, (LispSegmentLcafAddress) address); break; + case NONCE: + new LispNonceLcafAddress.NonceLcafAddressWriter().writeTo(byteBuf, + (LispNonceLcafAddress) address); + break; case MULTICAST: new LispMulticastLcafAddress.MulticastLcafAddressWriter().writeTo(byteBuf, (LispMulticastLcafAddress) address); diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispNonceLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispNonceLcafAddress.java new file mode 100644 index 0000000000..0930539764 --- /dev/null +++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispNonceLcafAddress.java @@ -0,0 +1,216 @@ +/* + * 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.msg.types.lcaf; + +import io.netty.buffer.ByteBuf; +import org.onosproject.lisp.msg.exceptions.LispParseError; +import org.onosproject.lisp.msg.exceptions.LispReaderException; +import org.onosproject.lisp.msg.exceptions.LispWriterException; +import org.onosproject.lisp.msg.types.LispAddressReader; +import org.onosproject.lisp.msg.types.LispAddressWriter; +import org.onosproject.lisp.msg.types.LispAfiAddress; + +import java.util.Objects; + +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Nonce locator data type LCAF address class. + *
+ * Nonce locator data type is defined in draft-ietf-lisp-lcaf-22 + * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-22#page-30 + *
+ *
+ * {@literal
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | AFI = 16387 | Rsvd1 | Flags |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type = 8 | Rsvd2 | Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Reserved | Nonce |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | AFI = x | Address ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * }
+ */
+public final class LispNonceLcafAddress extends LispLcafAddress {
+
+ private final int nonce;
+ private final LispAfiAddress address;
+
+ /**
+ * Initializes nonce locator data type LCAF address.
+ *
+ * @param nonce nonce
+ * @param address address
+ */
+ private LispNonceLcafAddress(int nonce, LispAfiAddress address) {
+ super(LispCanonicalAddressFormatEnum.NONCE);
+ this.nonce = nonce;
+ this.address = address;
+ }
+
+ /**
+ * Obtains nonce.
+ *
+ * @return nonce
+ */
+ public int getNonce() {
+ return nonce;
+ }
+
+ /**
+ * Obtains address.
+ *
+ * @return address
+ */
+ public LispAfiAddress getAddress() {
+ return address;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nonce, address);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof LispNonceLcafAddress) {
+ final LispNonceLcafAddress other = (LispNonceLcafAddress) obj;
+ return Objects.equals(this.nonce, other.nonce) &&
+ Objects.equals(this.address, other.address);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("nonce", nonce)
+ .add("address", address)
+ .toString();
+ }
+
+ public static final class NonceAddressBuilder
+ extends LcafAddressBuilder