updated Doxyfile
[strongswan.git] / src / charon / network / receiver.h
1 /*
2 * Copyright (C) 2005-2007 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup receiver receiver
21 * @{ @ingroup network
22 */
23
24 #ifndef RECEIVER_H_
25 #define RECEIVER_H_
26
27 typedef struct receiver_t receiver_t;
28
29 #include <library.h>
30 #include <utils/host.h>
31
32 /**
33 * Receives packets from the socket and adds them to the job queue.
34 *
35 * The receiver starts a thread, wich reads on the blocking socket. A received
36 * packet is preparsed and a process_message_job is queued in the job queue.
37 *
38 * To endure DoS attacks, cookies are enabled when to many IKE_SAs are half
39 * open. The calculation of cookies is slightly different from the proposed
40 * method in RFC4306. We do not include a nonce, because we think the advantage
41 * we gain does not justify the overhead to parse the whole message.
42 * Instead of VersionIdOfSecret, we include a timestamp. This allows us to
43 * find out wich key was used for cookie creation. Further, we can set a
44 * lifetime for the cookie, which allows us to reuse the secret for a longer
45 * time.
46 * COOKIE = time | sha1( IPi | SPIi | time | secret )
47 *
48 * The secret is changed after a certain amount of cookies sent. The old
49 * secret is stored to allow a clean migration between secret changes.
50 *
51 * Further, the number of half-initiated IKE_SAs is limited per peer. This
52 * mades it impossible for a peer to flood the server with its real IP address.
53 */
54 struct receiver_t {
55
56 /**
57 * Destroys a receiver_t object.
58 */
59 void (*destroy) (receiver_t *receiver);
60 };
61
62 /**
63 * Create a receiver_t object.
64 *
65 * The receiver thread will start working, get data
66 * from the socket and add those packets to the job queue.
67 *
68 * @return receiver_t object, NULL if initialization fails
69 */
70 receiver_t * receiver_create(void);
71
72 #endif /** RECEIVER_H_ @}*/