for igmp V2 join/leave, there would be some padding bytes and we found here the length is not exactly 8. add some more judgement here
Change-Id: I43feee4f4fd9381117c6fc33ee8c04d9829c4d98
diff --git a/utils/misc/src/main/java/org/onlab/packet/IGMP.java b/utils/misc/src/main/java/org/onlab/packet/IGMP.java
index ef14fd6..04308db 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IGMP.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IGMP.java
@@ -223,13 +223,19 @@
return (data, offset, length) -> {
checkInput(data, offset, length, IGMPv2.HEADER_LENGTH);
- // we will assume that this is IGMPv2 if the length is 8
- boolean isV2 = length == IGMPv2.HEADER_LENGTH;
+ final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+ byte igmpType = bb.get();
+ boolean isV2;
+ if (igmpType == TYPE_IGMPV2_MEMBERSHIP_REPORT || igmpType == TYPE_IGMPV2_LEAVE_GROUP ||
+ length == IGMPv2.HEADER_LENGTH) {
+ isV2 = true;
+ } else {
+ isV2 = false;
+ }
IGMP igmp = isV2 ? new IGMPv2() : new IGMPv3();
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
- igmp.igmpType = bb.get();
+ igmp.igmpType = igmpType;
igmp.resField = bb.get();
igmp.checksum = bb.getShort();