Commit Graph

194 Commits

Author SHA1 Message Date
Rene Gollent b8a716965a BSocketMessenger: Further improvements.
- Messages that expect a reply are now tagged with a unique ID field to
  indicate that expectation to the receiving socket messenger.
- The messenger now maintains a map of received reply IDs and their
  corresponding messages, along with a message queue of other unsolicited
  replies.
- After successfully connecting, the messenger now spawns a thread
  whose sole responsibility is receiving and parsing all incoming messages,
  and consequently sorting them into the aforementioned data structures based
  on the presence of the reply ID. Callers who are awaiting either replies or
  other messages are signalled appropriately via a semaphore. This allows
  multiplexing of both types of messages on the same socket.
2016-05-14 21:31:24 -04:00
Rene Gollent 493cced1ef libbnetapi: Add socket messenger class.
- Introduces new network API class BSocketMessenger, allowing one to send
  and receive BMessages across a network socket in a BMessenger-like
  fashion. Still very much WIP, hence currently not exposed via public headers.
  Based partly on previous work by Axel.
2016-04-30 18:32:50 -04:00
Michael Lotz 3b7b927dd0 libbnetapi: Add BNetworkRoute to replace use of route_entry.
The BNetworkRoute class manages a route_entry and the sockaddr's
associated with it. It replaces the direct use of route_entry in the
BNetworkInterface API.

Using route_entry is fragile and inconvenient as it only holds pointers
to the sockaddr's. When getting a list of routes from the kernel, each
route_entry is set up so that its pointers point into the single flat
buffer that is passed around. Creating a copy of the route_entry and
then deleting the flat buffer makes the pointers in the copy stale.
Returning these route entries therefore always lead to a use-after-free
when they were eventually used.

BNetworkRoute also takes over the code and functionallity of getting
routes from RouteSupport. The corresponding method in BNetworkRoster is
replaced by a static method in BNetworkRoute.

Also distinguish between the default route and gateway of an interface.
GetDefaultRoute() now gets the default BNetworkRoute for the interface
while GetDefaultGateway() gets the associated gateway address within
that default route. Adjust network preferences panel to this change.

Note that we currently only seem to have per interface default routes
and not an actual global default route. This was already the case before
these changes and I did not further investigate what this means.
2015-04-12 18:50:00 +02:00
Axel Dörfler c3ef93915b net_server: Clients can now check if a service is running.
* Using the new kMsgIsServiceRunning command.
2015-03-27 13:23:01 +01:00
Ingo Weinhold 6926863e37 DynamicBuffer::Write(): Fix return type and semantics 2014-07-03 17:39:58 +02:00
Ingo Weinhold 7616c39db6 DynamicBuffer: dos2unix 2014-07-03 17:39:57 +02:00
Ingo Weinhold 739f15e144 Revert "Revert "DynamicBuffer: implement BDataIO""
This reverts commit 747b401e87.
2014-07-03 17:39:57 +02:00
Ingo Weinhold 747b401e87 Revert "DynamicBuffer: implement BDataIO"
This reverts commit 36b1f55a18.
2014-06-18 22:13:39 +02:00
Ingo Weinhold a05da9f4b2 Revert "...and also fix a mismatched prototype"
This reverts commit 6555120f3b.
2014-06-18 22:13:38 +02:00
Adrien Destugues 6555120f3b ...and also fix a mismatched prototype
gcc2 doesn't seem to notice.
2014-02-11 13:26:32 +01:00
Adrien Destugues 36b1f55a18 DynamicBuffer: implement BDataIO
This makes it possible to use it with the ZlibDecompressor.
2014-02-11 12:06:41 +01:00
Adrien Destugues d417133ed2 Fix cookies with far expiration date.
Some websites set cookies expiring in the (not so) far future, after year 2038.
So, using time_t to store the cookie expiration date won't do. Use the
BDateTime class instead.

