Bugfix(collateral): Fixed TCP/UDP checksum on big-endian platforms; collateral of changes made in IPv4/IPv6 pseudo header cksum for variable fields feature
This commit is contained in:
parent
d677b09491
commit
24d341cce3
@ -813,14 +813,14 @@ quint32 Ip4Protocol::protocolFrameCksum(int streamIndex,
|
||||
{
|
||||
quint32 sum = 0;
|
||||
QByteArray fv = protocolFrameValue(streamIndex);
|
||||
const char *p = fv.constData();
|
||||
const quint8 *p = (quint8*) fv.constData();
|
||||
|
||||
sum += *((quint16*)(p + 12)); // src-ip hi
|
||||
sum += *((quint16*)(p + 14)); // src-ip lo
|
||||
sum += *((quint16*)(p + 16)); // dst-ip hi
|
||||
sum += *((quint16*)(p + 18)); // dst-ip lo
|
||||
sum += qToBigEndian((quint16) protocolFramePayloadSize()); // len
|
||||
sum += *((quint8*) (p + 9)) << 8; // proto
|
||||
sum += qToBigEndian((quint16) *(p + 9)); // proto
|
||||
|
||||
while(sum>>16)
|
||||
sum = (sum & 0xFFFF) + (sum >> 16);
|
||||
|
@ -776,13 +776,13 @@ quint32 Ip6Protocol::protocolFrameCksum(int streamIndex,
|
||||
{
|
||||
quint32 sum = 0;
|
||||
QByteArray fv = protocolFrameValue(streamIndex);
|
||||
const char *p = fv.constData();
|
||||
const quint8 *p = (quint8*) fv.constData();
|
||||
|
||||
// src-ip, dst-ip
|
||||
for (int i = 8; i < fv.size(); i+=2)
|
||||
sum += *((quint16*)(p + i));
|
||||
sum += *((quint16*)(p + 4)); // payload len
|
||||
sum += *((quint8*) (p + 6)) << 8; // proto
|
||||
sum += qToBigEndian((quint16) *(p + 6)); // proto
|
||||
|
||||
while(sum>>16)
|
||||
sum = (sum & 0xFFFF) + (sum >> 16);
|
||||
|
Loading…
Reference in New Issue
Block a user