[ONOS-5945] Initial implementation of MapReferral message type

1. Add skeleton code of LispMapReferral message type
2. Refactor LispLocatorRecord and LispMapRecord

Change-Id: Icbe6243e5892a0bfb784ba3c0daa22ab73c7e977
This commit is contained in:
Jian Li 2017-02-06 20:21:04 +09:00 committed by Andrea Campanella
parent a3b7f5d133
commit 672ebda3fd
29 changed files with 1502 additions and 672 deletions

View File

@ -23,7 +23,7 @@ import org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilde
import org.onosproject.lisp.msg.protocols.LispEidRecord; import org.onosproject.lisp.msg.protocols.LispEidRecord;
import org.onosproject.lisp.msg.protocols.LispEncapsulatedControl; import org.onosproject.lisp.msg.protocols.LispEncapsulatedControl;
import org.onosproject.lisp.msg.protocols.LispEncapsulatedControl.EcmBuilder; import org.onosproject.lisp.msg.protocols.LispEncapsulatedControl.EcmBuilder;
import org.onosproject.lisp.msg.protocols.LispLocatorRecord; import org.onosproject.lisp.msg.protocols.LispLocator;
import org.onosproject.lisp.msg.protocols.LispMapRecord; import org.onosproject.lisp.msg.protocols.LispMapRecord;
import org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder; import org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder;
import org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder; import org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder;
@ -194,7 +194,7 @@ public final class LispMapResolver {
MapRecordBuilder recordBuilder = new DefaultMapRecordBuilder(); MapRecordBuilder recordBuilder = new DefaultMapRecordBuilder();
recordBuilder.withRecordTtl(MAP_REPLY_RECORD_TTL); recordBuilder.withRecordTtl(MAP_REPLY_RECORD_TTL);
recordBuilder.withLocators(Lists.newArrayList()); recordBuilder.withLocators(Lists.newArrayList());
recordBuilder.withAuthoritative(false); recordBuilder.withIsAuthoritative(false);
recordBuilder.withMapVersionNumber(MAP_VERSION_NUMBER); recordBuilder.withMapVersionNumber(MAP_VERSION_NUMBER);
recordBuilder.withAction(LispMapReplyAction.NativelyForward); recordBuilder.withAction(LispMapReplyAction.NativelyForward);
@ -239,7 +239,7 @@ public final class LispMapResolver {
for (LispMapRecord mapRecord : mapRecords) { for (LispMapRecord mapRecord : mapRecords) {
// we only select the first locator record in all cases... // we only select the first locator record in all cases...
LispLocatorRecord locatorRecord = mapRecord.getLocators().get(0); LispLocator locatorRecord = mapRecord.getLocators().get(0);
if (locatorRecord != null) { if (locatorRecord != null) {
addresses.add(new InetSocketAddress(((LispIpAddress) addresses.add(new InetSocketAddress(((LispIpAddress)
locatorRecord.getLocatorAfi()).getAddress() locatorRecord.getLocatorAfi()).getAddress()

View File

@ -340,7 +340,7 @@ public class LispControllerImplTest {
return builder1 return builder1
.withRecordTtl(100) .withRecordTtl(100)
.withAuthoritative(true) .withIsAuthoritative(true)
.withMapVersionNumber((short) 1) .withMapVersionNumber((short) 1)
.withMaskLength((byte) 0x01) .withMaskLength((byte) 0x01)
.withAction(LispMapReplyAction.NativelyForward) .withAction(LispMapReplyAction.NativelyForward)

View File

@ -19,11 +19,11 @@ import com.google.common.collect.ImmutableList;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.onlab.packet.IpAddress; import org.onlab.packet.IpAddress;
import org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder;
import org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder; import org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder;
import org.onosproject.lisp.msg.protocols.LispEidRecord; import org.onosproject.lisp.msg.protocols.LispEidRecord;
import org.onosproject.lisp.msg.protocols.LispLocatorRecord; import org.onosproject.lisp.msg.protocols.LispLocator;
import org.onosproject.lisp.msg.protocols.LispMapRecord; import org.onosproject.lisp.msg.protocols.LispMapRecord;
import org.onosproject.lisp.msg.protocols.DefaultLispLocatorRecord.DefaultLocatorRecordBuilder;
import org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder; import org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder;
import org.onosproject.lisp.msg.types.LispIpv4Address; import org.onosproject.lisp.msg.types.LispIpv4Address;
@ -37,53 +37,73 @@ import static org.hamcrest.Matchers.is;
*/ */
public class LispMappingDatabaseTest { public class LispMappingDatabaseTest {
private static final String LOCATOR_IP_1_1 = "123.1.1.1";
private static final String LOCATOR_IP_1_2 = "123.1.1.2";
private static final String LOCATOR_IP_1_3 = "123.1.1.3";
private static final String LOCATOR_IP_2_1 = "123.2.1.1";
private static final String LOCATOR_IP_2_2 = "123.2.1.2";
private static final String LOCATOR_IP_3_1 = "123.3.1.1";
private static final String EID_IP_1 = "10.1.1.1";
private static final String EID_IP_2 = "10.1.2.0";
private static final String EID_IP_3 = "10.2.0.0";
private static final String EID_IP_PREFIX_1_32 = "10.2.1.1";
private static final String EID_IP_PREFIX_1_24 = "10.2.1.0";
private static final String EID_IP_PREFIX_1_16 = "10.2.0.0";
private static final String EID_IP_PREFIX_2_32 = "10.1.2.1";
private static final String EID_IP_PREFIX_2_24 = "10.1.2.0";
final LispMappingDatabase mapDb = LispMappingDatabase.getInstance(); final LispMappingDatabase mapDb = LispMappingDatabase.getInstance();
@Before @Before
public void setup() { public void setup() {
byte cidr1 = (byte) 32; byte cidr1 = (byte) 32;
LispIpv4Address eid1 = new LispIpv4Address(IpAddress.valueOf("10.1.1.1")); LispIpv4Address eid1 = new LispIpv4Address(IpAddress.valueOf(EID_IP_1));
LispEidRecord eidRecord1 = new LispEidRecord(cidr1, eid1); LispEidRecord eidRecord1 = new LispEidRecord(cidr1, eid1);
LispIpv4Address locator11 = new LispIpv4Address(IpAddress.valueOf("123.1.1.1")); LispIpv4Address locator11 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_1_1));
LispIpv4Address locator12 = new LispIpv4Address(IpAddress.valueOf("123.1.1.2")); LispIpv4Address locator12 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_1_2));
LispIpv4Address locator13 = new LispIpv4Address(IpAddress.valueOf("123.1.1.3")); LispIpv4Address locator13 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_1_3));
LispLocatorRecord locatorRecord11 = new DefaultLocatorRecordBuilder() LispLocator locatorRecord11 = new DefaultLocatorBuilder()
.withLocatorAfi(locator11).build(); .withLocatorAfi(locator11).build();
LispLocatorRecord locatorRecord12 = new DefaultLocatorRecordBuilder() LispLocator locatorRecord12 = new DefaultLocatorBuilder()
.withLocatorAfi(locator12).build(); .withLocatorAfi(locator12).build();
LispLocatorRecord locatorRecord13 = new DefaultLocatorRecordBuilder() LispLocator locatorRecord13 = new DefaultLocatorBuilder()
.withLocatorAfi(locator13).build(); .withLocatorAfi(locator13).build();
List<LispLocatorRecord> locatorRecords1 = List<LispLocator> locatorRecords1 =
ImmutableList.of(locatorRecord11, locatorRecord12, locatorRecord13); ImmutableList.of(locatorRecord11, locatorRecord12, locatorRecord13);
byte cidr2 = (byte) 24; byte cidr2 = (byte) 24;
LispIpv4Address eid2 = new LispIpv4Address(IpAddress.valueOf("10.1.2.0")); LispIpv4Address eid2 = new LispIpv4Address(IpAddress.valueOf(EID_IP_2));
LispEidRecord eidRecord2 = new LispEidRecord(cidr2, eid2); LispEidRecord eidRecord2 = new LispEidRecord(cidr2, eid2);
LispIpv4Address locator21 = new LispIpv4Address(IpAddress.valueOf("123.2.1.1")); LispIpv4Address locator21 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_2_1));
LispIpv4Address locator22 = new LispIpv4Address(IpAddress.valueOf("123.2.1.2")); LispIpv4Address locator22 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_2_2));
LispLocatorRecord locatorRecord21 = new DefaultLocatorRecordBuilder() LispLocator locatorRecord21 = new DefaultLocatorBuilder()
.withLocatorAfi(locator21).build(); .withLocatorAfi(locator21).build();
LispLocatorRecord locatorRecord22 = new DefaultLocatorRecordBuilder() LispLocator locatorRecord22 = new DefaultLocatorBuilder()
.withLocatorAfi(locator22).build(); .withLocatorAfi(locator22).build();
List<LispLocatorRecord> locatorRecords2 = List<LispLocator> locatorRecords2 =
ImmutableList.of(locatorRecord21, locatorRecord22); ImmutableList.of(locatorRecord21, locatorRecord22);
byte cidr3 = (byte) 16; byte cidr3 = (byte) 16;
LispIpv4Address eid3 = new LispIpv4Address(IpAddress.valueOf("10.2.0.0")); LispIpv4Address eid3 = new LispIpv4Address(IpAddress.valueOf(EID_IP_3));
LispEidRecord eidRecord3 = new LispEidRecord(cidr3, eid3); LispEidRecord eidRecord3 = new LispEidRecord(cidr3, eid3);
LispIpv4Address locator31 = new LispIpv4Address(IpAddress.valueOf("123.3.1.1")); LispIpv4Address locator31 = new LispIpv4Address(IpAddress.valueOf(LOCATOR_IP_3_1));
LispLocatorRecord locatorRecord31 = new DefaultLocatorRecordBuilder() LispLocator locatorRecord31 = new DefaultLocatorBuilder()
.withLocatorAfi(locator31).build(); .withLocatorAfi(locator31).build();
List<LispLocatorRecord> locatorRecords3 = ImmutableList.of(locatorRecord31); List<LispLocator> locatorRecords3 = ImmutableList.of(locatorRecord31);
MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); MapRecordBuilder builder1 = new DefaultMapRecordBuilder();
builder1.withMaskLength(cidr1); builder1.withMaskLength(cidr1);
@ -114,7 +134,7 @@ public class LispMappingDatabaseTest {
@Test @Test
public void test32MaskRange() { public void test32MaskRange() {
byte cidr32 = (byte) 32; byte cidr32 = (byte) 32;
LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf("10.1.1.1")); LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf(EID_IP_1));
LispEidRecord record = new LispEidRecord(cidr32, eid); LispEidRecord record = new LispEidRecord(cidr32, eid);
LispMapRecord mapRecord = mapDb.getMapRecordByEidRecord(record, true); LispMapRecord mapRecord = mapDb.getMapRecordByEidRecord(record, true);
@ -125,12 +145,12 @@ public class LispMappingDatabaseTest {
@Test @Test
public void test24MaskRange() { public void test24MaskRange() {
byte cidr32 = (byte) 32; byte cidr32 = (byte) 32;
LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf("10.1.2.1")); LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_2_32));
LispEidRecord record32 = new LispEidRecord(cidr32, eid); LispEidRecord record32 = new LispEidRecord(cidr32, eid);
LispMapRecord mapRecord32 = mapDb.getMapRecordByEidRecord(record32, true); LispMapRecord mapRecord32 = mapDb.getMapRecordByEidRecord(record32, true);
byte cidr24 = (byte) 24; byte cidr24 = (byte) 24;
LispIpv4Address eid24 = new LispIpv4Address(IpAddress.valueOf("10.1.2.0")); LispIpv4Address eid24 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_2_24));
LispEidRecord record24 = new LispEidRecord(cidr24, eid24); LispEidRecord record24 = new LispEidRecord(cidr24, eid24);
LispMapRecord mapRecord24 = mapDb.getMapRecordByEidRecord(record24, true); LispMapRecord mapRecord24 = mapDb.getMapRecordByEidRecord(record24, true);
@ -143,17 +163,17 @@ public class LispMappingDatabaseTest {
@Test @Test
public void test16MaskRange() { public void test16MaskRange() {
byte cidr32 = (byte) 32; byte cidr32 = (byte) 32;
LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf("10.2.1.1")); LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_32));
LispEidRecord record32 = new LispEidRecord(cidr32, eid); LispEidRecord record32 = new LispEidRecord(cidr32, eid);
LispMapRecord mapRecord32 = mapDb.getMapRecordByEidRecord(record32, true); LispMapRecord mapRecord32 = mapDb.getMapRecordByEidRecord(record32, true);
byte cidr24 = (byte) 24; byte cidr24 = (byte) 24;
LispIpv4Address eid24 = new LispIpv4Address(IpAddress.valueOf("10.2.1.0")); LispIpv4Address eid24 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_24));
LispEidRecord record24 = new LispEidRecord(cidr24, eid24); LispEidRecord record24 = new LispEidRecord(cidr24, eid24);
LispMapRecord mapRecord24 = mapDb.getMapRecordByEidRecord(record24, true); LispMapRecord mapRecord24 = mapDb.getMapRecordByEidRecord(record24, true);
byte cidr16 = (byte) 16; byte cidr16 = (byte) 16;
LispIpv4Address eid16 = new LispIpv4Address(IpAddress.valueOf("10.2.0.0")); LispIpv4Address eid16 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_16));
LispEidRecord record16 = new LispEidRecord(cidr16, eid16); LispEidRecord record16 = new LispEidRecord(cidr16, eid16);
LispMapRecord mapRecord16 = mapDb.getMapRecordByEidRecord(record16, true); LispMapRecord mapRecord16 = mapDb.getMapRecordByEidRecord(record16, true);