This makes goodsearch.com login work again (#10460).
2014-01-23 17:22:46 +01:00
Stefano Ceccherini 0bc615438a Style fixes.
Style fixes pointed out by Axel. I'm rusty, and it shows.
Hope I got it right.
Also moved get_route() into BPrivate.
2013-11-18 20:01:35 +01:00
Stefano Ceccherini 41d4206692 Added family parameter to the GetRoutes() API.
Moved common code to a private file.
2013-11-18 10:13:26 +01:00
Philippe Houdoin 1a84d6b362 Skip timeout computation in is_syscall_restarted case. 2013-05-04 11:27:04 +02:00
Axel Dörfler 4e78098e7c DatagramSocket: don't use absolute timeout 0.
* Use relative instead, or else the return value will be B_TIMED_OUT instead
  of B_WOULD_BLOCK.
* This fixes bug #9734.
2013-05-03 21:03:54 +02:00
Michael Lotz a9abcc37cd Rework initial auto joining and add big TODOs.
* If we have a configured network, then we always try to connect to it
  as soon as the interface has been brought up.
* If we don't have a configured network and are auto configuring, we
  use the AutoconfigLooper to also do initial auto joins.
* Before issuing auto joins we need to wait for scan results to come
  in, so we watch for corresponding messages.

For now auto joining is a one shot attempt as the infrastructure to
properly tell reasons for scans apart is not yet there.
2013-04-02 04:59:44 +02:00
Pawel Dziepak 7f61e6e4e5 Merge branch 'nfs4'
Conflicts:
	build/jam/HaikuImage
2013-03-11 13:00:55 +01:00
Pawel Dziepak 870528b799 nfs4: Fix gcc4 warnings 2012-08-16 03:41:29 +02:00
Alex Smith 6d796a84bd Fixed up network stack and drivers for x86_64.
* Various compilation fixes.
* Fixes to the FreeBSD compatibility layer (from comparing the x86-
  specific bits with the equivalent amd64 sources in FreeBSD).
* Compile all the Ethernet drivers except for sis900 and wb840, these
  require a bit more work to fix (will file a ticket soon). Tested
  ipro1000 and rtl81xx, no issues.
2012-08-10 14:30:54 +01:00
Pawel Dziepak 9054c96c17 Move parsing getattrinfo() result out of dns_resolver module 2012-07-05 01:25:17 +02:00
Pawel Dziepak 21769ef603 Add dns_resolver module
dns_resolver module provides a means for all kernel mode code to resolve
DNS hostnames.
2012-06-29 02:14:54 +02:00
Michael Lotz 7d7b963225 * Remove the BNetworkDevice::AddPersistentNetwork() again and instead introduce
BNetworkRoster::{Count|GetNext|Add|Remove}PersistentNetwork() as it fits
  better (thanks Philippe for the heads up).
* Implement the backend for these functions in the net_server and also move
  conversion of the wireless_network based format into the settings based format
  there.
* Implement removal of a network from the settings and make adding a new network
  with the same name replace the old one instead of just adding multiple ones.
  Might need to change this in the future depending on how we want to handle
  multiple networks with the same name (i.e. distinguish based on BSSID or
  similar).
* Fix apparent oversight that caused configured networks _not_ to be used in the
  auto join attempt.
* Remove auto joining open networks. I've been bitten by that more than once now
  because we happen to have an open network in the neighbourhood that I now
  accidentally used to transfer quite a bit of (unencrypted) stuff before
  noticing... In the future, one will instead have to explicitly join an open
  network once and store that config. Note that the driver will actually still
  auto-associate with open networks due to how things are set up currently.
  Note also that the auto join will fire join requests whenever there's a
  disassociation event, so you might see spurious join dialogs when the
  wpa_supplicant actually just re-establishes the connection.
* Make join requests async again. Instead of waiting for a synchronous reply of
  the wpa_supplicant we instead return success when the request has been sent.
  While the API call might still be made synchronous again in the future, the
  net_server should really not block on an external application. In the case of
  the wpa_supplicant we would otherwise deadlock when using the new
  *PersistentNetwork() API after a successful join, and in other cases we might
  just unacceptably delay other calls.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42816 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-09 19:56:19 +00:00
Michael Lotz 8fecaf03e3 Add message handling for adding persistent network configurations (as in
wireless_network).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42806 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-10-07 10:18:21 +00:00
Michael Lotz 4cde5cc228 * 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
2011-07-01 20:26:37 +00:00
Axel Dörfler 98e25dc3f9 * The net_server now tries to join the network via wpa_supplicant, if available.
* Add some output when automatically joining a network.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39851 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-12-14 20:22:18 +00:00
Axel Dörfler 60fed7e077 * Moved the shared part of NetServer.h into a new private header.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39597 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-11-23 21:44:37 +00:00
Philippe Houdoin 172971a18f Switch link speed unit to bit/s to support low bitrate speed too
(hello slow dialup line...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39581 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-11-23 13:35:30 +00:00
Axel Dörfler 4f1ec5b242 * Made bosii header self contained.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39390 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-11-10 21:54:47 +00:00
Stephan Aßmus 45939109b4 Patch done by Christophe Huriaux as part of GSoC 2010 "Services Kit" project:
Integrated the classes in the Network Kit (libbnetapi.so). Only the foundation
classed BUrl, BUrlContext, BNetworkCookie, BNetworkCookieJar and the private
HttpTime code is currently compiled. The BUrlProtocol currently contains some
misplaced BUrlProtocolHttp specific stuff, and the HTTP stuff itself has a
dependency on libcrypto and should live in an add-on instead. I've sprinkled
some TODOs in the code, and I've done some renaming compared to the last
version of the GSoC patch. Any help to bring this further along is appreciated.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39161 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-27 14:03:31 +00:00
Philippe Houdoin ed13a41e18 Fix the build, which was broken in r39147.
I hope I didn't overlap too much on your shoes, Axel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39155 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-10-26 10:24:17 +00:00
Axel Dörfler 89bf19ccde * Made an uint32 out of net_socket::bound_to_device.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38395 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-27 10:56:41 +00:00
Axel Dörfler 62d3dbd618 * Added a soon to be used index field.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38390 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-27 10:48:59 +00:00
Axel Dörfler db4015a5f8 * Work in progress of reworking the net80211 stack a bit, implementing some of
the missing notifications.
* Renamed ieee80211_haiku.c to .cpp, and made it compile (this part requires
  the updated GCC2, as it uses the ISO-C varargs macros).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38378 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-26 14:35:03 +00:00
Axel Dörfler ef3f86e723 * Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38364 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-26 09:16:18 +00:00
Axel Dörfler 4cd42050fa * Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38362 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-26 08:42:58 +00:00
Axel Dörfler 2b4154458a * Finished groundwork on ICMP by introducing a completely protocol agnostic
error mechanism.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37896 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-04 10:35:40 +00:00
Axel Dörfler 2b1c0755dd * Renamed the proprietary SIOC_* ioctls to B_SOCKET_* - no reason to pollute
global name space, and have ugly identifiers for nothing :-)
* Added a flags field to struct ifaliasreq. Added flags to mark an alias that
  is currently being configured, or has been automatically configured.
  Those flags aren't used yet, but they will replace IFF_CONFIGURING and
  friends.
* Implemented deleting addresses only from interfaces via ifconfig.
* Added more command aliases for delete to ifconfig ("del", and "delete", for
  more consistency with route).
* Fixed control_routes() to only release a reference to an address if it
  actually got one before.
* If an interface address is deleted, its routes are now removed as well.
* InterfaceAddress now holds a reference to its interface as planned.
* Implemented removing interfaces. Works quite nicely.
* When downing an interface, all of its routes are now removed. When upping
  it again, at least the default routes are added.
* datalink.cpp's get_interface_name_or_index() leaked a reference to the
  interface found.
* SIOCAIFADDR would also leak a reference when new addresses were added.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37872 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 15:51:54 +00:00
Axel Dörfler 2651e51d92 * Renamed net_datalink_module::send_data() to send_routed_data(), and
send_datagram() to send_data().
* Renamed DatagramSocket::SocketEnqueue() to EnqueueClone(), SocketDequeue()
  to Dequeue().
* Ordered the methods in ProtocolUtilities.h according to their declaration.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37870 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 12:00:06 +00:00
Axel Dörfler 03e02ed983 * Introduced a datalink layer (2) independent way of specifying the packet
type one wants to receive. Changed ipv6_datagram to use that (but note that
  it currently does not compile).
* Header cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37868 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 11:23:03 +00:00
Axel Dörfler 690acf8bd2 * Got rid of _SocketEnqueue().
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37867 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 11:19:22 +00:00
Axel Dörfler e4f401b349 * Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37866 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-03 11:18:52 +00:00
Axel Dörfler 61729d9323 * Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
  complete, though, InterfaceAddresses need to hold references to their
  interface as well).
