Moving charon to libcharon.
[strongswan.git] / src / libcharon / network / sender.h
1 /*
2 * Copyright (C) 2005-2007 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 /**
18 * @defgroup sender sender
19 * @{ @ingroup network
20 */
21
22 #ifndef SENDER_H_
23 #define SENDER_H_
24
25 typedef struct sender_t sender_t;
26
27 #include <library.h>
28 #include <network/packet.h>
29
30 /**
31 * Thread responsible for sending packets over the socket.
32 */
33 struct sender_t {
34
35 /**
36 * Send a packet over the network.
37 *
38 * This function is non blocking and adds the packet to a queue.
39 * Whenever the sender thread thinks it's good to send the packet,
40 * it'll do so.
41 *
42 * @param packet packet to send
43 */
44 void (*send) (sender_t *this, packet_t *packet);
45
46 /**
47 * Destroys a sender object.
48 */
49 void (*destroy) (sender_t *this);
50 };
51
52 /**
53 * Create the sender thread.
54 *
55 * The thread will start to work, getting packets
56 * from its queue and sends them out.
57 *
58 * @return created sender object
59 */
60 sender_t * sender_create(void);
61
62 #endif /** SENDER_H_ @}*/