moved interface enumeration code to socket, where it belongs
[strongswan.git] / src / charon / queues / send_queue.h
1 /**
2 * @file send_queue.h
3 *
4 * @brief Interface of send_queue_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24 #ifndef SEND_QUEUE_H_
25 #define SEND_QUEUE_H_
26
27 #include <types.h>
28 #include <network/packet.h>
29
30
31 typedef struct send_queue_t send_queue_t;
32
33 /**
34 * @brief The send queue stores packet for the sender_t instance.
35 *
36 * The sender_t will send them consequently over the wire.
37 * Although the send-queue is based on a linked_list_t
38 * all access functions are thread-save implemented.
39 *
40 * @b Constructors:
41 * - send_queue_create()
42 *
43 * @ingroup queues
44 */
45 struct send_queue_t {
46
47 /**
48 * @brief returns number of packets in queue
49 *
50 * @param send_queue_t calling object
51 * @param[out] count integer pointer to store the count in
52 * @returns number of items in queue
53 */
54 int (*get_count) (send_queue_t *send_queue);
55
56 /**
57 * @brief get the next packet from the queue.
58 *
59 * If the queue is empty, this function blocks until a packet can be returned.
60 *
61 * After using, the returned packet has to get destroyed by the caller.
62 *
63 * @param send_queue_t calling object
64 * @return next packet from the queue
65 */
66 packet_t *(*get) (send_queue_t *send_queue);
67
68 /**
69 * @brief adds a packet to the queue.
70 *
71 * This function is non blocking and adds a packet_t to the list.
72 * The specific packet object has to get destroyed by the thread which
73 * removes the packet.
74 *
75 * @param send_queue_t calling object
76 * @param packet packet_t to add to the queue (packet is not copied)
77 */
78 void (*add) (send_queue_t *send_queue, packet_t *packet);
79
80 /**
81 * @brief destroys a send_queue object.
82 *
83 * @warning The caller of this function has to make sure
84 * that no thread is going to add or get a packet from the send_queue
85 * after calling this function.
86 *
87 * @param send_queue_t calling object
88 */
89 void (*destroy) (send_queue_t *send_queue);
90 };
91
92 /**
93 * @brief Creates an empty send_queue_t.
94 *
95 * @return send_queue_t object
96 *
97 * @ingroup queues
98 */
99 send_queue_t *send_queue_create(void);
100
101 #endif /*SEND_QUEUE_H_*/