Commit Graph

148 Commits

Author SHA1 Message Date
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
Axel Dörfler e67cf5815b * Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25738 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-31 12:04:09 +00:00
Ingo Weinhold 2b07b8e0f1 * Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25690 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-29 02:08:23 +00:00
Stephan Aßmus ae6b38b83e Patch by Andreas Faerber:
* Added "struct" to ancillary_data_container which fixes the build of the
  Bluetooth h2generic driver.
---
* Updated license header.
* Honour 80 char line width.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25606 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-22 11:59:26 +00:00
Ingo Weinhold 07ddcd64cf * Renamed libnetapi to libbnetapi. Create a symlink in the image.
* Extended R5 compatibility check to also consider calls from
  libbnetapi.
* Fixed incorrect R5 compatibility check in BNetEndpoint constructor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25489 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-14 13:49:48 +00:00
Ingo Weinhold cdc00dadfc * Added optional {send,read}_data_no_buffer() hooks to the protocol
module interface. They directly operate on iovecs and thus allow
  protocols that don't need it to avoid the creation of a net_buffer.
* Adjusted the socket module to support the new hooks. If they are
  present, they will be chosen over the old hooks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25299 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-03 01:11:21 +00:00
Ingo Weinhold 49e00d1f99 Moved the container management for ancillary data from the net_buffer
module to the stack module. There's a dedicated struct
ancillary_data_container, now. One can just set the container on a
net_buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25292 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-02 14:37:16 +00:00
Axel Dörfler 45e95a057f * Removed the old net_stack driver code, and the kernel socket interface.
* Also removed the header files that belong to those files.
* Only kept the userland_ipc.h header for now, to remember us about the
  former userland server driver (that I also removed - it can always be
  resurrected from SVN if needed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25045 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-19 12:42:25 +00:00
Ingo Weinhold 97cdbb548e Added support for sending/receiving ancillary data. The protocol modules
have two more optional hooks for attaching supplied ancillary data to a
net_buffer and for processing received ancillary data. Not sure, if that
is flexible enough for all kinds of ancillary data, but it is for
SCM_RIGHTS and also should for SCM_CRED[ENTIAL]S (if we ever decide to
implement one of those) -- don't know any other types on other protocol
levels.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24941 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-12 09:28:05 +00:00
Ingo Weinhold 62d7da1f45 Added support for attaching ancillary data to a net_buffer. It's a naive
implementation ATM, since it malloc()s the required memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24940 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-12 09:19:44 +00:00
Ingo Weinhold 75015ff525 * Renamed THREAD_FLAGS_IOCTL_SYSCALL to THREAD_FLAGS_SYSCALL,
syscall_restart_ioctl_is_restarted() to syscall_restart_is_restarted,
  IoctlSyscallFlagUnsetter to SyscallFlagUnsetter, and
  IoctlSyscallRestartWrapper to SyscallRestartWrapper, as they are no
  longer only used for ioctl().
* Removed unused syscall_restart_ioctl_handle_post().
* Made SyscallRestartWrapper a lot fancier. Instead of storing a
  reference to the result value, it stores the value itself, and it
  features all the interesting operators that make it appear like that
  value. This simplifies the use of the class quite a bit.
* THREAD_FLAGS_SYSCALL is now set for all socket function and the
  read[v](), write[v]() syscalls.
* Added is_syscall() function and net_stack hook to the net stack.
* Removed "kernel" parameter from all net_stack_interface and net_socket
  module hooks. They aren't need any longer, since is_syscall() can be
  used instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24914 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-11 16:13:47 +00:00
Ingo Weinhold df50f7a9b4 * Changed the way the socket functions work:
- The net_stack driver is no longer used. Instead we have a kernel
    module which is directly used by syscall implementations in the
    kernel. I.e. we no longer tunnel those functions through ioctls, but
    have normal syscalls.
  - Removed the superfluous net starter module.
  - Implemented the FDTYPE_SOCKET type file_descriptors, that is sockets
    are no longer vnode based.
  - Adjusted libnetwork (the socket function implementations)
    accordingly.
  - Adjusted netstat accordingly.
* Socket module:
  - Implemented socketpair().
  - Added "kernel" parameter to the control hook. Quite a few more hooks
    would actually need the parameter, but I didn't change those yet,
    since that would probably also require changes to the protocol
    module interface.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24908 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-11 04:12:23 +00:00
Axel Dörfler b5a5aebc90 * Added a set_to_defaults() function to the address module: it can be used
to retrieve the default settings for the netmask/broadcast depending on the
  specified address/netmask.
* interface_protocol_control() now uses this to reset the broadcast/netmask
  to their default values on SIOCSIFADDR resp. the former only on
  SIOCSIFNETMASK.
* This fixes bug #1861.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24170 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-28 15:43:27 +00:00
Ingo Weinhold 058494285a axeld + bonefish:
* Added syscall restart support for connect(), accept(), send(), recv(),
  which are implemented via ioctl()s. The actual restart support is done
  in the net stack driver's ioctl() hook. Lower layers need to correctly
  deal with socket timeouts, though, for which the stack module provides
  support functions.
* TCPEndpoint::_WaitForEstablished() does abort now when an error
  occurred earlier, so that trying to connect to an unused port fails
  immediately, as it should.
* Fixed and refactored TCP connection reset handling. The new
  TCPEndpoint::_HandleReset() does the job. Got rid of
  TCPEndpoint::fError.
* Fixed sequence numbers for SYNC/FINI packets.
* The former two fix the problem that connections wouldn't be closed
  correctly and could even be reused when trying to connect again (as
  was reproducible with svnserve + svn).
* Some style cleanup in CPEndpoint.h.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23984 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-17 16:25:07 +00:00
Axel Dörfler 6f58064f10 * Added flags field in net_protocol_module_info; there is currently a single
defined flag: NET_PROTOCOL_ATOMIC_MESSAGES.
* socket_send() now honours NET_PROTOCOL_ATOMIC_MESSAGES and returns either
  EMSGSIZE if the data to be send is larger than net_socket::send::buffer_size,
  or divides the data in appropriately sized chunks.
* This fixes sending >=64K over a TCP socket at once (TCP would just have
  returned an error in that case).
* TCP now overrides the default send buffer size (to 32768 for now).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23915 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-07 15:09:19 +00:00
Axel Dörfler 15ab0bcf01 * int32_t, uint32_t are now of type "int", and no longer of type "long".
This should help to reduce the number of warnings imported code will throw
  during compilation (helps a lot with tcpdump, for example).
* Since long is 64 bit on 64 bit platforms, we might want to think about doing
  that change for the Haiku types int32 and uint32 as well.
* Fixed several occurences of hidden type problems.
* Fixed build of the stack and TCP under BeOS.
* Fixed incorrect typedef in socket_interface.h.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22643 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-10-21 20:10:43 +00:00
Hugo Santos 77bf99deb0 fixed the way accept() works in regards to the cookie pointer. It is no longer visible to userspace, we pass the fd instead. Also renamed kernel's shutdown() to system_shutdown as it collides with Posix's shutdown().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21223 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-23 19:56:40 +00:00
Hugo Santos 969885b848 loop: no longer requires a reader thread, it delivers directly to the device's receive queue
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21215 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-23 07:56:15 +00:00
Hugo Santos a1deb55ef5 net_interface_private: added receive queue and splited device reading from packet processing. Delivering to self no longer is executed in the sender's context, which had some problems with TCP's locking.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21214 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-23 07:55:54 +00:00
Hugo Santos d3d38faf41 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
2007-05-23 03:48:57 +00:00
Hugo Santos 79a0d25245 net_buffer: preparing for better metadata management
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21210 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-23 03:48:23 +00:00
Axel Dörfler 8c40c83fa1 Renamed net_device::{add|rem}_multi() to {add|remove}_multicast for consistency and clarity.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21008 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-04 06:57:26 +00:00
Hugo Santos 6d043beb03 freebsd compat. layer: added mii placeholders, callout implementation.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21006 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-03 21:18:21 +00:00