Jian Li
Committed by Gerrit Code Review

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

Change-Id: I52f7905538e5832e5282812df869b8158ce23334
/*
* 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);
}
}
/*
* 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
......@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
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 @@ public final class DefaultLispMapNotify implements LispMapNotify {
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;
}
}
}
......
......@@ -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 @@ public final class DefaultLispMapRecord implements LispMapRecord {
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;
}
}
}
......
......@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
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 @@ public final class DefaultLispMapRegister implements LispMapRegister {
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;
}
}
}
......
......@@ -17,6 +17,7 @@ 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 static com.google.common.base.MoreObjects.toStringHelper;
......@@ -169,4 +170,15 @@ public final class DefaultLispMapReply implements LispMapReply {
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;
}
}
}
......
......@@ -19,6 +19,7 @@ import com.google.common.base.Objects;
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 @@ public final class DefaultLispMapRequest implements LispMapRequest {
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;
}
}
}
......
......@@ -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 final class LispEidRecord {
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;
}
}
}
......
/*
* 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;
}