[ONOS-4718] Add skeleton code for de-serializing LISP ctrl messages
Change-Id: I52f7905538e5832e5282812df869b8158ce23334
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/exceptions/LispParseError.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/exceptions/LispParseError.java
new file mode 100644
index 0000000..12d19e5
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/exceptions/LispParseError.java
@@ -0,0 +1,57 @@
+/*
+ * 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.exceptions;
+
+/**
+ * LISP control message parse error.
+ */
+public class LispParseError extends Exception {
+
+ /**
+ * Constructor for LispParseError.
+ */
+ public LispParseError() {
+ super();
+ }
+
+ /**
+ * Constructor for LispParseError with message and cause parameters.
+ *
+ * @param message error message
+ * @param cause throwable cause
+ */
+ public LispParseError(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructor for LispParseError with message parameter.
+ *
+ * @param message error message
+ */
+ public LispParseError(final String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor for LispParseError with cause parameter.
+ *
+ * @param cause throwable cause
+ */
+ public LispParseError(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/exceptions/package-info.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/exceptions/package-info.java
new file mode 100644
index 0000000..bcd37bd
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/exceptions/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+/**
+ * A package subsumes various LISP control message exceptions.
+ */
+package org.onosproject.lisp.msg.exceptions;
\ No newline at end of file
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 7d55e1e..831065a 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
@@ -20,6 +20,7 @@
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
import java.util.List;
@@ -173,4 +174,15 @@
recordCount, mapRecords);
}
}
+
+ /**
+ * A private LISP message reader for MapNotify message.
+ */
+ private static class NotifyReader implements LispMessageReader<LispMapNotify> {
+
+ @Override
+ public LispMapNotify readFrom(ByteBuf byteBuf) throws LispParseError {
+ 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
index 6f00376..7b0c86c 100644
--- 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
@@ -16,6 +16,8 @@
package org.onosproject.lisp.msg.protocols;
import com.google.common.base.Objects;
+import io.netty.buffer.ByteBuf;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -185,4 +187,15 @@
action, authoritative, mapVersionNumber, eidPrefixAfi);
}
}
+
+ /**
+ * A private LISP message reader for MapRecord portion.
+ */
+ private static class RecordReader implements LispMessageReader<LispMapRecord> {
+
+ @Override
+ public LispMapRecord readFrom(ByteBuf byteBuf) throws LispParseError {
+ 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 bbfe3b9..b77e580 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
@@ -20,6 +20,7 @@
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
import java.util.List;
@@ -211,4 +212,15 @@
recordCount, mapRecords, proxyMapReply, wantMapNotify);
}
}
+
+ /**
+ * A private LISP message reader for MapRegister message.
+ */
+ private static class RegisterReader implements LispMessageReader<LispMapRegister> {
+
+ @Override
+ public LispMapRegister readFrom(ByteBuf byteBuf) throws LispParseError {
+ return null;
+ }
+ }
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapReply.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapReply.java
index 760d1ad..ee42dd1 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapReply.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapReply.java
@@ -17,6 +17,7 @@
import com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -169,4 +170,15 @@
return new DefaultLispMapReply(nonce, recordCount, probe, etr, security);
}
}
+
+ /**
+ * A private LISP message reader for MapReply message.
+ */
+ private static class ReplyReader implements LispMessageReader<LispMapReply> {
+
+ @Override
+ public LispMapReply readFrom(ByteBuf byteBuf) throws LispParseError {
+ 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 57732ca..f988fa1 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
@@ -19,6 +19,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import java.util.List;
@@ -281,4 +282,15 @@
eidRecords, authoritative, mapDataPresent, probe, smr, pitr, smrInvoked);
}
}
+
+ /**
+ * A private LISP message reader for MapRequest message.
+ */
+ private static class RequestReader implements LispMessageReader<LispMapRequest> {
+
+ @Override
+ public LispMapRequest readFrom(ByteBuf byteBuf) throws LispParseError {
+ return null;
+ }
+ }
}
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
index 9b5e3b2..0984324 100644
--- 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
@@ -15,6 +15,8 @@
*/
package org.onosproject.lisp.msg.protocols;
+import io.netty.buffer.ByteBuf;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.types.LispAfiAddress;
/**
@@ -53,4 +55,15 @@
public LispAfiAddress getPrefix() {
return prefix;
}
+
+ /**
+ * A private LISP message reader for EidRecord portion.
+ */
+ private static class EidRecordReader implements LispMessageReader<LispEidRecord> {
+
+ @Override
+ public LispEidRecord readFrom(ByteBuf byteBuf) throws LispParseError {
+ return null;
+ }
+ }
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMessageReader.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMessageReader.java
new file mode 100644
index 0000000..b11dc3f
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMessageReader.java
@@ -0,0 +1,34 @@
+/*
+ * 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 io.netty.buffer.ByteBuf;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
+
+/**
+ * An interface for de-serializing LISP control message.
+ */
+public interface LispMessageReader<T> {
+
+ /**
+ * Reads from byte buffer and de-serialize the LISP control message.
+ *
+ * @param byteBuf byte buffer
+ * @return LISP message instance
+ * @throws LispParseError LISP control message parse error
+ */
+ T readFrom(ByteBuf byteBuf) throws LispParseError;
+}