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