2 * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
9 #include <sys/socket.h>
13 #include <util/list.h>
16 #define NET_BUFFER_MODULE_NAME "network/stack/buffer/v1"
19 typedef struct net_buffer
{
20 struct list_link link
;
22 struct sockaddr
* source
;
23 struct sockaddr
* destination
;
24 struct net_interface_address
* interface_address
;
40 struct ancillary_data_container
;
42 struct net_buffer_module_info
{
45 net_buffer
* (*create
)(size_t headerSpace
);
46 void (*free
)(net_buffer
* buffer
);
48 net_buffer
* (*duplicate
)(net_buffer
* from
);
49 net_buffer
* (*clone
)(net_buffer
* from
, bool shareFreeSpace
);
50 net_buffer
* (*split
)(net_buffer
* from
, uint32 offset
);
51 status_t (*merge
)(net_buffer
* buffer
, net_buffer
* with
, bool after
);
53 status_t (*prepend_size
)(net_buffer
* buffer
, size_t size
,
54 void** _contiguousBuffer
);
55 status_t (*prepend
)(net_buffer
* buffer
, const void* data
,
57 status_t (*append_size
)(net_buffer
* buffer
, size_t size
,
58 void** _contiguousBuffer
);
59 status_t (*append
)(net_buffer
* buffer
, const void* data
,
61 status_t (*insert
)(net_buffer
* buffer
, uint32 offset
,
62 const void* data
, size_t bytes
, uint32 flags
);
63 status_t (*remove
)(net_buffer
* buffer
, uint32 offset
,
65 status_t (*remove_header
)(net_buffer
* buffer
, size_t bytes
);
66 status_t (*remove_trailer
)(net_buffer
* buffer
, size_t bytes
);
67 status_t (*trim
)(net_buffer
* buffer
, size_t newSize
);
68 status_t (*append_cloned
)(net_buffer
* buffer
, net_buffer
* source
,
69 uint32 offset
, size_t bytes
);
71 status_t (*associate_data
)(net_buffer
* buffer
, void* data
);
73 void (*set_ancillary_data
)(net_buffer
* buffer
,
74 struct ancillary_data_container
* container
);
75 struct ancillary_data_container
* (*get_ancillary_data
)(net_buffer
* buffer
);
76 void* (*transfer_ancillary_data
)(net_buffer
* from
,
79 status_t (*store_header
)(net_buffer
* buffer
);
80 ssize_t (*stored_header_length
)(net_buffer
* buffer
);
81 status_t (*restore_header
)(net_buffer
* buffer
, uint32 offset
,
82 void* data
, size_t bytes
);
83 status_t (*append_restored_header
)(net_buffer
* buffer
,
84 net_buffer
* source
, uint32 offset
, size_t bytes
);
86 status_t (*direct_access
)(net_buffer
* buffer
, uint32 offset
,
87 size_t bytes
, void** _data
);
88 status_t (*read
)(net_buffer
* buffer
, size_t offset
, void* data
,
90 status_t (*write
)(net_buffer
* buffer
, size_t offset
,
91 const void* data
, size_t bytes
);
93 int32 (*checksum
)(net_buffer
* buffer
, uint32 offset
, size_t bytes
,
95 status_t (*get_memory_map
)(net_buffer
* buffer
,
96 struct iovec
* iovecs
, uint32 vecCount
);
97 uint32 (*get_iovecs
)(net_buffer
* buffer
,
98 struct iovec
* iovecs
, uint32 vecCount
);
99 uint32 (*count_iovecs
)(net_buffer
* buffer
);
101 void (*swap_addresses
)(net_buffer
* buffer
);
103 void (*dump
)(net_buffer
* buffer
);
107 #endif // NET_BUFFER_H