i'm trying to recalculate UDP Checksum on a packet where i changed IPD destination, but the function udp checksum seems to doesn't accept any parameter,i'm using jnetpcap 1.4
Pcap pcap_off = Pcap.openOffline(fileName, errorBuf); //open pcap
PcapPacket temp= new PcapPacket(JMemory.Type.POINTER);
pcap_off.nextEx(temp);
//System.out.print(temp);
JBuffer buff=new JBuffer(temp.size()); //new buffer
Ethernet eth=temp.getHeader(new Ethernet());
Ip4 ip=temp.getHeader(new Ip4());
Udp udp=temp.getHeader(new Udp());
Payload data=temp.getHeader(new Payload());
InetAddress dst = InetAddress.getByName("10.0.0.10");
InetAddress src = InetAddress.getByName("10.0.0.10");
ip.destination(dst.getAddress()); //modify ip dst
ip.checksum(ip.calculateChecksum()); // recalculate ip checksum OK !!!
eth.transferTo(buff);
ip.transferTo(buff, 0, ip.size(), eth.size());
udp.checksum(udp.calculateChecksum()); // NOT OK
udp.transferTo(buff, 0, udp.size(), eth.size() + ip.size());
data.transferTo(buff, 0, data.size(), eth.size() + ip.size()+ udp.size());
JPacket packet =new JMemoryPacket(JProtocol.ETHERNET_ID,buff); //new packet to send
Some one can help me to get information about the location and format of the checksum field in UDP, i can try to write manually the proper field in according to the recalculate value. Thanks !!