From 4cde5cc2281605a6aae698448132d807011cab79 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 1 Jul 2011 20:26:37 +0000 Subject: [PATCH] * Fix binding to link level sockets. The bound type was constructed using the sdl_e_type in network byte order, causing such a socket not to receive anything. When working around that by not using htons() on bind, sending would then fail on such a socket because the byte order is actually required to be swapped there. * Extend the comment for the B_NET_FRAME_TYPE macro to document that the input types are supposed to be in host byte order to avoid future confusion. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42357 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/net/net_stack.h | 2 +- src/add-ons/kernel/network/stack/link.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/headers/private/net/net_stack.h b/headers/private/net/net_stack.h index 6c66e5f563..1ec5e87f01 100644 --- a/headers/private/net/net_stack.h +++ b/headers/private/net/net_stack.h @@ -77,7 +77,7 @@ typedef struct ancillary_data_container ancillary_data_container; #define B_NET_FRAME_TYPE(super, sub) (((int32)(super) << 16) | (sub)) // Use this when registering a device handler, see net/if_types.h for - // the possible "super" values. + // the possible "super" values. Input values are in host byte order. // sub types diff --git a/src/add-ons/kernel/network/stack/link.cpp b/src/add-ons/kernel/network/stack/link.cpp index 5351970633..a1341aafc7 100644 --- a/src/add-ons/kernel/network/stack/link.cpp +++ b/src/add-ons/kernel/network/stack/link.cpp @@ -167,7 +167,7 @@ LinkProtocol::Bind(const sockaddr* address) if (linkAddress.sdl_type != 0) { fBoundType = B_NET_FRAME_TYPE(linkAddress.sdl_type, - linkAddress.sdl_e_type); + ntohs(linkAddress.sdl_e_type)); // Bind to the type requested - this is needed in order to // receive any buffers // TODO: this could be easily changed by introducing catch all or rule