diff options
Diffstat (limited to 'src/cadet/gnunet-service-cadet_hello.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_hello.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/cadet/gnunet-service-cadet_hello.c b/src/cadet/gnunet-service-cadet_hello.c index fe2477c34..7d6d2b0ce 100644 --- a/src/cadet/gnunet-service-cadet_hello.c +++ b/src/cadet/gnunet-service-cadet_hello.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file cadet/gnunet-service-cadet_hello.c | 21 | * @file cadet/gnunet-service-cadet_hello.c |
22 | * @brief spread knowledge about how to contact us (get HELLO from peerinfo), | 22 | * @brief spread knowledge about how to contact us (get HELLO from peerinfo), |
@@ -35,7 +35,7 @@ | |||
35 | #include "gnunet-service-cadet_hello.h" | 35 | #include "gnunet-service-cadet_hello.h" |
36 | #include "gnunet-service-cadet_peer.h" | 36 | #include "gnunet-service-cadet_peer.h" |
37 | 37 | ||
38 | #define LOG(level, ...) GNUNET_log_from(level,"cadet-hll",__VA_ARGS__) | 38 | #define LOG(level, ...) GNUNET_log_from(level, "cadet-hll", __VA_ARGS__) |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Hello message of local peer. | 41 | * Hello message of local peer. |
@@ -62,34 +62,34 @@ static struct GNUNET_PEERINFO_NotifyContext *nc; | |||
62 | * @param err_msg Error message. | 62 | * @param err_msg Error message. |
63 | */ | 63 | */ |
64 | static void | 64 | static void |
65 | got_hello (void *cls, | 65 | got_hello(void *cls, |
66 | const struct GNUNET_PeerIdentity *id, | 66 | const struct GNUNET_PeerIdentity *id, |
67 | const struct GNUNET_HELLO_Message *hello, | 67 | const struct GNUNET_HELLO_Message *hello, |
68 | const char *err_msg) | 68 | const char *err_msg) |
69 | { | 69 | { |
70 | struct CadetPeer *peer; | 70 | struct CadetPeer *peer; |
71 | 71 | ||
72 | if ( (NULL == id) || | 72 | if ((NULL == id) || |
73 | (NULL == hello) ) | 73 | (NULL == hello)) |
74 | return; | ||
75 | if (0 == GNUNET_memcmp (id, | ||
76 | &my_full_id)) | ||
77 | { | ||
78 | GNUNET_free_non_null (mine); | ||
79 | mine = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (&hello->header); | ||
80 | GCD_hello_update (); | ||
81 | return; | 74 | return; |
82 | } | 75 | if (0 == GNUNET_memcmp(id, |
83 | 76 | &my_full_id)) | |
84 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 77 | { |
85 | "Hello for %s (%d bytes), expires on %s\n", | 78 | GNUNET_free_non_null(mine); |
86 | GNUNET_i2s (id), | 79 | mine = (struct GNUNET_HELLO_Message *)GNUNET_copy_message(&hello->header); |
87 | GNUNET_HELLO_size (hello), | 80 | GCD_hello_update(); |
88 | GNUNET_STRINGS_absolute_time_to_string (GNUNET_HELLO_get_last_expiration (hello))); | 81 | return; |
89 | peer = GCP_get (id, | 82 | } |
90 | GNUNET_YES); | 83 | |
91 | GCP_set_hello (peer, | 84 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
92 | hello); | 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(GNUNET_HELLO_get_last_expiration(hello))); | ||
89 | peer = GCP_get(id, | ||
90 | GNUNET_YES); | ||
91 | GCP_set_hello(peer, | ||
92 | hello); | ||
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
@@ -99,14 +99,14 @@ got_hello (void *cls, | |||
99 | * @param c Configuration. | 99 | * @param c Configuration. |
100 | */ | 100 | */ |
101 | void | 101 | void |
102 | GCH_init (const struct GNUNET_CONFIGURATION_Handle *c) | 102 | GCH_init(const struct GNUNET_CONFIGURATION_Handle *c) |
103 | { | 103 | { |
104 | GNUNET_assert (NULL == nc); | 104 | GNUNET_assert(NULL == nc); |
105 | peerinfo = GNUNET_PEERINFO_connect (c); | 105 | peerinfo = GNUNET_PEERINFO_connect(c); |
106 | nc = GNUNET_PEERINFO_notify (c, | 106 | nc = GNUNET_PEERINFO_notify(c, |
107 | GNUNET_NO, | 107 | GNUNET_NO, |
108 | &got_hello, | 108 | &got_hello, |
109 | NULL); | 109 | NULL); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
@@ -114,23 +114,23 @@ GCH_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
114 | * Shut down the hello subsystem. | 114 | * Shut down the hello subsystem. |
115 | */ | 115 | */ |
116 | void | 116 | void |
117 | GCH_shutdown () | 117 | GCH_shutdown() |
118 | { | 118 | { |
119 | if (NULL != nc) | 119 | if (NULL != nc) |
120 | { | 120 | { |
121 | GNUNET_PEERINFO_notify_cancel (nc); | 121 | GNUNET_PEERINFO_notify_cancel(nc); |
122 | nc = NULL; | 122 | nc = NULL; |
123 | } | 123 | } |
124 | if (NULL != peerinfo) | 124 | if (NULL != peerinfo) |
125 | { | 125 | { |
126 | GNUNET_PEERINFO_disconnect (peerinfo); | 126 | GNUNET_PEERINFO_disconnect(peerinfo); |
127 | peerinfo = NULL; | 127 | peerinfo = NULL; |
128 | } | 128 | } |
129 | if (NULL != mine) | 129 | if (NULL != mine) |
130 | { | 130 | { |
131 | GNUNET_free (mine); | 131 | GNUNET_free(mine); |
132 | mine = NULL; | 132 | mine = NULL; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
@@ -140,7 +140,7 @@ GCH_shutdown () | |||
140 | * @return Own hello message. | 140 | * @return Own hello message. |
141 | */ | 141 | */ |
142 | const struct GNUNET_HELLO_Message * | 142 | const struct GNUNET_HELLO_Message * |
143 | GCH_get_mine (void) | 143 | GCH_get_mine(void) |
144 | { | 144 | { |
145 | return mine; | 145 | return mine; |
146 | } | 146 | } |