2f1f627272a6946f46aa8ebc3a45123c7820cb57
2 * Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
3 * Copyright (C) 2005-2006 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, we currently
39 * do not support HASH_AND_URL certificates, so we require to transmit
40 * the full certificates. To run our multi-CA test with 2 intermediate CAs,
41 * 5000 bytes is sufficient.
43 #define MAX_PACKET 5000
46 * Abstraction of all sockets (IPv4/IPv6 send/receive).
48 * All available sockets are bound and the receive function
49 * reads from them. There are actually two implementations:
50 * The first uses raw sockets to allow binding of other daemons (pluto) to
51 * UDP/500. An installed "Linux socket filter" filters out all non-IKEv2
52 * traffic and handles just IKEv2 messages. An other daemon (pluto) must
53 * handle all traffic separately, e.g. ignore IKEv2 traffic, since charon
55 * The other implementation uses normal sockets and is built if
56 * --disable-pluto is given to the configure script.
63 * Reads a packet from the socket and sets source/dest
66 * @param packet pinter gets address from allocated packet_t
68 * - SUCCESS when packet successfully received
69 * - FAILED when unable to receive
71 status_t (*receive
) (socket_t
*this, packet_t
**packet
);
76 * Sends a packet to the net using destination from the packet.
77 * Packet is sent using default routing mechanisms, thus the
78 * source address in packet is ignored.
80 * @param packet packet_t to send
82 * - SUCCESS when packet successfully sent
83 * - FAILED when unable to send
85 status_t (*send
) (socket_t
*this, packet_t
*packet
);
88 * Enumerate the underlying sockets.
90 * @return enumerator_t object
92 enumerator_t
*(*create_enumerator
) (socket_t
*this);
97 void (*destroy
) (socket_t
*this);
101 * Create a socket_t, which binds multiple sockets.
103 * @return socket_t object
105 socket_t
*socket_create();
107 #endif /*SOCKET_H_ @} */