diff options
author | Gabor X Toth <*@tg-x.net> | 2014-05-17 10:16:15 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2014-05-17 10:16:15 +0000 |
commit | 83c058a5ea11b6d7aa05cb71963c6063cb373603 (patch) | |
tree | 30921098e391d492cf52311983348232d41d9634 /src/psyc/psyc_api.c | |
parent | d78b7d8a3f6cdaee244557667350da443ca76db5 (diff) | |
download | gnunet-83c058a5ea11b6d7aa05cb71963c6063cb373603.tar.gz gnunet-83c058a5ea11b6d7aa05cb71963c6063cb373603.zip |
multicast, psyc: client connections, join requests
Diffstat (limited to 'src/psyc/psyc_api.c')
-rw-r--r-- | src/psyc/psyc_api.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index 85f86ceaa..62f099166 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -126,12 +126,7 @@ struct GNUNET_PSYC_Channel | |||
126 | GNUNET_PSYC_MessageCallback hist_message_cb; | 126 | GNUNET_PSYC_MessageCallback hist_message_cb; |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Join handler callback. | 129 | * Closure for @a message_cb. |
130 | */ | ||
131 | GNUNET_PSYC_JoinCallback join_cb; | ||
132 | |||
133 | /** | ||
134 | * Closure for @a message_cb and @a join_cb. | ||
135 | */ | 130 | */ |
136 | void *cb_cls; | 131 | void *cb_cls; |
137 | 132 | ||
@@ -200,6 +195,11 @@ struct GNUNET_PSYC_Master | |||
200 | struct GNUNET_PSYC_Channel ch; | 195 | struct GNUNET_PSYC_Channel ch; |
201 | 196 | ||
202 | GNUNET_PSYC_MasterStartCallback start_cb; | 197 | GNUNET_PSYC_MasterStartCallback start_cb; |
198 | |||
199 | /** | ||
200 | * Join handler callback. | ||
201 | */ | ||
202 | GNUNET_PSYC_JoinCallback join_cb; | ||
203 | }; | 203 | }; |
204 | 204 | ||
205 | 205 | ||
@@ -908,6 +908,18 @@ handle_psyc_message_ack (struct GNUNET_PSYC_Channel *ch) | |||
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | static void | ||
912 | handle_psyc_join_request (struct GNUNET_PSYC_Master *mst, | ||
913 | const struct MasterJoinRequest *req) | ||
914 | { | ||
915 | // FIXME: extract join message from req[1] | ||
916 | const char *method_name = "_fixme"; | ||
917 | struct GNUNET_PSYC_JoinHandle *jh = GNUNET_malloc (sizeof (*jh)); | ||
918 | mst->join_cb (mst->ch.cb_cls, &req->slave_key, method_name, | ||
919 | 0, NULL, NULL, 0, jh); | ||
920 | } | ||
921 | |||
922 | |||
911 | /** | 923 | /** |
912 | * Type of a function to call when we receive a message | 924 | * Type of a function to call when we receive a message |
913 | * from the service. | 925 | * from the service. |
@@ -951,6 +963,9 @@ message_handler (void *cls, | |||
951 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK: | 963 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK: |
952 | size_eq = sizeof (struct GNUNET_MessageHeader); | 964 | size_eq = sizeof (struct GNUNET_MessageHeader); |
953 | break; | 965 | break; |
966 | case GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST: | ||
967 | size_min = sizeof (struct MasterJoinRequest); | ||
968 | break; | ||
954 | default: | 969 | default: |
955 | GNUNET_break_op (0); | 970 | GNUNET_break_op (0); |
956 | return; | 971 | return; |
@@ -988,6 +1003,11 @@ message_handler (void *cls, | |||
988 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE: | 1003 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE: |
989 | handle_psyc_message (ch, (const struct GNUNET_PSYC_MessageHeader *) msg); | 1004 | handle_psyc_message (ch, (const struct GNUNET_PSYC_MessageHeader *) msg); |
990 | break; | 1005 | break; |
1006 | |||
1007 | case GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST: | ||
1008 | handle_psyc_join_request ((struct GNUNET_PSYC_Master *) ch, | ||
1009 | (const struct MasterJoinRequest *) msg); | ||
1010 | break; | ||
991 | } | 1011 | } |
992 | 1012 | ||
993 | if (NULL != ch->client) | 1013 | if (NULL != ch->client) |
@@ -1186,8 +1206,8 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1186 | req->policy = policy; | 1206 | req->policy = policy; |
1187 | 1207 | ||
1188 | mst->start_cb = master_started_cb; | 1208 | mst->start_cb = master_started_cb; |
1209 | mst->join_cb = join_cb; | ||
1189 | ch->message_cb = message_cb; | 1210 | ch->message_cb = message_cb; |
1190 | ch->join_cb = join_cb; | ||
1191 | ch->cb_cls = cls; | 1211 | ch->cb_cls = cls; |
1192 | ch->cfg = cfg; | 1212 | ch->cfg = cfg; |
1193 | ch->is_master = GNUNET_YES; | 1213 | ch->is_master = GNUNET_YES; |
@@ -1320,9 +1340,7 @@ GNUNET_PSYC_master_transmit_cancel (struct GNUNET_PSYC_MasterTransmitHandle *th) | |||
1320 | * @param message_cb Function to invoke on message parts received from the | 1340 | * @param message_cb Function to invoke on message parts received from the |
1321 | * channel, typically at least contains method handlers for @e join and | 1341 | * channel, typically at least contains method handlers for @e join and |
1322 | * @e part. | 1342 | * @e part. |
1323 | * @param join_cb function invoked once we have joined with the current | 1343 | * @param slave_joined_cb Function invoked once we have joined the channel. |
1324 | * message ID of the channel | ||
1325 | * @param slave_joined_cb Function to invoke when a peer wants to join. | ||
1326 | * @param cls Closure for @a message_cb and @a slave_joined_cb. | 1344 | * @param cls Closure for @a message_cb and @a slave_joined_cb. |
1327 | * @param method_name Method name for the join request. | 1345 | * @param method_name Method name for the join request. |
1328 | * @param env Environment containing transient variables for the request, or NULL. | 1346 | * @param env Environment containing transient variables for the request, or NULL. |
@@ -1339,7 +1357,6 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1339 | uint32_t relay_count, | 1357 | uint32_t relay_count, |
1340 | const struct GNUNET_PeerIdentity *relays, | 1358 | const struct GNUNET_PeerIdentity *relays, |
1341 | GNUNET_PSYC_MessageCallback message_cb, | 1359 | GNUNET_PSYC_MessageCallback message_cb, |
1342 | GNUNET_PSYC_JoinCallback join_cb, | ||
1343 | GNUNET_PSYC_SlaveJoinCallback slave_joined_cb, | 1360 | GNUNET_PSYC_SlaveJoinCallback slave_joined_cb, |
1344 | void *cls, | 1361 | void *cls, |
1345 | const char *method_name, | 1362 | const char *method_name, |
@@ -1362,7 +1379,6 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1362 | 1379 | ||
1363 | slv->join_cb = slave_joined_cb; | 1380 | slv->join_cb = slave_joined_cb; |
1364 | ch->message_cb = message_cb; | 1381 | ch->message_cb = message_cb; |
1365 | ch->join_cb = join_cb; | ||
1366 | ch->cb_cls = cls; | 1382 | ch->cb_cls = cls; |
1367 | 1383 | ||
1368 | ch->cfg = cfg; | 1384 | ch->cfg = cfg; |