View File

@ -0,0 +1,118 @@
/*
* Copyright 2017-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;
/**
* Abstract LISP record class that provide default implementations.
*/
public abstract class AbstractLispRecord implements LispRecord {
protected final int recordTtl;
protected final byte maskLength;
protected final LispMapReplyAction action;
protected final boolean authoritative;
protected final short mapVersionNumber;
protected final LispAfiAddress eidPrefixAfi;
protected AbstractLispRecord(int recordTtl, byte maskLength,
LispMapReplyAction action, boolean authoritative,
short mapVersionNumber, LispAfiAddress eidPrefixAfi) {
this.recordTtl = recordTtl;
this.maskLength = maskLength;
this.action = action;
this.authoritative = authoritative;
this.mapVersionNumber = mapVersionNumber;
this.eidPrefixAfi = eidPrefixAfi;
}
@Override
public int getRecordTtl() {
return recordTtl;
}
@Override
public byte getMaskLength() {
return maskLength;
}
@Override
public LispMapReplyAction getAction() {
return action;
}
@Override
public boolean isAuthoritative() {
return authoritative;
}
@Override
public short getMapVersionNumber() {
return mapVersionNumber;
}
@Override
public LispAfiAddress getEidPrefixAfi() {
return eidPrefixAfi;
}
public static class AbstractRecordBuilder<T> implements RecordBuilder<T> {
protected int recordTtl;
protected byte maskLength;
protected LispMapReplyAction action;
protected boolean authoritative;
protected short mapVersionNumber;
protected LispAfiAddress eidPrefixAfi;
@Override
public T withRecordTtl(int recordTtl) {
this.recordTtl = recordTtl;
return (T) this;
}
@Override
public T withMaskLength(byte maskLength) {
this.maskLength = maskLength;
return (T) this;
}
@Override
public T withAction(LispMapReplyAction action) {
this.action = action;
return (T) this;
}
@Override
public T withIsAuthoritative(boolean authoritative) {
this.authoritative = authoritative;
return (T) this;
}
@Override
public T withMapVersionNumber(short mapVersionNumber) {
this.mapVersionNumber = mapVersionNumber;
return (T) this;
}
@Override
public T withEidPrefixAfi(LispAfiAddress prefix) {
this.eidPrefixAfi = prefix;
return (T) this;
}
}
}

View File

