IPv4PacketImpl extends AbstractPacket implements IPv4Packet { @Override public void setSourceIP(final int a, final int b, final int c, final int d) { this.headers.setByte(12, (byte) a); this.headers.setByte(13, (byte) b); this.headers.setByte(14, (byte) c); this.headers.setByte(15, (byte) d); reCalculateChecksum(); } IPv4PacketImpl(final Packet parent, final Buffer headers, final int options, final Buffer payload); @Override int getIpChecksum(); @Override byte[] getRawSourceIP(); int getRawSourceIpInt(); @Override String getSourceIP(); @Override byte[] getRawDestinationIP(); int getRawDestinationIpInt(); @Override String getDestinationIP(); @Override void verify(); @Override long getArrivalTime(); @Override void write(final OutputStream out, final Buffer payload); @Override int getTotalIPLength(); void setTotalLength(final int length); @Override void setSourceIP(final int a, final int b, final int c, final int d); @Override void setSourceIP(final byte a, final byte b, final byte c, final byte d); @Override void setDestinationIP(final int a, final int b, final int c, final int d); @Override void setDestinationIP(final byte a, final byte b, final byte c, final byte d); @Override void setSourceIP(final String sourceIp); @Override void setDestinationIP(final String destinationIP); @Override void reCalculateChecksum(); @Override boolean verifyIpChecksum(); @Override IPv4Packet clone(); @Override Packet getNextPacket(); @Override int getVersion(); @Override int getHeaderLength(); @Override boolean isFragmented(); @Override boolean isReservedFlagSet(); @Override boolean isDontFragmentSet(); @Override boolean isMoreFragmentsSet(); @Override short getFragmentOffset(); @Override int getIdentification(); @Override String toString();  }
@Test public void testSetSourceIP() throws Exception { final IPv4Packet pkt = loadIPPackets("sipp.pcap").get(0); pkt.setSourceIP(11, 22, 33, 44); assertThat(pkt.getSourceIP(), is("11.22.33.44")); pkt.setSourceIP("55.66.77.88"); assertThat(pkt.getSourceIP(), is("55.66.77.88")); }