Commit Graph

170 Commits

Author SHA1 Message Date
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
Axel Dörfler 8d1485fa06 Work in progress commit by Atis Elsts (I'm posting his ChangeLog comments
directly here), I made only a few style changes:
* introduced 'has_broadcast_address' field in
struct net_address_module_info
 - REVIEW: the name, and the status of this field for UNIX and L2CAP
	families
* ipv6 address family support
* ipv6 address printing	
* ipv6 protocol support	
* ipv6 multicast support
  - TODO: add and remove multicast routes in a more proper way
  - TODO: support MLD
* ipv6 datalink protocol support
* icmpv6 protocol support (EchoRequest and EchoResponse messages)
* ipv6 neigbor discovery protocol support
  (Advertisement and Solicitation messages)
  - TODO: only the very basic support is present,
	the protocol state machine is by no means completed
  - TODO: replying to Solicitation does not work too good ATM
	(visible, when pinging Haiku from outside)
* added Jenkin's hash algorith
* minor changes in existing IPv4 code - cleanup function
	ipv4_get_loopback_address(), written by myself
* add tests: raw, udp, tcp/udp, mullicast sender
* add 'hoplimit' field in struct net_buffer
  - TODO: this is just a hack, more generic approach would be  better.
* add 'receive_data' function pointer in
	struct net_datalink_protocol_module_info
  - TODO: this is also more like a hack, to support information
	passing from ICMPv6 to IPv6_datagram level.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37604 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-19 16:55:55 +00:00
Oliver Tappe ab1a4bef4f cleaning up after myself 4 years later:
* remove matches_broadcast_address slot in address module, as it
  doesn't exist anywhere
* automatic whitespace cleanup



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36193 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 19:06:46 +00:00
Oliver Tappe 56f097ebd9 Applying patch by Atis Elsts:
* fix connecting to INADDR_ANY work for tcp (effectively will
  connect to INADDR_LOOPBACK)
* add same behaviour to udp
* move some ipv4-specific code out of tcp into ipv4 address module
* bind() and connect() now reject addresses from non-matching 
  families
* myself: minor cleanup in udp.cpp with respect to 80 chars limit
Closes #5716 - many thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36192 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-04-12 18:39:34 +00:00
Axel Dörfler 751ce9e228 * Removed the interface fallback from the datalink module's is_local_address().
* Instead, added a new function is_local_link_address() which returns the
  interface with the matching link level address, and can additionally test
  for unconfigured interfaces.
* Merged the two versions of fill_sockaddr_in() together in ipv4.cpp.
* ipv4 now uses the new is_local_link_address() function to figure out whether
  the received packet should be processed or not. This should fix a few DHCP
  issues with multiple and configured interfaces as recently explained on the
  mailing list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34466 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-12-03 14:31:39 +00:00
Colin Günther 53b11310d4 Needed header to allow compilation of the wlan stack.
Bosii is a transcription of 802.11. It is a work-in-progress title to
point out parts of the wlan stack which are still in an experimental state.
For example the control codes within bosii_driver.h are moving targets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34349 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-11-29 18:09:33 +00:00
Michael Lotz b78c74fdc4 Fix GCC4 build. Duplicate parameter names generate a warning there.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31599 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-15 23:38:15 +00:00
Axel Dörfler 78888c44da Applied patch by Ma Jie adding functionality needed by mDNSResponder:
* added new protocol method process_ancillary_data_no_container() that does not
  need a container to fill the cmsghdr data.
* Added support for the IP_RECVDSTADDR option using this call.
* Implemented support for IP_MULTICAST_IF.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31585 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-15 11:53:29 +00:00
Axel Dörfler 65b5dd5064 * DatagramSocket::InitCheck() returned the sem_id instead of a status_t, causing
pings to fail (raw socket initialization) after r31079.
* Further cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31238 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-06-25 16:01:11 +00:00
Axel Dörfler 6f440aed2c * net_socket_module_info::acquire_socket() now returns whether or not the
socket could be acquired, ie. when its reference count is 0, it cannot be
  acquired anymore. This requires the protocol to do proper locking, though.
* The TCP EndpointManager now checks the return value of acquire_socket(), and
  only returns the endpoint if that succeeded.
* This fixes bug #2197.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30363 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-24 10:12:30 +00:00
Axel Dörfler 1111232758 * Sockets now inherit from WeakReferenceable.
* This fixes the problem when a socket changes something with regards to its
  parent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30000 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-04-07 16:07:15 +00:00