@ -0,0 +1,314 @@
/*
* Copyright 2017-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 com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
import org.onlab.util.ByteOperator;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import org.onosproject.lisp.msg.types.LispAfiAddress.AfiAddressWriter;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* A default implementation class of LISP generic locator interface.
*/
public class DefaultLispGenericLocator implements LispGenericLocator {
protected final byte priority;
protected final byte weight;
protected final byte multicastPriority;
protected final byte multicastWeight;
protected final boolean localLocator;
protected final boolean rlocProbed;
protected final boolean routed;
protected final LispAfiAddress locatorAfi;
private static final int LOCAL_LOCATOR_SHIFT_BIT = 2;
private static final int PROBED_SHIFT_BIT = 1;
private static final int ENABLE_BIT = 1;
private static final int DISABLE_BIT = 0;
private static final int SKIP_UNUSED_FLAG_LENGTH = 1;
private static final int LOCAL_LOCATOR_INDEX = 2;
private static final int RLOC_PROBED_INDEX = 1;
private static final int ROUTED_INDEX = 0;
/**
* A private constructor that protects object instantiation from external.
*
* @param priority uni-cast priority
* @param weight uni-cast weight
* @param multicastPriority multi-cast priority
* @param multicastWeight multi-cast weight
* @param localLocator local locator flag
* @param rlocProbed RLOC probed flag
* @param routed routed flag
* @param locatorAfi locator AFI
*/
protected DefaultLispGenericLocator(byte priority, byte weight,
byte multicastPriority,
byte multicastWeight,
boolean localLocator, boolean rlocProbed,
boolean routed, LispAfiAddress locatorAfi) {
this.priority = priority;
this.weight = weight;
this.multicastPriority = multicastPriority;
this.multicastWeight = multicastWeight;
this.localLocator = localLocator;
this.rlocProbed = rlocProbed;
this.routed = routed;
this.locatorAfi = locatorAfi;
}
@Override
public byte getPriority() {
return priority;
}
@Override
public byte getWeight() {
return weight;
}
@Override
public byte getMulticastPriority() {
return multicastPriority;
}
@Override
public byte getMulticastWeight() {
return multicastWeight;
}
@Override
public boolean isLocalLocator() {
return localLocator;
}
@Override
public boolean isRlocProbed() {
return rlocProbed;
}
@Override
public boolean isRouted() {
return routed;
}
@Override
public LispAfiAddress getLocatorAfi() {
return locatorAfi;
}
@Override
public void writeTo(ByteBuf byteBuf) throws LispWriterException {
}
@Override
public String toString() {
return toStringHelper(this)
.add("priority", priority)
.add("weight", weight)
.add("multi-cast priority", multicastPriority)
.add("multi-cast weight", multicastWeight)
.add("local locator", localLocator)
.add("RLOC probed", rlocProbed)
.add("routed", routed)
.add("locator AFI", locatorAfi).toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultLispGenericLocator that = (DefaultLispGenericLocator) o;
return Objects.equal(priority, that.priority) &&
Objects.equal(weight, that.weight) &&
Objects.equal(multicastPriority, that.multicastPriority) &&
Objects.equal(multicastWeight, that.multicastWeight) &&
Objects.equal(localLocator, that.localLocator) &&
Objects.equal(rlocProbed, that.rlocProbed) &&
Objects.equal(routed, that.routed) &&
Objects.equal(locatorAfi, that.locatorAfi);
}
@Override
public int hashCode() {
return Objects.hashCode(priority, weight, multicastPriority,
multicastWeight, localLocator, rlocProbed, routed, locatorAfi);
}
public abstract static class AbstractGenericLocatorBuilder<T>
implements GenericLocatorBuilder<T> {
protected byte priority;
protected byte weight;
protected byte multicastPriority;
protected byte multicastWeight;
protected boolean localLocator;
protected boolean rlocProbed;
protected boolean routed;
protected LispAfiAddress locatorAfi;
@Override
public T withPriority(byte priority) {
this.priority = priority;
return (T) this;
}
@Override
public T withWeight(byte weight) {
this.weight = weight;
return (T) this;
}
@Override
public T withMulticastPriority(byte priority) {
this.multicastPriority = priority;
return (T) this;
}
@Override
public T withMulticastWeight(byte weight) {
this.multicastWeight = weight;
return (T) this;
}
@Override
public T withLocalLocator(boolean localLocator) {
this.localLocator = localLocator;
return (T) this;
}
@Override
public T withRlocProbed(boolean rlocProbed) {
this.rlocProbed = rlocProbed;
return (T) this;
}
@Override
public T withRouted(boolean routed) {
this.routed = routed;
return (T) this;
}
@Override
public T withLocatorAfi(LispAfiAddress locatorAfi) {
this.locatorAfi = locatorAfi;
return (T) this;
}
}
/**
* Deserializes LispGenericLocator message portion.
*
* @param byteBuf byte buffer
* @return LispGenericLocator
* @throws LispParseError LISP message parse error
* @throws LispReaderException LISP message reader exception
*/
public static LispGenericLocator deserialize(ByteBuf byteBuf)
throws LispParseError,
LispReaderException {
// priority -> 8 bits
byte priority = (byte) byteBuf.readUnsignedByte();
// weight -> 8 bits
byte weight = (byte) byteBuf.readUnsignedByte();
// multi-cast priority -> 8 bits
byte multicastPriority = (byte) byteBuf.readUnsignedByte();
// multi-cast weight -> 8 bits
byte multicastWeight = (byte) byteBuf.readUnsignedByte();
// let's skip unused flags
byteBuf.skipBytes(SKIP_UNUSED_FLAG_LENGTH);
byte flags = byteBuf.readByte();
// local locator flag -> 1 bit
boolean localLocator = ByteOperator.getBit(flags, LOCAL_LOCATOR_INDEX);
// rloc probe flag -> 1 bit
boolean rlocProbed = ByteOperator.getBit(flags, RLOC_PROBED_INDEX);
// routed flag -> 1 bit
boolean routed = ByteOperator.getBit(flags, ROUTED_INDEX);
LispAfiAddress address = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
return new DefaultLispGenericLocator(priority, weight, multicastPriority,
multicastWeight, localLocator, rlocProbed, routed, address);
}
/**
* Serializes LispGenericLocator message portion.
*
* @param byteBuf byte buffer
* @param genericLocator generic locator
* @throws LispWriterException LISP message writer exception
*/
public static void serialize(ByteBuf byteBuf, LispGenericLocator genericLocator)
throws LispWriterException {
// priority
byteBuf.writeByte(genericLocator.getPriority());
// weight
byteBuf.writeByte(genericLocator.getWeight());
// multicast priority
byteBuf.writeByte(genericLocator.getMulticastPriority());
// multicast weight
byteBuf.writeByte(genericLocator.getMulticastWeight());
// unused flags
byteBuf.writeByte((short) 0);
// localLocator flag
short localLocator = DISABLE_BIT;
if (genericLocator.isLocalLocator()) {
localLocator = (byte) (ENABLE_BIT << LOCAL_LOCATOR_SHIFT_BIT);
}
// rlocProbed flag
short probed = DISABLE_BIT;
if (genericLocator.isRlocProbed()) {
probed = (byte) (ENABLE_BIT << PROBED_SHIFT_BIT);
}
// routed flag
short routed = DISABLE_BIT;
if (genericLocator.isRouted()) {
routed = (byte) ENABLE_BIT;
}
byteBuf.writeByte((byte) (localLocator + probed + routed));
// EID prefix AFI with EID prefix
AfiAddressWriter afiAddressWriter = new AfiAddressWriter();
afiAddressWriter.writeTo(byteBuf, genericLocator.getLocatorAfi());
}
}

View File

@ -0,0 +1,110 @@
/*
* 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;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Default implementation of LispLocator.
*/
public final class DefaultLispLocator extends DefaultLispGenericLocator
implements LispLocator {
static final LocatorWriter WRITER;
static {
WRITER = new LocatorWriter();
}
/**
* A private constructor that protects object instantiation from external.
*
* @param priority uni-cast priority
* @param weight uni-cast weight
* @param multicastPriority multi-cast priority
* @param multicastWeight multi-cast weight
* @param localLocator local locator flag
* @param rlocProbed RLOC probed flag
* @param routed routed flag
* @param locatorAfi locator AFI
*/
private DefaultLispLocator(byte priority, byte weight, byte multicastPriority,
byte multicastWeight, boolean localLocator,
boolean rlocProbed, boolean routed,
LispAfiAddress locatorAfi) {
super(priority, weight, multicastPriority, multicastWeight,
localLocator, rlocProbed, routed, locatorAfi);
}
@Override
public void writeTo(ByteBuf byteBuf) throws LispWriterException {
WRITER.writeTo(byteBuf, this);
}
public static final class DefaultLocatorBuilder
extends AbstractGenericLocatorBuilder<LocatorBuilder>
implements LocatorBuilder {
@Override
public LispLocator build() {
checkNotNull(locatorAfi, "Must specify a locator address");
return new DefaultLispLocator(priority, weight, multicastPriority,
multicastWeight, localLocator, rlocProbed, routed, locatorAfi);
}
}
/**
* A LISP message reader for Locator portion.
*/
public static final class LocatorReader
implements LispMessageReader<LispLocator> {
@Override
public LispLocator readFrom(ByteBuf byteBuf) throws LispParseError,
LispReaderException {
LispGenericLocator gl = deserialize(byteBuf);
return new DefaultLocatorBuilder()
.withPriority(gl.getPriority())
.withWeight(gl.getWeight())
.withMulticastPriority(gl.getMulticastPriority())
.withMulticastWeight(gl.getMulticastWeight())
.withLocalLocator(gl.isLocalLocator())
.withRouted(gl.isRouted())
.withLocatorAfi(gl.getLocatorAfi()).build();
}
}
/**
* A LISP message writer for Locator portion.
*/
public static final class LocatorWriter
implements LispMessageWriter<LispLocator> {
@Override
public void writeTo(ByteBuf byteBuf, LispLocator message)
throws LispWriterException {
serialize(byteBuf, message);
}
}
}

View File

