aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-tng.c118
-rw-r--r--src/transport/transport.h2
2 files changed, 106 insertions, 14 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 9f0e7845c..b55cd2485 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -2068,10 +2068,48 @@ handle_communicator_available (void *cls,
2068 2068
2069 2069
2070/** 2070/**
2071 * Communicator requests backchannel transmission. Check the request.
2072 *
2073 * @param cls the client
2074 * @param cb the send message that was sent
2075 * @return #GNUNET_OK if message is well-formed
2076 */
2077static int
2078check_communicator_backchannel (void *cls,
2079 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
2080{
2081 // FIXME: check encapsulated message
2082 // FIXME: check 0-termination of communcator at target
2083 return GNUNET_OK;
2084}
2085
2086
2087/**
2088 * Communicator requests backchannel transmission. Process the request.
2089 *
2090 * @param cls the client
2091 * @param cb the send message that was sent
2092 */
2093static void
2094handle_communicator_backchannel (void *cls,
2095 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
2096{
2097 struct TransportClient *tc = cls;
2098
2099 // FIXME: determine path (possibly DV)! to target peer
2100 // FIXME: encapsulate message, encrypt message!
2101 // FIXME: possibly fragment message
2102 // FIXME: possibly DV-route message!
2103 GNUNET_SERVICE_client_continue (tc->client);
2104}
2105
2106
2107/**
2071 * Address of our peer added. Test message is well-formed. 2108 * Address of our peer added. Test message is well-formed.
2072 * 2109 *
2073 * @param cls the client 2110 * @param cls the client
2074 * @param aam the send message that was sent 2111 * @param aam the send message that was sent
2112 * @return #GNUNET_OK if message is well-formed
2075 */ 2113 */
2076static int 2114static int
2077check_add_address (void *cls, 2115check_add_address (void *cls,
@@ -2272,14 +2310,13 @@ finish_cmc_handling (struct CommunicatorMessageContext *cmc)
2272 env); 2310 env);
2273 } 2311 }
2274 GNUNET_SERVICE_client_continue (cmc->tc->client); 2312 GNUNET_SERVICE_client_continue (cmc->tc->client);
2275
2276 GNUNET_free (cmc); 2313 GNUNET_free (cmc);
2277} 2314}
2278 2315
2279 2316
2280/** 2317/**
2281 * Communicator gave us an unencapsulated message to pass 2318 * Communicator gave us an unencapsulated message to pass as-is to
2282 * as-is to CORE. Process the request. 2319 * CORE. Process the request.
2283 * 2320 *
2284 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done) 2321 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
2285 * @param mh the message that was received 2322 * @param mh the message that was received
@@ -2289,8 +2326,41 @@ handle_raw_message (void *cls,
2289 const struct GNUNET_MessageHeader *mh) 2326 const struct GNUNET_MessageHeader *mh)
2290{ 2327{
2291 struct CommunicatorMessageContext *cmc = cls; 2328 struct CommunicatorMessageContext *cmc = cls;
2292 2329 uint16_t size = ntohs (mh->size);
2293 // FIXME: do work! 2330
2331 if ( (size > UINT16_MAX - sizeof (struct InboundMessage)) ||
2332 (size < sizeof (struct GNUNET_MessageHeader)) )
2333 {
2334 struct GNUNET_SERVICE_Client *client = cmc->tc->client;
2335
2336 GNUNET_break (0);
2337 finish_cmc_handling (cmc);
2338 GNUNET_SERVICE_client_drop (client);
2339 return;
2340 }
2341 /* Forward to all CORE clients */
2342 for (struct TransportClient *tc = clients_head;
2343 NULL != tc;
2344 tc = tc->next)
2345 {
2346 struct GNUNET_MQ_Envelope *env;
2347 struct InboundMessage *im;
2348
2349 if (CT_CORE != tc->type)
2350 continue;
2351 env = GNUNET_MQ_msg_extra (im,
2352 size,
2353 GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
2354 im->peer = cmc->im.sender;
2355 memcpy (&im[1],
2356 mh,
2357 size);
2358 GNUNET_MQ_send (tc->mq,
2359 env);
2360 }
2361 /* FIXME: consider doing this _only_ once the message
2362 was drained from the CORE MQs to extend flow control to CORE!
2363 (basically, increment counter in cmc, decrement on MQ send continuation! */
2294 finish_cmc_handling (cmc); 2364 finish_cmc_handling (cmc);
2295} 2365}
2296 2366
@@ -2389,9 +2459,12 @@ handle_reliability_box (void *cls,
2389 const struct TransportReliabilityBox *rb) 2459 const struct TransportReliabilityBox *rb)
2390{ 2460{
2391 struct CommunicatorMessageContext *cmc = cls; 2461 struct CommunicatorMessageContext *cmc = cls;
2462 const struct GNUNET_MessageHeader *inbox = (const struct GNUNET_MessageHeader *) &rb[1];
2392 2463
2393 // FIXME: do work! 2464 // FIXME: send back reliability ACK (possibly conditional)
2394 finish_cmc_handling (cmc); 2465 /* forward encapsulated message to CORE */
2466 handle_raw_message (cmc,
2467 inbox);
2395} 2468}
2396 2469
2397 2470
@@ -2407,7 +2480,8 @@ handle_reliability_ack (void *cls,
2407{ 2480{
2408 struct CommunicatorMessageContext *cmc = cls; 2481 struct CommunicatorMessageContext *cmc = cls;
2409 2482
2410 // FIXME: do work! 2483 // FIXME: do work: find message that was acknowledged, and
2484 // remove from transmission queue; update RTT.
2411 finish_cmc_handling (cmc); 2485 finish_cmc_handling (cmc);
2412} 2486}
2413 2487
@@ -2445,8 +2519,13 @@ handle_backchannel_encapsulation (void *cls,
2445 const struct TransportBackchannelEncapsulationMessage *be) 2519 const struct TransportBackchannelEncapsulationMessage *be)
2446{ 2520{
2447 struct CommunicatorMessageContext *cmc = cls; 2521 struct CommunicatorMessageContext *cmc = cls;
2522
2523 // FIMXE: test if it is for me, if not, try to forward to target (DV routes!)
2524 // FIXME: compute shared secret
2525 // FIXME: check HMAC
2526 // FIXME: decrypt payload
2527 // FIXME: forward to specified communicator!
2448 2528
2449 // FIXME: do work!
2450 finish_cmc_handling (cmc); 2529 finish_cmc_handling (cmc);
2451} 2530}
2452 2531
@@ -2462,8 +2541,15 @@ handle_ephemeral_confirmation (void *cls,
2462 const struct EphemeralConfirmationMessage *ec) 2541 const struct EphemeralConfirmationMessage *ec)
2463{ 2542{
2464 struct CommunicatorMessageContext *cmc = cls; 2543 struct CommunicatorMessageContext *cmc = cls;
2465 2544
2466 // FIXME: do work! 2545 // FIXME: notify communicator (?) about ephemeral confirmation!?
2546 // FIXME: or does this have something to do with the ephemeral_map?
2547 // where did I plan to use this message again!?
2548 // FIXME: communicator API has a very general notification API,
2549 // nothing specific for ephemeral keys;
2550 // why do we have a ephemeral key-specific message here?
2551 // => first revise where we get such messages from communicator
2552 // before processing further here!
2467 finish_cmc_handling (cmc); 2553 finish_cmc_handling (cmc);
2468} 2554}
2469 2555
@@ -2521,7 +2607,8 @@ handle_dv_learn (void *cls,
2521{ 2607{
2522 struct CommunicatorMessageContext *cmc = cls; 2608 struct CommunicatorMessageContext *cmc = cls;
2523 2609
2524 // FIXME: do work! 2610 // FIXME: learn path from DV message (if bi-directional flags are set)
2611 // FIXME: expand DV message, forward on (unless path is getting too long)
2525 finish_cmc_handling (cmc); 2612 finish_cmc_handling (cmc);
2526} 2613}
2527 2614
@@ -2578,7 +2665,8 @@ handle_dv_box (void *cls,
2578{ 2665{
2579 struct CommunicatorMessageContext *cmc = cls; 2666 struct CommunicatorMessageContext *cmc = cls;
2580 2667
2581 // FIXME: do work! 2668 // FIXME: are we the target? Then unbox and handle message.
2669 // FIXME: if we are not the target, shorten path and forward along.
2582 finish_cmc_handling (cmc); 2670 finish_cmc_handling (cmc);
2583} 2671}
2584 2672
@@ -3814,6 +3902,10 @@ GNUNET_SERVICE_MAIN
3814 GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, 3902 GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
3815 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, 3903 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
3816 NULL), 3904 NULL),
3905 GNUNET_MQ_hd_var_size (communicator_backchannel,
3906 GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
3907 struct GNUNET_TRANSPORT_CommunicatorBackchannel,
3908 NULL),
3817 GNUNET_MQ_hd_var_size (add_address, 3909 GNUNET_MQ_hd_var_size (add_address,
3818 GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, 3910 GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
3819 struct GNUNET_TRANSPORT_AddAddressMessage, 3911 struct GNUNET_TRANSPORT_AddAddressMessage,
diff --git a/src/transport/transport.h b/src/transport/transport.h
index 6b1a2cac1..24479e4c6 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -973,7 +973,7 @@ struct GNUNET_TRANSPORT_CommunicatorBackchannel
973 message to the communicator */ 973 message to the communicator */
974 974
975 /* Followed by the 0-terminated string specifying the desired 975 /* Followed by the 0-terminated string specifying the desired
976 communicator */ 976 communicator at the target (@e pid) peer */
977}; 977};
978 978
979 979