* 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
This commit is contained in:
@@ -16,31 +16,27 @@
|
||||
|
||||
|
||||
typedef struct net_buffer {
|
||||
struct list_link link;
|
||||
struct list_link link;
|
||||
|
||||
// TODO: we should think about moving the address fields into the buffer
|
||||
// data itself via associated data or something like this. Or this
|
||||
// structure as a whole, too...
|
||||
|
||||
struct sockaddr *source;
|
||||
struct sockaddr *destination;
|
||||
struct net_interface *interface;
|
||||
int32 type;
|
||||
struct sockaddr* source;
|
||||
struct sockaddr* destination;
|
||||
struct net_interface* interface;
|
||||
int32 type;
|
||||
union {
|
||||
struct {
|
||||
uint16 start;
|
||||
uint16 end;
|
||||
} fragment;
|
||||
uint32 sequence;
|
||||
uint32 offset;
|
||||
uint16 start;
|
||||
uint16 end;
|
||||
} fragment;
|
||||
uint32 sequence;
|
||||
uint32 offset;
|
||||
};
|
||||
uint32 flags;
|
||||
uint32 size;
|
||||
uint8 protocol;
|
||||
|
||||
// TODO: these two should go away again
|
||||
uint8 hoplimit;
|
||||
void * network_header;
|
||||
uint32 flags;
|
||||
uint32 size;
|
||||
uint8 protocol;
|
||||
} net_buffer;
|
||||
|
||||
struct ancillary_data_container;
|
||||
@@ -48,58 +44,65 @@ struct ancillary_data_container;
|
||||
struct net_buffer_module_info {
|
||||
module_info info;
|
||||
|
||||
net_buffer * (*create)(size_t headerSpace);
|
||||
void (*free)(net_buffer *buffer);
|
||||
net_buffer* (*create)(size_t headerSpace);
|
||||
void (*free)(net_buffer* buffer);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
status_t (*prepend_size)(net_buffer *buffer, size_t size,
|
||||
void **_contiguousBuffer);
|
||||
status_t (*prepend)(net_buffer *buffer, const void *data,
|
||||
status_t (*prepend_size)(net_buffer* buffer, size_t size,
|
||||
void** _contiguousBuffer);
|
||||
status_t (*prepend)(net_buffer* buffer, const void* data,
|
||||
size_t bytes);
|
||||
status_t (*append_size)(net_buffer *buffer, size_t size,
|
||||
void **_contiguousBuffer);
|
||||
status_t (*append)(net_buffer *buffer, const void *data,
|
||||
status_t (*append_size)(net_buffer* buffer, size_t size,
|
||||
void** _contiguousBuffer);
|
||||
status_t (*append)(net_buffer* buffer, const void* data,
|
||||
size_t bytes);
|
||||
status_t (*insert)(net_buffer *buffer, uint32 offset,
|
||||
const void *data, size_t bytes, uint32 flags);
|
||||
status_t (*remove)(net_buffer *buffer, uint32 offset,
|
||||
status_t (*insert)(net_buffer* buffer, uint32 offset,
|
||||
const void* data, size_t bytes, uint32 flags);
|
||||
status_t (*remove)(net_buffer* buffer, uint32 offset,
|
||||
size_t bytes);
|
||||
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,
|
||||
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,
|
||||
uint32 offset, size_t bytes);
|
||||
|
||||
status_t (*associate_data)(net_buffer *buffer, void *data);
|
||||
status_t (*associate_data)(net_buffer* buffer, void* data);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
status_t (*direct_access)(net_buffer *buffer, uint32 offset,
|
||||
size_t bytes, void **_data);
|
||||
status_t (*read)(net_buffer *buffer, uint32 offset, void *data,
|
||||
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,
|
||||
size_t bytes);
|
||||
status_t (*write)(net_buffer *buffer, uint32 offset,
|
||||
const void *data, size_t bytes);
|
||||
status_t (*write)(net_buffer* buffer, uint32 offset,
|
||||
const void* data, size_t bytes);
|
||||
|
||||
int32 (*checksum)(net_buffer *buffer, uint32 offset, size_t bytes,
|
||||
int32 (*checksum)(net_buffer* buffer, uint32 offset, size_t bytes,
|
||||
bool finalize);
|
||||
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);
|
||||
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);
|
||||
|
||||
void (*swap_addresses)(net_buffer *buffer);
|
||||
void (*swap_addresses)(net_buffer* buffer);
|
||||
|
||||
void (*dump)(net_buffer *buffer);
|
||||
void (*dump)(net_buffer* buffer);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user