@Test public void testDeserializeTruncated() throws Exception { byte[] bits = igmpQuery.serialize(); PacketTestUtils.testDeserializeTruncated(deserializer, bits); bits = igmpMembership.serialize(); PacketTestUtils.testDeserializeTruncated(deserializer, bits); }
@java.lang.SuppressWarnings("squid:S128") @Override public byte[] serialize() { byte[] data = new byte[8915]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.getIgmpType()); bb.put(this.resField); bb.putShort((short) 0); switch (this.igmpType) { case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: bb.putShort((short) 0); bb.putShort((short) groups.size()); case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY: for (IGMPGroup grp : groups) { grp.serialize(bb); } break; default: bb.put(this.unsupportTypeData); break; } int size = bb.position(); if (this.checksum == 0) { bb.rewind(); int accumulation = 0; for (int i = 0; i < size * 2; ++i) { accumulation += 0xffff & bb.getShort(); } accumulation = (accumulation >> 16 & 0xffff) + (accumulation & 0xffff); this.checksum = (short) (~accumulation & 0xffff); bb.putShort(2, this.checksum); } bb.position(0); byte[] rdata = new byte[size]; bb.get(rdata, 0, size); return rdata; }
IGMP extends BasePacket { @java.lang.SuppressWarnings("squid:S128") @Override public byte[] serialize() { byte[] data = new byte[8915]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.getIgmpType()); bb.put(this.resField); bb.putShort((short) 0); switch (this.igmpType) { case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: bb.putShort((short) 0); bb.putShort((short) groups.size()); case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY: for (IGMPGroup grp : groups) { grp.serialize(bb); } break; default: bb.put(this.unsupportTypeData); break; } int size = bb.position(); if (this.checksum == 0) { bb.rewind(); int accumulation = 0; for (int i = 0; i < size * 2; ++i) { accumulation += 0xffff & bb.getShort(); } accumulation = (accumulation >> 16 & 0xffff) + (accumulation & 0xffff); this.checksum = (short) (~accumulation & 0xffff); bb.putShort(2, this.checksum); } bb.position(0); byte[] rdata = new byte[size]; bb.get(rdata, 0, size); return rdata; } }
IGMP extends BasePacket { @java.lang.SuppressWarnings("squid:S128") @Override public byte[] serialize() { byte[] data = new byte[8915]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.getIgmpType()); bb.put(this.resField); bb.putShort((short) 0); switch (this.igmpType) { case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: bb.putShort((short) 0); bb.putShort((short) groups.size()); case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY: for (IGMPGroup grp : groups) { grp.serialize(bb); } break; default: bb.put(this.unsupportTypeData); break; } int size = bb.position(); if (this.checksum == 0) { bb.rewind(); int accumulation = 0; for (int i = 0; i < size * 2; ++i) { accumulation += 0xffff & bb.getShort(); } accumulation = (accumulation >> 16 & 0xffff) + (accumulation & 0xffff); this.checksum = (short) (~accumulation & 0xffff); bb.putShort(2, this.checksum); } bb.position(0); byte[] rdata = new byte[size]; bb.get(rdata, 0, size); return rdata; } IGMP(); }
IGMP extends BasePacket { @java.lang.SuppressWarnings("squid:S128") @Override public byte[] serialize() { byte[] data = new byte[8915]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.getIgmpType()); bb.put(this.resField); bb.putShort((short) 0); switch (this.igmpType) { case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: bb.putShort((short) 0); bb.putShort((short) groups.size()); case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY: for (IGMPGroup grp : groups) { grp.serialize(bb); } break; default: bb.put(this.unsupportTypeData); break; } int size = bb.position(); if (this.checksum == 0) { bb.rewind(); int accumulation = 0; for (int i = 0; i < size * 2; ++i) { accumulation += 0xffff & bb.getShort(); } accumulation = (accumulation >> 16 & 0xffff) + (accumulation & 0xffff); this.checksum = (short) (~accumulation & 0xffff); bb.putShort(2, this.checksum); } bb.position(0); byte[] rdata = new byte[size]; bb.get(rdata, 0, size); return rdata; } IGMP(); byte getIgmpType(); void setIgmpType(byte msgType); short getChecksum(); byte getMaxRespField(); void setMaxRespCode(byte respCode); List<IGMPGroup> getGroups(); boolean addGroup(IGMPGroup group); @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning @Override byte[] serialize(); @Override IPacket deserialize(final byte[] data, final int offset,
                               final int length); static Deserializer<IGMP> deserializer(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); }
IGMP extends BasePacket { @java.lang.SuppressWarnings("squid:S128") @Override public byte[] serialize() { byte[] data = new byte[8915]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.getIgmpType()); bb.put(this.resField); bb.putShort((short) 0); switch (this.igmpType) { case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: bb.putShort((short) 0); bb.putShort((short) groups.size()); case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY: for (IGMPGroup grp : groups) { grp.serialize(bb); } break; default: bb.put(this.unsupportTypeData); break; } int size = bb.position(); if (this.checksum == 0) { bb.rewind(); int accumulation = 0; for (int i = 0; i < size * 2; ++i) { accumulation += 0xffff & bb.getShort(); } accumulation = (accumulation >> 16 & 0xffff) + (accumulation & 0xffff); this.checksum = (short) (~accumulation & 0xffff); bb.putShort(2, this.checksum); } bb.position(0); byte[] rdata = new byte[size]; bb.get(rdata, 0, size); return rdata; } IGMP(); byte getIgmpType(); void setIgmpType(byte msgType); short getChecksum(); byte getMaxRespField(); void setMaxRespCode(byte respCode); List<IGMPGroup> getGroups(); boolean addGroup(IGMPGroup group); @java.lang.SuppressWarnings("squid:S128") // suppress switch fall through warning @Override byte[] serialize(); @Override IPacket deserialize(final byte[] data, final int offset,
                               final int length); static Deserializer<IGMP> deserializer(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); static final byte TYPE_IGMPV3_MEMBERSHIP_QUERY; static final byte TYPE_IGMPV1_MEMBERSHIP_REPORT; static final byte TYPE_IGMPV2_MEMBERSHIP_REPORT; static final byte TYPE_IGMPV2_LEAVE_GROUP; static final byte TYPE_IGMPV3_MEMBERSHIP_REPORT; static final Map<Byte, Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP; static final int MINIMUM_HEADER_LEN; }