Commit Graph

134 Commits

Author SHA1 Message Date
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
Hugo Santos 954038303d added add_multi/rem_multi to net_devices. Glued the interface protocol multicast handling with net_device via add_multi/rem_multi.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20947 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-01 12:26:03 +00:00
Hugo Santos 1a41adbcd2 added join_multicast/leave_multicast to datalink protocols, preparing for full multicast support.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20944 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-01 11:38:39 +00:00
Hugo Santos 73f1548be1 some getsockopt/setsockopt and multicast fixes.
* allow an ipv4 bind() to a multicast address.
 * bumped getsockopt/setsockopt kernel driver buffers to 256 bytes to at least handle structures which take one sockaddr_storage.
 * convert generic multicast delta API names to IPv4 ones before handling the specific option.
 * changed ipv4_getsockopt/ipv4_setsockopt a bit as the code gcc 2.95 was generating was a bit too funky.
 * properly pass setsockopt/getsockopt to handling protocols.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20939 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-30 19:42:12 +00:00
Hugo Santos cf5d9f4b8d added 'udp_endpoints' debugger command.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20908 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-29 19:03:06 +00:00
Hugo Santos 4e8a1b331f miniature cleanups.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20874 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-28 09:37:26 +00:00
Hugo Santos 5084c83901 addressed Axel's suggestion regarding SocketAddress' GetPort() name.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20851 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-27 07:20:43 +00:00
Hugo Santos 25a2744f9e adapted UDP to use AddressUtilities, for readability.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20850 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-27 07:10:11 +00:00
Hugo Santos 4b55736dde added new helper ProtocolSocket. Moved some stuff together to achieve better inlining.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20848 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-27 07:09:46 +00:00
Hugo Santos 66a4a42802 added Recv-Q/Send-Q output to netstat.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20819 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-25 17:41:18 +00:00
Hugo Santos 585195c28d introduced SocketAddress wrappers and use them in TCP.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20818 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-25 17:41:01 +00:00
Hugo Santos 53f23f85a2 partially rewrote TCP's endpoint manager. Fixes #1173
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20814 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-25 16:14:14 +00:00
Hugo Santos 8a819b17e4 retrieve the incoming interface on the domain_receive_adapter(). This should fix potential issues with packets addressed to the IP broadcast address, such as in with some DHCP implementations.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20767 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-20 04:40:53 +00:00
Hugo Santos 74b0e85845 merged a bit more of functionality into DatagramSocket so we don't require a custom ReadData in the link protocol.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20765 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-20 02:13:54 +00:00
Hugo Santos 2445c00e64 some internal reorganization of getsockopt()/setsockopt() handling. TCP is now able to fully use the application requested sender/receiver buffer sizes for improved performance.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20764 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-20 01:58:14 +00:00