From 57e2a3d5842686e03674ee3f61b1740d56034960 Mon Sep 17 00:00:00 2001 From: Hugo Santos Date: Fri, 13 Apr 2007 04:20:39 +0000 Subject: [PATCH] only deliver frames to IPv4 raw sockets of the specified protocol. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20675 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/net/ProtocolUtilities.h | 2 ++ .../kernel/network/protocols/ipv4/ipv4.cpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/headers/private/net/ProtocolUtilities.h b/headers/private/net/ProtocolUtilities.h index f5549bd28f..2ebd8e67ed 100644 --- a/headers/private/net/ProtocolUtilities.h +++ b/headers/private/net/ProtocolUtilities.h @@ -60,6 +60,8 @@ public: void WakeAll(); + net_socket *Socket() const { return fSocket; } + protected: status_t _Enqueue(net_buffer *buffer); status_t _EnqueueClone(net_buffer *buffer); diff --git a/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp b/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp index 0ed5b0ad17..500873fc6d 100644 --- a/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp +++ b/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp @@ -585,8 +585,12 @@ raw_receive_data(net_buffer *buffer) RawSocketList::Iterator iterator = sRawSockets.GetIterator(); - while (iterator.HasNext()) - iterator.Next()->EnqueueClone(buffer); + while (iterator.HasNext()) { + RawSocket *raw = iterator.Next(); + + if (raw->Socket()->protocol == buffer->protocol) + raw->EnqueueClone(buffer); + } } @@ -909,7 +913,7 @@ ipv4_send_routed_data(net_protocol *_protocol, struct net_route *route, gBufferModule->checksum(buffer, 0, buffer->size, true))); TRACE(("destination-IP: buffer=%p addr=%p %08lx\n", buffer, &buffer->destination, - ntohl(destination->sin_addr.s_addr))); + ntohl(destination.sin_addr.s_addr))); uint32 mtu = route->mtu ? route->mtu : interface->mtu; if (buffer->size > mtu) { @@ -1074,10 +1078,7 @@ ipv4_receive_data(net_buffer *buffer) // we must no longer access bufferHeader or header anymore after // this point - if (protocol != IPPROTO_TCP && protocol != IPPROTO_UDP) { - // SOCK_RAW doesn't get all packets - raw_receive_data(buffer); - } + raw_receive_data(buffer); gBufferModule->remove_header(buffer, headerLength); // the header is of variable size and may include IP options