Various fixes
Change-Id: I9f4ec7248e3449f9540fc70d60cbdbc3f8cadab0
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/neighbour/impl/DefaultNeighbourMessageContext.java b/incubator/net/src/main/java/org/onosproject/incubator/net/neighbour/impl/DefaultNeighbourMessageContext.java
index 350e67c..8dfb84e 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/neighbour/impl/DefaultNeighbourMessageContext.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/neighbour/impl/DefaultNeighbourMessageContext.java
@@ -252,7 +252,7 @@
ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();
IpAddress sender = Ip6Address.valueOf(ipv6.getSourceAddress());
- IpAddress target = null;
+ IpAddress target;
NeighbourMessageType type;
if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
@@ -261,6 +261,11 @@
target = Ip6Address.valueOf(nsol.getTargetAddress());
} else if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_ADVERTISEMENT) {
type = NeighbourMessageType.REPLY;
+ /*
+ * sender and target are the same in the reply.
+ * We use as target the destination ip.
+ */
+ target = Ip6Address.valueOf(ipv6.getDestinationAddress());
} else {
return null;
}
diff --git a/utils/misc/src/main/java/org/onlab/packet/Ethernet.java b/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
index 69e6480..a0e07e9 100644
--- a/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
+++ b/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
@@ -38,6 +38,7 @@
*/
public class Ethernet extends BasePacket {
private static final String HEXES = "0123456789ABCDEF";
+ private static final String HEX_PROTO = "0x%s";
public static final short TYPE_ARP = EthType.EtherType.ARP.ethType().toShort();
public static final short TYPE_RARP = EthType.EtherType.RARP.ethType().toShort();
@@ -494,7 +495,13 @@
} else if (pkt instanceof DHCP) {
sb.append("dhcp");
} else {
- sb.append(this.getEtherType());
+ /*
+ * When we don't know the protocol, we print using
+ * the well known hex format instead of a decimal
+ * value.
+ */
+ sb.append(String.format(HEX_PROTO,
+ Integer.toHexString(this.getEtherType() & 0xffff)));
}
sb.append("\ndl_vlan: ");
diff --git a/utils/misc/src/main/java/org/onlab/packet/IpAddress.java b/utils/misc/src/main/java/org/onlab/packet/IpAddress.java
index bf01406..d992e52 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IpAddress.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IpAddress.java
@@ -15,15 +15,16 @@
*/
package org.onlab.packet;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
+import com.google.common.net.InetAddresses;
+import com.google.common.primitives.UnsignedBytes;
+
import java.net.Inet4Address;
import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Objects;
-import com.google.common.net.InetAddresses;
-import com.google.common.primitives.UnsignedBytes;
/**
@@ -71,6 +72,14 @@
}
/**
+ * Default constructor for Kryo serialization.
+ */
+ protected IpAddress() {
+ this.version = null;
+ this.octets = null;
+ }
+
+ /**
* Returns the IP version of this address.
*
* @return the version
diff --git a/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java b/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
index a076530..7f50327 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
@@ -66,6 +66,14 @@
}
/**
+ * Default constructor for Kryo serialization.
+ */
+ protected IpPrefix() {
+ this.address = null;
+ this.prefixLength = 0;
+ }
+
+ /**
* Returns the IP version of the prefix.
*
* @return the IP version of the prefix