Bruno G. Albuquerque ef93221da6 - Now NetBuffer and DynamicBuffer agree and the smallest buffer size posible.
- This means that buffers with a initial size of 0 work now.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29006 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-01-24 23:42:43 +00:00
Bruno G. Albuquerque a12096e5c7 - Got it to actually compile.
- Default buffer size is now set to 1 instead of 0, which would cause the
  construction without a given size to fail.
- Added copy constructor.
- Changed _GrowToFit() to have a boolean parameter to indicate if we want
  to resize the buffer to an exact size. Used by the copy constructor. 



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28924 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-01-17 15:56:40 +00:00
Bruno G. Albuquerque c98ce75f21 - Fixed style violations pointed by stippi.
- Use std:nothrow for new calls.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28919 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-01-17 14:01:22 +00:00
Bruno G. Albuquerque 550d24175f - Simple dynamic buffer class implementation.
- Will be used by the new (R5 compatible) NetBuffer class.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28918 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-01-17 13:30:21 +00:00
Axel Dörfler d68ffdedc0 * More or less completed the network notification module - it does not remove
old invalid user listeners yet, though (ie. if a team dies).
* Implemented userland network monitor functions.
* Added a few notifications to the network stack, even though this part isn't
  complete yet (especially notify_interface_changed()).
* Added optional debug output to the notifications module.
* Added the module to the image, it basically works now (tested).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28825 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-12-27 20:48:28 +00:00
Rene Gollent eaed962ce9 send_notification needs to return a status_t, otherwise the build breaks in the notifications module.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28795 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-12-10 01:06:50 +00:00
Axel Dörfler e6dd439f7c * Work-in-progress of a network notification implementation.
* Compiles, but doesn't work at all yet. For those who wonder: the networking
  notifications are put into a separate module, so that the network stack can
  be unloaded without losing connection, IOW user applications will continue
  to retrieve notifications when the stack is loaded again.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28790 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-12-09 23:16:10 +00:00
Axel Dörfler 27e0dea9f0 * Actually implemented the SO_BINDTODEVICE socket option I added some time ago.
* This makes it possible to select a specific device, even if no interface
  has been configured for it yet. To make it work, each interface now has a
  private direct route which will be returned if a socket is bound to a device.
* This will be used for example in DHCP to make it work when more than one
  adapter is attached.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27983 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-10-11 22:10:31 +00:00
Oliver Tappe c4c2a6192d * we no longer demand the socket that receives a broadcast
datagram to have the SO_BROADCAST flags set (the flag
  is only needed for sending a broadcast) - fixes part of 
  #2065 

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27973 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-10-11 17:28:57 +00:00
Axel Dörfler 491da20dbf * Added a is_timer_running() function.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27631 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-09-19 09:11:12 +00:00
Axel Dörfler 8f3c0d9fcc * wait_for_timer() now returns a status code.
* wait_for_timer() now detects if it has been called from within the timer
  execution thread, and will return in error instead of waiting for itself
  forever. This fixes bug #2682.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27620 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-09-18 12:45:43 +00:00
Axel Dörfler 9e8be8bb9c * Added a net_timer::flags field, and used it to implement the new
wait_for_timer() function.
* Moved the internal Fifo class into utility.cpp - we should probably just
  remove it again.
* Fixed uninit_timers() so that it would even work in combination with the
  timer thread if there are timers left to be scheduled.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26980 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-08-15 14:46:16 +00:00
François Revol 3594171541 This weren't typedefed, using them without struct is invalid in C.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26412 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-07-14 18:47:02 +00:00
Oliver Tappe aebcc506e2 Corrected by previous assumption, since gethostbyname() has nothing to do with
struct sockaddr_in - the real culprits were BNetAddress::GetAddr(sockaddr_in&)
and BNetAddress::SetTo(const sockaddr_in&):
* moved check_r5_compatibility() into r5_compatibility.h to make that function
  available to BNetAddress, too
* adjusted sockaddr_in-handling methods of BNetAddress to deal with R5-addresses
  if in compatibility mode
* removed is_r5_sockaddr() again, since it is no longer needed

With this less hacky solution, Beam, NetPositive, NetworkTime and Vision still work. So, there's hope that the R5 compatibility layer is now complete.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26377 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-07-10 21:25:19 +00:00