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
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>.
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
21 * @defgroup socket socket
28 typedef struct socket_t socket_t
;
31 #include <network/packet.h>
32 #include <utils/host.h>
33 #include <utils/enumerator.h>
36 * Maximum size of a packet.
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.
41 #define MAX_PACKET 5000
44 * Abstraction of all sockets (IPv4/IPv6 send/receive).
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
53 * The other implementation uses normal sockets and is built if
54 * --disable-pluto is given to the configure script.
61 * Reads a packet from the socket and sets source/dest
64 * @param packet pinter gets address from allocated packet_t
66 * - SUCCESS when packet successfully received
67 * - FAILED when unable to receive
69 status_t (*receive
) (socket_t
*this, packet_t
**packet
);
74 * Sends a packet to the net using source and destination addresses of
77 * @param packet packet_t to send
79 * - SUCCESS when packet successfully sent
80 * - FAILED when unable to send
82 status_t (*send
) (socket_t
*this, packet_t
*packet
);
85 * Enumerate all underlying socket file descriptors.
87 * @return enumerator over (int fd, int family, int port)
89 enumerator_t
*(*create_enumerator
) (socket_t
*this);
94 void (*destroy
) (socket_t
*this);
98 * Create a socket_t, which binds multiple sockets.
100 * @return socket_t object
102 socket_t
*socket_create();
104 #endif /*SOCKET_H_ @} */