Jian Li
Committed by Gerrit Code Review

[ONOS-4718] Initial implementation of LISP control msg serializer

Change-Id: Ia068e1b158f05dd70839cb1020f15dc66b0142a0
...@@ -20,9 +20,11 @@ import io.netty.buffer.ByteBuf; ...@@ -20,9 +20,11 @@ import io.netty.buffer.ByteBuf;
20 import org.onlab.util.ByteOperator; 20 import org.onlab.util.ByteOperator;
21 import org.onosproject.lisp.msg.exceptions.LispParseError; 21 import org.onosproject.lisp.msg.exceptions.LispParseError;
22 import org.onosproject.lisp.msg.exceptions.LispReaderException; 22 import org.onosproject.lisp.msg.exceptions.LispReaderException;
23 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
23 import org.onosproject.lisp.msg.types.LispAfiAddress; 24 import org.onosproject.lisp.msg.types.LispAfiAddress;
24 25
25 import static com.google.common.base.MoreObjects.toStringHelper; 26 import static com.google.common.base.MoreObjects.toStringHelper;
27 +import static org.onosproject.lisp.msg.types.LispAfiAddress.AfiAddressWriter;
26 28
27 /** 29 /**
28 * Default implementation of LispLocatorRecord. 30 * Default implementation of LispLocatorRecord.
...@@ -265,4 +267,59 @@ public final class DefaultLispLocatorRecord implements LispLocatorRecord { ...@@ -265,4 +267,59 @@ public final class DefaultLispLocatorRecord implements LispLocatorRecord {
265 .build(); 267 .build();
266 } 268 }
267 } 269 }
270 +
271 + /**
272 + * A LISP message writer for LocatorRecord portion.
273 + */
274 + public static final class LocatorRecordWriter implements LispMessageWriter<LispLocatorRecord> {
275 +
276 + private static final int LOCAL_LOCATOR_SHIFT_BIT = 2;
277 + private static final int PROBED_SHIFT_BIT = 1;
278 +
279 + private static final int ENABLE_BIT = 1;
280 + private static final int DISABLE_BIT = 0;
281 +
282 + @Override
283 + public void writeTo(ByteBuf byteBuf, LispLocatorRecord message) throws LispWriterException {
284 +
285 + // priority
286 + byteBuf.writeByte(message.getPriority());
287 +
288 + // weight
289 + byteBuf.writeByte(message.getWeight());
290 +
291 + // multicast priority
292 + byteBuf.writeByte(message.getMulticastPriority());
293 +
294 + // multicast weight
295 + byteBuf.writeByte(message.getMulticastWeight());
296 +
297 + // unused flags
298 + byteBuf.writeByte((short) 0);
299 +
300 + // localLocator flag
301 + short localLocator = DISABLE_BIT;
302 + if (message.isLocalLocator()) {
303 + localLocator = (byte) (ENABLE_BIT << LOCAL_LOCATOR_SHIFT_BIT);
304 + }
305 +
306 + // rlocProbed flag
307 + short probed = DISABLE_BIT;
308 + if (message.isRlocProbed()) {
309 + probed = (byte) (ENABLE_BIT << PROBED_SHIFT_BIT);
310 + }
311 +
312 + // routed flag
313 + short routed = DISABLE_BIT;
314 + if (message.isRouted()) {
315 + routed = (byte) ENABLE_BIT;
316 + }
317 +
318 + byteBuf.writeByte((byte) (localLocator + probed + routed));
319 +
320 + // EID prefix AFI with EID prefix
321 + AfiAddressWriter afiAddressWriter = new AfiAddressWriter();
322 + afiAddressWriter.writeTo(byteBuf, message.getLocatorAfi());
323 + }
324 + }
268 } 325 }
......
...@@ -22,10 +22,13 @@ import io.netty.buffer.ByteBuf; ...@@ -22,10 +22,13 @@ import io.netty.buffer.ByteBuf;
22 import org.onlab.util.ImmutableByteSequence; 22 import org.onlab.util.ImmutableByteSequence;
23 import org.onosproject.lisp.msg.exceptions.LispParseError; 23 import org.onosproject.lisp.msg.exceptions.LispParseError;
24 import org.onosproject.lisp.msg.exceptions.LispReaderException; 24 import org.onosproject.lisp.msg.exceptions.LispReaderException;
25 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
25 26
27 +import java.util.Arrays;
26 import java.util.List; 28 import java.util.List;
27 29
28 import static com.google.common.base.MoreObjects.toStringHelper; 30 import static com.google.common.base.MoreObjects.toStringHelper;
31 +import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.MapRecordWriter;
29 32
30 /** 33 /**
31 * Default LISP map notify message class. 34 * Default LISP map notify message class.
...@@ -34,6 +37,7 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -34,6 +37,7 @@ public final class DefaultLispMapNotify implements LispMapNotify {
34 37
35 private final long nonce; 38 private final long nonce;
36 private final short keyId; 39 private final short keyId;
40 + private final short authDataLength;
37 private final byte[] authenticationData; 41 private final byte[] authenticationData;
38 private final byte recordCount; 42 private final byte recordCount;
39 private final List<LispMapRecord> mapRecords; 43 private final List<LispMapRecord> mapRecords;
...@@ -47,10 +51,12 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -47,10 +51,12 @@ public final class DefaultLispMapNotify implements LispMapNotify {
47 * @param recordCount record count number 51 * @param recordCount record count number
48 * @param mapRecords a collection of map records 52 * @param mapRecords a collection of map records
49 */ 53 */
50 - private DefaultLispMapNotify(long nonce, short keyId, byte[] authenticationData, 54 + private DefaultLispMapNotify(long nonce, short keyId, short authDataLength,
51 - byte recordCount, List<LispMapRecord> mapRecords) { 55 + byte[] authenticationData, byte recordCount,
56 + List<LispMapRecord> mapRecords) {
52 this.nonce = nonce; 57 this.nonce = nonce;
53 this.keyId = keyId; 58 this.keyId = keyId;
59 + this.authDataLength = authDataLength;
54 this.authenticationData = authenticationData; 60 this.authenticationData = authenticationData;
55 this.recordCount = recordCount; 61 this.recordCount = recordCount;
56 this.mapRecords = mapRecords; 62 this.mapRecords = mapRecords;
...@@ -73,26 +79,31 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -73,26 +79,31 @@ public final class DefaultLispMapNotify implements LispMapNotify {
73 79
74 @Override 80 @Override
75 public long getNonce() { 81 public long getNonce() {
76 - return this.nonce; 82 + return nonce;
77 } 83 }
78 84
79 @Override 85 @Override
80 public byte getRecordCount() { 86 public byte getRecordCount() {
81 - return this.recordCount; 87 + return recordCount;
82 } 88 }
83 89
84 @Override 90 @Override
85 public short getKeyId() { 91 public short getKeyId() {
86 - return this.keyId; 92 + return keyId;
93 + }
94 +
95 + @Override
96 + public short getAuthDataLength() {
97 + return authDataLength;
87 } 98 }
88 99
89 @Override 100 @Override
90 public byte[] getAuthenticationData() { 101 public byte[] getAuthenticationData() {
91 - return ImmutableByteSequence.copyFrom(this.authenticationData).asArray(); 102 + return ImmutableByteSequence.copyFrom(authenticationData).asArray();
92 } 103 }
93 104
94 @Override 105 @Override
95 - public List<LispMapRecord> getLispRecords() { 106 + public List<LispMapRecord> getMapRecords() {
96 return ImmutableList.copyOf(mapRecords); 107 return ImmutableList.copyOf(mapRecords);
97 } 108 }
98 109
...@@ -103,6 +114,8 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -103,6 +114,8 @@ public final class DefaultLispMapNotify implements LispMapNotify {
103 .add("nonce", nonce) 114 .add("nonce", nonce)
104 .add("recordCount", recordCount) 115 .add("recordCount", recordCount)
105 .add("keyId", keyId) 116 .add("keyId", keyId)
117 + .add("authentication data length", authDataLength)
118 + .add("authentication data", authenticationData)
106 .add("mapRecords", mapRecords).toString(); 119 .add("mapRecords", mapRecords).toString();
107 } 120 }
108 121
...@@ -118,18 +131,20 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -118,18 +131,20 @@ public final class DefaultLispMapNotify implements LispMapNotify {
118 return Objects.equal(nonce, that.nonce) && 131 return Objects.equal(nonce, that.nonce) &&
119 Objects.equal(recordCount, that.recordCount) && 132 Objects.equal(recordCount, that.recordCount) &&
120 Objects.equal(keyId, that.keyId) && 133 Objects.equal(keyId, that.keyId) &&
134 + Objects.equal(authDataLength, that.authDataLength) &&
121 Objects.equal(authenticationData, that.authenticationData); 135 Objects.equal(authenticationData, that.authenticationData);
122 } 136 }
123 137
124 @Override 138 @Override
125 public int hashCode() { 139 public int hashCode() {
126 - return Objects.hashCode(nonce, recordCount, keyId, authenticationData); 140 + return Objects.hashCode(nonce, recordCount, keyId, authDataLength, authenticationData);
127 } 141 }
128 142
129 public static final class DefaultNotifyBuilder implements NotifyBuilder { 143 public static final class DefaultNotifyBuilder implements NotifyBuilder {
130 144
131 private long nonce; 145 private long nonce;
132 private short keyId; 146 private short keyId;
147 + private short authDataLength;
133 private byte[] authenticationData; 148 private byte[] authenticationData;
134 private byte recordCount; 149 private byte recordCount;
135 private List<LispMapRecord> mapRecords; 150 private List<LispMapRecord> mapRecords;
...@@ -158,6 +173,12 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -158,6 +173,12 @@ public final class DefaultLispMapNotify implements LispMapNotify {
158 } 173 }
159 174
160 @Override 175 @Override
176 + public NotifyBuilder withAuthDataLength(short authDataLength) {
177 + this.authDataLength = authDataLength;
178 + return this;
179 + }
180 +
181 + @Override
161 public NotifyBuilder withAuthenticationData(byte[] authenticationData) { 182 public NotifyBuilder withAuthenticationData(byte[] authenticationData) {
162 this.authenticationData = authenticationData; 183 this.authenticationData = authenticationData;
163 return this; 184 return this;
...@@ -171,15 +192,15 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -171,15 +192,15 @@ public final class DefaultLispMapNotify implements LispMapNotify {
171 192
172 @Override 193 @Override
173 public LispMapNotify build() { 194 public LispMapNotify build() {
174 - return new DefaultLispMapNotify(nonce, keyId, authenticationData, 195 + return new DefaultLispMapNotify(nonce, keyId, authDataLength,
175 - recordCount, mapRecords); 196 + authenticationData, recordCount, mapRecords);
176 } 197 }
177 } 198 }
178 199
179 /** 200 /**
180 - * A private LISP message reader for MapNotify message. 201 + * A LISP message reader for MapNotify message.
181 */ 202 */
182 - private static class NotifyReader implements LispMessageReader<LispMapNotify> { 203 + public static final class NotifyReader implements LispMessageReader<LispMapNotify> {
183 204
184 private static final int RESERVED_SKIP_LENGTH = 3; 205 private static final int RESERVED_SKIP_LENGTH = 3;
185 206
...@@ -218,9 +239,64 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -218,9 +239,64 @@ public final class DefaultLispMapNotify implements LispMapNotify {
218 .withRecordCount(recordCount) 239 .withRecordCount(recordCount)
219 .withNonce(nonce) 240 .withNonce(nonce)
220 .withKeyId(keyId) 241 .withKeyId(keyId)
242 + .withAuthDataLength(authLength)
221 .withAuthenticationData(authData) 243 .withAuthenticationData(authData)
222 .withMapRecords(mapRecords) 244 .withMapRecords(mapRecords)
223 .build(); 245 .build();
224 } 246 }
225 } 247 }
248 +
249 + /**
250 + * A LISP message reader for MapNotify message.
251 + */
252 + public static final class NotifyWriter implements LispMessageWriter<LispMapNotify> {
253 +
254 + private static final int NOTIFY_MSG_TYPE = 4;
255 + private static final int NOTIFY_SHIFT_BIT = 4;
256 +
257 + private static final int UNUSED_ZERO = 0;
258 +
259 + @Override
260 + public void writeTo(ByteBuf byteBuf, LispMapNotify message) throws LispWriterException {
261 +
262 + // specify LISP message type
263 + byte msgType = (byte) (NOTIFY_MSG_TYPE << NOTIFY_SHIFT_BIT);
264 + byteBuf.writeByte(msgType);
265 +
266 + // reserved field
267 + byteBuf.writeShort((short) UNUSED_ZERO);
268 +
269 + // record count
270 + byteBuf.writeByte(message.getRecordCount());
271 +
272 + // nonce
273 + byteBuf.writeLong(message.getNonce());
274 +
275 + // keyId
276 + byteBuf.writeShort(message.getKeyId());
277 +
278 + // authentication data length in octet
279 + byteBuf.writeShort(message.getAuthDataLength());
280 +
281 + // authentication data
282 + byte[] data = message.getAuthenticationData();
283 + byte[] clone;
284 + if (data != null) {
285 + clone = data.clone();
286 + Arrays.fill(clone, (byte) UNUSED_ZERO);
287 + }
288 +
289 + byteBuf.writeBytes(data);
290 +
291 + // TODO: need to implement MAC authentication mechanism
292 +
293 + // serialize map records
294 + MapRecordWriter writer = new MapRecordWriter();
295 + List<LispMapRecord> records = message.getMapRecords();
296 +
297 + for (int i = 0; i < records.size(); i++) {
298 + writer.writeTo(byteBuf, records.get(i));
299 + }
300 + }
301 + }
226 } 302 }
......
...@@ -22,11 +22,14 @@ import io.netty.buffer.ByteBuf; ...@@ -22,11 +22,14 @@ import io.netty.buffer.ByteBuf;
22 import org.onlab.util.ByteOperator; 22 import org.onlab.util.ByteOperator;
23 import org.onosproject.lisp.msg.exceptions.LispParseError; 23 import org.onosproject.lisp.msg.exceptions.LispParseError;
24 import org.onosproject.lisp.msg.exceptions.LispReaderException; 24 import org.onosproject.lisp.msg.exceptions.LispReaderException;
25 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
25 import org.onosproject.lisp.msg.types.LispAfiAddress; 26 import org.onosproject.lisp.msg.types.LispAfiAddress;
26 27
27 import java.util.List; 28 import java.util.List;
28 29
29 import static com.google.common.base.MoreObjects.toStringHelper; 30 import static com.google.common.base.MoreObjects.toStringHelper;
31 +import static org.onosproject.lisp.msg.types.LispAfiAddress.AfiAddressWriter;
32 +import static org.onosproject.lisp.msg.protocols.DefaultLispLocatorRecord.LocatorRecordWriter;
30 33
31 /** 34 /**
32 * Default implementation of LispMapRecord. 35 * Default implementation of LispMapRecord.
...@@ -268,4 +271,58 @@ public final class DefaultLispMapRecord implements LispMapRecord { ...@@ -268,4 +271,58 @@ public final class DefaultLispMapRecord implements LispMapRecord {
268 .build(); 271 .build();
269 } 272 }
270 } 273 }
274 +
275 + /**
276 + * A LISP message writer for MapRecord portion.
277 + */
278 + public static final class MapRecordWriter implements LispMessageWriter<LispMapRecord> {
279 +
280 + private static final int REPLY_ACTION_SHIFT_BIT = 5;
281 + private static final int AUTHORITATIVE_FLAG_SHIFT_BIT = 4;
282 +
283 + private static final int ENABLE_BIT = 1;
284 + private static final int DISABLE_BIT = 0;
285 +
286 + @Override
287 + public void writeTo(ByteBuf byteBuf, LispMapRecord message) throws LispWriterException {
288 +
289 + // record TTL
290 + byteBuf.writeInt(message.getRecordTtl());
291 +
292 + // locator count
293 + byteBuf.writeByte((byte) message.getLocatorCount());
294 +
295 + // EID mask length
296 + byteBuf.writeByte(message.getMaskLength());
297 +
298 + // reply action
299 + byte action = (byte) (message.getAction().getAction() << REPLY_ACTION_SHIFT_BIT);
300 +
301 + // authoritative bit
302 + byte authoritative = DISABLE_BIT;
303 + if (message.isAuthoritative()) {
304 + authoritative = ENABLE_BIT;
305 + }
306 + authoritative = (byte) (authoritative << AUTHORITATIVE_FLAG_SHIFT_BIT);
307 +
308 + byteBuf.writeByte((byte) (action + authoritative));
309 +
310 + // fill zero into reserved field
311 + byteBuf.writeByte((short) 0);
312 +
313 + // map version number
314 + byteBuf.writeShort(message.getMapVersionNumber());
315 +
316 + // EID prefix AFI with EID prefix
317 + AfiAddressWriter afiAddressWriter = new AfiAddressWriter();
318 + afiAddressWriter.writeTo(byteBuf, message.getEidPrefixAfi());
319 +
320 + // serialize locator
321 + LocatorRecordWriter recordWriter = new LocatorRecordWriter();
322 + List<LispLocatorRecord> locators = message.getLocators();
323 + for (int i = 0; i < locators.size(); i++) {
324 + recordWriter.writeTo(byteBuf, locators.get(i));
325 + }
326 + }
327 + }
271 } 328 }
......
...@@ -23,11 +23,14 @@ import org.onlab.util.ByteOperator; ...@@ -23,11 +23,14 @@ import org.onlab.util.ByteOperator;
23 import org.onlab.util.ImmutableByteSequence; 23 import org.onlab.util.ImmutableByteSequence;
24 import org.onosproject.lisp.msg.exceptions.LispParseError; 24 import org.onosproject.lisp.msg.exceptions.LispParseError;
25 import org.onosproject.lisp.msg.exceptions.LispReaderException; 25 import org.onosproject.lisp.msg.exceptions.LispReaderException;
26 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
26 27
28 +import java.util.Arrays;
27 import java.util.List; 29 import java.util.List;
28 30
29 import static com.google.common.base.MoreObjects.toStringHelper; 31 import static com.google.common.base.MoreObjects.toStringHelper;
30 32
33 +
31 /** 34 /**
32 * Default LISP map register message class. 35 * Default LISP map register message class.
33 */ 36 */
...@@ -35,6 +38,7 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -35,6 +38,7 @@ public final class DefaultLispMapRegister implements LispMapRegister {
35 38
36 private final long nonce; 39 private final long nonce;
37 private final short keyId; 40 private final short keyId;
41 + private final short authDataLength;
38 private final byte[] authenticationData; 42 private final byte[] authenticationData;
39 private final byte recordCount; 43 private final byte recordCount;
40 private final List<LispMapRecord> mapRecords; 44 private final List<LispMapRecord> mapRecords;
...@@ -52,12 +56,13 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -52,12 +56,13 @@ public final class DefaultLispMapRegister implements LispMapRegister {
52 * @param proxyMapReply proxy map reply flag 56 * @param proxyMapReply proxy map reply flag
53 * @param wantMapNotify want map notify flag 57 * @param wantMapNotify want map notify flag
54 */ 58 */
55 - private DefaultLispMapRegister(long nonce, short keyId, 59 + private DefaultLispMapRegister(long nonce, short keyId, short authDataLength,
56 byte[] authenticationData, byte recordCount, 60 byte[] authenticationData, byte recordCount,
57 List<LispMapRecord> mapRecords, 61 List<LispMapRecord> mapRecords,
58 boolean proxyMapReply, boolean wantMapNotify) { 62 boolean proxyMapReply, boolean wantMapNotify) {
59 this.nonce = nonce; 63 this.nonce = nonce;
60 this.keyId = keyId; 64 this.keyId = keyId;
65 + this.authDataLength = authDataLength;
61 this.authenticationData = authenticationData; 66 this.authenticationData = authenticationData;
62 this.recordCount = recordCount; 67 this.recordCount = recordCount;
63 this.mapRecords = mapRecords; 68 this.mapRecords = mapRecords;
...@@ -106,6 +111,11 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -106,6 +111,11 @@ public final class DefaultLispMapRegister implements LispMapRegister {
106 } 111 }
107 112
108 @Override 113 @Override
114 + public short getAuthDataLength() {
115 + return authDataLength;
116 + }
117 +
118 + @Override
109 public byte[] getAuthenticationData() { 119 public byte[] getAuthenticationData() {
110 return ImmutableByteSequence.copyFrom(this.authenticationData).asArray(); 120 return ImmutableByteSequence.copyFrom(this.authenticationData).asArray();
111 } 121 }
...@@ -122,6 +132,8 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -122,6 +132,8 @@ public final class DefaultLispMapRegister implements LispMapRegister {
122 .add("nonce", nonce) 132 .add("nonce", nonce)
123 .add("recordCount", recordCount) 133 .add("recordCount", recordCount)
124 .add("keyId", keyId) 134 .add("keyId", keyId)
135 + .add("authentication data length", authDataLength)
136 + .add("authentication data", authenticationData)
125 .add("mapRecords", mapRecords) 137 .add("mapRecords", mapRecords)
126 .add("proxyMapReply", proxyMapReply) 138 .add("proxyMapReply", proxyMapReply)
127 .add("wantMapNotify", wantMapNotify).toString(); 139 .add("wantMapNotify", wantMapNotify).toString();
...@@ -140,6 +152,7 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -140,6 +152,7 @@ public final class DefaultLispMapRegister implements LispMapRegister {
140 return Objects.equal(nonce, that.nonce) && 152 return Objects.equal(nonce, that.nonce) &&
141 Objects.equal(recordCount, that.recordCount) && 153 Objects.equal(recordCount, that.recordCount) &&
142 Objects.equal(keyId, that.keyId) && 154 Objects.equal(keyId, that.keyId) &&
155 + Objects.equal(authDataLength, that.authDataLength) &&
143 Objects.equal(authenticationData, that.authenticationData) && 156 Objects.equal(authenticationData, that.authenticationData) &&
144 Objects.equal(proxyMapReply, that.proxyMapReply) && 157 Objects.equal(proxyMapReply, that.proxyMapReply) &&
145 Objects.equal(wantMapNotify, that.wantMapNotify); 158 Objects.equal(wantMapNotify, that.wantMapNotify);
...@@ -147,14 +160,15 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -147,14 +160,15 @@ public final class DefaultLispMapRegister implements LispMapRegister {
147 160
148 @Override 161 @Override
149 public int hashCode() { 162 public int hashCode() {
150 - return Objects.hashCode(nonce, recordCount, keyId, authenticationData, 163 + return Objects.hashCode(nonce, recordCount, keyId, authDataLength,
151 - proxyMapReply, wantMapNotify); 164 + authenticationData, proxyMapReply, wantMapNotify);
152 } 165 }
153 166
154 public static final class DefaultRegisterBuilder implements RegisterBuilder { 167 public static final class DefaultRegisterBuilder implements RegisterBuilder {
155 168
156 private long nonce; 169 private long nonce;
157 private short keyId; 170 private short keyId;
171 + private short authDataLength;
158 private byte[] authenticationData; 172 private byte[] authenticationData;
159 private byte recordCount; 173 private byte recordCount;
160 private List<LispMapRecord> mapRecords; 174 private List<LispMapRecord> mapRecords;
...@@ -191,6 +205,12 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -191,6 +205,12 @@ public final class DefaultLispMapRegister implements LispMapRegister {
191 } 205 }
192 206
193 @Override 207 @Override
208 + public RegisterBuilder withAuthDataLength(short authDataLength) {
209 + this.authDataLength = authDataLength;
210 + return this;
211 + }
212 +
213 + @Override
194 public RegisterBuilder withKeyId(short keyId) { 214 public RegisterBuilder withKeyId(short keyId) {
195 this.keyId = keyId; 215 this.keyId = keyId;
196 return this; 216 return this;
...@@ -210,15 +230,15 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -210,15 +230,15 @@ public final class DefaultLispMapRegister implements LispMapRegister {
210 230
211 @Override 231 @Override
212 public LispMapRegister build() { 232 public LispMapRegister build() {
213 - return new DefaultLispMapRegister(nonce, keyId, authenticationData, 233 + return new DefaultLispMapRegister(nonce, keyId, authDataLength,
214 - recordCount, mapRecords, proxyMapReply, wantMapNotify); 234 + authenticationData, recordCount, mapRecords, proxyMapReply, wantMapNotify);
215 } 235 }
216 } 236 }
217 237
218 /** 238 /**
219 - * A private LISP message reader for MapRegister message. 239 + * A LISP message reader for MapRegister message.
220 */ 240 */
221 - private static class RegisterReader implements LispMessageReader<LispMapRegister> { 241 + public static final class RegisterReader implements LispMessageReader<LispMapRegister> {
222 242
223 private static final int PROXY_MAP_REPLY_INDEX = 3; 243 private static final int PROXY_MAP_REPLY_INDEX = 3;
224 private static final int WANT_MAP_NOTIFY_INDEX = 0; 244 private static final int WANT_MAP_NOTIFY_INDEX = 0;
...@@ -274,4 +294,78 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -274,4 +294,78 @@ public final class DefaultLispMapRegister implements LispMapRegister {
274 .build(); 294 .build();
275 } 295 }
276 } 296 }
297 +
298 + /**
299 + * LISP map register message writer class.
300 + */
301 + public static class RegisterWriter implements LispMessageWriter<LispMapRegister> {
302 +
303 + private static final int REGISTER_MSG_TYPE = 3;
304 + private static final int REGISTER_SHIFT_BIT = 4;
305 +
306 + private static final int PROXY_MAP_REPLY_SHIFT_BIT = 3;
307 +
308 + private static final int ENABLE_BIT = 1;
309 + private static final int DISABLE_BIT = 0;
310 +
311 + private static final int UNUSED_ZERO = 0;
312 +
313 + @Override
314 + public void writeTo(ByteBuf byteBuf, LispMapRegister message) throws LispWriterException {
315 +
316 + // specify LISP message type
317 + byte msgType = (byte) (REGISTER_MSG_TYPE << REGISTER_SHIFT_BIT);
318 +
319 + // proxy map reply flag
320 + byte proxyMapReply = DISABLE_BIT;
321 + if (message.isProxyMapReply()) {
322 + proxyMapReply = (byte) (ENABLE_BIT << PROXY_MAP_REPLY_SHIFT_BIT);
323 + }
324 +
325 + byteBuf.writeByte(msgType + proxyMapReply);
326 +
327 + // fill zero into reserved field
328 + byteBuf.writeByte((short) UNUSED_ZERO);
329 +
330 + // want map notify flag
331 + byte wantMapNotify = DISABLE_BIT;
332 + if (message.isWantMapNotify()) {
333 + wantMapNotify = (byte) ENABLE_BIT;
334 + }
335 +
336 + byteBuf.writeByte(wantMapNotify);
337 +
338 + // record count
339 + byteBuf.writeByte(message.getRecordCount());
340 +
341 + // nonce
342 + byteBuf.writeLong(message.getNonce());
343 +
344 + // keyId
345 + byteBuf.writeShort(message.getKeyId());
346 +
347 + // authentication data length in octet
348 + byteBuf.writeShort(message.getAuthDataLength());
349 +
350 + // authentication data
351 + byte[] data = message.getAuthenticationData();
352 + byte[] clone;
353 + if (data != null) {
354 + clone = data.clone();
355 + Arrays.fill(clone, (byte) UNUSED_ZERO);
356 + }
357 +
358 + byteBuf.writeBytes(data);
359 +
360 + // TODO: need to implement MAC authentication mechanism
361 +
362 + // serialize map records
363 + DefaultLispMapRecord.MapRecordWriter writer = new DefaultLispMapRecord.MapRecordWriter();
364 + List<LispMapRecord> records = message.getMapRecords();
365 +
366 + for (int i = 0; i < records.size(); i++) {
367 + writer.writeTo(byteBuf, records.get(i));
368 + }
369 + }
370 + }
277 } 371 }
......
...@@ -22,10 +22,12 @@ import io.netty.buffer.ByteBuf; ...@@ -22,10 +22,12 @@ import io.netty.buffer.ByteBuf;
22 import org.onlab.util.ByteOperator; 22 import org.onlab.util.ByteOperator;
23 import org.onosproject.lisp.msg.exceptions.LispParseError; 23 import org.onosproject.lisp.msg.exceptions.LispParseError;
24 import org.onosproject.lisp.msg.exceptions.LispReaderException; 24 import org.onosproject.lisp.msg.exceptions.LispReaderException;
25 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
25 26
26 import java.util.List; 27 import java.util.List;
27 28
28 import static com.google.common.base.MoreObjects.toStringHelper; 29 import static com.google.common.base.MoreObjects.toStringHelper;
30 +import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.MapRecordWriter;
29 31
30 /** 32 /**
31 * Default LISP map reply message class. 33 * Default LISP map reply message class.
...@@ -75,27 +77,27 @@ public final class DefaultLispMapReply implements LispMapReply { ...@@ -75,27 +77,27 @@ public final class DefaultLispMapReply implements LispMapReply {
75 77
76 @Override 78 @Override
77 public boolean isProbe() { 79 public boolean isProbe() {
78 - return this.probe; 80 + return probe;
79 } 81 }
80 82
81 @Override 83 @Override
82 public boolean isEtr() { 84 public boolean isEtr() {
83 - return this.etr; 85 + return etr;
84 } 86 }
85 87
86 @Override 88 @Override
87 public boolean isSecurity() { 89 public boolean isSecurity() {
88 - return this.security; 90 + return security;
89 } 91 }
90 92
91 @Override 93 @Override
92 public byte getRecordCount() { 94 public byte getRecordCount() {
93 - return this.recordCount; 95 + return recordCount;
94 } 96 }
95 97
96 @Override 98 @Override
97 public long getNonce() { 99 public long getNonce() {
98 - return this.nonce; 100 + return nonce;
99 } 101 }
100 102
101 @Override 103 @Override
...@@ -194,9 +196,9 @@ public final class DefaultLispMapReply implements LispMapReply { ...@@ -194,9 +196,9 @@ public final class DefaultLispMapReply implements LispMapReply {
194 } 196 }
195 197
196 /** 198 /**
197 - * A private LISP message reader for MapReply message. 199 + * A LISP message reader for MapReply message.
198 */ 200 */
199 - private static class ReplyReader implements LispMessageReader<LispMapReply> { 201 + public static final class ReplyReader implements LispMessageReader<LispMapReply> {
200 202
201 private static final int PROBE_INDEX = 3; 203 private static final int PROBE_INDEX = 3;
202 private static final int ETR_INDEX = 2; 204 private static final int ETR_INDEX = 2;
...@@ -244,4 +246,66 @@ public final class DefaultLispMapReply implements LispMapReply { ...@@ -244,4 +246,66 @@ public final class DefaultLispMapReply implements LispMapReply {
244 .build(); 246 .build();
245 } 247 }
246 } 248 }
249 +
250 + /**
251 + * A LISP message writer for MapReply message.
252 + */
253 + public static final class ReplyWriter implements LispMessageWriter<LispMapReply> {
254 +
255 + private static final int REPLY_MSG_TYPE = 2;
256 + private static final int REPLY_SHIFT_BIT = 4;
257 +
258 + private static final int PROBE_FLAG_SHIFT_BIT = 3;
259 + private static final int ETR_FLAG_SHIFT_BIT = 2;
260 + private static final int SECURITY_FLAG_SHIFT_BIT = 1;
261 +
262 + private static final int ENABLE_BIT = 1;
263 + private static final int DISABLE_BIT = 0;
264 +
265 + private static final int UNUSED_ZERO = 0;
266 +
267 + @Override
268 + public void writeTo(ByteBuf byteBuf, LispMapReply message) throws LispWriterException {
269 +
270 + // specify LISP message type
271 + byte msgType = (byte) (REPLY_MSG_TYPE << REPLY_SHIFT_BIT);
272 +
273 + // probe flag
274 + byte probe = DISABLE_BIT;
275 + if (message.isProbe()) {
276 + probe = (byte) (ENABLE_BIT << PROBE_FLAG_SHIFT_BIT);
277 + }
278 +
279 + // etr flag
280 + byte etr = DISABLE_BIT;
281 + if (message.isEtr()) {
282 + etr = (byte) (ENABLE_BIT << ETR_FLAG_SHIFT_BIT);
283 + }
284 +
285 + // security flag
286 + byte security = DISABLE_BIT;
287 + if (message.isSecurity()) {
288 + security = (byte) (ENABLE_BIT << SECURITY_FLAG_SHIFT_BIT);
289 + }
290 +
291 + byteBuf.writeByte((byte) (msgType + probe + etr + security));
292 +
293 + // reserved field
294 + byteBuf.writeShort((short) UNUSED_ZERO);
295 +
296 + // record count
297 + byteBuf.writeByte(message.getRecordCount());
298 +
299 + // nonce
300 + byteBuf.writeLong(message.getNonce());
301 +
302 + // serialize map records
303 + MapRecordWriter writer = new MapRecordWriter();
304 + List<LispMapRecord> records = message.getMapRecords();
305 +
306 + for (int i = 0; i < records.size(); i++) {
307 + writer.writeTo(byteBuf, records.get(i));
308 + }
309 + }
310 + }
247 } 311 }
......
...@@ -22,11 +22,14 @@ import io.netty.buffer.ByteBuf; ...@@ -22,11 +22,14 @@ import io.netty.buffer.ByteBuf;
22 import org.onlab.util.ByteOperator; 22 import org.onlab.util.ByteOperator;
23 import org.onosproject.lisp.msg.exceptions.LispParseError; 23 import org.onosproject.lisp.msg.exceptions.LispParseError;
24 import org.onosproject.lisp.msg.exceptions.LispReaderException; 24 import org.onosproject.lisp.msg.exceptions.LispReaderException;
25 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
25 import org.onosproject.lisp.msg.types.LispAfiAddress; 26 import org.onosproject.lisp.msg.types.LispAfiAddress;
26 27
27 import java.util.List; 28 import java.util.List;
28 29
29 import static com.google.common.base.MoreObjects.toStringHelper; 30 import static com.google.common.base.MoreObjects.toStringHelper;
31 +import static org.onosproject.lisp.msg.types.LispAfiAddress.AfiAddressWriter;
32 +import static org.onosproject.lisp.msg.protocols.LispEidRecord.EidRecordWriter;
30 33
31 /** 34 /**
32 * Default LISP map request message class. 35 * Default LISP map request message class.
...@@ -94,47 +97,47 @@ public final class DefaultLispMapRequest implements LispMapRequest { ...@@ -94,47 +97,47 @@ public final class DefaultLispMapRequest implements LispMapRequest {
94 97
95 @Override 98 @Override
96 public boolean isAuthoritative() { 99 public boolean isAuthoritative() {
97 - return this.authoritative; 100 + return authoritative;
98 } 101 }
99 102
100 @Override 103 @Override
101 public boolean isMapDataPresent() { 104 public boolean isMapDataPresent() {
102 - return this.mapDataPresent; 105 + return mapDataPresent;
103 } 106 }
104 107
105 @Override 108 @Override
106 public boolean isProbe() { 109 public boolean isProbe() {
107 - return this.probe; 110 + return probe;
108 } 111 }
109 112
110 @Override 113 @Override
111 public boolean isSmr() { 114 public boolean isSmr() {
112 - return this.smr; 115 + return smr;
113 } 116 }
114 117
115 @Override 118 @Override
116 public boolean isPitr() { 119 public boolean isPitr() {
117 - return this.pitr; 120 + return pitr;
118 } 121 }
119 122
120 @Override 123 @Override
121 public boolean isSmrInvoked() { 124 public boolean isSmrInvoked() {
122 - return this.smrInvoked; 125 + return smrInvoked;
123 } 126 }
124 127
125 @Override 128 @Override
126 public byte getRecordCount() { 129 public byte getRecordCount() {
127 - return this.recordCount; 130 + return recordCount;
128 } 131 }
129 132
130 @Override 133 @Override
131 public long getNonce() { 134 public long getNonce() {
132 - return this.nonce; 135 + return nonce;
133 } 136 }
134 137
135 @Override 138 @Override
136 public LispAfiAddress getSourceEid() { 139 public LispAfiAddress getSourceEid() {
137 - return this.sourceEid; 140 + return sourceEid;
138 } 141 }
139 142
140 @Override 143 @Override
...@@ -285,9 +288,9 @@ public final class DefaultLispMapRequest implements LispMapRequest { ...@@ -285,9 +288,9 @@ public final class DefaultLispMapRequest implements LispMapRequest {
285 } 288 }
286 289
287 /** 290 /**
288 - * A private LISP message reader for MapRequest message. 291 + * A LISP message reader for MapRequest message.
289 */ 292 */
290 - private static class RequestReader implements LispMessageReader<LispMapRequest> { 293 + public static final class RequestReader implements LispMessageReader<LispMapRequest> {
291 294
292 private static final int AUTHORITATIVE_INDEX = 3; 295 private static final int AUTHORITATIVE_INDEX = 3;
293 private static final int MAP_DATA_PRESENT_INDEX = 2; 296 private static final int MAP_DATA_PRESENT_INDEX = 2;
...@@ -365,4 +368,101 @@ public final class DefaultLispMapRequest implements LispMapRequest { ...@@ -365,4 +368,101 @@ public final class DefaultLispMapRequest implements LispMapRequest {
365 .build(); 368 .build();
366 } 369 }
367 } 370 }
371 +
372 + /**
373 + * A LISP message writer for MapRequest message.
374 + */
375 + public static final class RequestWriter implements LispMessageWriter<LispMapRequest> {
376 +
377 + private static final int REQUEST_MSG_TYPE = 1;
378 + private static final int REQUEST_SHIFT_BIT = 4;
379 +
380 + private static final int AUTHORITATIVE_SHIFT_BIT = 3;
381 + private static final int MAP_DATA_PRESENT_SHIFT_BIT = 2;
382 + private static final int PROBE_SHIFT_BIT = 1;
383 +
384 + private static final int PITR_SHIFT_BIT = 7;
385 + private static final int SMR_INVOKED_SHIFT_BIT = 6;
386 +
387 + private static final int ENABLE_BIT = 1;
388 + private static final int DISABLE_BIT = 0;
389 +
390 + private static final int UNUSED_ZERO = 0;
391 +
392 + @Override
393 + public void writeTo(ByteBuf byteBuf, LispMapRequest message) throws LispWriterException {
394 +
395 + // specify LISP message type
396 + byte msgType = (byte) (REQUEST_MSG_TYPE << REQUEST_SHIFT_BIT);
397 +
398 + // authoritative flag
399 + byte authoritative = DISABLE_BIT;
400 + if (message.isAuthoritative()) {
401 + authoritative = (byte) (ENABLE_BIT << AUTHORITATIVE_SHIFT_BIT);
402 + }
403 +
404 + // map data present flag
405 + byte mapDataPresent = DISABLE_BIT;
406 + if (message.isMapDataPresent()) {
407 + mapDataPresent = (byte) (ENABLE_BIT << MAP_DATA_PRESENT_SHIFT_BIT);
408 + }
409 +
410 + // probe flag
411 + byte probe = DISABLE_BIT;
412 + if (message.isProbe()) {
413 + probe = (byte) (ENABLE_BIT << PROBE_SHIFT_BIT);
414 + }
415 +
416 + // SMR flag
417 + byte smr = DISABLE_BIT;
418 + if (message.isSmr()) {
419 + smr = (byte) ENABLE_BIT;
420 + }
421 +
422 + byteBuf.writeByte((byte) (msgType + authoritative + mapDataPresent + probe + smr));
423 +
424 + // PITR flag bit
425 + byte pitr = DISABLE_BIT;
426 + if (message.isPitr()) {
427 + pitr = (byte) (ENABLE_BIT << PITR_SHIFT_BIT);
428 + }
429 +
430 + // SMR invoked flag bit
431 + byte smrInvoked = DISABLE_BIT;
432 + if (message.isSmrInvoked()) {
433 + smrInvoked = (byte) (ENABLE_BIT << SMR_INVOKED_SHIFT_BIT);
434 + }
435 +
436 + byteBuf.writeByte((byte) (pitr + smrInvoked));
437 +
438 + // TODO: ITR RLOC count
439 + byteBuf.writeByte((byte) UNUSED_ZERO);
440 +
441 + // record count
442 + byteBuf.writeByte(message.getRecordCount());
443 +
444 + // nonce
445 + byteBuf.writeLong(message.getNonce());
446 +
447 + // Source EID AFI with Source EID address
448 + AfiAddressWriter afiAddressWriter = new AfiAddressWriter();
449 + afiAddressWriter.writeTo(byteBuf, message.getSourceEid());
450 +
451 + // ITR RLOCs
452 + List<LispAfiAddress> rlocs = message.getItrRlocs();
453 + for (int i = 0; i < rlocs.size(); i++) {
454 + afiAddressWriter.writeTo(byteBuf, rlocs.get(i));
455 + }
456 +
457 + // EID records
458 + EidRecordWriter recordWriter = new EidRecordWriter();
459 + List<LispEidRecord> records = message.getEids();
460 +
461 + for (int i = 0; i < records.size(); i++) {
462 + recordWriter.writeTo(byteBuf, records.get(i));
463 + }
464 +
465 + // TODO: handle Map-Reply record
466 + }
467 + }
368 } 468 }
......
...@@ -18,8 +18,11 @@ package org.onosproject.lisp.msg.protocols; ...@@ -18,8 +18,11 @@ package org.onosproject.lisp.msg.protocols;
18 import io.netty.buffer.ByteBuf; 18 import io.netty.buffer.ByteBuf;
19 import org.onosproject.lisp.msg.exceptions.LispParseError; 19 import org.onosproject.lisp.msg.exceptions.LispParseError;
20 import org.onosproject.lisp.msg.exceptions.LispReaderException; 20 import org.onosproject.lisp.msg.exceptions.LispReaderException;
21 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
21 import org.onosproject.lisp.msg.types.LispAfiAddress; 22 import org.onosproject.lisp.msg.types.LispAfiAddress;
22 23
24 +import static org.onosproject.lisp.msg.types.LispAfiAddress.AfiAddressWriter;
25 +
23 /** 26 /**
24 * LISP EID record section which is part of LISP map request message. 27 * LISP EID record section which is part of LISP map request message.
25 */ 28 */
...@@ -58,9 +61,9 @@ public final class LispEidRecord { ...@@ -58,9 +61,9 @@ public final class LispEidRecord {
58 } 61 }
59 62
60 /** 63 /**
61 - * A private LISP message reader for EidRecord portion. 64 + * A LISP message reader for EidRecord portion.
62 */ 65 */
63 - public static class EidRecordReader implements LispMessageReader<LispEidRecord> { 66 + public static final class EidRecordReader implements LispMessageReader<LispEidRecord> {
64 67
65 private static final int RESERVED_SKIP_LENGTH = 1; 68 private static final int RESERVED_SKIP_LENGTH = 1;
66 69
...@@ -77,4 +80,26 @@ public final class LispEidRecord { ...@@ -77,4 +80,26 @@ public final class LispEidRecord {
77 return new LispEidRecord((byte) maskLength, prefix); 80 return new LispEidRecord((byte) maskLength, prefix);
78 } 81 }
79 } 82 }
83 +
84 + /**
85 + * A LISP message writer for EidRecord portion.
86 + */
87 + public static final class EidRecordWriter implements LispMessageWriter<LispEidRecord> {
88 +
89 + private static final int UNUSED_ZERO = 0;
90 +
91 + @Override
92 + public void writeTo(ByteBuf byteBuf, LispEidRecord message) throws LispWriterException {
93 +
94 + // fill zero into reserved field
95 + byteBuf.writeByte((short) UNUSED_ZERO);
96 +
97 + // mask length
98 + byteBuf.writeByte(message.getMaskLength());
99 +
100 + // EID prefix AFI with EID prefix
101 + AfiAddressWriter afiAddressWriter = new AfiAddressWriter();
102 + afiAddressWriter.writeTo(byteBuf, message.getPrefix());
103 + }
104 + }
80 } 105 }
......
...@@ -78,6 +78,13 @@ public interface LispMapNotify extends LispMessage { ...@@ -78,6 +78,13 @@ public interface LispMapNotify extends LispMessage {
78 short getKeyId(); 78 short getKeyId();
79 79
80 /** 80 /**
81 + * Obtains authentication data length.
82 + *
83 + * @return authentication data length
84 + */
85 + short getAuthDataLength();
86 +
87 + /**
81 * Obtains authentication data. 88 * Obtains authentication data.
82 * 89 *
83 * @return authentication data 90 * @return authentication data
...@@ -89,7 +96,7 @@ public interface LispMapNotify extends LispMessage { ...@@ -89,7 +96,7 @@ public interface LispMapNotify extends LispMessage {
89 * 96 *
90 * @return a collection of records 97 * @return a collection of records
91 */ 98 */
92 - List<LispMapRecord> getLispRecords(); 99 + List<LispMapRecord> getMapRecords();
93 100
94 /** 101 /**
95 * A builder of LISP map notify message. 102 * A builder of LISP map notify message.
...@@ -121,6 +128,14 @@ public interface LispMapNotify extends LispMessage { ...@@ -121,6 +128,14 @@ public interface LispMapNotify extends LispMessage {
121 NotifyBuilder withKeyId(short keyId); 128 NotifyBuilder withKeyId(short keyId);
122 129
123 /** 130 /**
131 + * Sets authentication data length.
132 + *
133 + * @param authDataLength authentication data length
134 + * @return NotifyBuilder object
135 + */
136 + NotifyBuilder withAuthDataLength(short authDataLength);
137 +
138 + /**
124 * Sets authentication data. 139 * Sets authentication data.
125 * 140 *
126 * @param authenticationData authentication data 141 * @param authenticationData authentication data
......
...@@ -92,6 +92,13 @@ public interface LispMapRegister extends LispMessage { ...@@ -92,6 +92,13 @@ public interface LispMapRegister extends LispMessage {
92 short getKeyId(); 92 short getKeyId();
93 93
94 /** 94 /**
95 + * Obtains authentication data length.
96 + *
97 + * @return authentication data length
98 + */
99 + short getAuthDataLength();
100 +
101 + /**
95 * Obtains authentication data. 102 * Obtains authentication data.
96 * 103 *
97 * @return authentication data 104 * @return authentication data
...@@ -143,6 +150,14 @@ public interface LispMapRegister extends LispMessage { ...@@ -143,6 +150,14 @@ public interface LispMapRegister extends LispMessage {
143 RegisterBuilder withNonce(long nonce); 150 RegisterBuilder withNonce(long nonce);
144 151
145 /** 152 /**
153 + * Sets authentication data length.
154 + *
155 + * @param authDataLength authentication data length
156 + * @return RegisterBuilder object
157 + */
158 + RegisterBuilder withAuthDataLength(short authDataLength);
159 +
160 + /**
146 * Sets key identifier. 161 * Sets key identifier.
147 * 162 *
148 * @param keyId key identifier 163 * @param keyId key identifier
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.lisp.msg.protocols;
17 +
18 +import io.netty.buffer.ByteBuf;
19 +import org.onosproject.lisp.msg.exceptions.LispWriterException;
20 +
21 +/**
22 + * An interface for serializing LISP control message.
23 + */
24 +public interface LispMessageWriter<T> {
25 +
26 + /**
27 + * Serializes LISP control message object and writes to byte buffer.
28 + *
29 + * @param byteBuf byte buffer
30 + * @param message LISP address type instance
31 + * @throws LispWriterException LISP writer exception
32 + */
33 + void writeTo(ByteBuf byteBuf, T message) throws LispWriterException;
34 +}
...@@ -24,11 +24,11 @@ import org.onosproject.lisp.msg.exceptions.LispWriterException; ...@@ -24,11 +24,11 @@ import org.onosproject.lisp.msg.exceptions.LispWriterException;
24 public interface LispAddressWriter<T> { 24 public interface LispAddressWriter<T> {
25 25
26 /** 26 /**
27 - * Writes from LISP address object and serialize to byte buffer. 27 + * Serializes LISP address object and writes to byte buffer.
28 * 28 *
29 * @param byteBuf byte buffer 29 * @param byteBuf byte buffer
30 * @param address LISP address type instance 30 * @param address LISP address type instance
31 - * @throws LispWriterException Lisp writer exception 31 + * @throws LispWriterException LISP writer exception
32 */ 32 */
33 void writeTo(ByteBuf byteBuf, T address) throws LispWriterException; 33 void writeTo(ByteBuf byteBuf, T address) throws LispWriterException;
34 34
......