introduced Checksum::PseudoHeader helper.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20717 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include <net_buffer.h>
|
||||
#include <net_datalink.h>
|
||||
|
||||
#include <netinet/in.h> // for htons
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
class Checksum {
|
||||
@@ -32,6 +34,10 @@ class Checksum {
|
||||
|
||||
operator uint16();
|
||||
|
||||
static uint16 PseudoHeader(net_address_module_info *addressModule,
|
||||
net_buffer_module_info *bufferModule, net_buffer *buffer,
|
||||
uint16 protocol);
|
||||
|
||||
private:
|
||||
uint32 fSum;
|
||||
};
|
||||
@@ -77,6 +83,19 @@ inline Checksum::operator uint16() {
|
||||
}
|
||||
|
||||
|
||||
inline uint16
|
||||
Checksum::PseudoHeader(net_address_module_info *addressModule,
|
||||
net_buffer_module_info *bufferModule, net_buffer *buffer, uint16 protocol)
|
||||
{
|
||||
Checksum checksum;
|
||||
addressModule->checksum_address(&checksum, (sockaddr *)&buffer->source);
|
||||
addressModule->checksum_address(&checksum, (sockaddr *)&buffer->destination);
|
||||
checksum << (uint16)htons(protocol) << (uint16)htons(buffer->size)
|
||||
<< Checksum::BufferHelper(buffer, bufferModule);
|
||||
return checksum;
|
||||
}
|
||||
|
||||
|
||||
// helper class that prints an address (and optionally a port) into a buffer that
|
||||
// is automatically freed at end of scope:
|
||||
class AddressString {
|
||||
|
||||
Reference in New Issue
Block a user