@ -1,335 +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;
import com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
import org.onlab.util.ByteOperator;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import org.onosproject.lisp.msg.types.LispAfiAddress.AfiAddressReader;
import org.onosproject.lisp.msg.types.LispAfiAddress.AfiAddressWriter;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Default implementation of LispLocatorRecord.
*/
public final class DefaultLispLocatorRecord implements LispLocatorRecord {
private final byte priority;
private final byte weight;
private final byte multicastPriority;
private final byte multicastWeight;
private final boolean localLocator;
private final boolean rlocProbed;
private final boolean routed;
private final LispAfiAddress locatorAfi;
static final LocatorRecordWriter WRITER;
static {
WRITER = new LocatorRecordWriter();
}
/**
* A private constructor that protects object instantiation from external.
*
* @param priority uni-cast priority
* @param weight uni-cast weight
* @param multicastPriority multi-cast priority
* @param multicastWeight multi-cast weight
* @param localLocator local locator flag
* @param rlocProbed RLOC probed flag
* @param routed routed flag
* @param locatorAfi locator AFI
*/
private DefaultLispLocatorRecord(byte priority, byte weight, byte multicastPriority,
byte multicastWeight, boolean localLocator, boolean rlocProbed,
boolean routed, LispAfiAddress locatorAfi) {
this.priority = priority;
this.weight = weight;
this.multicastPriority = multicastPriority;
this.multicastWeight = multicastWeight;
this.localLocator = localLocator;
this.rlocProbed = rlocProbed;
this.routed = routed;
this.locatorAfi = locatorAfi;
}
@Override
public byte getPriority() {
return priority;
}
@Override
public byte getWeight() {
return weight;
}
@Override
public byte getMulticastPriority() {
return multicastPriority;
}
@Override
public byte getMulticastWeight() {
return multicastWeight;
}
@Override
public boolean isLocalLocator() {
return localLocator;
}
@Override
public boolean isRlocProbed() {
return rlocProbed;
}
@Override
public boolean isRouted() {
return routed;
}
@Override
public LispAfiAddress getLocatorAfi() {
return locatorAfi;
}
@Override
public void writeTo(ByteBuf byteBuf) throws LispWriterException {
WRITER.writeTo(byteBuf, this);
}
@Override
public String toString() {
return toStringHelper(this)
.add("priority", priority)
.add("weight", weight)
.add("multi-cast priority", multicastPriority)
.add("multi-cast weight", multicastWeight)
.add("local locator", localLocator)
.add("RLOC probed", rlocProbed)
.add("routed", routed)
.add("locator AFI", locatorAfi).toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultLispLocatorRecord that = (DefaultLispLocatorRecord) o;
return Objects.equal(priority, that.priority) &&
Objects.equal(weight, that.weight) &&
Objects.equal(multicastPriority, that.multicastPriority) &&
Objects.equal(multicastWeight, that.multicastWeight) &&
Objects.equal(localLocator, that.localLocator) &&
Objects.equal(rlocProbed, that.rlocProbed) &&
Objects.equal(routed, that.routed) &&
Objects.equal(locatorAfi, that.locatorAfi);
}
@Override
public int hashCode() {
return Objects.hashCode(priority, weight, multicastPriority,
multicastWeight, localLocator, rlocProbed, routed, locatorAfi);
}
public static final class DefaultLocatorRecordBuilder implements LocatorRecordBuilder {
private byte priority;
private byte weight;
private byte multicastPriority;
private byte multicastWeight;
private boolean localLocator;
private boolean rlocProbed;
private boolean routed;
private LispAfiAddress locatorAfi;
@Override
public LocatorRecordBuilder withPriority(byte priority) {
this.priority = priority;
return this;
}
@Override
public LocatorRecordBuilder withWeight(byte weight) {
this.weight = weight;
return this;
}
@Override
public LocatorRecordBuilder withMulticastPriority(byte priority) {
this.multicastPriority = priority;
return this;
}
@Override
public LocatorRecordBuilder withMulticastWeight(byte weight) {
this.multicastWeight = weight;
return this;
}
@Override
public LocatorRecordBuilder withLocalLocator(boolean localLocator) {
this.localLocator = localLocator;
return this;
}
@Override
public LocatorRecordBuilder withRlocProbed(boolean rlocProbed) {
this.rlocProbed = rlocProbed;
return this;
}
@Override
public LocatorRecordBuilder withRouted(boolean routed) {
this.routed = routed;
return this;
}
@Override
public LocatorRecordBuilder withLocatorAfi(LispAfiAddress locatorAfi) {
this.locatorAfi = locatorAfi;
return this;
}
@Override
public LispLocatorRecord build() {
checkNotNull(locatorAfi, "Must specify a locator address");
return new DefaultLispLocatorRecord(priority, weight, multicastPriority,
multicastWeight, localLocator, rlocProbed, routed, locatorAfi);
}
}
/**
* A LISP message reader for LocatorRecord portion.
*/
public static final class LocatorRecordReader implements LispMessageReader<LispLocatorRecord> {
private static final int SKIP_UNUSED_FLAG_LENGTH = 1;
private static final int LOCAL_LOCATOR_INDEX = 2;
private static final int RLOC_PROBED_INDEX = 1;
private static final int ROUTED_INDEX = 0;
@Override
public LispLocatorRecord readFrom(ByteBuf byteBuf) throws LispParseError, LispReaderException {
// priority -> 8 bits
byte priority = (byte) byteBuf.readUnsignedByte();
// weight -> 8 bits
byte weight = (byte) byteBuf.readUnsignedByte();
// multi-cast priority -> 8 bits
byte multicastPriority = (byte) byteBuf.readUnsignedByte();
// multi-cast weight -> 8 bits
byte multicastWeight = (byte) byteBuf.readUnsignedByte();
// let's skip unused flags
byteBuf.skipBytes(SKIP_UNUSED_FLAG_LENGTH);
byte flags = byteBuf.readByte();
// local locator flag -> 1 bit
boolean localLocator = ByteOperator.getBit(flags, LOCAL_LOCATOR_INDEX);
// rloc probe flag -> 1 bit
boolean rlocProbed = ByteOperator.getBit(flags, RLOC_PROBED_INDEX);
// routed flag -> 1 bit
boolean routed = ByteOperator.getBit(flags, ROUTED_INDEX);
LispAfiAddress address = new AfiAddressReader().readFrom(byteBuf);
return new DefaultLocatorRecordBuilder()
.withPriority(priority)
.withWeight(weight)
.withMulticastPriority(multicastPriority)
.withMulticastWeight(multicastWeight)
.withLocalLocator(localLocator)
.withRlocProbed(rlocProbed)
.withRouted(routed)
.withLocatorAfi(address)
.build();
}
}
/**
* A LISP message writer for LocatorRecord portion.
*/
public static final class LocatorRecordWriter implements LispMessageWriter<LispLocatorRecord> {
private static final int LOCAL_LOCATOR_SHIFT_BIT = 2;
private static final int PROBED_SHIFT_BIT = 1;
private static final int ENABLE_BIT = 1;
private static final int DISABLE_BIT = 0;
@Override
public void writeTo(ByteBuf byteBuf, LispLocatorRecord message) throws LispWriterException {
// priority
byteBuf.writeByte(message.getPriority());
// weight
byteBuf.writeByte(message.getWeight());
// multicast priority
byteBuf.writeByte(message.getMulticastPriority());
// multicast weight
byteBuf.writeByte(message.getMulticastWeight());
// unused flags
byteBuf.writeByte((short) 0);
// localLocator flag
short localLocator = DISABLE_BIT;
if (message.isLocalLocator()) {
localLocator = (byte) (ENABLE_BIT << LOCAL_LOCATOR_SHIFT_BIT);
}
// rlocProbed flag
short probed = DISABLE_BIT;
if (message.isRlocProbed()) {
probed = (byte) (ENABLE_BIT << PROBED_SHIFT_BIT);
}
// routed flag
short routed = DISABLE_BIT;
if (message.isRouted()) {
routed = (byte) ENABLE_BIT;
}
byteBuf.writeByte((byte) (localLocator + probed + routed));
// EID prefix AFI with EID prefix
AfiAddressWriter afiAddressWriter = new AfiAddressWriter();
afiAddressWriter.writeTo(byteBuf, message.getLocatorAfi());
}
}
}

View File

