summaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_hello.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet_hello.c')
-rw-r--r--src/cadet/gnunet-service-cadet_hello.c89
1 files changed, 45 insertions, 44 deletions
diff --git a/src/cadet/gnunet-service-cadet_hello.c b/src/cadet/gnunet-service-cadet_hello.c
index 7d6d2b0ce..bbe947ad1 100644
--- a/src/cadet/gnunet-service-cadet_hello.c
+++ b/src/cadet/gnunet-service-cadet_hello.c
@@ -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,35 @@ static struct GNUNET_PEERINFO_NotifyContext *nc;
62 * @param err_msg Error message. 62 * @param err_msg Error message.
63 */ 63 */
64static void 64static void
65got_hello(void *cls, 65got_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; 74 return;
75 if (0 == GNUNET_memcmp(id, 75 if (0 == GNUNET_memcmp (id,
76 &my_full_id)) 76 &my_full_id))
77 { 77 {
78 GNUNET_free_non_null(mine); 78 GNUNET_free_non_null (mine);
79 mine = (struct GNUNET_HELLO_Message *)GNUNET_copy_message(&hello->header); 79 mine = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (&hello->header);
80 GCD_hello_update(); 80 GCD_hello_update ();
81 return; 81 return;
82 } 82 }
83 83
84 LOG(GNUNET_ERROR_TYPE_DEBUG, 84 LOG (GNUNET_ERROR_TYPE_DEBUG,
85 "Hello for %s (%d bytes), expires on %s\n", 85 "Hello for %s (%d bytes), expires on %s\n",
86 GNUNET_i2s(id), 86 GNUNET_i2s (id),
87 GNUNET_HELLO_size(hello), 87 GNUNET_HELLO_size (hello),
88 GNUNET_STRINGS_absolute_time_to_string(GNUNET_HELLO_get_last_expiration(hello))); 88 GNUNET_STRINGS_absolute_time_to_string (
89 peer = GCP_get(id, 89 GNUNET_HELLO_get_last_expiration (hello)));
90 GNUNET_YES); 90 peer = GCP_get (id,
91 GCP_set_hello(peer, 91 GNUNET_YES);
92 hello); 92 GCP_set_hello (peer,
93 hello);
93} 94}
94 95
95 96
@@ -99,14 +100,14 @@ got_hello(void *cls,
99 * @param c Configuration. 100 * @param c Configuration.
100 */ 101 */
101void 102void
102GCH_init(const struct GNUNET_CONFIGURATION_Handle *c) 103GCH_init (const struct GNUNET_CONFIGURATION_Handle *c)
103{ 104{
104 GNUNET_assert(NULL == nc); 105 GNUNET_assert (NULL == nc);
105 peerinfo = GNUNET_PEERINFO_connect(c); 106 peerinfo = GNUNET_PEERINFO_connect (c);
106 nc = GNUNET_PEERINFO_notify(c, 107 nc = GNUNET_PEERINFO_notify (c,
107 GNUNET_NO, 108 GNUNET_NO,
108 &got_hello, 109 &got_hello,
109 NULL); 110 NULL);
110} 111}
111 112
112 113
@@ -114,23 +115,23 @@ GCH_init(const struct GNUNET_CONFIGURATION_Handle *c)
114 * Shut down the hello subsystem. 115 * Shut down the hello subsystem.
115 */ 116 */
116void 117void
117GCH_shutdown() 118GCH_shutdown ()
118{ 119{
119 if (NULL != nc) 120 if (NULL != nc)
120 { 121 {
121 GNUNET_PEERINFO_notify_cancel(nc); 122 GNUNET_PEERINFO_notify_cancel (nc);
122 nc = NULL; 123 nc = NULL;
123 } 124 }
124 if (NULL != peerinfo) 125 if (NULL != peerinfo)
125 { 126 {
126 GNUNET_PEERINFO_disconnect(peerinfo); 127 GNUNET_PEERINFO_disconnect (peerinfo);
127 peerinfo = NULL; 128 peerinfo = NULL;
128 } 129 }
129 if (NULL != mine) 130 if (NULL != mine)
130 { 131 {
131 GNUNET_free(mine); 132 GNUNET_free (mine);
132 mine = NULL; 133 mine = NULL;
133 } 134 }
134} 135}
135 136
136 137
@@ -140,7 +141,7 @@ GCH_shutdown()
140 * @return Own hello message. 141 * @return Own hello message.
141 */ 142 */
142const struct GNUNET_HELLO_Message * 143const struct GNUNET_HELLO_Message *
143GCH_get_mine(void) 144GCH_get_mine (void)
144{ 145{
145 return mine; 146 return mine;
146} 147}