2006-08-08 13:07:07 +00:00
|
|
|
/*
|
2010-07-21 12:00:27 +00:00
|
|
|
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
|
2006-08-08 13:07:07 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef NET_BUFFER_H
|
|
|
|
#define NET_BUFFER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <util/list.h>
|
|
|
|
|
|
|
|
#include <module.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define NET_BUFFER_MODULE_NAME "network/stack/buffer/v1"
|
|
|
|
|
2010-07-21 12:00:27 +00:00
|
|
|
|
2006-08-08 13:07:07 +00:00
|
|
|
typedef struct net_buffer {
|
|
|
|
struct list_link link;
|
|
|
|
|
2008-05-22 11:59:26 +00:00
|
|
|
// 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...
|
2007-05-23 03:48:23 +00:00
|
|
|
|
|
|
|
struct sockaddr *source;
|
|
|
|
struct sockaddr *destination;
|
2006-08-08 13:07:07 +00:00
|
|
|
struct net_interface *interface;
|
2007-05-23 07:55:54 +00:00
|
|
|
int32 type;
|
2006-11-25 11:29:36 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint16 start;
|
|
|
|
uint16 end;
|
|
|
|
} fragment;
|
|
|
|
uint32 sequence;
|
|
|
|
uint32 offset;
|
|
|
|
};
|
2006-08-08 13:07:07 +00:00
|
|
|
uint32 flags;
|
|
|
|
uint32 size;
|
|
|
|
uint8 protocol;
|
2010-07-21 12:00:27 +00:00
|
|
|
|
|
|
|
// TODO: these two should go away again
|
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
|
|
|
uint8 hoplimit;
|
2010-07-21 12:00:27 +00:00
|
|
|
void * network_header;
|
2006-08-08 13:07:07 +00:00
|
|
|
} net_buffer;
|
|
|
|
|
2008-05-02 14:37:16 +00:00
|
|
|
struct ancillary_data_container;
|
2008-04-12 09:19:44 +00:00
|
|
|
|
2006-08-08 13:07:07 +00:00
|
|
|
struct net_buffer_module_info {
|
|
|
|
module_info info;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
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);
|
2006-11-25 14:30:54 +00:00
|
|
|
status_t (*append_cloned)(net_buffer *buffer, net_buffer *source,
|
|
|
|
uint32 offset, size_t bytes);
|
2006-08-08 13:07:07 +00:00
|
|
|
|
|
|
|
status_t (*associate_data)(net_buffer *buffer, void *data);
|
|
|
|
|
2008-05-02 14:37:16 +00:00
|
|
|
void (*set_ancillary_data)(net_buffer *buffer,
|
2008-05-22 11:59:26 +00:00
|
|
|
struct ancillary_data_container *container);
|
|
|
|
struct ancillary_data_container* (*get_ancillary_data)(net_buffer *buffer);
|
2008-04-12 09:19:44 +00:00
|
|
|
void * (*transfer_ancillary_data)(net_buffer *from,
|
|
|
|
net_buffer *to);
|
|
|
|
|
2006-08-08 13:07:07 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2007-05-23 03:48:57 +00:00
|
|
|
void (*swap_addresses)(net_buffer *buffer);
|
|
|
|
|
2006-08-08 13:07:07 +00:00
|
|
|
void (*dump)(net_buffer *buffer);
|
|
|
|
};
|
|
|
|
|
2010-07-21 12:00:27 +00:00
|
|
|
|
2006-08-08 13:07:07 +00:00
|
|
|
#endif // NET_BUFFER_H
|