@ -21,7 +21,8 @@ import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import org.onlab.util.ByteOperator; import org.onlab.util.ByteOperator;
import org.onosproject.lisp.msg.exceptions.LispParseError; import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.protocols.DefaultLispLocatorRecord.LocatorRecordReader; import org.onosproject.lisp.msg.protocols.DefaultLispLocator.LocatorReader;
import org.onosproject.lisp.msg.protocols.DefaultLispLocator.LocatorWriter;
import org.onosproject.lisp.msg.types.LispAfiAddress; import org.onosproject.lisp.msg.types.LispAfiAddress;
import org.onosproject.lisp.msg.exceptions.LispReaderException; import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException; import org.onosproject.lisp.msg.exceptions.LispWriterException;
@ -31,20 +32,14 @@ import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.lisp.msg.protocols.DefaultLispLocatorRecord.LocatorRecordWriter;
/** /**
* Default implementation of LispMapRecord. * Default implementation of LispMapRecord.
*/ */
public final class DefaultLispMapRecord implements LispMapRecord { public final class DefaultLispMapRecord extends AbstractLispRecord
implements LispMapRecord {
private final int recordTtl; private final List<LispLocator> locators;
private final byte maskLength;
private final LispMapReplyAction action;
private final boolean authoritative;
private final short mapVersionNumber;
private final LispAfiAddress eidPrefixAfi;
private final List<LispLocatorRecord> locatorRecords;
static final MapRecordWriter WRITER; static final MapRecordWriter WRITER;
static { static {
@ -60,58 +55,24 @@ public final class DefaultLispMapRecord implements LispMapRecord {
* @param authoritative authoritative flag * @param authoritative authoritative flag
* @param mapVersionNumber map version number * @param mapVersionNumber map version number
* @param eidPrefixAfi EID prefix AFI address * @param eidPrefixAfi EID prefix AFI address
* @param locators a collection of locators
*/ */
private DefaultLispMapRecord(int recordTtl, byte maskLength, private DefaultLispMapRecord(int recordTtl, byte maskLength,
LispMapReplyAction action, boolean authoritative, LispMapReplyAction action, boolean authoritative,
short mapVersionNumber, LispAfiAddress eidPrefixAfi, short mapVersionNumber, LispAfiAddress eidPrefixAfi,
List<LispLocatorRecord> locatorRecords) { List<LispLocator> locators) {
this.recordTtl = recordTtl; super(recordTtl, maskLength, action, authoritative, mapVersionNumber, eidPrefixAfi);
this.maskLength = maskLength; this.locators = locators;
this.action = action;
this.authoritative = authoritative;
this.mapVersionNumber = mapVersionNumber;
this.eidPrefixAfi = eidPrefixAfi;
this.locatorRecords = locatorRecords;
}
@Override
public int getRecordTtl() {
return recordTtl;
} }
@Override @Override
public int getLocatorCount() { public int getLocatorCount() {
return locatorRecords.size(); return locators.size();
} }
@Override @Override
public byte getMaskLength() { public List<LispLocator> getLocators() {
return maskLength; return ImmutableList.copyOf(locators);
}
@Override
public LispMapReplyAction getAction() {
return action;
}
@Override
public boolean isAuthoritative() {
return authoritative;
}
@Override
public short getMapVersionNumber() {
return mapVersionNumber;
}
@Override
public LispAfiAddress getEidPrefixAfi() {
return eidPrefixAfi;
}
@Override
public List<LispLocatorRecord> getLocators() {
return ImmutableList.copyOf(locatorRecords);
} }
@Override @Override
@ -128,8 +89,8 @@ public final class DefaultLispMapRecord implements LispMapRecord {
.add("authoritative", authoritative) .add("authoritative", authoritative)
.add("mapVersionNumber", mapVersionNumber) .add("mapVersionNumber", mapVersionNumber)
.add("EID prefix AFI address", eidPrefixAfi) .add("EID prefix AFI address", eidPrefixAfi)
.add("locator records", locatorRecords).toString(); .add("locators", locators)
.toString();
} }
@Override @Override
@ -147,65 +108,25 @@ public final class DefaultLispMapRecord implements LispMapRecord {
Objects.equal(authoritative, that.authoritative) && Objects.equal(authoritative, that.authoritative) &&
Objects.equal(mapVersionNumber, that.mapVersionNumber) && Objects.equal(mapVersionNumber, that.mapVersionNumber) &&
Objects.equal(eidPrefixAfi, that.eidPrefixAfi) && Objects.equal(eidPrefixAfi, that.eidPrefixAfi) &&
Objects.equal(locatorRecords, that.locatorRecords); Objects.equal(locators, that.locators);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(recordTtl, maskLength, action, return Objects.hashCode(recordTtl, maskLength, action, authoritative,
authoritative, mapVersionNumber, eidPrefixAfi, locatorRecords); mapVersionNumber, eidPrefixAfi, locators);
} }
public static final class DefaultMapRecordBuilder implements MapRecordBuilder { public static final class DefaultMapRecordBuilder
extends AbstractRecordBuilder<MapRecordBuilder>
implements MapRecordBuilder {
private int recordTtl; private List<LispLocator> locators = Lists.newArrayList();
private byte maskLength;
private LispMapReplyAction action;
private boolean authoritative;
private short mapVersionNumber;
private LispAfiAddress eidPrefixAfi;
private List<LispLocatorRecord> locatorRecords = Lists.newArrayList();
@Override @Override
public MapRecordBuilder withRecordTtl(int recordTtl) { public MapRecordBuilder withLocators(List<LispLocator> locators) {
this.recordTtl = recordTtl; if (locators != null) {
return this; this.locators = ImmutableList.copyOf(locators);
}
@Override
public MapRecordBuilder withMaskLength(byte maskLength) {
this.maskLength = maskLength;
return this;
}
@Override
public MapRecordBuilder withAction(LispMapReplyAction action) {
this.action = action;
return this;
}
@Override
public MapRecordBuilder withAuthoritative(boolean authoritative) {
this.authoritative = authoritative;
return this;
}
@Override
public MapRecordBuilder withMapVersionNumber(short mapVersionNumber) {
this.mapVersionNumber = mapVersionNumber;
return this;
}
@Override
public MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix) {
this.eidPrefixAfi = prefix;
return this;
}
@Override
public MapRecordBuilder withLocators(List<LispLocatorRecord> records) {
if (records != null) {
this.locatorRecords = ImmutableList.copyOf(records);
} }
return this; return this;
} }
@ -216,7 +137,7 @@ public final class DefaultLispMapRecord implements LispMapRecord {
checkNotNull(eidPrefixAfi, "Must specify an EID prefix"); checkNotNull(eidPrefixAfi, "Must specify an EID prefix");
return new DefaultLispMapRecord(recordTtl, maskLength, action, return new DefaultLispMapRecord(recordTtl, maskLength, action,
authoritative, mapVersionNumber, eidPrefixAfi, locatorRecords); authoritative, mapVersionNumber, eidPrefixAfi, locators);
} }
} }
@ -231,7 +152,8 @@ public final class DefaultLispMapRecord implements LispMapRecord {
private static final int REPLY_ACTION_SHIFT_BIT = 5; private static final int REPLY_ACTION_SHIFT_BIT = 5;
@Override @Override
public LispMapRecord readFrom(ByteBuf byteBuf) throws LispParseError, LispReaderException { public LispMapRecord readFrom(ByteBuf byteBuf) throws LispParseError,
LispReaderException {
// Record TTL -> 32 bits // Record TTL -> 32 bits
int recordTtl = byteBuf.readInt(); int recordTtl = byteBuf.readInt();
@ -252,7 +174,8 @@ public final class DefaultLispMapRecord implements LispMapRecord {
} }
// authoritative flag -> 1 bit // authoritative flag -> 1 bit
boolean authoritative = ByteOperator.getBit((byte) (actionWithFlag >> AUTHORITATIVE_INDEX), 0); boolean authoritative = ByteOperator.getBit((byte)
(actionWithFlag >> AUTHORITATIVE_INDEX), 0);
// let's skip the reserved field // let's skip the reserved field
byteBuf.skipBytes(RESERVED_SKIP_LENGTH); byteBuf.skipBytes(RESERVED_SKIP_LENGTH);
@ -260,18 +183,19 @@ public final class DefaultLispMapRecord implements LispMapRecord {
// Map version number -> 12 bits, we treat Rsvd field is all zero // Map version number -> 12 bits, we treat Rsvd field is all zero
short mapVersionNumber = (short) byteBuf.readUnsignedShort(); short mapVersionNumber = (short) byteBuf.readUnsignedShort();
LispAfiAddress eidPrefixAfi = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf); LispAfiAddress eidPrefixAfi =
new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
List<LispLocatorRecord> locators = Lists.newArrayList(); List<LispLocator> locators = Lists.newArrayList();
for (int i = 0; i < locatorCount; i++) { for (int i = 0; i < locatorCount; i++) {
locators.add(new LocatorRecordReader().readFrom(byteBuf)); locators.add(new LocatorReader().readFrom(byteBuf));
} }
return new DefaultMapRecordBuilder() return new DefaultMapRecordBuilder()
.withRecordTtl(recordTtl) .withRecordTtl(recordTtl)
.withMaskLength(maskLength) .withMaskLength(maskLength)
.withAction(action) .withAction(action)
.withAuthoritative(authoritative) .withIsAuthoritative(authoritative)
.withMapVersionNumber(mapVersionNumber) .withMapVersionNumber(mapVersionNumber)
.withLocators(locators) .withLocators(locators)
.withEidPrefixAfi(eidPrefixAfi) .withEidPrefixAfi(eidPrefixAfi)
@ -324,8 +248,8 @@ public final class DefaultLispMapRecord implements LispMapRecord {
afiAddressWriter.writeTo(byteBuf, message.getEidPrefixAfi()); afiAddressWriter.writeTo(byteBuf, message.getEidPrefixAfi());
// serialize locator // serialize locator
LocatorRecordWriter recordWriter = new LocatorRecordWriter(); LocatorWriter recordWriter = new LocatorWriter();
List<LispLocatorRecord> locators = message.getLocators(); List<LispLocator> locators = message.getLocators();
for (int i = 0; i < locators.size(); i++) { for (int i = 0; i < locators.size(); i++) {
recordWriter.writeTo(byteBuf, locators.get(i)); recordWriter.writeTo(byteBuf, locators.get(i));
} }

View File

@ -0,0 +1,22 @@
/*
* Copyright 2017-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;
/**
* Default LISP referral message class.
*/
public class DefaultLispMapReferral implements LispMapReferral {
}

View File

@ -0,0 +1,111 @@
/*
* 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.onlab.packet.DeserializationException;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Default implementation of LispReferral.
*/
public final class DefaultLispReferral extends DefaultLispGenericLocator
implements LispReferral {
static final DefaultLispReferral.ReferralWriter WRITER;
static {
WRITER = new ReferralWriter();
}
/**
* A private constructor that protects object instantiation from external.
*
* @param priority uni-cast priority
* @param weight uni-cast weight
* @param multicastPriority multi-cast priority
* @param multicastWeight multi-cast weight
* @param localLocator local locator flag
* @param rlocProbed RLOC probed flag
* @param routed routed flag
* @param locatorAfi locator AFI
*/
private DefaultLispReferral(byte priority, byte weight, byte multicastPriority,
byte multicastWeight, boolean localLocator,
boolean rlocProbed, boolean routed,
LispAfiAddress locatorAfi) {
super(priority, weight, multicastPriority, multicastWeight,
localLocator, rlocProbed, routed, locatorAfi);
}
@Override
public void writeTo(ByteBuf byteBuf) throws LispWriterException {
WRITER.writeTo(byteBuf, this);
}
public static final class DefaultReferralBuilder
extends AbstractGenericLocatorBuilder<ReferralBuilder>
implements ReferralBuilder {
@Override
public LispReferral build() {
checkNotNull(locatorAfi, "Must specify a locator address");
return new DefaultLispReferral(priority, weight, multicastPriority,
multicastWeight, localLocator, rlocProbed, routed, locatorAfi);
}
}
/**
* A LISP message reader for Referral portion.
*/
public static final class ReferralReader implements LispMessageReader<LispReferral> {
@Override
public LispReferral readFrom(ByteBuf byteBuf) throws LispParseError,
LispReaderException,
DeserializationException {
LispGenericLocator gl = deserialize(byteBuf);
return new DefaultReferralBuilder()
.withPriority(gl.getPriority())
.withWeight(gl.getWeight())
.withMulticastPriority(gl.getMulticastPriority())
.withMulticastWeight(gl.getMulticastWeight())
.withLocalLocator(gl.isLocalLocator())
.withRouted(gl.isRouted())
.withLocatorAfi(gl.getLocatorAfi()).build();
}
}
/**
* A LISP message writer for Referral portion.
*/
public static final class ReferralWriter implements LispMessageWriter<LispReferral> {
@Override
public void writeTo(ByteBuf byteBuf, LispReferral message)
throws LispWriterException {
serialize(byteBuf, message);
}
}
}

View File

@ -0,0 +1,207 @@
/*
* Copyright 2017-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 com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import org.onlab.packet.DeserializationException;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Default LISP referral record class.
*/
public final class DefaultLispReferralRecord extends AbstractLispRecord
implements LispReferralRecord {
private final boolean incomplete;
private final List<LispReferral> referrals;
private final List<LispSignature> signatures;
static final ReferralRecordWriter WRITER;
static {
WRITER = new ReferralRecordWriter();
}
/**
* A private constructor that protects object instantiation from external.
*
* @param recordTtl record time-to-live value
* @param maskLength mask length
* @param action lisp map reply action
* @param authoritative authoritative flag
* @param mapVersionNumber map version number
* @param eidPrefixAfi EID prefix AFI address
* @param incomplete incomplete flag value
* @param referrals a collection referrals
* @param signatures a collection signatures
*/
private DefaultLispReferralRecord(int recordTtl, byte maskLength,
LispMapReplyAction action, boolean authoritative,
short mapVersionNumber, LispAfiAddress eidPrefixAfi,
boolean incomplete, List<LispReferral> referrals,
List<LispSignature> signatures) {
super(recordTtl, maskLength, action, authoritative, mapVersionNumber, eidPrefixAfi);
this.incomplete = incomplete;
this.referrals = referrals;
this.signatures = signatures;
}
@Override
public int getReferralCount() {
return referrals.size();
}
@Override
public int getSignatureCount() {
return signatures.size();
}
@Override
public boolean isIncomplete() {
return incomplete;
}
@Override
public List<LispReferral> getReferrals() {
return ImmutableList.copyOf(referrals);
}
@Override
public List<LispSignature> getSignatures() {
return ImmutableList.copyOf(signatures);
}
@Override
public void writeTo(ByteBuf byteBuf) throws LispWriterException {
WRITER.writeTo(byteBuf, this);
}
@Override
public String toString() {
return toStringHelper(this)
.add("record TTL", recordTtl)
.add("maskLength", maskLength)
.add("action", action)
.add("authoritative", authoritative)
.add("mapVersionNumber", mapVersionNumber)
.add("EID prefix AFI address", eidPrefixAfi)
.add("incomplete", incomplete)
.add("referrals", referrals)
.add("signatures", signatures)
.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultLispReferralRecord that = (DefaultLispReferralRecord) o;
return Objects.equal(recordTtl, that.recordTtl) &&
Objects.equal(maskLength, that.maskLength) &&
Objects.equal(action, that.action) &&
Objects.equal(authoritative, that.authoritative) &&
Objects.equal(mapVersionNumber, that.mapVersionNumber) &&
Objects.equal(eidPrefixAfi, that.eidPrefixAfi) &&
Objects.equal(referrals, that.referrals) &&
Objects.equal(signatures, that.signatures);
}
@Override
public int hashCode() {
return Objects.hashCode(recordTtl, maskLength, action, authoritative,
mapVersionNumber, eidPrefixAfi, incomplete, referrals, signatures);
}
public static final class DefaultReferralRecordBuilder
extends AbstractRecordBuilder<ReferralRecordBuilder>
implements ReferralRecordBuilder {
private boolean incomplete;
private List<LispReferral> referrals = Lists.newArrayList();
private List<LispSignature> signatures = Lists.newArrayList();
@Override
public ReferralRecordBuilder withReferrals(List<LispReferral> referrals) {
if (referrals != null) {
this.referrals = ImmutableList.copyOf(referrals);
}
return this;
}
@Override
public ReferralRecordBuilder withSignatures(List<LispSignature> signatures) {
if (signatures != null) {
this.signatures = ImmutableList.copyOf(signatures);
}
return this;
}
@Override
public ReferralRecordBuilder withIsIncomplete(boolean incomplete) {
this.incomplete = incomplete;
return this;
}
@Override
public LispReferralRecord build() {
checkNotNull(eidPrefixAfi, "Must specify an EID prefix");
return new DefaultLispReferralRecord(recordTtl, maskLength, action,
authoritative, mapVersionNumber, eidPrefixAfi,
incomplete, referrals, signatures);
}
}
public static final class ReferralRecordReader
implements LispMessageReader<LispReferralRecord> {
@Override
public LispReferralRecord readFrom(ByteBuf byteBuf)
throws LispParseError, LispReaderException,
DeserializationException {
// TODO: need to implement serialization logic
return null;
}
}
/**
* A LISP message writer for ReferralRecord portion.
*/
public static final class ReferralRecordWriter
implements LispMessageWriter<LispReferralRecord> {
@Override
public void writeTo(ByteBuf byteBuf, LispReferralRecord message)
throws LispWriterException {
// TODO: need to implement serialization logic
}
}
}

View File

@ -0,0 +1,22 @@
/*
* Copyright 2017-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;
/**
* Default LISP signature class.
*/
public class DefaultLispSignature implements LispSignature {
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2016-present Open Networking Laboratory * Copyright 2017-present Open Networking Laboratory
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,13 +16,13 @@
package org.onosproject.lisp.msg.protocols; package org.onosproject.lisp.msg.protocols;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import org.onosproject.lisp.msg.exceptions.LispWriterException; import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
/** /**
* LISP locator record section which is part of LISP map record. * A generic LISP locator used for both location and referral purposes.
*/ */
public interface LispLocatorRecord { public interface LispGenericLocator {
/** /**
* Obtains priority value. * Obtains priority value.
@ -89,79 +89,74 @@ public interface LispLocatorRecord {
void writeTo(ByteBuf byteBuf) throws LispWriterException; void writeTo(ByteBuf byteBuf) throws LispWriterException;
/** /**
* A builder of LISP locator record. * A builder of LISP generic locator.
*
* @param <T> sub-builder type
*/ */
interface LocatorRecordBuilder { interface GenericLocatorBuilder<T> {
/** /**
* Sets priority value. * Sets priority value.
* *
* @param priority priority * @param priority priority
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withPriority(byte priority); T withPriority(byte priority);
/** /**
* Sets weight value. * Sets weight value.
* *
* @param weight weight * @param weight weight
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withWeight(byte weight); T withWeight(byte weight);
/** /**
* Sets multi-cast priority value. * Sets multi-cast priority value.
* *
* @param priority priority * @param priority priority
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withMulticastPriority(byte priority); T withMulticastPriority(byte priority);
/** /**
* Sets multi-cast weight value. * Sets multi-cast weight value.
* *
* @param weight weight * @param weight weight
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withMulticastWeight(byte weight); T withMulticastWeight(byte weight);
/** /**
* Sets local locator flag. * Sets local locator flag.
* *
* @param localLocator local locator flag * @param localLocator local locator flag
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withLocalLocator(boolean localLocator); T withLocalLocator(boolean localLocator);
/** /**
* Sets RLOC probed flag. * Sets RLOC probed flag.
* *
* @param rlocProbed RLOC probed flag * @param rlocProbed RLOC probed flag
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withRlocProbed(boolean rlocProbed); T withRlocProbed(boolean rlocProbed);
/** /**
* Sets routed flag. * Sets routed flag.
* *
* @param routed routed flag * @param routed routed flag
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withRouted(boolean routed); T withRouted(boolean routed);
/** /**
* Sets locator AFI. * Sets locator AFI.
* *
* @param locatorAfi locator AFI * @param locatorAfi locator AFI
* @return LocatorRecordBuilder object * @return parameterized object
*/ */
LocatorRecordBuilder withLocatorAfi(LispAfiAddress locatorAfi); T withLocatorAfi(LispAfiAddress locatorAfi);
/**
* Builds locator record.
*
* @return locator record instance
*/
LispLocatorRecord build();
} }
} }

View File

@ -0,0 +1,35 @@
/*
* 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 locator section which is part of LISP map record.
*/
public interface LispLocator extends LispGenericLocator {
/**
* A builder of LISP locator.
*/
interface LocatorBuilder extends GenericLocatorBuilder<LocatorBuilder> {
/**
* Builds locator.
*
* @return locator instance
*/
LispLocator build();
}
}

View File

@ -15,23 +15,12 @@
*/ */
package org.onosproject.lisp.msg.protocols; package org.onosproject.lisp.msg.protocols;
import io.netty.buffer.ByteBuf;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import java.util.List; import java.util.List;
/** /**
* LISP record section which is part of LISP map register message. * LISP map record section which is part of LISP map register message.
*/ */
public interface LispMapRecord { public interface LispMapRecord extends LispRecord {
/**
* Obtains record TTL value.
*
* @return record TTL value
*/
int getRecordTtl();
/** /**
* Obtains locator count value. * Obtains locator count value.
@ -41,120 +30,29 @@ public interface LispMapRecord {
int getLocatorCount(); int getLocatorCount();
/** /**
* Obtains address mask length. * Obtains a collection of locators.
* *
* @return mask length * @return a collection of locators
*/ */
byte getMaskLength(); List<LispLocator> getLocators();
/**
* 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();
/**
* Obtains a collection of locator records.
*
* @return a collection of locator records
*/
List<LispLocatorRecord> getLocators();
/**
* Writes LISP message object into communication channel.
*
* @param byteBuf byte buffer
* @throws LispWriterException on error
*/
void writeTo(ByteBuf byteBuf) throws LispWriterException;
/** /**
* A builder of LISP map record. * A builder of LISP map record.
*/ */
interface MapRecordBuilder { interface MapRecordBuilder extends RecordBuilder<MapRecordBuilder> {
/** /**
* Sets record TTL value. * Sets a collection of locators.
* *
* @param recordTtl record TTL * @param locators a collection of locators
* @return MapRecordBuilder object * @return MapRecordBuilder object
*/ */
MapRecordBuilder withRecordTtl(int recordTtl); MapRecordBuilder withLocators(List<LispLocator> locators);
/** /**
* Sets mask length. * Builds LISP map record object.
* *
* @param maskLength mask length * @return LISP map record object
* @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);
/**
* Sets a collection of locator records.
*
* @param records a collection of locator records
* @return MapRecordBuilder object
*/
MapRecordBuilder withLocators(List<LispLocatorRecord> records);
/**
* Builds map record.
*
* @return map record instance
*/ */
LispMapRecord build(); LispMapRecord build();
} }

View File

@ -0,0 +1,56 @@
/*
* Copyright 2017-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 map referral message interface.
* <p>
* LISP map referral message format is defined in draft-ietf-lisp-ddt-09.
* https://tools.ietf.org/html/draft-ietf-lisp-ddt-09
*
* <pre>
* {@literal
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |Type=6 | Reserved | Record Count |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Nonce . . . |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | . . . Nonce |
* +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | | Record TTL |
* | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* R | Referral Count| EID mask-len | ACT |A|I| Reserved |
* e +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* c |SigCnt | Map Version Number | EID-AFI |
* o +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* r | EID-prefix ... |
* d +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | /| Priority | Weight | M Priority | M Weight |
* | R +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | e | Unused Flags |L|p|R| Loc-AFI |
* | f +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | \| Locator ... |
* | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ~ Sig section ~
* +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* }</pre>
*/
public interface LispMapReferral {
// TODO: need to implement LispMapReferral
}

View File

@ -0,0 +1,132 @@
/*
* Copyright 2017-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.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
/**
* Generic LISP record interface.
*/
public interface LispRecord {
/**
* Obtains record TTL value.
*
* @return record TTL value
*/
int getRecordTtl();
/**
* 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();
/**
* Writes LISP message object into communication channel.
*
* @param byteBuf byte buffer
* @throws LispWriterException on error
*/
void writeTo(ByteBuf byteBuf) throws LispWriterException;
/**
* A builder for LISP record.
*
* @param <T> sub-builder type
*/
interface RecordBuilder<T> {
/**
* Sets record TTL value.
*
* @param recordTtl record TTL
* @return parameterized object
*/
T withRecordTtl(int recordTtl);
/**
* Sets mask length.
*
* @param maskLength mask length
* @return parameterized object
*/
T withMaskLength(byte maskLength);
/**
* Sets LISP map reply action enum.
*
* @param action map reply action
* @return parameterized object
*/
T withAction(LispMapReplyAction action);
/**
* Sets authoritative flag.
*
* @param authoritative authoritative flag
* @return parameterized object
*/
T withIsAuthoritative(boolean authoritative);
/**
* Sets LISP map version number.
*
* @param mapVersionNumber map version number
* @return parameterized object
*/
T withMapVersionNumber(short mapVersionNumber);
/**
* Sets EID prefix.
*
* @param prefix EID prefix
* @return parameterized object
*/
T withEidPrefixAfi(LispAfiAddress prefix);
}
}

View File

@ -0,0 +1,35 @@
/*
* Copyright 2017-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 referral section which is part of LISP referral record.
*/
public interface LispReferral extends LispGenericLocator {
/**
* A builder of LISP referral.
*/
interface ReferralBuilder extends GenericLocatorBuilder<ReferralBuilder> {
/**
* Builds referral.
*
* @return referral instance
*/
LispReferral build();
}
}

View File

@ -0,0 +1,96 @@
/*
* Copyright 2017-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 java.util.List;
/**
* LISP referral record section which is part of LISP map referral message.
*/
public interface LispReferralRecord extends LispRecord {
/**
* Obtains referral count value.
*
* @return referral count value
*/
int getReferralCount();
/**
* Obtains signature count value.
*
* @return signature count value
*/
int getSignatureCount();
/**
* Obtains incomplete flag.
*
* @return incomplete flag
*/
boolean isIncomplete();
/**
* Obtains a collection of referrals.
*
* @return a collection of referrals
*/
List<LispReferral> getReferrals();
/**
* Obtains a collection of signatures.
*
* @return a collection of signatures
*/
List<LispSignature> getSignatures();
/**
* A builder of LISP referral record.
*/
interface ReferralRecordBuilder extends RecordBuilder<ReferralRecordBuilder> {
/**
* Sets a collection of referrals.
*
* @param referrals a collection of referrals
* @return ReferralRecordBuilder object
*/
ReferralRecordBuilder withReferrals(List<LispReferral> referrals);
/**
* Sets a collection of signatures.
*
* @param signatures a collection of signatures
* @return ReferralRecordBuilder object
*/
ReferralRecordBuilder withSignatures(List<LispSignature> signatures);
/**
* Sets incomplete flag.
*
* @param incomplete incomplete flag
* @return ReferralRecordBuilder object
*/
ReferralRecordBuilder withIsIncomplete(boolean incomplete);
/**
* Builds LISP referral record object.
*
* @return LISP referral record object
*/
LispReferralRecord build();
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright 2017-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 signature interface.
*
* <p>
* LISP signature format is defined in draft-ietf-lisp-ddt-09.
* https://tools.ietf.org/html/draft-ietf-lisp-ddt-09#page-14
*
* <pre>
* {@literal
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* /| Original Record TTL |
* / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* / | Signature Expiration |
* | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* s | Signature Inception |
* i +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* g | Key Tag | Sig Length |
* | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* \ | Sig-Algorithm | Reserved | Reserved |
* \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* \ ~ Signature ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* }</pre>
*/
public interface LispSignature {
// TODO: need to implement LispSignature
}

View File

@ -35,6 +35,9 @@ public enum LispType {
/** LISP Map-Notify Message. */ /** LISP Map-Notify Message. */
LISP_MAP_NOTIFY(4), LISP_MAP_NOTIFY(4),
/** LISP Map-Referral Message. */
LISP_MAP_REFERRAL(5),
/** LISP Info-Request or Info-Reply Message. */ /** LISP Info-Request or Info-Reply Message. */
LISP_INFO(7), LISP_INFO(7),

View File

@ -205,7 +205,7 @@ public final class DefaultLispEncapsulatedControlTest {
return builder1 return builder1
.withRecordTtl(100) .withRecordTtl(100)
.withAuthoritative(true) .withIsAuthoritative(true)
.withMapVersionNumber((short) 1) .withMapVersionNumber((short) 1)
.withMaskLength((byte) 0x01) .withMaskLength((byte) 0x01)
.withAction(LispMapReplyAction.NativelyForward) .withAction(LispMapReplyAction.NativelyForward)

View File

@ -24,30 +24,33 @@ import org.onlab.packet.IpAddress;
import org.onosproject.lisp.msg.exceptions.LispParseError; import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException; import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException; import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.protocols.DefaultLispLocatorRecord.DefaultLocatorRecordBuilder; import org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder;
import org.onosproject.lisp.msg.protocols.LispLocatorRecord.LocatorRecordBuilder; import org.onosproject.lisp.msg.protocols.DefaultLispLocator.LocatorReader;
import org.onosproject.lisp.msg.protocols.DefaultLispLocatorRecord.LocatorRecordWriter; import org.onosproject.lisp.msg.protocols.DefaultLispLocator.LocatorWriter;
import org.onosproject.lisp.msg.protocols.DefaultLispLocatorRecord.LocatorRecordReader; import org.onosproject.lisp.msg.protocols.LispLocator.LocatorBuilder;
import org.onosproject.lisp.msg.types.LispIpv4Address; import org.onosproject.lisp.msg.types.LispIpv4Address;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
/** /**
* Unit tests for DefaultLispLocatorRecord class. * Unit tests for DefaultLispLocator class.
*/ */
public final class DefaultLispLocatorRecordTest { public final class DefaultLispLocatorTest {
private LispLocatorRecord record1; private static final String IP_ADDRESS_1 = "192.168.1.1";
private LispLocatorRecord sameAsRecord1; private static final String IP_ADDRESS_2 = "192.168.1.2";
private LispLocatorRecord record2;
private LispLocator record1;
private LispLocator sameAsRecord1;
private LispLocator record2;
@Before @Before
public void setup() { public void setup() {
LocatorRecordBuilder builder1 = new DefaultLocatorRecordBuilder(); LispLocator.LocatorBuilder builder1 = new DefaultLocatorBuilder();
LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_1));
record1 = builder1 record1 = builder1
.withPriority((byte) 0x01) .withPriority((byte) 0x01)
@ -60,7 +63,7 @@ public final class DefaultLispLocatorRecordTest {
.withLocatorAfi(ipv4Locator1) .withLocatorAfi(ipv4Locator1)
.build(); .build();
LocatorRecordBuilder builder2 = new DefaultLocatorRecordBuilder(); LocatorBuilder builder2 = new DefaultLocatorBuilder();
sameAsRecord1 = builder2 sameAsRecord1 = builder2
.withPriority((byte) 0x01) .withPriority((byte) 0x01)
@ -73,9 +76,9 @@ public final class DefaultLispLocatorRecordTest {
.withLocatorAfi(ipv4Locator1) .withLocatorAfi(ipv4Locator1)
.build(); .build();
LocatorRecordBuilder builder3 = new DefaultLocatorRecordBuilder(); LispLocator.LocatorBuilder builder3 = new DefaultLocatorBuilder();
LispIpv4Address ipv4Locator2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); LispIpv4Address ipv4Locator2 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_2));
record2 = builder3 record2 = builder3
.withPriority((byte) 0x02) .withPriority((byte) 0x02)
@ -98,9 +101,9 @@ public final class DefaultLispLocatorRecordTest {
@Test @Test
public void testConstruction() { public void testConstruction() {
DefaultLispLocatorRecord record = (DefaultLispLocatorRecord) record1; DefaultLispLocator record = (DefaultLispLocator) record1;
LispIpv4Address ipv4Locator = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Locator = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_1));
assertThat(record.getPriority(), is((byte) 0x01)); assertThat(record.getPriority(), is((byte) 0x01));
assertThat(record.getWeight(), is((byte) 0x01)); assertThat(record.getWeight(), is((byte) 0x01));
@ -116,11 +119,11 @@ public final class DefaultLispLocatorRecordTest {
public void testSerialization() throws LispReaderException, LispWriterException, LispParseError { public void testSerialization() throws LispReaderException, LispWriterException, LispParseError {
ByteBuf byteBuf = Unpooled.buffer(); ByteBuf byteBuf = Unpooled.buffer();
LocatorRecordWriter writer = new LocatorRecordWriter(); LocatorWriter writer = new LocatorWriter();
writer.writeTo(byteBuf, record1); writer.writeTo(byteBuf, record1);
LocatorRecordReader reader = new LocatorRecordReader(); LocatorReader reader = new LocatorReader();
LispLocatorRecord deserialized = reader.readFrom(byteBuf); LispLocator deserialized = reader.readFrom(byteBuf);
new EqualsTester() new EqualsTester()
.addEqualityGroup(record1, deserialized).testEquals(); .addEqualityGroup(record1, deserialized).testEquals();

View File

@ -43,6 +43,8 @@ import static org.hamcrest.Matchers.is;
*/ */
public final class DefaultLispMapNotifyTest { public final class DefaultLispMapNotifyTest {
private static final String IP_ADDRESS = "192.168.1.1";
private LispMapNotify notify1; private LispMapNotify notify1;
private LispMapNotify sameAsNotify1; private LispMapNotify sameAsNotify1;
private LispMapNotify notify2; private LispMapNotify notify2;
@ -85,11 +87,11 @@ public final class DefaultLispMapNotifyTest {
private LispMapRecord getMapRecord() { private LispMapRecord getMapRecord() {
MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); MapRecordBuilder builder1 = new DefaultMapRecordBuilder();
LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS));
return builder1 return builder1
.withRecordTtl(100) .withRecordTtl(100)
.withAuthoritative(true) .withIsAuthoritative(true)
.withMapVersionNumber((short) 1) .withMapVersionNumber((short) 1)
.withMaskLength((byte) 0x01) .withMaskLength((byte) 0x01)
.withAction(LispMapReplyAction.NativelyForward) .withAction(LispMapReplyAction.NativelyForward)

View File

@ -37,6 +37,9 @@ import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.*;
*/ */
public final class DefaultLispMapRecordTest { public final class DefaultLispMapRecordTest {
private static final String IP_ADDRESS_1 = "192.168.1.1";
private static final String IP_ADDRESS_2 = "192.168.1.2";
private LispMapRecord record1; private LispMapRecord record1;
private LispMapRecord sameAsRecord1; private LispMapRecord sameAsRecord1;
private LispMapRecord record2; private LispMapRecord record2;
@ -46,11 +49,11 @@ public final class DefaultLispMapRecordTest {
MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); MapRecordBuilder builder1 = new DefaultMapRecordBuilder();
LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_1));
record1 = builder1 record1 = builder1
.withRecordTtl(100) .withRecordTtl(100)
.withAuthoritative(true) .withIsAuthoritative(true)
.withMapVersionNumber((short) 1) .withMapVersionNumber((short) 1)
.withMaskLength((byte) 0x01) .withMaskLength((byte) 0x01)
.withAction(LispMapReplyAction.NativelyForward) .withAction(LispMapReplyAction.NativelyForward)
@ -61,7 +64,7 @@ public final class DefaultLispMapRecordTest {
sameAsRecord1 = builder2 sameAsRecord1 = builder2
.withRecordTtl(100) .withRecordTtl(100)
.withAuthoritative(true) .withIsAuthoritative(true)
.withMapVersionNumber((short) 1) .withMapVersionNumber((short) 1)
.withMaskLength((byte) 0x01) .withMaskLength((byte) 0x01)
.withAction(LispMapReplyAction.NativelyForward) .withAction(LispMapReplyAction.NativelyForward)
@ -70,11 +73,11 @@ public final class DefaultLispMapRecordTest {
MapRecordBuilder builder3 = new DefaultMapRecordBuilder(); MapRecordBuilder builder3 = new DefaultMapRecordBuilder();
LispIpv4Address ipv4Locator2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); LispIpv4Address ipv4Locator2 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_2));
record2 = builder3 record2 = builder3
.withRecordTtl(200) .withRecordTtl(200)
.withAuthoritative(false) .withIsAuthoritative(false)
.withMapVersionNumber((short) 2) .withMapVersionNumber((short) 2)
.withMaskLength((byte) 0x02) .withMaskLength((byte) 0x02)
.withAction(LispMapReplyAction.Drop) .withAction(LispMapReplyAction.Drop)
@ -93,7 +96,7 @@ public final class DefaultLispMapRecordTest {
public void testConstruction() { public void testConstruction() {
DefaultLispMapRecord record = (DefaultLispMapRecord) record1; DefaultLispMapRecord record = (DefaultLispMapRecord) record1;
LispIpv4Address ipv4Locator = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Locator = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_1));
assertThat(record.getRecordTtl(), is(100)); assertThat(record.getRecordTtl(), is(100));
assertThat(record.isAuthoritative(), is(true)); assertThat(record.isAuthoritative(), is(true));

View File

@ -43,6 +43,8 @@ import static org.hamcrest.Matchers.is;
*/ */
public final class DefaultLispMapRegisterTest { public final class DefaultLispMapRegisterTest {
private static final String IP_ADDRESS = "192.168.1.1";
private LispMapRegister register1; private LispMapRegister register1;
private LispMapRegister sameAsRegister1; private LispMapRegister sameAsRegister1;
private LispMapRegister register2; private LispMapRegister register2;
@ -91,11 +93,11 @@ public final class DefaultLispMapRegisterTest {
private LispMapRecord getMapRecord() { private LispMapRecord getMapRecord() {
MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); MapRecordBuilder builder1 = new DefaultMapRecordBuilder();
LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS));
return builder1 return builder1
.withRecordTtl(100) .withRecordTtl(100)
.withAuthoritative(true) .withIsAuthoritative(true)
.withMapVersionNumber((short) 1) .withMapVersionNumber((short) 1)
.withMaskLength((byte) 0x01) .withMaskLength((byte) 0x01)
.withAction(LispMapReplyAction.NativelyForward) .withAction(LispMapReplyAction.NativelyForward)

View File

@ -43,6 +43,8 @@ import static org.onosproject.lisp.msg.protocols.DefaultLispMapReply.ReplyBuilde
*/ */
public final class DefaultLispMapReplyTest { public final class DefaultLispMapReplyTest {
private static final String IP_ADDRESS = "192.168.1.1";
private LispMapReply reply1; private LispMapReply reply1;
private LispMapReply sameAsReply1; private LispMapReply sameAsReply1;
private LispMapReply reply2; private LispMapReply reply2;
@ -87,11 +89,11 @@ public final class DefaultLispMapReplyTest {
private LispMapRecord getMapRecord() { private LispMapRecord getMapRecord() {
MapRecordBuilder builder1 = new DefaultMapRecordBuilder(); MapRecordBuilder builder1 = new DefaultMapRecordBuilder();
LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Locator1 = new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS));
return builder1 return builder1
.withRecordTtl(100) .withRecordTtl(100)
.withAuthoritative(true) .withIsAuthoritative(true)
.withMapVersionNumber((short) 1) .withMapVersionNumber((short) 1)
.withMaskLength((byte) 0x01) .withMaskLength((byte) 0x01)
.withAction(LispMapReplyAction.NativelyForward) .withAction(LispMapReplyAction.NativelyForward)

View File

@ -42,6 +42,14 @@ import static org.hamcrest.Matchers.is;
*/ */
public final class DefaultLispMapRequestTest { public final class DefaultLispMapRequestTest {
private static final String EID_IP_ADDRESS_1 = "192.168.1.1";
private static final String EID_IP_ADDRESS_2 = "192.168.1.1";
private static final String RLOC_IP_ADDRESS_1_1 = "10.1.1.1";
private static final String RLOC_IP_ADDRESS_1_2 = "10.1.1.2";
private static final String RLOC_IP_ADDRESS_2_1 = "20.1.1.1";
private static final String RLOC_IP_ADDRESS_2_2 = "20.1.1.2";
private LispMapRequest request1; private LispMapRequest request1;
private LispMapRequest sameAsRequest1; private LispMapRequest sameAsRequest1;
private LispMapRequest request2; private LispMapRequest request2;
@ -51,10 +59,10 @@ public final class DefaultLispMapRequestTest {
RequestBuilder builder1 = new DefaultRequestBuilder(); RequestBuilder builder1 = new DefaultRequestBuilder();
LispIpv4Address ipv4Eid1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1")); LispIpv4Address ipv4Eid1 = new LispIpv4Address(IpAddress.valueOf(EID_IP_ADDRESS_1));
LispIpv4Address ipv4Rloc1 = new LispIpv4Address(IpAddress.valueOf("10.1.1.1")); LispIpv4Address ipv4Rloc1 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_1_1));
LispIpv4Address ipv4Rloc2 = new LispIpv4Address(IpAddress.valueOf("10.1.1.2")); LispIpv4Address ipv4Rloc2 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_1_2));
List<LispAfiAddress> rlocs1 = ImmutableList.of(ipv4Rloc1, ipv4Rloc2); List<LispAfiAddress> rlocs1 = ImmutableList.of(ipv4Rloc1, ipv4Rloc2);
List<LispEidRecord> records1 = ImmutableList.of(getEidRecord(), getEidRecord()); List<LispEidRecord> records1 = ImmutableList.of(getEidRecord(), getEidRecord());
@ -92,10 +100,10 @@ public final class DefaultLispMapRequestTest {
RequestBuilder builder3 = new DefaultRequestBuilder(); RequestBuilder builder3 = new DefaultRequestBuilder();
LispIpv4Address ipv4Eid2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2")); LispIpv4Address ipv4Eid2 = new LispIpv4Address(IpAddress.valueOf(EID_IP_ADDRESS_2));
LispIpv4Address ipv4Rloc3 = new LispIpv4Address(IpAddress.valueOf("20.1.1.1")); LispIpv4Address ipv4Rloc3 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_2_1));
LispIpv4Address ipv4Rloc4 = new LispIpv4Address(IpAddress.valueOf("20.1.1.2")); LispIpv4Address ipv4Rloc4 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_2_2));
List<LispAfiAddress> rlocs2 = ImmutableList.of(ipv4Rloc3, ipv4Rloc4); List<LispAfiAddress> rlocs2 = ImmutableList.of(ipv4Rloc3, ipv4Rloc4);
@ -114,7 +122,7 @@ public final class DefaultLispMapRequestTest {
} }
private LispEidRecord getEidRecord() { private LispEidRecord getEidRecord() {
LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf("20.1.1.1")); LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_2_1));
return new LispEidRecord((byte) 24, eid); return new LispEidRecord((byte) 24, eid);
} }