diff options
author | Bart Polot <bart@net.in.tum.de> | 2015-10-06 12:03:14 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2015-10-06 12:03:14 +0000 |
commit | 79f53fe65e00a29889b290fca9c9390101ea537e (patch) | |
tree | e169fc09e181acc9d73cc51f224bbbc3898564cf /src/cadet/gnunet-service-cadet_channel.c | |
parent | c3c8597a4ce377b7825e4a526b7de1daeba2105d (diff) | |
download | gnunet-79f53fe65e00a29889b290fca9c9390101ea537e.tar.gz gnunet-79f53fe65e00a29889b290fca9c9390101ea537e.zip |
- Revamp traffic logging, small bugfixes, complete doxygen
Diffstat (limited to 'src/cadet/gnunet-service-cadet_channel.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.c | 120 |
1 files changed, 99 insertions, 21 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 367a34e5d..d7fe82d20 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -1041,7 +1041,7 @@ channel_rel_free_sent (struct CadetChannelReliability *rel, | |||
1041 | 1041 | ||
1042 | bitfield = msg->futures; | 1042 | bitfield = msg->futures; |
1043 | mid = ntohl (msg->mid); | 1043 | mid = ntohl (msg->mid); |
1044 | LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable %u %llX\n", mid, bitfield); | 1044 | LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable %u %lX\n", mid, bitfield); |
1045 | LOG (GNUNET_ERROR_TYPE_DEBUG, " rel %p, head %p\n", rel, rel->head_sent); | 1045 | LOG (GNUNET_ERROR_TYPE_DEBUG, " rel %p, head %p\n", rel, rel->head_sent); |
1046 | for (i = 0, r = 0, copy = rel->head_sent; | 1046 | for (i = 0, r = 0, copy = rel->head_sent; |
1047 | i < 64 && NULL != copy && 0 != bitfield; | 1047 | i < 64 && NULL != copy && 0 != bitfield; |
@@ -1561,11 +1561,9 @@ GCCH_send_data_ack (struct CadetChannel *ch, int fwd) | |||
1561 | mask = 0x1LL << delta; | 1561 | mask = 0x1LL << delta; |
1562 | msg.futures |= mask; | 1562 | msg.futures |= mask; |
1563 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1563 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1564 | " setting bit for %u (delta %u) (%llX) -> %llX\n", | 1564 | " setting bit for %u (delta %u) (%lX) -> %lX\n", |
1565 | copy->mid, delta, mask, msg.futures); | 1565 | copy->mid, delta, mask, msg.futures); |
1566 | } | 1566 | } |
1567 | LOG (GNUNET_ERROR_TYPE_INFO, "===> DATA_ACK for %u + %llX\n", | ||
1568 | ack, msg.futures); | ||
1569 | 1567 | ||
1570 | GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL); | 1568 | GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL); |
1571 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n"); | 1569 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n"); |
@@ -1859,7 +1857,7 @@ GCCH_handle_local_create (struct CadetClient *c, | |||
1859 | CADET_ChannelNumber chid; | 1857 | CADET_ChannelNumber chid; |
1860 | 1858 | ||
1861 | LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", | 1859 | LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", |
1862 | GNUNET_i2s (&msg->peer), ntohl (msg->port)); | 1860 | GNUNET_i2s (&msg->peer), ntohl (msg->port)); |
1863 | chid = ntohl (msg->channel_id); | 1861 | chid = ntohl (msg->channel_id); |
1864 | 1862 | ||
1865 | /* Sanity check for duplicate channel IDs */ | 1863 | /* Sanity check for duplicate channel IDs */ |
@@ -1924,7 +1922,10 @@ GCCH_handle_data (struct CadetChannel *ch, | |||
1924 | { | 1922 | { |
1925 | struct CadetChannelReliability *rel; | 1923 | struct CadetChannelReliability *rel; |
1926 | struct CadetClient *c; | 1924 | struct CadetClient *c; |
1925 | struct GNUNET_MessageHeader *payload_msg; | ||
1927 | uint32_t mid; | 1926 | uint32_t mid; |
1927 | uint16_t payload_type; | ||
1928 | uint16_t payload_size; | ||
1928 | 1929 | ||
1929 | /* If this is a remote (non-loopback) channel, find 'fwd'. */ | 1930 | /* If this is a remote (non-loopback) channel, find 'fwd'. */ |
1930 | if (GNUNET_SYSERR == fwd) | 1931 | if (GNUNET_SYSERR == fwd) |
@@ -1965,18 +1966,22 @@ GCCH_handle_data (struct CadetChannel *ch, | |||
1965 | channel_confirm (ch, GNUNET_NO); | 1966 | channel_confirm (ch, GNUNET_NO); |
1966 | } | 1967 | } |
1967 | 1968 | ||
1968 | GNUNET_STATISTICS_update (stats, "# data received", 1, GNUNET_NO); | 1969 | payload_msg = (struct GNUNET_MessageHeader *) &msg[1]; |
1970 | payload_type = ntohs (payload_msg->type); | ||
1971 | payload_size = ntohs (payload_msg->size); | ||
1972 | |||
1973 | GNUNET_STATISTICS_update (stats, "# messages received", 1, GNUNET_NO); | ||
1974 | GNUNET_STATISTICS_update (stats, "# bytes received", payload_size, GNUNET_NO); | ||
1969 | 1975 | ||
1970 | mid = ntohl (msg->mid); | 1976 | mid = ntohl (msg->mid); |
1971 | LOG (GNUNET_ERROR_TYPE_INFO, "<=== DATA %u %s on channel %s\n", | 1977 | LOG (GNUNET_ERROR_TYPE_INFO, "<== %s (%s %4u) on chan %s (%p) %s [%5u]\n", |
1972 | mid, GC_f2s (fwd), GCCH_2s (ch)); | 1978 | GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA), GC_m2s (payload_type), mid, |
1979 | GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size)); | ||
1973 | 1980 | ||
1974 | if (GNUNET_NO == ch->reliable || | 1981 | if (GNUNET_NO == ch->reliable || |
1975 | ( !GC_is_pid_bigger (rel->mid_recv, mid) && | 1982 | ( !GC_is_pid_bigger (rel->mid_recv, mid) && |
1976 | GC_is_pid_bigger (rel->mid_recv + 64, mid) ) ) | 1983 | GC_is_pid_bigger (rel->mid_recv + 64, mid) ) ) |
1977 | { | 1984 | { |
1978 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RECV MID %u (%u)\n", | ||
1979 | mid, ntohs (msg->header.size)); | ||
1980 | if (GNUNET_YES == ch->reliable) | 1985 | if (GNUNET_YES == ch->reliable) |
1981 | { | 1986 | { |
1982 | /* Is this the exact next expected messasge? */ | 1987 | /* Is this the exact next expected messasge? */ |
@@ -2063,8 +2068,10 @@ GCCH_handle_data_ack (struct CadetChannel *ch, | |||
2063 | } | 2068 | } |
2064 | 2069 | ||
2065 | ack = ntohl (msg->mid); | 2070 | ack = ntohl (msg->mid); |
2066 | LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s ACK %u + %llX\n", | 2071 | LOG (GNUNET_ERROR_TYPE_INFO, |
2067 | GC_f2s (fwd), ack, msg->futures); | 2072 | "<== %s (0x%010lX %4u) on chan %s (%p) %s [%5u]\n", |
2073 | GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA_ACK), msg->futures, ack, | ||
2074 | GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size)); | ||
2068 | 2075 | ||
2069 | if (GNUNET_YES == fwd) | 2076 | if (GNUNET_YES == fwd) |
2070 | rel = ch->root_rel; | 2077 | rel = ch->root_rel; |
@@ -2151,8 +2158,10 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2151 | struct CadetChannel *ch; | 2158 | struct CadetChannel *ch; |
2152 | struct CadetClient *c; | 2159 | struct CadetClient *c; |
2153 | int new_channel; | 2160 | int new_channel; |
2161 | uint32_t port; | ||
2154 | 2162 | ||
2155 | chid = ntohl (msg->chid); | 2163 | chid = ntohl (msg->chid); |
2164 | |||
2156 | ch = GCT_get_channel (t, chid); | 2165 | ch = GCT_get_channel (t, chid); |
2157 | if (NULL == ch) | 2166 | if (NULL == ch) |
2158 | { | 2167 | { |
@@ -2166,11 +2175,17 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2166 | { | 2175 | { |
2167 | new_channel = GNUNET_NO; | 2176 | new_channel = GNUNET_NO; |
2168 | } | 2177 | } |
2178 | port = ntohl (msg->port); | ||
2179 | |||
2180 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
2181 | "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n", | ||
2182 | GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE), chid, port, | ||
2183 | GCCH_2s (ch), ch, GC_f2s (GNUNET_YES), ntohs (msg->header.size)); | ||
2169 | 2184 | ||
2170 | if (GNUNET_YES == new_channel || GCT_is_loopback (t)) | 2185 | if (GNUNET_YES == new_channel || GCT_is_loopback (t)) |
2171 | { | 2186 | { |
2172 | /* Find a destination client */ | 2187 | /* Find a destination client */ |
2173 | ch->port = ntohl (msg->port); | 2188 | ch->port = port; |
2174 | LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port); | 2189 | LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port); |
2175 | c = GML_client_get_by_port (ch->port); | 2190 | c = GML_client_get_by_port (ch->port); |
2176 | if (NULL == c) | 2191 | if (NULL == c) |
@@ -2235,6 +2250,11 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2235 | void | 2250 | void |
2236 | GCCH_handle_nack (struct CadetChannel *ch) | 2251 | GCCH_handle_nack (struct CadetChannel *ch) |
2237 | { | 2252 | { |
2253 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
2254 | "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n", | ||
2255 | GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK), ch->gid, 0, | ||
2256 | GCCH_2s (ch), ch, "---", 0); | ||
2257 | |||
2238 | send_client_nack (ch); | 2258 | send_client_nack (ch); |
2239 | GCCH_destroy (ch); | 2259 | GCCH_destroy (ch); |
2240 | } | 2260 | } |
@@ -2255,6 +2275,11 @@ GCCH_handle_ack (struct CadetChannel *ch, | |||
2255 | const struct GNUNET_CADET_ChannelManage *msg, | 2275 | const struct GNUNET_CADET_ChannelManage *msg, |
2256 | int fwd) | 2276 | int fwd) |
2257 | { | 2277 | { |
2278 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
2279 | "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n", | ||
2280 | GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK), ch->gid, 0, | ||
2281 | GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size)); | ||
2282 | |||
2258 | /* If this is a remote (non-loopback) channel, find 'fwd'. */ | 2283 | /* If this is a remote (non-loopback) channel, find 'fwd'. */ |
2259 | if (GNUNET_SYSERR == fwd) | 2284 | if (GNUNET_SYSERR == fwd) |
2260 | { | 2285 | { |
@@ -2288,6 +2313,11 @@ GCCH_handle_destroy (struct CadetChannel *ch, | |||
2288 | { | 2313 | { |
2289 | struct CadetChannelReliability *rel; | 2314 | struct CadetChannelReliability *rel; |
2290 | 2315 | ||
2316 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
2317 | "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n", | ||
2318 | GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY), ch->gid, 0, | ||
2319 | GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size)); | ||
2320 | |||
2291 | /* If this is a remote (non-loopback) channel, find 'fwd'. */ | 2321 | /* If this is a remote (non-loopback) channel, find 'fwd'. */ |
2292 | if (GNUNET_SYSERR == fwd) | 2322 | if (GNUNET_SYSERR == fwd) |
2293 | { | 2323 | { |
@@ -2342,11 +2372,64 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2342 | void *existing_copy) | 2372 | void *existing_copy) |
2343 | { | 2373 | { |
2344 | struct CadetChannelQueue *chq; | 2374 | struct CadetChannelQueue *chq; |
2375 | uint32_t data_id; | ||
2345 | uint16_t type; | 2376 | uint16_t type; |
2377 | uint16_t size; | ||
2378 | char info[32]; | ||
2346 | 2379 | ||
2347 | type = ntohs (message->type); | 2380 | type = ntohs (message->type); |
2348 | LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %s on channel %s\n", | 2381 | size = ntohs (message->size); |
2349 | GC_m2s (type), GC_f2s (fwd), GCCH_2s (ch)); | 2382 | |
2383 | switch (type) | ||
2384 | { | ||
2385 | case GNUNET_MESSAGE_TYPE_CADET_DATA: | ||
2386 | { | ||
2387 | struct GNUNET_CADET_Data *data_msg; | ||
2388 | struct GNUNET_MessageHeader *payload_msg; | ||
2389 | uint16_t payload_type; | ||
2390 | |||
2391 | data_msg = (struct GNUNET_CADET_Data *) message; | ||
2392 | data_id = ntohl (data_msg->mid); | ||
2393 | payload_msg = (struct GNUNET_MessageHeader *) &data_msg[1]; | ||
2394 | payload_type = ntohs (payload_msg->type); | ||
2395 | strncpy (info, GC_m2s (payload_type), 31); | ||
2396 | info[31] = '\0'; | ||
2397 | break; | ||
2398 | } | ||
2399 | case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK: | ||
2400 | { | ||
2401 | struct GNUNET_CADET_DataACK *ack_msg; | ||
2402 | ack_msg = (struct GNUNET_CADET_DataACK *) message; | ||
2403 | data_id = ntohl (ack_msg->mid); | ||
2404 | SPRINTF (info, "0x%010lX", ack_msg->futures); | ||
2405 | break; | ||
2406 | } | ||
2407 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: | ||
2408 | { | ||
2409 | struct GNUNET_CADET_ChannelCreate *cc_msg; | ||
2410 | cc_msg = (struct GNUNET_CADET_ChannelCreate *) message; | ||
2411 | data_id = ntohl (cc_msg->port); | ||
2412 | SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid)); | ||
2413 | break; | ||
2414 | } | ||
2415 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK: | ||
2416 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK: | ||
2417 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY: | ||
2418 | { | ||
2419 | struct GNUNET_CADET_ChannelManage *m_msg; | ||
2420 | m_msg = (struct GNUNET_CADET_ChannelManage *) message; | ||
2421 | data_id = 0; | ||
2422 | SPRINTF (info, " 0x%08X", ntohl (m_msg->chid)); | ||
2423 | break; | ||
2424 | } | ||
2425 | default: | ||
2426 | data_id = 0; | ||
2427 | info[0] = '\0'; | ||
2428 | } | ||
2429 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
2430 | "==> %s (%12s %4u) on chan %s (%p) %s [%5u]\n", | ||
2431 | GC_m2s (type), info, data_id, | ||
2432 | GCCH_2s (ch), ch, GC_f2s (fwd), size); | ||
2350 | 2433 | ||
2351 | if (GCT_is_loopback (ch->t)) | 2434 | if (GCT_is_loopback (ch->t)) |
2352 | { | 2435 | { |
@@ -2356,12 +2439,7 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2356 | 2439 | ||
2357 | switch (type) | 2440 | switch (type) |
2358 | { | 2441 | { |
2359 | struct GNUNET_CADET_Data *payload; | ||
2360 | case GNUNET_MESSAGE_TYPE_CADET_DATA: | 2442 | case GNUNET_MESSAGE_TYPE_CADET_DATA: |
2361 | |||
2362 | payload = (struct GNUNET_CADET_Data *) message; | ||
2363 | LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %u\n", | ||
2364 | GC_m2s (type), ntohl (payload->mid)); | ||
2365 | if (GNUNET_YES == ch->reliable) | 2443 | if (GNUNET_YES == ch->reliable) |
2366 | { | 2444 | { |
2367 | chq = GNUNET_new (struct CadetChannelQueue); | 2445 | chq = GNUNET_new (struct CadetChannelQueue); |
@@ -2450,7 +2528,7 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2450 | 2528 | ||
2451 | default: | 2529 | default: |
2452 | GNUNET_break (0); | 2530 | GNUNET_break (0); |
2453 | LOG (GNUNET_ERROR_TYPE_DEBUG, "type %s unknown!\n", GC_m2s (type)); | 2531 | LOG (GNUNET_ERROR_TYPE_WARNING, "type %s unknown!\n", GC_m2s (type)); |
2454 | fire_and_forget (message, ch, GNUNET_YES); | 2532 | fire_and_forget (message, ch, GNUNET_YES); |
2455 | } | 2533 | } |
2456 | } | 2534 | } |