94185d21ca8ea53977e92085a0503b29270db105
[strongswan.git] / src / libcharon / network / socket_manager.h
1 /*
2 * Copyright (C) 2010 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 * Copyright (C) 2010 Martin Willi
5 * Copyright (C) 2010 revosec AG
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 socket_manager socket_manager
20 * @{ @ingroup network
21 */
22
23 #ifndef SOCKET_MANAGER_H_
24 #define SOCKET_MANAGER_H_
25
26 #include <network/socket.h>
27
28 typedef struct socket_manager_t socket_manager_t;
29
30 /**
31 * Handle pluggable socket implementations and send/receive packets through it.
32 */
33 struct socket_manager_t {
34
35 /**
36 * Receive a packet using the registered socket.
37 *
38 * @param packet allocated packet that has been received
39 * @return
40 * - SUCCESS when packet successfully received
41 * - FAILED when unable to receive
42 */
43 status_t (*receive) (socket_manager_t *this, packet_t **packet);
44
45 /**
46 * Send a packet using the registered socket.
47 *
48 * @param packet packet to send out
49 * @return
50 * - SUCCESS when packet successfully sent
51 * - FAILED when unable to send
52 */
53 status_t (*send) (socket_manager_t *this, packet_t *packet);
54
55 /**
56 * Register a socket constructor.
57 *
58 * @param create constructor for the socket
59 */
60 void (*add_socket)(socket_manager_t *this, socket_constructor_t create);
61
62 /**
63 * Unregister a registered socket constructor.
64 *
65 * @param create constructor for the socket
66 */
67 void (*remove_socket)(socket_manager_t *this, socket_constructor_t create);
68
69 /**
70 * Destroy a socket_manager_t.
71 */
72 void (*destroy)(socket_manager_t *this);
73 };
74
75 /**
76 * Create a socket_manager instance.
77 */
78 socket_manager_t *socket_manager_create();
79
80 #endif /** SOCKET_MANAGER_H_ @}*/