Change-Id: I4562587fd32a6d6576d7f2f59f180068d1d86282
Signed-off-by: Giles Heron <giheron@cisco.com>
private static ByteBuf serializeIp(final IpAddress ipAddress) {
final ByteBuf body = Unpooled.buffer();
private static ByteBuf serializeIp(final IpAddress ipAddress) {
final ByteBuf body = Unpooled.buffer();
- if (ipAddress.getIpv4Address() != null) {
- body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
- body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
- } else if (ipAddress.getIpv6Address() != null) {
- body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
- body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
+ if (ipAddress != null) {
+ if (ipAddress.getIpv4Address() != null) {
+ body.writeByte(Ipv4Util.IP4_BITS_LENGTH);
+ body.writeBytes(Ipv4Util.bytesForAddress(ipAddress.getIpv4Address()));
+ } else if (ipAddress.getIpv6Address() != null) {
+ body.writeByte(Ipv6Util.IPV6_BITS_LENGTH);
+ body.writeBytes(Ipv6Util.bytesForAddress(ipAddress.getIpv6Address()));
+ } else {
+ body.writeZero(ZERO_BYTE);
+ }
} else {
body.writeZero(ZERO_BYTE);
}
} else {
body.writeZero(ZERO_BYTE);
}