Jian Li
Committed by Gerrit Code Review

[ONOS-4718] Add skeleton code for de-serializing LISP ctrl messages

Change-Id: I52f7905538e5832e5282812df869b8158ce23334
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.lisp.msg.exceptions;
17 +
18 +/**
19 + * LISP control message parse error.
20 + */
21 +public class LispParseError extends Exception {
22 +
23 + /**
24 + * Constructor for LispParseError.
25 + */
26 + public LispParseError() {
27 + super();
28 + }
29 +
30 + /**
31 + * Constructor for LispParseError with message and cause parameters.
32 + *
33 + * @param message error message
34 + * @param cause throwable cause
35 + */
36 + public LispParseError(final String message, final Throwable cause) {
37 + super(message, cause);
38 + }
39 +
40 + /**
41 + * Constructor for LispParseError with message parameter.
42 + *
43 + * @param message error message
44 + */
45 + public LispParseError(final String message) {
46 + super(message);
47 + }
48 +
49 + /**
50 + * Constructor for LispParseError with cause parameter.
51 + *
52 + * @param cause throwable cause
53 + */
54 + public LispParseError(final Throwable cause) {
55 + super(cause);
56 + }
57 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +/**
17 + * A package subsumes various LISP control message exceptions.
18 + */
19 +package org.onosproject.lisp.msg.exceptions;
...\ No newline at end of file ...\ No newline at end of file
...@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; ...@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
20 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
21 import io.netty.buffer.ByteBuf; 21 import io.netty.buffer.ByteBuf;
22 import org.onlab.util.ImmutableByteSequence; 22 import org.onlab.util.ImmutableByteSequence;
23 +import org.onosproject.lisp.msg.exceptions.LispParseError;
23 24
24 import java.util.List; 25 import java.util.List;
25 26
...@@ -173,4 +174,15 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -173,4 +174,15 @@ public final class DefaultLispMapNotify implements LispMapNotify {
173 recordCount, mapRecords); 174 recordCount, mapRecords);
174 } 175 }
175 } 176 }
177 +
178 + /**
179 + * A private LISP message reader for MapNotify message.
180 + */
181 + private static class NotifyReader implements LispMessageReader<LispMapNotify> {
182 +
183 + @Override
184 + public LispMapNotify readFrom(ByteBuf byteBuf) throws LispParseError {
185 + return null;
186 + }
187 + }
176 } 188 }
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 import com.google.common.base.Objects; 18 import com.google.common.base.Objects;
19 +import io.netty.buffer.ByteBuf;
20 +import org.onosproject.lisp.msg.exceptions.LispParseError;
19 import org.onosproject.lisp.msg.types.LispAfiAddress; 21 import org.onosproject.lisp.msg.types.LispAfiAddress;
20 22
21 import static com.google.common.base.MoreObjects.toStringHelper; 23 import static com.google.common.base.MoreObjects.toStringHelper;
...@@ -185,4 +187,15 @@ public final class DefaultLispMapRecord implements LispMapRecord { ...@@ -185,4 +187,15 @@ public final class DefaultLispMapRecord implements LispMapRecord {
185 action, authoritative, mapVersionNumber, eidPrefixAfi); 187 action, authoritative, mapVersionNumber, eidPrefixAfi);
186 } 188 }
187 } 189 }
190 +
191 + /**
192 + * A private LISP message reader for MapRecord portion.
193 + */
194 + private static class RecordReader implements LispMessageReader<LispMapRecord> {
195 +
196 + @Override
197 + public LispMapRecord readFrom(ByteBuf byteBuf) throws LispParseError {
198 + return null;
199 + }
200 + }
188 } 201 }
......
...@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; ...@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
20 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
21 import io.netty.buffer.ByteBuf; 21 import io.netty.buffer.ByteBuf;
22 import org.onlab.util.ImmutableByteSequence; 22 import org.onlab.util.ImmutableByteSequence;
23 +import org.onosproject.lisp.msg.exceptions.LispParseError;
23 24
24 import java.util.List; 25 import java.util.List;
25 26
...@@ -211,4 +212,15 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -211,4 +212,15 @@ public final class DefaultLispMapRegister implements LispMapRegister {
211 recordCount, mapRecords, proxyMapReply, wantMapNotify); 212 recordCount, mapRecords, proxyMapReply, wantMapNotify);
212 } 213 }
213 } 214 }
215 +
216 + /**
217 + * A private LISP message reader for MapRegister message.
218 + */
219 + private static class RegisterReader implements LispMessageReader<LispMapRegister> {
220 +
221 + @Override
222 + public LispMapRegister readFrom(ByteBuf byteBuf) throws LispParseError {
223 + return null;
224 + }
225 + }
214 } 226 }
......
...@@ -17,6 +17,7 @@ package org.onosproject.lisp.msg.protocols; ...@@ -17,6 +17,7 @@ package org.onosproject.lisp.msg.protocols;
17 17
18 import com.google.common.base.Objects; 18 import com.google.common.base.Objects;
19 import io.netty.buffer.ByteBuf; 19 import io.netty.buffer.ByteBuf;
20 +import org.onosproject.lisp.msg.exceptions.LispParseError;
20 21
21 import static com.google.common.base.MoreObjects.toStringHelper; 22 import static com.google.common.base.MoreObjects.toStringHelper;
22 23
...@@ -169,4 +170,15 @@ public final class DefaultLispMapReply implements LispMapReply { ...@@ -169,4 +170,15 @@ public final class DefaultLispMapReply implements LispMapReply {
169 return new DefaultLispMapReply(nonce, recordCount, probe, etr, security); 170 return new DefaultLispMapReply(nonce, recordCount, probe, etr, security);
170 } 171 }
171 } 172 }
173 +
174 + /**
175 + * A private LISP message reader for MapReply message.
176 + */
177 + private static class ReplyReader implements LispMessageReader<LispMapReply> {
178 +
179 + @Override
180 + public LispMapReply readFrom(ByteBuf byteBuf) throws LispParseError {
181 + return null;
182 + }
183 + }
172 } 184 }
......
...@@ -19,6 +19,7 @@ import com.google.common.base.Objects; ...@@ -19,6 +19,7 @@ import com.google.common.base.Objects;
19 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
20 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
21 import io.netty.buffer.ByteBuf; 21 import io.netty.buffer.ByteBuf;
22 +import org.onosproject.lisp.msg.exceptions.LispParseError;
22 import org.onosproject.lisp.msg.types.LispAfiAddress; 23 import org.onosproject.lisp.msg.types.LispAfiAddress;
23 24
24 import java.util.List; 25 import java.util.List;
...@@ -281,4 +282,15 @@ public final class DefaultLispMapRequest implements LispMapRequest { ...@@ -281,4 +282,15 @@ public final class DefaultLispMapRequest implements LispMapRequest {
281 eidRecords, authoritative, mapDataPresent, probe, smr, pitr, smrInvoked); 282 eidRecords, authoritative, mapDataPresent, probe, smr, pitr, smrInvoked);
282 } 283 }
283 } 284 }
285 +
286 + /**
287 + * A private LISP message reader for MapRequest message.
288 + */
289 + private static class RequestReader implements LispMessageReader<LispMapRequest> {
290 +
291 + @Override
292 + public LispMapRequest readFrom(ByteBuf byteBuf) throws LispParseError {
293 + return null;
294 + }
295 + }
284 } 296 }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import io.netty.buffer.ByteBuf;
19 +import org.onosproject.lisp.msg.exceptions.LispParseError;
18 import org.onosproject.lisp.msg.types.LispAfiAddress; 20 import org.onosproject.lisp.msg.types.LispAfiAddress;
19 21
20 /** 22 /**
...@@ -53,4 +55,15 @@ public final class LispEidRecord { ...@@ -53,4 +55,15 @@ public final class LispEidRecord {
53 public LispAfiAddress getPrefix() { 55 public LispAfiAddress getPrefix() {
54 return prefix; 56 return prefix;
55 } 57 }
58 +
59 + /**
60 + * A private LISP message reader for EidRecord portion.
61 + */
62 + private static class EidRecordReader implements LispMessageReader<LispEidRecord> {
63 +
64 + @Override
65 + public LispEidRecord readFrom(ByteBuf byteBuf) throws LispParseError {
66 + return null;
67 + }
68 + }
56 } 69 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.lisp.msg.protocols;
17 +
18 +import io.netty.buffer.ByteBuf;
19 +import org.onosproject.lisp.msg.exceptions.LispParseError;
20 +
21 +/**
22 + * An interface for de-serializing LISP control message.
23 + */
24 +public interface LispMessageReader<T> {
25 +
26 + /**
27 + * Reads from byte buffer and de-serialize the LISP control message.
28 + *
29 + * @param byteBuf byte buffer
30 + * @return LISP message instance
31 + * @throws LispParseError LISP control message parse error
32 + */
33 + T readFrom(ByteBuf byteBuf) throws LispParseError;
34 +}