2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef PACKET_BUFFER_H
6 #define PACKET_BUFFER_H
9 #include <KernelExport.h>
16 /** The idea behind this packet buffer is to have multi-threading safe
17 * implementation that can be used in interrupts on top of the
18 * ring_buffer implementation provided by the kernel.
19 * It uses a spinlock for synchronization.
21 * IOW if you don't have such high restrictions in your environment,
22 * you better don't want to use it at all.
24 struct packet_buffer
{
25 struct ring_buffer
* buffer
;
30 struct packet_buffer
* create_packet_buffer(size_t size
);
31 void delete_packet_buffer(struct packet_buffer
* buffer
);
33 void packet_buffer_clear(struct packet_buffer
* buffer
);
34 size_t packet_buffer_readable(struct packet_buffer
* buffer
);
35 size_t packet_buffer_writable(struct packet_buffer
*buffer
);
36 void packet_buffer_flush(struct packet_buffer
* buffer
, size_t bytes
);
37 size_t packet_buffer_read(struct packet_buffer
* buffer
, uint8
* data
, size_t
39 size_t packet_buffer_write(struct packet_buffer
* buffer
, const uint8
* data
,
42 #endif /* PACKET_BUFFER_H */