* There are two known regressions of this commit that I will fix later:
  - you cannot remove interfaces anymore
  - IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
  not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
  the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
  is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
  set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
  available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
  anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
  belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-28 17:38:23 +00:00
Axel Dörfler b216fbd077 * Applied next work in progress patch by Atis that takes into account most of
my comments so far. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37793 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-28 17:09:12 +00:00
Axel Dörfler d62ee168ed * Corrected naming/visibility of the DatagramSocket methods (protected methods
do not get the '_' prefix, only private ones do).
* Added a "peek" argument to SocketStatus() (and generally renamed "clone" to
  "peek" where it made sense).
* Implemented the base version of SocketStatus() to return the actual socket
  error. This enables returning ICMP errors back to the socket user.
* Other minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37712 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-23 10:12:06 +00:00
Axel Dörfler 74a4c33fda * Implemented a way to preserve header data while passing along a buffer to the
upper layers: you use the store_header() function to mark the header you want
  to preserve. All subsequent remove_header() calls won't claim the actual
  data, but only move the node start around.
* This header can then be restored by restore_header(). However, a call to
  prepend_data() will destroy the stored header. Also, if remove_header() cuts
  off a whole node, restoring the header won't succeed anymore.
* Discarded the no longer needed net_buffer::network_header field.
* Also discarded the hoplimit field which temporarily breaks the IPv6 build
  until Atis reworks it.
* IPv4 now also dumps the IP header in the send path if debug output is enabled.
* icmp_error_reply() might be called so early that the net_buffer's addresses
  do not point to the reply address; this is now detected, and the addresses are
  taken out of the IP header in that case.
* Improved dumping the net_buffer to also include its address, and flags.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37688 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-22 12:26:46 +00:00
Axel Dörfler 68d1b69012 * Fixed broken decode function. I wonder how that one could have been missed
before...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37660 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-21 16:13:51 +00:00
Axel Dörfler 1978fb81ee * First part of ICMP support: this is based on the work by Ivo Vachkov (GSoC
2007), and Yin Qiu (GSoC 2008). And even though I needed to rewrite pretty
  much all of it because of the countless bugs and problems it had, it still
  shares the same architectural problems of introducing a domain dependent
  error mechanism to the upper layers, and needing the
  net_buffer::network_header hack. This I will rework later.
* net_buffer's append_size(), and prepend_size() will now gracefully handle
  buffers without a data node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37647 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-21 12:00:27 +00:00
Axel Dörfler f6a57629c3 * Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37646 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-21 11:23:42 +00:00
Axel Dörfler 866e21d3a6 * Moved DatagramSocket::Socket() up to its parent.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37645 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-21 11:22:54 +00:00