updated Doxyfile
[strongswan.git] / src / charon / network / socket.h
1 /*
2 * Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
3 * Copyright (C) 2005-2008 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 * $Id$
18 */
19
20 /**
21 * @defgroup socket socket
22 * @{ @ingroup network
23 */
24
25 #ifndef SOCKET_H_
26 #define SOCKET_H_
27
28 typedef struct socket_t socket_t;
29
30 #include <library.h>
31 #include <network/packet.h>
32 #include <utils/host.h>
33 #include <utils/enumerator.h>
34
35 /**
36 * Maximum size of a packet.
37 *
38 * 3000 Bytes should be sufficient, see IKEv2 RFC. However, to run our
39 * multi-CA test with 2 intermediate CAs, we increase that to 5000 bytes.
40 */
41 #define MAX_PACKET 5000
42
43 /**
44 * Abstraction of all sockets (IPv4/IPv6 send/receive).
45 *
46 * All available sockets are bound and the receive function
47 * reads from them. There are actually two implementations:
48 * The first uses raw sockets to allow binding of other daemons (pluto) to
49 * UDP/500. An installed "Linux socket filter" filters out all non-IKEv2
50 * traffic and handles just IKEv2 messages. An other daemon (pluto) must
51 * handle all traffic separately, e.g. ignore IKEv2 traffic, since charon
52 * handles that.
53 * The other implementation uses normal sockets and is built if
54 * --disable-pluto is given to the configure script.
55 */
56 struct socket_t {
57
58 /**
59 * Receive a packet.
60 *
61 * Reads a packet from the socket and sets source/dest
62 * appropriately.
63 *
64 * @param packet pinter gets address from allocated packet_t
65 * @return
66 * - SUCCESS when packet successfully received
67 * - FAILED when unable to receive
68 */
69 status_t (*receive) (socket_t *this, packet_t **packet);
70
71 /**
72 * Send a packet.
73 *
74 * Sends a packet to the net using source and destination addresses of
75 * the packet.
76 *
77 * @param packet packet_t to send
78 * @return
79 * - SUCCESS when packet successfully sent
80 * - FAILED when unable to send
81 */
82 status_t (*send) (socket_t *this, packet_t *packet);
83
84 /**
85 * Enumerate all underlying socket file descriptors.
86 *
87 * @return enumerator over (int fd, int family, int port)
88 */
89 enumerator_t *(*create_enumerator) (socket_t *this);
90
91 /**
92 * Destroy socket.
93 */
94 void (*destroy) (socket_t *this);
95 };
96
97 /**
98 * Create a socket_t, which binds multiple sockets.
99 *
100 * @return socket_t object
101 */
102 socket_t *socket_create();
103
104 #endif /** SOCKET_H_ @}*/