diff options
Diffstat (limited to 'src/cadet/gnunet-service-cadet_hello.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_hello.c | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/src/cadet/gnunet-service-cadet_hello.c b/src/cadet/gnunet-service-cadet_hello.c deleted file mode 100644 index c7857032b..000000000 --- a/src/cadet/gnunet-service-cadet_hello.c +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2014, 2017 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file cadet/gnunet-service-cadet_hello.c | ||
22 | * @brief spread knowledge about how to contact us (get HELLO from peerinfo), | ||
23 | * and remember HELLOs of other peers we have an interest in | ||
24 | * @author Bartlomiej Polot | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | |||
30 | #include "gnunet_statistics_service.h" | ||
31 | #include "gnunet_peerinfo_service.h" | ||
32 | #include "cadet_protocol.h" | ||
33 | #include "gnunet-service-cadet.h" | ||
34 | #include "gnunet-service-cadet_dht.h" | ||
35 | #include "gnunet-service-cadet_hello.h" | ||
36 | #include "gnunet-service-cadet_peer.h" | ||
37 | |||
38 | #define LOG(level, ...) GNUNET_log_from (level, "cadet-hll", __VA_ARGS__) | ||
39 | |||
40 | /** | ||
41 | * Hello message of local peer. | ||
42 | */ | ||
43 | static struct GNUNET_HELLO_Message *mine; | ||
44 | |||
45 | /** | ||
46 | * Handle to peerinfo service. | ||
47 | */ | ||
48 | static struct GNUNET_PEERINFO_Handle *peerinfo; | ||
49 | |||
50 | /** | ||
51 | * Iterator context. | ||
52 | */ | ||
53 | static struct GNUNET_PEERINFO_NotifyContext *nc; | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Process each hello message received from peerinfo. | ||
58 | * | ||
59 | * @param cls Closure (unused). | ||
60 | * @param peer Identity of the peer. | ||
61 | * @param hello Hello of the peer. | ||
62 | * @param err_msg Error message. | ||
63 | */ | ||
64 | static void | ||
65 | got_hello (void *cls, | ||
66 | const struct GNUNET_PeerIdentity *id, | ||
67 | const struct GNUNET_HELLO_Message *hello, | ||
68 | const char *err_msg) | ||
69 | { | ||
70 | struct CadetPeer *peer; | ||
71 | |||
72 | if ((NULL == id) || | ||
73 | (NULL == hello)) | ||
74 | return; | ||
75 | if (0 == GNUNET_memcmp (id, | ||
76 | &my_full_id)) | ||
77 | { | ||
78 | GNUNET_free (mine); | ||
79 | mine = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (&hello->header); | ||
80 | GCD_hello_update (); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
85 | "Hello for %s (%d bytes), expires on %s\n", | ||
86 | GNUNET_i2s (id), | ||
87 | GNUNET_HELLO_size (hello), | ||
88 | GNUNET_STRINGS_absolute_time_to_string ( | ||
89 | GNUNET_HELLO_get_last_expiration (hello))); | ||
90 | peer = GCP_get (id, | ||
91 | GNUNET_YES); | ||
92 | GCP_set_hello (peer, | ||
93 | hello); | ||
94 | } | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Initialize the hello subsystem. | ||
99 | * | ||
100 | * @param c Configuration. | ||
101 | */ | ||
102 | void | ||
103 | GCH_init (const struct GNUNET_CONFIGURATION_Handle *c) | ||
104 | { | ||
105 | GNUNET_assert (NULL == nc); | ||
106 | peerinfo = GNUNET_PEERINFO_connect (c); | ||
107 | nc = GNUNET_PEERINFO_notify (c, | ||
108 | GNUNET_NO, | ||
109 | &got_hello, | ||
110 | NULL); | ||
111 | } | ||
112 | |||
113 | |||
114 | /** | ||
115 | * Shut down the hello subsystem. | ||
116 | */ | ||
117 | void | ||
118 | GCH_shutdown () | ||
119 | { | ||
120 | if (NULL != nc) | ||
121 | { | ||
122 | GNUNET_PEERINFO_notify_cancel (nc); | ||
123 | nc = NULL; | ||
124 | } | ||
125 | if (NULL != peerinfo) | ||
126 | { | ||
127 | GNUNET_PEERINFO_disconnect (peerinfo); | ||
128 | peerinfo = NULL; | ||
129 | } | ||
130 | if (NULL != mine) | ||
131 | { | ||
132 | GNUNET_free (mine); | ||
133 | mine = NULL; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Get own hello message. | ||
140 | * | ||
141 | * @return Own hello message. | ||
142 | */ | ||
143 | const struct GNUNET_HELLO_Message * | ||
144 | GCH_get_mine (void) | ||
145 | { | ||
146 | return mine; | ||
147 | } | ||
148 | |||
149 | |||
150 | /* end of gnunet-service-cadet-new_hello.c */ | ||