aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_local.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet_local.c')
-rw-r--r--src/cadet/gnunet-service-cadet_local.c182
1 files changed, 97 insertions, 85 deletions
diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c
index 9be1224c1..743fbf054 100644
--- a/src/cadet/gnunet-service-cadet_local.c
+++ b/src/cadet/gnunet-service-cadet_local.c
@@ -61,7 +61,7 @@ struct CadetClient
61 * Tunnels that belong to this client, indexed by local id 61 * Tunnels that belong to this client, indexed by local id
62 */ 62 */
63 struct GNUNET_CONTAINER_MultiHashMap32 *own_channels; 63 struct GNUNET_CONTAINER_MultiHashMap32 *own_channels;
64 64
65 /** 65 /**
66 * Tunnels this client has accepted, indexed by incoming local id 66 * Tunnels this client has accepted, indexed by incoming local id
67 */ 67 */
@@ -70,7 +70,7 @@ struct CadetClient
70 /** 70 /**
71 * Channel ID for the next incoming channel. 71 * Channel ID for the next incoming channel.
72 */ 72 */
73 CADET_ChannelNumber next_chid; 73 struct GNUNET_CADET_ClientChannelNumber next_chid;
74 74
75 /** 75 /**
76 * Handle to communicate with the client 76 * Handle to communicate with the client
@@ -188,7 +188,9 @@ channel_destroy_iterator (void *cls,
188 " Channel %s destroy, due to client %s shutdown.\n", 188 " Channel %s destroy, due to client %s shutdown.\n",
189 GCCH_2s (ch), GML_2s (c)); 189 GCCH_2s (ch), GML_2s (c));
190 190
191 GCCH_handle_local_destroy (ch, c, key < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV); 191 GCCH_handle_local_destroy (ch,
192 c,
193 key < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
192 return GNUNET_OK; 194 return GNUNET_OK;
193} 195}
194 196
@@ -247,7 +249,6 @@ client_new (struct GNUNET_SERVER_Client *client)
247 c = GNUNET_new (struct CadetClient); 249 c = GNUNET_new (struct CadetClient);
248 c->handle = client; 250 c->handle = client;
249 c->id = next_client_id++; /* overflow not important: just for debug */ 251 c->id = next_client_id++; /* overflow not important: just for debug */
250 c->next_chid = GNUNET_CADET_LOCAL_CHANNEL_ID_SERV;
251 252
252 c->own_channels = GNUNET_CONTAINER_multihashmap32_create (32); 253 c->own_channels = GNUNET_CONTAINER_multihashmap32_create (32);
253 c->incoming_channels = GNUNET_CONTAINER_multihashmap32_create (32); 254 c->incoming_channels = GNUNET_CONTAINER_multihashmap32_create (32);
@@ -474,7 +475,7 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
474 struct GNUNET_CADET_ChannelDestroyMessage *msg; 475 struct GNUNET_CADET_ChannelDestroyMessage *msg;
475 struct CadetClient *c; 476 struct CadetClient *c;
476 struct CadetChannel *ch; 477 struct CadetChannel *ch;
477 CADET_ChannelNumber chid; 478 struct GNUNET_CADET_ClientChannelNumber chid;
478 479
479 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got a DESTROY CHANNEL from client!\n"); 480 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got a DESTROY CHANNEL from client!\n");
480 481
@@ -499,7 +500,7 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
499 msg = (struct GNUNET_CADET_ChannelDestroyMessage *) message; 500 msg = (struct GNUNET_CADET_ChannelDestroyMessage *) message;
500 501
501 /* Retrieve tunnel */ 502 /* Retrieve tunnel */
502 chid = ntohl (msg->channel_id); 503 chid = msg->channel_id;
503 ch = GML_channel_get (c, chid); 504 ch = GML_channel_get (c, chid);
504 505
505 LOG (GNUNET_ERROR_TYPE_INFO, "Client %u is destroying channel %X\n", 506 LOG (GNUNET_ERROR_TYPE_INFO, "Client %u is destroying channel %X\n",
@@ -515,7 +516,9 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
515 return; 516 return;
516 } 517 }
517 518
518 GCCH_handle_local_destroy (ch, c, chid < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV); 519 GCCH_handle_local_destroy (ch,
520 c,
521 ntohl (chid.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
519 522
520 GNUNET_SERVER_receive_done (client, GNUNET_OK); 523 GNUNET_SERVER_receive_done (client, GNUNET_OK);
521 return; 524 return;
@@ -537,7 +540,7 @@ handle_data (void *cls, struct GNUNET_SERVER_Client *client,
537 struct GNUNET_CADET_LocalData *msg; 540 struct GNUNET_CADET_LocalData *msg;
538 struct CadetClient *c; 541 struct CadetClient *c;
539 struct CadetChannel *ch; 542 struct CadetChannel *ch;
540 CADET_ChannelNumber chid; 543 struct GNUNET_CADET_ClientChannelNumber chid;
541 size_t message_size; 544 size_t message_size;
542 size_t payload_size; 545 size_t payload_size;
543 size_t payload_claimed_size; 546 size_t payload_claimed_size;
@@ -583,12 +586,12 @@ handle_data (void *cls, struct GNUNET_SERVER_Client *client,
583 return; 586 return;
584 } 587 }
585 588
586 chid = ntohl (msg->id); 589 chid = msg->id;
587 LOG (GNUNET_ERROR_TYPE_DEBUG, " %u bytes (%u payload) by client %u\n", 590 LOG (GNUNET_ERROR_TYPE_DEBUG, " %u bytes (%u payload) by client %u\n",
588 payload_size, payload_claimed_size, c->id); 591 payload_size, payload_claimed_size, c->id);
589 592
590 /* Channel exists? */ 593 /* Channel exists? */
591 fwd = chid < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV; 594 fwd = ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
592 ch = GML_channel_get (c, chid); 595 ch = GML_channel_get (c, chid);
593 if (NULL == ch) 596 if (NULL == ch)
594 { 597 {
@@ -626,7 +629,7 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client,
626 struct GNUNET_CADET_LocalAck *msg; 629 struct GNUNET_CADET_LocalAck *msg;
627 struct CadetChannel *ch; 630 struct CadetChannel *ch;
628 struct CadetClient *c; 631 struct CadetClient *c;
629 CADET_ChannelNumber chid; 632 struct GNUNET_CADET_ClientChannelNumber chid;
630 int fwd; 633 int fwd;
631 634
632 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n"); 635 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
@@ -644,13 +647,16 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client,
644 msg = (struct GNUNET_CADET_LocalAck *) message; 647 msg = (struct GNUNET_CADET_LocalAck *) message;
645 648
646 /* Channel exists? */ 649 /* Channel exists? */
647 chid = ntohl (msg->channel_id); 650 chid = msg->channel_id;
648 LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", chid); 651 LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n",
652 ntohl (chid.channel_of_client));
649 ch = GML_channel_get (c, chid); 653 ch = GML_channel_get (c, chid);
650 LOG (GNUNET_ERROR_TYPE_DEBUG, " -- ch %p\n", ch); 654 LOG (GNUNET_ERROR_TYPE_DEBUG, " -- ch %p\n", ch);
651 if (NULL == ch) 655 if (NULL == ch)
652 { 656 {
653 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %X unknown.\n", chid); 657 LOG (GNUNET_ERROR_TYPE_DEBUG,
658 "Channel %X unknown.\n",
659 ntohl (chid.channel_of_client));
654 LOG (GNUNET_ERROR_TYPE_DEBUG, " for client %u.\n", c->id); 660 LOG (GNUNET_ERROR_TYPE_DEBUG, " for client %u.\n", c->id);
655 GNUNET_STATISTICS_update (stats, 661 GNUNET_STATISTICS_update (stats,
656 "# client ack messages on unknown channel", 662 "# client ack messages on unknown channel",
@@ -661,12 +667,10 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client,
661 667
662 /* If client is root, the ACK is going FWD, therefore this is "BCK ACK". */ 668 /* If client is root, the ACK is going FWD, therefore this is "BCK ACK". */
663 /* If client is dest, the ACK is going BCK, therefore this is "FWD ACK" */ 669 /* If client is dest, the ACK is going BCK, therefore this is "FWD ACK" */
664 fwd = chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV; 670 fwd = ntohl (chid.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI;
665 671
666 GCCH_handle_local_ack (ch, fwd); 672 GCCH_handle_local_ack (ch, fwd);
667 GNUNET_SERVER_receive_done (client, GNUNET_OK); 673 GNUNET_SERVER_receive_done (client, GNUNET_OK);
668
669 return;
670} 674}
671 675
672 676
@@ -972,9 +976,9 @@ iter_channel (void *cls, struct CadetChannel *ch)
972{ 976{
973 struct GNUNET_CADET_LocalInfoTunnel *msg = cls; 977 struct GNUNET_CADET_LocalInfoTunnel *msg = cls;
974 struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1]; 978 struct GNUNET_CADET_Hash *h = (struct GNUNET_CADET_Hash *) &msg[1];
975 CADET_ChannelNumber *chn = (CADET_ChannelNumber *) &h[msg->connections]; 979 struct GNUNET_CADET_ChannelNumber *chn = (struct GNUNET_CADET_ChannelNumber *) &h[msg->connections];
976 980
977 chn[msg->channels] = htonl (GCCH_get_id (ch)); 981 chn[msg->channels] = GCCH_get_id (ch);
978 msg->channels++; 982 msg->channels++;
979} 983}
980 984
@@ -1040,7 +1044,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
1040 1044
1041 size = sizeof (struct GNUNET_CADET_LocalInfoTunnel); 1045 size = sizeof (struct GNUNET_CADET_LocalInfoTunnel);
1042 size += c_n * sizeof (struct GNUNET_CADET_Hash); 1046 size += c_n * sizeof (struct GNUNET_CADET_Hash);
1043 size += ch_n * sizeof (CADET_ChannelNumber); 1047 size += ch_n * sizeof (struct GNUNET_CADET_ChannelNumber);
1044 1048
1045 resp = GNUNET_malloc (size); 1049 resp = GNUNET_malloc (size);
1046 resp->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); 1050 resp->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL);
@@ -1214,26 +1218,16 @@ GML_shutdown (void)
1214 * @return non-NULL if channel exists in the clients lists 1218 * @return non-NULL if channel exists in the clients lists
1215 */ 1219 */
1216struct CadetChannel * 1220struct CadetChannel *
1217GML_channel_get (struct CadetClient *c, CADET_ChannelNumber chid) 1221GML_channel_get (struct CadetClient *c,
1222 struct GNUNET_CADET_ClientChannelNumber chid)
1218{ 1223{
1219 struct GNUNET_CONTAINER_MultiHashMap32 *map; 1224 struct GNUNET_CONTAINER_MultiHashMap32 *map;
1220 1225
1221 if (0 == (chid & GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)) 1226 if (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1222 {
1223 GNUNET_break_op (0);
1224 LOG (GNUNET_ERROR_TYPE_DEBUG, "CHID %X not a local chid\n", chid);
1225 return NULL;
1226 }
1227
1228 if (chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV)
1229 map = c->incoming_channels;
1230 else if (chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1231 map = c->own_channels; 1227 map = c->own_channels;
1232 else 1228 else
1233 { 1229 map = c->incoming_channels;
1234 GNUNET_break (0); 1230
1235 map = NULL;
1236 }
1237 if (NULL == map) 1231 if (NULL == map)
1238 { 1232 {
1239 GNUNET_break (0); 1233 GNUNET_break (0);
@@ -1242,7 +1236,8 @@ GML_channel_get (struct CadetClient *c, CADET_ChannelNumber chid)
1242 GML_2s (c), chid); 1236 GML_2s (c), chid);
1243 return NULL; 1237 return NULL;
1244 } 1238 }
1245 return GNUNET_CONTAINER_multihashmap32_get (map, chid); 1239 return GNUNET_CONTAINER_multihashmap32_get (map,
1240 chid.channel_of_client);
1246} 1241}
1247 1242
1248 1243
@@ -1255,17 +1250,19 @@ GML_channel_get (struct CadetClient *c, CADET_ChannelNumber chid)
1255 */ 1250 */
1256void 1251void
1257GML_channel_add (struct CadetClient *client, 1252GML_channel_add (struct CadetClient *client,
1258 uint32_t chid, 1253 struct GNUNET_CADET_ClientChannelNumber chid,
1259 struct CadetChannel *ch) 1254 struct CadetChannel *ch)
1260{ 1255{
1261 if (chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_SERV) 1256 if (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1262 GNUNET_CONTAINER_multihashmap32_put (client->incoming_channels, chid, ch, 1257 GNUNET_CONTAINER_multihashmap32_put (client->own_channels,
1263 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 1258 chid.channel_of_client,
1264 else if (chid >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) 1259 ch,
1265 GNUNET_CONTAINER_multihashmap32_put (client->own_channels, chid, ch,
1266 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 1260 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
1267 else 1261 else
1268 GNUNET_break (0); 1262 GNUNET_CONTAINER_multihashmap32_put (client->incoming_channels,
1263 chid.channel_of_client,
1264 ch,
1265 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
1269} 1266}
1270 1267
1271 1268
@@ -1278,19 +1275,17 @@ GML_channel_add (struct CadetClient *client,
1278 */ 1275 */
1279void 1276void
1280GML_channel_remove (struct CadetClient *client, 1277GML_channel_remove (struct CadetClient *client,
1281 uint32_t chid, 1278 struct GNUNET_CADET_ClientChannelNumber chid,
1282 struct CadetChannel *ch) 1279 struct CadetChannel *ch)
1283{ 1280{
1284 if (GNUNET_CADET_LOCAL_CHANNEL_ID_SERV <= chid) 1281 if (ntohl (chid.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1285 GNUNET_break (GNUNET_YES == 1282 GNUNET_CONTAINER_multihashmap32_remove (client->own_channels,
1286 GNUNET_CONTAINER_multihashmap32_remove (client->incoming_channels, 1283 chid.channel_of_client,
1287 chid, ch)); 1284 ch);
1288 else if (GNUNET_CADET_LOCAL_CHANNEL_ID_CLI <= chid)
1289 GNUNET_break (GNUNET_YES ==
1290 GNUNET_CONTAINER_multihashmap32_remove (client->own_channels,
1291 chid, ch));
1292 else 1285 else
1293 GNUNET_break (0); 1286 GNUNET_CONTAINER_multihashmap32_remove (client->incoming_channels,
1287 chid.channel_of_client,
1288 ch);
1294} 1289}
1295 1290
1296 1291
@@ -1301,18 +1296,26 @@ GML_channel_remove (struct CadetClient *client,
1301 * 1296 *
1302 * @return LID of a channel free to use. 1297 * @return LID of a channel free to use.
1303 */ 1298 */
1304CADET_ChannelNumber 1299struct GNUNET_CADET_ClientChannelNumber
1305GML_get_next_chid (struct CadetClient *c) 1300GML_get_next_chid (struct CadetClient *c)
1306{ 1301{
1307 CADET_ChannelNumber chid; 1302 struct GNUNET_CADET_ClientChannelNumber chid;
1308 1303
1309 while (NULL != GML_channel_get (c, c->next_chid)) 1304 while (NULL != GML_channel_get (c,
1305 c->next_chid))
1310 { 1306 {
1311 LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", c->next_chid); 1307 LOG (GNUNET_ERROR_TYPE_DEBUG,
1312 c->next_chid = (c->next_chid + 1) | GNUNET_CADET_LOCAL_CHANNEL_ID_SERV; 1308 "Channel %u exists...\n",
1309 c->next_chid);
1310 c->next_chid.channel_of_client
1311 = htonl (1 + (ntohl (c->next_chid.channel_of_client)));
1312 if (ntohl (c->next_chid.channel_of_client) >=
1313 GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1314 c->next_chid.channel_of_client = htonl (0);
1313 } 1315 }
1314 chid = c->next_chid; 1316 chid = c->next_chid;
1315 c->next_chid = (c->next_chid + 1) | GNUNET_CADET_LOCAL_CHANNEL_ID_SERV; 1317 c->next_chid.channel_of_client
1318 = htonl (1 + (ntohl (c->next_chid.channel_of_client)));
1316 1319
1317 return chid; 1320 return chid;
1318} 1321}
@@ -1330,9 +1333,11 @@ GML_client_get (struct GNUNET_SERVER_Client *client)
1330{ 1333{
1331 if (NULL == client) 1334 if (NULL == client)
1332 return NULL; 1335 return NULL;
1333 return GNUNET_SERVER_client_get_user_context (client, struct CadetClient); 1336 return GNUNET_SERVER_client_get_user_context (client,
1337 struct CadetClient);
1334} 1338}
1335 1339
1340
1336/** 1341/**
1337 * Find a client that has opened a port 1342 * Find a client that has opened a port
1338 * 1343 *
@@ -1357,27 +1362,25 @@ GML_client_get_by_port (const struct GNUNET_HashCode *port)
1357void 1362void
1358GML_client_delete_channel (struct CadetClient *c, 1363GML_client_delete_channel (struct CadetClient *c,
1359 struct CadetChannel *ch, 1364 struct CadetChannel *ch,
1360 CADET_ChannelNumber id) 1365 struct GNUNET_CADET_ClientChannelNumber id)
1361{ 1366{
1362 int res; 1367 int res;
1363 1368
1364 if (GNUNET_CADET_LOCAL_CHANNEL_ID_SERV <= id) 1369 if (ntohl (id.channel_of_client) >= GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1365 {
1366 res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels,
1367 id, ch);
1368 if (GNUNET_YES != res)
1369 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_channel dest KO\n");
1370 }
1371 else if (GNUNET_CADET_LOCAL_CHANNEL_ID_CLI <= id)
1372 { 1370 {
1373 res = GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, 1371 res = GNUNET_CONTAINER_multihashmap32_remove (c->own_channels,
1374 id, ch); 1372 id.channel_of_client,
1373 ch);
1375 if (GNUNET_YES != res) 1374 if (GNUNET_YES != res)
1376 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel root KO\n"); 1375 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel root KO\n");
1377 } 1376 }
1378 else 1377 else
1379 { 1378 {
1380 GNUNET_break (0); 1379 res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels,
1380 id.channel_of_client,
1381 ch);
1382 if (GNUNET_YES != res)
1383 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_delete_channel dest KO\n");
1381 } 1384 }
1382} 1385}
1383 1386
@@ -1390,17 +1393,21 @@ GML_client_delete_channel (struct CadetClient *c,
1390 * @param id Channel ID to use 1393 * @param id Channel ID to use
1391 */ 1394 */
1392void 1395void
1393GML_send_ack (struct CadetClient *c, CADET_ChannelNumber id) 1396GML_send_ack (struct CadetClient *c,
1397 struct GNUNET_CADET_ClientChannelNumber id)
1394{ 1398{
1395 struct GNUNET_CADET_LocalAck msg; 1399 struct GNUNET_CADET_LocalAck msg;
1396 1400
1397 LOG (GNUNET_ERROR_TYPE_DEBUG, 1401 LOG (GNUNET_ERROR_TYPE_DEBUG,
1398 "send local %s ack on %X towards %p\n", 1402 "send local %s ack on %X towards %p\n",
1399 id < GNUNET_CADET_LOCAL_CHANNEL_ID_SERV ? "FWD" : "BCK", id, c); 1403 ntohl (id.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
1404 ? "FWD" : "BCK",
1405 ntohl (id.channel_of_client),
1406 c);
1400 1407
1401 msg.header.size = htons (sizeof (msg)); 1408 msg.header.size = htons (sizeof (msg));
1402 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK); 1409 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
1403 msg.channel_id = htonl (id); 1410 msg.channel_id = id;
1404 GNUNET_SERVER_notification_context_unicast (nc, 1411 GNUNET_SERVER_notification_context_unicast (nc,
1405 c->handle, 1412 c->handle,
1406 &msg.header, 1413 &msg.header,
@@ -1421,14 +1428,16 @@ GML_send_ack (struct CadetClient *c, CADET_ChannelNumber id)
1421 */ 1428 */
1422void 1429void
1423GML_send_channel_create (struct CadetClient *c, 1430GML_send_channel_create (struct CadetClient *c,
1424 uint32_t id, struct GNUNET_HashCode *port, 1431 struct GNUNET_CADET_ClientChannelNumber id,
1425 uint32_t opt, const struct GNUNET_PeerIdentity *peer) 1432 const struct GNUNET_HashCode *port,
1433 uint32_t opt,
1434 const struct GNUNET_PeerIdentity *peer)
1426{ 1435{
1427 struct GNUNET_CADET_ChannelCreateMessage msg; 1436 struct GNUNET_CADET_ChannelCreateMessage msg;
1428 1437
1429 msg.header.size = htons (sizeof (msg)); 1438 msg.header.size = htons (sizeof (msg));
1430 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE); 1439 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE);
1431 msg.channel_id = htonl (id); 1440 msg.channel_id = id;
1432 msg.port = *port; 1441 msg.port = *port;
1433 msg.opt = htonl (opt); 1442 msg.opt = htonl (opt);
1434 msg.peer = *peer; 1443 msg.peer = *peer;
@@ -1444,17 +1453,19 @@ GML_send_channel_create (struct CadetClient *c,
1444 * @param id Channel ID to use 1453 * @param id Channel ID to use
1445 */ 1454 */
1446void 1455void
1447GML_send_channel_nack (struct CadetClient *c, CADET_ChannelNumber id) 1456GML_send_channel_nack (struct CadetClient *c,
1457 struct GNUNET_CADET_ClientChannelNumber id)
1448{ 1458{
1449 struct GNUNET_CADET_LocalAck msg; 1459 struct GNUNET_CADET_LocalAck msg;
1450 1460
1451 LOG (GNUNET_ERROR_TYPE_DEBUG, 1461 LOG (GNUNET_ERROR_TYPE_DEBUG,
1452 "send local nack on %X towards %p\n", 1462 "send local nack on %X towards %p\n",
1453 id, c); 1463 ntohl (id.channel_of_client),
1464 c);
1454 1465
1455 msg.header.size = htons (sizeof (msg)); 1466 msg.header.size = htons (sizeof (msg));
1456 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK); 1467 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK);
1457 msg.channel_id = htonl (id); 1468 msg.channel_id = id;
1458 GNUNET_SERVER_notification_context_unicast (nc, 1469 GNUNET_SERVER_notification_context_unicast (nc,
1459 c->handle, 1470 c->handle,
1460 &msg.header, 1471 &msg.header,
@@ -1469,7 +1480,8 @@ GML_send_channel_nack (struct CadetClient *c, CADET_ChannelNumber id)
1469 * @param id ID of the channel that is destroyed. 1480 * @param id ID of the channel that is destroyed.
1470 */ 1481 */
1471void 1482void
1472GML_send_channel_destroy (struct CadetClient *c, uint32_t id) 1483GML_send_channel_destroy (struct CadetClient *c,
1484 struct GNUNET_CADET_ClientChannelNumber id)
1473{ 1485{
1474 struct GNUNET_CADET_ChannelDestroyMessage msg; 1486 struct GNUNET_CADET_ChannelDestroyMessage msg;
1475 1487
@@ -1482,7 +1494,7 @@ GML_send_channel_destroy (struct CadetClient *c, uint32_t id)
1482 return; 1494 return;
1483 msg.header.size = htons (sizeof (msg)); 1495 msg.header.size = htons (sizeof (msg));
1484 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); 1496 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
1485 msg.channel_id = htonl (id); 1497 msg.channel_id = id;
1486 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 1498 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
1487 &msg.header, GNUNET_NO); 1499 &msg.header, GNUNET_NO);
1488} 1500}
@@ -1498,7 +1510,7 @@ GML_send_channel_destroy (struct CadetClient *c, uint32_t id)
1498void 1510void
1499GML_send_data (struct CadetClient *c, 1511GML_send_data (struct CadetClient *c,
1500 const struct GNUNET_CADET_Data *msg, 1512 const struct GNUNET_CADET_Data *msg,
1501 CADET_ChannelNumber id) 1513 struct GNUNET_CADET_ClientChannelNumber id)
1502{ 1514{
1503 struct GNUNET_CADET_LocalData *copy; 1515 struct GNUNET_CADET_LocalData *copy;
1504 uint16_t size = ntohs (msg->header.size) - sizeof (struct GNUNET_CADET_Data); 1516 uint16_t size = ntohs (msg->header.size) - sizeof (struct GNUNET_CADET_Data);
@@ -1518,7 +1530,7 @@ GML_send_data (struct CadetClient *c,
1518 GNUNET_memcpy (&copy[1], &msg[1], size); 1530 GNUNET_memcpy (&copy[1], &msg[1], size);
1519 copy->header.size = htons (sizeof (struct GNUNET_CADET_LocalData) + size); 1531 copy->header.size = htons (sizeof (struct GNUNET_CADET_LocalData) + size);
1520 copy->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); 1532 copy->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
1521 copy->id = htonl (id); 1533 copy->id = id;
1522 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 1534 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
1523 &copy->header, GNUNET_NO); 1535 &copy->header, GNUNET_NO);
1524} 1536}