diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c index 7edd76d32..989157ceb 100644 --- a/src/messenger/gnunet-service-messenger.c +++ b/src/messenger/gnunet-service-messenger.c | |||
@@ -39,14 +39,16 @@ struct GNUNET_MESSENGER_Client | |||
39 | struct GNUNET_MESSENGER_Service *messenger; | 39 | struct GNUNET_MESSENGER_Service *messenger; |
40 | 40 | ||
41 | static int | 41 | static int |
42 | check_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg) | 42 | check_create (void *cls, |
43 | const struct GNUNET_MESSENGER_CreateMessage *msg) | ||
43 | { | 44 | { |
44 | GNUNET_MQ_check_zero_termination(msg); | 45 | GNUNET_MQ_check_zero_termination(msg); |
45 | return GNUNET_OK; | 46 | return GNUNET_OK; |
46 | } | 47 | } |
47 | 48 | ||
48 | static void | 49 | static void |
49 | handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg) | 50 | handle_create (void *cls, |
51 | const struct GNUNET_MESSENGER_CreateMessage *msg) | ||
50 | { | 52 | { |
51 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 53 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
52 | 54 | ||
@@ -60,7 +62,8 @@ handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg) | |||
60 | } | 62 | } |
61 | 63 | ||
62 | static void | 64 | static void |
63 | handle_update (void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg) | 65 | handle_update (void *cls, |
66 | const struct GNUNET_MESSENGER_UpdateMessage *msg) | ||
64 | { | 67 | { |
65 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 68 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
66 | 69 | ||
@@ -70,7 +73,8 @@ handle_update (void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg) | |||
70 | } | 73 | } |
71 | 74 | ||
72 | static void | 75 | static void |
73 | handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg) | 76 | handle_destroy (void *cls, |
77 | const struct GNUNET_MESSENGER_DestroyMessage *msg) | ||
74 | { | 78 | { |
75 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 79 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
76 | 80 | ||
@@ -78,14 +82,16 @@ handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg) | |||
78 | } | 82 | } |
79 | 83 | ||
80 | static int | 84 | static int |
81 | check_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | 85 | check_set_name (void *cls, |
86 | const struct GNUNET_MESSENGER_NameMessage *msg) | ||
82 | { | 87 | { |
83 | GNUNET_MQ_check_zero_termination(msg); | 88 | GNUNET_MQ_check_zero_termination(msg); |
84 | return GNUNET_OK; | 89 | return GNUNET_OK; |
85 | } | 90 | } |
86 | 91 | ||
87 | static void | 92 | static void |
88 | handle_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | 93 | handle_set_name (void *cls, |
94 | const struct GNUNET_MESSENGER_NameMessage *msg) | ||
89 | { | 95 | { |
90 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 96 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
91 | 97 | ||
@@ -99,7 +105,8 @@ handle_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg) | |||
99 | } | 105 | } |
100 | 106 | ||
101 | static void | 107 | static void |
102 | handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 108 | handle_room_open (void *cls, |
109 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
103 | { | 110 | { |
104 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 111 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
105 | 112 | ||
@@ -125,7 +132,8 @@ handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
125 | } | 132 | } |
126 | 133 | ||
127 | static void | 134 | static void |
128 | handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 135 | handle_room_entry (void *cls, |
136 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
129 | { | 137 | { |
130 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 138 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
131 | 139 | ||
@@ -153,7 +161,8 @@ handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
153 | } | 161 | } |
154 | 162 | ||
155 | static void | 163 | static void |
156 | handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | 164 | handle_room_close (void *cls, |
165 | const struct GNUNET_MESSENGER_RoomMessage *msg) | ||
157 | { | 166 | { |
158 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 167 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
159 | 168 | ||
@@ -179,7 +188,8 @@ handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg) | |||
179 | } | 188 | } |
180 | 189 | ||
181 | static int | 190 | static int |
182 | check_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg) | 191 | check_send_message (void *cls, |
192 | const struct GNUNET_MESSENGER_SendMessage *msg) | ||
183 | { | 193 | { |
184 | const uint16_t full_length = ntohs (msg->header.size); | 194 | const uint16_t full_length = ntohs (msg->header.size); |
185 | 195 | ||
@@ -224,7 +234,8 @@ check_for_message: | |||
224 | } | 234 | } |
225 | 235 | ||
226 | static void | 236 | static void |
227 | handle_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg) | 237 | handle_send_message (void *cls, |
238 | const struct GNUNET_MESSENGER_SendMessage *msg) | ||
228 | { | 239 | { |
229 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 240 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
230 | 241 | ||
@@ -271,7 +282,8 @@ end_handling: | |||
271 | } | 282 | } |
272 | 283 | ||
273 | static void | 284 | static void |
274 | callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | 285 | callback_found_message (void *cls, |
286 | struct GNUNET_MESSENGER_SrvRoom *room, | ||
275 | const struct GNUNET_MESSENGER_Message *message, | 287 | const struct GNUNET_MESSENGER_Message *message, |
276 | const struct GNUNET_HashCode *hash) | 288 | const struct GNUNET_HashCode *hash) |
277 | { | 289 | { |
@@ -300,7 +312,8 @@ callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | |||
300 | } | 312 | } |
301 | 313 | ||
302 | static void | 314 | static void |
303 | handle_get_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg) | 315 | handle_get_message (void *cls, |
316 | const struct GNUNET_MESSENGER_GetMessage *msg) | ||
304 | { | 317 | { |
305 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 318 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
306 | 319 | ||
@@ -341,7 +354,9 @@ end_handling: | |||
341 | } | 354 | } |
342 | 355 | ||
343 | static void* | 356 | static void* |
344 | callback_client_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) | 357 | callback_client_connect (void *cls, |
358 | struct GNUNET_SERVICE_Client *client, | ||
359 | struct GNUNET_MQ_Handle *mq) | ||
345 | { | 360 | { |
346 | struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client); | 361 | struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client); |
347 | 362 | ||
@@ -352,7 +367,9 @@ callback_client_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct | |||
352 | } | 367 | } |
353 | 368 | ||
354 | static void | 369 | static void |
355 | callback_client_disconnect (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls) | 370 | callback_client_disconnect (void *cls, |
371 | struct GNUNET_SERVICE_Client *client, | ||
372 | void *internal_cls) | ||
356 | { | 373 | { |
357 | struct GNUNET_MESSENGER_Client *msg_client = internal_cls; | 374 | struct GNUNET_MESSENGER_Client *msg_client = internal_cls; |
358 | 375 | ||
@@ -369,7 +386,9 @@ callback_client_disconnect (void *cls, struct GNUNET_SERVICE_Client *client, voi | |||
369 | * @param[in/out] service the initialized service | 386 | * @param[in/out] service the initialized service |
370 | */ | 387 | */ |
371 | static void | 388 | static void |
372 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service) | 389 | run (void *cls, |
390 | const struct GNUNET_CONFIGURATION_Handle *config, | ||
391 | struct GNUNET_SERVICE_Handle *service) | ||
373 | { | 392 | { |
374 | messenger = create_service (config, service); | 393 | messenger = create_service (config, service); |
375 | 394 | ||