show kind of notify contained in messages in log
[strongswan.git] / src / charon / network / receiver.h
1 /**
2 * @file receiver.h
3 *
4 * @brief Interface of receiver_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2007 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
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 * @brief 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 * @b Constructors:
55 * - receiver_create()
56 *
57 * @ingroup network
58 */
59 struct receiver_t {
60
61 /**
62 * @brief Destroys a receiver_t object.
63 *
64 * @param receiver receiver object
65 */
66 void (*destroy) (receiver_t *receiver);
67 };
68
69 /**
70 * @brief Create a receiver_t object.
71 *
72 * The receiver thread will start working, get data
73 * from the socket and add those packets to the job queue.
74 *
75 * @return receiver_t object
76 *
77 * @ingroup network
78 */
79 receiver_t * receiver_create(void);
80
81 #endif /*RECEIVER_H_*/