Fixed endian errors in UDP source and destination port handling.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19633 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
dde7916d62
commit
6378dd7cf4
@ -288,9 +288,12 @@ UDPService::HandleIPPacket(IPService *ipService, ip_addr_t sourceIP,
|
|||||||
if (!data || size < sizeof(udp_header))
|
if (!data || size < sizeof(udp_header))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// check the header
|
|
||||||
const udp_header *header = (const udp_header*)data;
|
const udp_header *header = (const udp_header*)data;
|
||||||
|
uint16 source = ntohs(header->source);
|
||||||
|
uint16 destination = ntohs(header->destination);
|
||||||
uint16 length = ntohs(header->length);
|
uint16 length = ntohs(header->length);
|
||||||
|
|
||||||
|
// check the header
|
||||||
if (length < sizeof(udp_header) || length > size
|
if (length < sizeof(udp_header) || length > size
|
||||||
|| (header->checksum != 0 // 0 => checksum disabled
|
|| (header->checksum != 0 // 0 => checksum disabled
|
||||||
&& _ChecksumData(data, length, sourceIP, destinationIP) != 0)) {
|
&& _ChecksumData(data, length, sourceIP, destinationIP) != 0)) {
|
||||||
@ -300,7 +303,7 @@ UDPService::HandleIPPacket(IPService *ipService, ip_addr_t sourceIP,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find the target socket
|
// find the target socket
|
||||||
UDPSocket *socket = _FindSocket(destinationIP, header->destination);
|
UDPSocket *socket = _FindSocket(destinationIP, destination);
|
||||||
if (!socket)
|
if (!socket)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -309,8 +312,8 @@ UDPService::HandleIPPacket(IPService *ipService, ip_addr_t sourceIP,
|
|||||||
if (!packet)
|
if (!packet)
|
||||||
return;
|
return;
|
||||||
status_t error = packet->SetTo((uint8*)data + sizeof(udp_header),
|
status_t error = packet->SetTo((uint8*)data + sizeof(udp_header),
|
||||||
length - sizeof(udp_header), sourceIP, header->source, destinationIP,
|
length - sizeof(udp_header), sourceIP, source, destinationIP,
|
||||||
header->destination);
|
destination);
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
socket->PushPacket(packet);
|
socket->PushPacket(packet);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user