2006-08-08 17:07:07 +04:00
|
|
|
/*
|
2010-07-21 16:00:27 +04:00
|
|
|
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
|
2006-08-08 17:07:07 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef NET_BUFFER_H
|
|
|
|
#define NET_BUFFER_H
|
|
|
|
|
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
#include <sys/socket.h>
|
2006-08-08 17:07:07 +04:00
|
|
|
|
|
|
|
#include <module.h>
|
2010-08-03 15:23:03 +04:00
|
|
|
|
|
|
|
#include <util/list.h>
|
2006-08-08 17:07:07 +04:00
|
|
|
|
|
|
|
|
|
|
|
#define NET_BUFFER_MODULE_NAME "network/stack/buffer/v1"
|
|
|
|
|
2010-07-21 16:00:27 +04:00
|
|
|
|
2006-08-08 17:07:07 +04:00
|
|
|
typedef struct net_buffer {
|
2010-07-22 16:26:46 +04:00
|
|
|
struct list_link link;
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
struct sockaddr* source;
|
|
|
|
struct sockaddr* destination;
|
2010-08-26 13:16:18 +04:00
|
|
|
struct net_interface_address* interface_address;
|
2006-11-25 14:29:36 +03:00
|
|
|
union {
|
|
|
|
struct {
|
2010-07-22 16:26:46 +04:00
|
|
|
uint16 start;
|
|
|
|
uint16 end;
|
|
|
|
} fragment;
|
|
|
|
uint32 sequence;
|
|
|
|
uint32 offset;
|
2010-08-27 14:48:59 +04:00
|
|
|
uint32 index;
|
* 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 21:38:23 +04:00
|
|
|
int32 type;
|
2006-11-25 14:29:36 +03:00
|
|
|
};
|
2010-07-22 16:26:46 +04:00
|
|
|
uint32 flags;
|
|
|
|
uint32 size;
|
|
|
|
uint8 protocol;
|
2006-08-08 17:07:07 +04:00
|
|
|
} net_buffer;
|
|
|
|
|
2008-05-02 18:37:16 +04:00
|
|
|
struct ancillary_data_container;
|
2008-04-12 13:19:44 +04:00
|
|
|
|
2006-08-08 17:07:07 +04:00
|
|
|
struct net_buffer_module_info {
|
|
|
|
module_info info;
|
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
net_buffer* (*create)(size_t headerSpace);
|
|
|
|
void (*free)(net_buffer* buffer);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
net_buffer* (*duplicate)(net_buffer* from);
|
|
|
|
net_buffer* (*clone)(net_buffer* from, bool shareFreeSpace);
|
|
|
|
net_buffer* (*split)(net_buffer* from, uint32 offset);
|
|
|
|
status_t (*merge)(net_buffer* buffer, net_buffer* with, bool after);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*prepend_size)(net_buffer* buffer, size_t size,
|
|
|
|
void** _contiguousBuffer);
|
|
|
|
status_t (*prepend)(net_buffer* buffer, const void* data,
|
2006-08-08 17:07:07 +04:00
|
|
|
size_t bytes);
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*append_size)(net_buffer* buffer, size_t size,
|
|
|
|
void** _contiguousBuffer);
|
|
|
|
status_t (*append)(net_buffer* buffer, const void* data,
|
2006-08-08 17:07:07 +04:00
|
|
|
size_t bytes);
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*insert)(net_buffer* buffer, uint32 offset,
|
|
|
|
const void* data, size_t bytes, uint32 flags);
|
|
|
|
status_t (*remove)(net_buffer* buffer, uint32 offset,
|
2006-08-08 17:07:07 +04:00
|
|
|
size_t bytes);
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*remove_header)(net_buffer* buffer, size_t bytes);
|
|
|
|
status_t (*remove_trailer)(net_buffer* buffer, size_t bytes);
|
|
|
|
status_t (*trim)(net_buffer* buffer, size_t newSize);
|
|
|
|
status_t (*append_cloned)(net_buffer* buffer, net_buffer* source,
|
2006-11-25 17:30:54 +03:00
|
|
|
uint32 offset, size_t bytes);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*associate_data)(net_buffer* buffer, void* data);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
void (*set_ancillary_data)(net_buffer* buffer,
|
|
|
|
struct ancillary_data_container* container);
|
|
|
|
struct ancillary_data_container* (*get_ancillary_data)(net_buffer* buffer);
|
|
|
|
void* (*transfer_ancillary_data)(net_buffer* from,
|
|
|
|
net_buffer* to);
|
2008-04-12 13:19:44 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*store_header)(net_buffer* buffer);
|
|
|
|
ssize_t (*stored_header_length)(net_buffer* buffer);
|
|
|
|
status_t (*restore_header)(net_buffer* buffer, uint32 offset,
|
|
|
|
void* data, size_t bytes);
|
|
|
|
status_t (*append_restored_header)(net_buffer* buffer,
|
|
|
|
net_buffer* source, uint32 offset, size_t bytes);
|
|
|
|
|
|
|
|
status_t (*direct_access)(net_buffer* buffer, uint32 offset,
|
|
|
|
size_t bytes, void** _data);
|
|
|
|
status_t (*read)(net_buffer* buffer, uint32 offset, void* data,
|
2006-08-08 17:07:07 +04:00
|
|
|
size_t bytes);
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*write)(net_buffer* buffer, uint32 offset,
|
|
|
|
const void* data, size_t bytes);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
int32 (*checksum)(net_buffer* buffer, uint32 offset, size_t bytes,
|
2006-08-08 17:07:07 +04:00
|
|
|
bool finalize);
|
2010-07-22 16:26:46 +04:00
|
|
|
status_t (*get_memory_map)(net_buffer* buffer,
|
|
|
|
struct iovec* iovecs, uint32 vecCount);
|
|
|
|
uint32 (*get_iovecs)(net_buffer* buffer,
|
|
|
|
struct iovec* iovecs, uint32 vecCount);
|
|
|
|
uint32 (*count_iovecs)(net_buffer* buffer);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
void (*swap_addresses)(net_buffer* buffer);
|
2007-05-23 07:48:57 +04:00
|
|
|
|
2010-07-22 16:26:46 +04:00
|
|
|
void (*dump)(net_buffer* buffer);
|
2006-08-08 17:07:07 +04:00
|
|
|
};
|
|
|
|
|
2010-07-21 16:00:27 +04:00
|
|
|
|
2006-08-08 17:07:07 +04:00
|
|
|
#endif // NET_BUFFER_H
|