[ONOS-4718] Initial implementation of LISP address serializer
Change-Id: I71e1923f6daf1abdf2bf9798a9e421c81926a45c
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java
index 6f2cc22..8405695 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddress.java
@@ -18,6 +18,7 @@
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 java.util.Objects;
@@ -212,4 +213,21 @@
.build();
}
}
+
+ /**
+ * Segment LCAF address writer class.
+ */
+ public static class SegmentLcafAddressWriter
+ implements LispAddressWriter<LispSegmentLcafAddress> {
+
+ @Override
+ public void writeTo(ByteBuf byteBuf, LispSegmentLcafAddress address)
+ throws LispWriterException {
+
+ LispLcafAddress.serializeCommon(byteBuf, address);
+
+ byteBuf.writeInt(address.getInstanceId());
+ new LispIpAddress.IpAddressWriter().writeTo(byteBuf, (LispIpAddress) address.getAddress());
+ }
+ }
}