[ONOS-4718] Add LispMapRecord, rename EidRecord to LispEidRecord
Change-Id: Ib43ad5201787a7d9a3b18c0cd8949822d2e31e29
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java
index d187d88..6a41ad3 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java
@@ -60,7 +60,7 @@
}
@Override
- public List<LispRecord> getLispRecords() {
+ public List<LispMapRecord> getLispRecords() {
return null;
}
@@ -97,7 +97,7 @@
}
@Override
- public NotifyBuilder addRecord(LispRecord record) {
+ public NotifyBuilder addRecord(LispMapRecord record) {
return null;
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRecord.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRecord.java
new file mode 100644
index 0000000..c910b43
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRecord.java
@@ -0,0 +1,98 @@
+/*
+ * 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.protocols;
+
+import org.onosproject.lisp.msg.types.LispAfiAddress;
+
+/**
+ * Default implementation of LispMapRecord.
+ */
+public class DefaultLispMapRecord implements LispMapRecord {
+
+ private int recordTtl;
+ private int locatorCount;
+ private byte maskLength;
+ private LispMapReplyAction action;
+ private boolean authoritative;
+ private short mapVersionNumber;
+ private LispAfiAddress eidPrefixAfi;
+
+ public int getRecordTtl() {
+ return recordTtl;
+ }
+
+ public int getLocatorCount() {
+ return locatorCount;
+ }
+
+ public byte getMaskLength() {
+ return maskLength;
+ }
+
+ public LispMapReplyAction getAction() {
+ return action;
+ }
+
+ public boolean isAuthoritative() {
+ return authoritative;
+ }
+
+ public short getMapVersionNumber() {
+ return mapVersionNumber;
+ }
+
+ public LispAfiAddress getEidPrefixAfi() {
+ return eidPrefixAfi;
+ }
+
+ public static final class DefaultMapRecordBuilder implements MapRecordBuilder {
+
+ @Override
+ public MapRecordBuilder withRecordTtl(int recordTtl) {
+ return null;
+ }
+
+ @Override
+ public MapRecordBuilder withLocatorCount(int locatorCount) {
+ return null;
+ }
+
+ @Override
+ public MapRecordBuilder withMaskLength(byte maskLength) {
+ return null;
+ }
+
+ @Override
+ public MapRecordBuilder withAction(LispMapReplyAction action) {
+ return null;
+ }
+
+ @Override
+ public MapRecordBuilder withAuthoritative(boolean authoritative) {
+ return null;
+ }
+
+ @Override
+ public MapRecordBuilder withMapVersionNumber(short mapVersionNumber) {
+ return null;
+ }
+
+ @Override
+ public MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix) {
+ return null;
+ }
+ }
+}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
index 259f80a..1b2987e 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
@@ -69,7 +69,7 @@
}
@Override
- public List<LispRecord> getLispRecords() {
+ public List<LispMapRecord> getLispRecords() {
return null;
}
@@ -116,7 +116,7 @@
}
@Override
- public RegisterBuilder addRecord(LispRecord record) {
+ public RegisterBuilder addRecord(LispMapRecord record) {
return null;
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRequest.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRequest.java
index 9f8ac0f..ab109d1 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRequest.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRequest.java
@@ -85,7 +85,7 @@
}
@Override
- public List<EidRecord> getEids() {
+ public List<LispEidRecord> getEids() {
return null;
}
@@ -142,7 +142,7 @@
}
@Override
- public RequestBuilder addEidRecord(EidRecord record) {
+ public RequestBuilder addEidRecord(LispEidRecord record) {
return null;
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/EidRecord.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/EidRecord.java
deleted file mode 100644
index ffcd90e..0000000
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/EidRecord.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.protocols;
-
-/**
- * LISP EID record section which is part of LISP map request message.
- */
-public class EidRecord {
-}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispEidRecord.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispEidRecord.java
new file mode 100644
index 0000000..f6538a6
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispEidRecord.java
@@ -0,0 +1,56 @@
+/*
+ * 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.protocols;
+
+import org.onosproject.lisp.msg.types.LispAfiAddress;
+
+/**
+ * LISP EID record section which is part of LISP map request message.
+ */
+public class LispEidRecord {
+
+ private final byte maskLength;
+ private final LispAfiAddress prefix;
+
+ /**
+ * Initializes LispEidRecord with mask length and EID prefix.
+ *
+ * @param maskLength mask length
+ * @param prefix EID prefix
+ */
+ public LispEidRecord(byte maskLength, LispAfiAddress prefix) {
+ this.maskLength = maskLength;
+ this.prefix = prefix;
+ }
+
+ /**
+ * Obtains mask length of the EID Record.
+ *
+ * @return mask length of the EID Record
+ */
+ public byte getMaskLength() {
+ return maskLength;
+ }
+
+ /**
+ * Obtains EID prefix.
+ *
+ * @return EID prefix
+ */
+ public LispAfiAddress getPrefix() {
+ return prefix;
+ }
+}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java
index dd0fbf5..65c0703 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java
@@ -89,7 +89,7 @@
*
* @return a collection of records
*/
- List<LispRecord> getLispRecords();
+ List<LispMapRecord> getLispRecords();
/**
* A builder of LISP map notify message.
@@ -134,6 +134,6 @@
* @param record record
* @return NotifyBuilder object
*/
- NotifyBuilder addRecord(LispRecord record);
+ NotifyBuilder addRecord(LispMapRecord record);
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRecord.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRecord.java
new file mode 100644
index 0000000..2896e80
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRecord.java
@@ -0,0 +1,135 @@
+/*
+ * 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.protocols;
+
+import org.onosproject.lisp.msg.types.LispAfiAddress;
+
+/**
+ * LISP record section which is part of LISP map register message.
+ */
+public interface LispMapRecord {
+
+ /**
+ * Obtains record TTL value.
+ *
+ * @return record TTL value
+ */
+ int getRecordTtl();
+
+ /**
+ * Obtains locator count value.
+ *
+ * @return locator count value
+ */
+ int getLocatorCount();
+
+ /**
+ * Obtains address mask length.
+ *
+ * @return mask length
+ */
+ byte getMaskLength();
+
+ /**
+ * Obtains LispMapReplyAction enum code.
+ *
+ * @return LispMapReplyAction enum code
+ */
+ LispMapReplyAction getAction();
+
+ /**
+ * Obtains authoritative flag.
+ *
+ * @return authoritative flag
+ */
+ boolean isAuthoritative();
+
+ /**
+ * Obtains map version number.
+ *
+ * @return map version number
+ */
+ short getMapVersionNumber();
+
+ /**
+ * Obtains EID prefix.
+ *
+ * @return EID prefix
+ */
+ LispAfiAddress getEidPrefixAfi();
+
+ /**
+ * A builder of LISP map record.
+ */
+ interface MapRecordBuilder {
+
+ /**
+ * Sets record TTL value.
+ *
+ * @param recordTtl record TTL
+ * @return MapRecordBuilder object
+ */
+ MapRecordBuilder withRecordTtl(int recordTtl);
+
+ /**
+ * Sets locator count.
+ *
+ * @param locatorCount locator count
+ * @return MapRecordBuilder object
+ */
+ MapRecordBuilder withLocatorCount(int locatorCount);
+
+ /**
+ * Sets mask length.
+ *
+ * @param maskLength mask length
+ * @return MapRecordBuilder object
+ */
+ MapRecordBuilder withMaskLength(byte maskLength);
+
+ /**
+ * Sets LISP map reply action enum.
+ *
+ * @param action map reply action
+ * @return MapRecordBuilder object
+ */
+ MapRecordBuilder withAction(LispMapReplyAction action);
+
+ /**
+ * Sets authoritative flag.
+ *
+ * @param authoritative authoritative flag
+ * @return MapRecordBuilder object
+ */
+ MapRecordBuilder withAuthoritative(boolean authoritative);
+
+ /**
+ * Sets LISP map version number.
+ *
+ * @param mapVersionNumber map version number
+ * @return MapRecordBuilder object
+ */
+ MapRecordBuilder withMapVersionNumber(short mapVersionNumber);
+
+ /**
+ * Sets EID prefix.
+ *
+ * @param prefix EID prefix
+ * @return MapRecordBuilder object
+ */
+ MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix);
+ }
+}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java
index 52bd7af..4703cba 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java
@@ -103,7 +103,7 @@
*
* @return a collection of records
*/
- List<LispRecord> getLispRecords();
+ List<LispMapRecord> getLispRecords();
/**
* A builder of LISP map register message.
@@ -164,6 +164,6 @@
* @param record record
* @return RegisterBuilder object
*/
- RegisterBuilder addRecord(LispRecord record);
+ RegisterBuilder addRecord(LispMapRecord record);
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapReplyAction.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapReplyAction.java
new file mode 100644
index 0000000..60ad5c3
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapReplyAction.java
@@ -0,0 +1,70 @@
+/*
+ * 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.protocols;
+
+/**
+ * An enumeration class that represents Map-Reply action.
+ *
+ * The current assigned values are:
+ *
+ * (0) No-Action: The map-cache is kept alive, and no packet
+ * encapsulation occurs.
+ *
+ * (1) Natively-Forward: The packet is not encapsulated or dropped
+ * but natively forwarded.
+ *
+ * (2) Send-Map-Request: The packet invokes sending a Map-Request.
+ *
+ * (3) Drop: A packet that matches this map-cache entry is dropped.
+ * An ICMP Destination Unreachable message SHOULD be sent.
+ */
+public enum LispMapReplyAction {
+
+ NoAction(0), // No-Action
+ NativelyForward(1), // Natively-Forward
+ SendMapRequest(2), // Send-Map-Request
+ Drop(3); // Drop
+
+ private int action;
+
+ LispMapReplyAction(int action) {
+ this.action = action;
+ }
+
+ /**
+ * Obtains MapReplyAction code.
+ *
+ * @return map reply action code
+ */
+ public int getAction() {
+ return action;
+ }
+
+ /**
+ * Obtains the LispMapReplyAction enum with given action code.
+ *
+ * @param action action code
+ * @return an enumeration of LispMapReplyAction
+ */
+ public static LispMapReplyAction valueOf(int action) {
+ for (LispMapReplyAction act : values()) {
+ if (act.getAction() == action) {
+ return act;
+ }
+ }
+ return null;
+ }
+}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRequest.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRequest.java
index 968f89e..f0a49e8 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRequest.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRequest.java
@@ -122,7 +122,7 @@
*
* @return a collection of EID records
*/
- List<EidRecord> getEids();
+ List<LispEidRecord> getEids();
/**
* A builder of LISP map request message.
@@ -199,6 +199,6 @@
* @param record EID record
* @return RequestBuilder object
*/
- RequestBuilder addEidRecord(EidRecord record);
+ RequestBuilder addEidRecord(LispEidRecord record);
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispRecord.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispRecord.java
deleted file mode 100644
index efbe17b..0000000
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispRecord.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.protocols;
-
-/**
- * LISP record section which is part of LISP map register message.
- */
-public class LispRecord {
-
-}