Jian Li
Committed by Gerrit Code Review

[ONOS-4718] Add LispMapRecord, rename EidRecord to LispEidRecord

Change-Id: Ib43ad5201787a7d9a3b18c0cd8949822d2e31e29
......@@ -60,7 +60,7 @@ public class DefaultLispMapNotify implements LispMapNotify {
}
@Override
public List<LispRecord> getLispRecords() {
public List<LispMapRecord> getLispRecords() {
return null;
}
......@@ -97,7 +97,7 @@ public class DefaultLispMapNotify implements LispMapNotify {
}
@Override
public NotifyBuilder addRecord(LispRecord record) {
public NotifyBuilder addRecord(LispMapRecord record) {
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 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;
}
}
}
......@@ -69,7 +69,7 @@ public class DefaultLispMapRegister implements LispMapRegister {
}
@Override
public List<LispRecord> getLispRecords() {
public List<LispMapRecord> getLispRecords() {
return null;
}
......@@ -116,7 +116,7 @@ public class DefaultLispMapRegister implements LispMapRegister {
}
@Override
public RegisterBuilder addRecord(LispRecord record) {
public RegisterBuilder addRecord(LispMapRecord record) {
return null;
}
}
......
......@@ -85,7 +85,7 @@ public class DefaultLispMapRequest implements LispMapRequest {
}
@Override
public List<EidRecord> getEids() {
public List<LispEidRecord> getEids() {
return null;
}
......@@ -142,7 +142,7 @@ public class DefaultLispMapRequest implements LispMapRequest {
}
@Override
public RequestBuilder addEidRecord(EidRecord record) {
public RequestBuilder addEidRecord(LispEidRecord record) {
return null;
}
}
......
......@@ -15,8 +15,42 @@
*/
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 EidRecord {
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;
}
}
......
......@@ -89,7 +89,7 @@ public interface LispMapNotify extends LispMessage {
*
* @return a collection of records
*/
List<LispRecord> getLispRecords();
List<LispMapRecord> getLispRecords();
/**
* A builder of LISP map notify message.
......@@ -134,6 +134,6 @@ public interface LispMapNotify extends LispMessage {
* @param record record
* @return NotifyBuilder object
*/
NotifyBuilder addRecord(LispRecord record);
NotifyBuilder addRecord(LispMapRecord record);
}
}
......
/*
* 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);
}
}
......@@ -103,7 +103,7 @@ public interface LispMapRegister extends LispMessage {
*
* @return a collection of records
*/
List<LispRecord> getLispRecords();
List<LispMapRecord> getLispRecords();
/**
* A builder of LISP map register message.
......@@ -164,6 +164,6 @@ public interface LispMapRegister extends LispMessage {
* @param record record
* @return RegisterBuilder object
*/
RegisterBuilder addRecord(LispRecord record);
RegisterBuilder addRecord(LispMapRecord record);
}
}
......
/*
* 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;
}
}
......@@ -122,7 +122,7 @@ public interface LispMapRequest extends LispMessage {
*
* @return a collection of EID records
*/
List<EidRecord> getEids();
List<LispEidRecord> getEids();
/**
* A builder of LISP map request message.
......@@ -199,6 +199,6 @@ public interface LispMapRequest extends LispMessage {
* @param record EID record
* @return RequestBuilder object
*/
RequestBuilder addEidRecord(EidRecord record);
RequestBuilder addEidRecord(LispEidRecord record);
}
}
......
/*
* 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 {
}