net_buffer: prevent modules from messing with metadata too much
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21211 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
79a0d25245
commit
d3d38faf41
@ -82,6 +82,8 @@ struct net_buffer_module_info {
|
||||
struct iovec *iovecs, uint32 vecCount);
|
||||
uint32 (*count_iovecs)(net_buffer *buffer);
|
||||
|
||||
void (*swap_addresses)(net_buffer *buffer);
|
||||
|
||||
void (*dump)(net_buffer *buffer);
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_media.h>
|
||||
@ -159,7 +158,7 @@ loopback_receive_data(net_device *_device, net_buffer **_buffer)
|
||||
return status;
|
||||
|
||||
// swap network addresses before delivering
|
||||
std::swap(buffer->source, buffer->destination);
|
||||
gBufferModule->swap_addresses(buffer);
|
||||
|
||||
*_buffer = buffer;
|
||||
return B_OK;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <KernelExport.h>
|
||||
#include <util/list.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <netinet/in.h>
|
||||
#include <new>
|
||||
#include <stdlib.h>
|
||||
@ -263,7 +262,7 @@ icmp_receive_data(net_buffer *buffer)
|
||||
if (reply == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
std::swap(reply->source, reply->destination);
|
||||
gBufferModule->swap_addresses(reply);
|
||||
|
||||
// There already is an ICMP header, and we'll reuse it
|
||||
NetBufferHeaderReader<icmp_header> header(reply);
|
||||
|
@ -1321,7 +1321,7 @@ TCPEndpoint::_SendQueued(bool force, uint32 sendWindow)
|
||||
int
|
||||
TCPEndpoint::_GetMSS(const sockaddr *address) const
|
||||
{
|
||||
return next->module->get_mtu(next, (sockaddr *)address) - sizeof(tcp_header);
|
||||
return next->module->get_mtu(next, address) - sizeof(tcp_header);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <KernelExport.h>
|
||||
#include <util/AutoLock.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/uio.h>
|
||||
@ -1174,6 +1175,13 @@ count_iovecs(net_buffer *_buffer)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
swap_addresses(net_buffer *buffer)
|
||||
{
|
||||
std::swap(buffer->source, buffer->destination);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
init_net_buffers()
|
||||
{
|
||||
@ -1257,6 +1265,8 @@ net_buffer_module_info gNetBufferModule = {
|
||||
get_iovecs,
|
||||
count_iovecs,
|
||||
|
||||
swap_addresses,
|
||||
|
||||
dump_buffer, // dump
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user