diff options
author | Bart Polot <bart@net.in.tum.de> | 2016-07-20 12:07:02 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2016-07-20 12:07:02 +0000 |
commit | caa4196867da8684c5b1fd2e747ecb9d21cbba8b (patch) | |
tree | a8d2ab68b81df8040c013118b7197209c70fa4c2 /src/cadet/gnunet-service-cadet_channel.c | |
parent | a603aaacbb3e786ab50644ca6fb49add439c8d8b (diff) | |
download | gnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.tar.gz gnunet-caa4196867da8684c5b1fd2e747ecb9d21cbba8b.zip |
Change CADET ports from uint32 to HashCode
Diffstat (limited to 'src/cadet/gnunet-service-cadet_channel.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 3d204e5b3..d01356c3a 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -211,7 +211,7 @@ struct CadetChannel | |||
211 | /** | 211 | /** |
212 | * Destination port of the channel. | 212 | * Destination port of the channel. |
213 | */ | 213 | */ |
214 | uint32_t port; | 214 | struct GNUNET_HashCode port; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * Global channel number ( < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) | 217 | * Global channel number ( < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI) |
@@ -552,7 +552,7 @@ send_client_create (struct CadetChannel *ch) | |||
552 | opt = 0; | 552 | opt = 0; |
553 | opt |= GNUNET_YES == ch->reliable ? GNUNET_CADET_OPTION_RELIABLE : 0; | 553 | opt |= GNUNET_YES == ch->reliable ? GNUNET_CADET_OPTION_RELIABLE : 0; |
554 | opt |= GNUNET_YES == ch->nobuffer ? GNUNET_CADET_OPTION_NOBUFFER : 0; | 554 | opt |= GNUNET_YES == ch->nobuffer ? GNUNET_CADET_OPTION_NOBUFFER : 0; |
555 | GML_send_channel_create (ch->dest, ch->lid_dest, ch->port, opt, | 555 | GML_send_channel_create (ch->dest, ch->lid_dest, &ch->port, opt, |
556 | GCT_get_destination (ch->t)); | 556 | GCT_get_destination (ch->t)); |
557 | 557 | ||
558 | } | 558 | } |
@@ -884,7 +884,7 @@ send_create (struct CadetChannel *ch) | |||
884 | msgcc.header.size = htons (sizeof (msgcc)); | 884 | msgcc.header.size = htons (sizeof (msgcc)); |
885 | msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE); | 885 | msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE); |
886 | msgcc.chid = htonl (ch->gid); | 886 | msgcc.chid = htonl (ch->gid); |
887 | msgcc.port = htonl (ch->port); | 887 | msgcc.port = ch->port; |
888 | msgcc.opt = htonl (channel_get_options (ch)); | 888 | msgcc.opt = htonl (channel_get_options (ch)); |
889 | 889 | ||
890 | GCCH_send_prebuilt_message (&msgcc.header, ch, GNUNET_YES, NULL); | 890 | GCCH_send_prebuilt_message (&msgcc.header, ch, GNUNET_YES, NULL); |
@@ -1840,7 +1840,7 @@ GCCH_handle_local_destroy (struct CadetChannel *ch, | |||
1840 | */ | 1840 | */ |
1841 | int | 1841 | int |
1842 | GCCH_handle_local_create (struct CadetClient *c, | 1842 | GCCH_handle_local_create (struct CadetClient *c, |
1843 | struct GNUNET_CADET_ChannelMessage *msg) | 1843 | struct GNUNET_CADET_ChannelCreateMessage *msg) |
1844 | { | 1844 | { |
1845 | struct CadetChannel *ch; | 1845 | struct CadetChannel *ch; |
1846 | struct CadetTunnel *t; | 1846 | struct CadetTunnel *t; |
@@ -1848,7 +1848,7 @@ GCCH_handle_local_create (struct CadetClient *c, | |||
1848 | CADET_ChannelNumber chid; | 1848 | CADET_ChannelNumber chid; |
1849 | 1849 | ||
1850 | LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", | 1850 | LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", |
1851 | GNUNET_i2s (&msg->peer), ntohl (msg->port)); | 1851 | GNUNET_i2s (&msg->peer), GNUNET_h2s (&msg->port)); |
1852 | chid = ntohl (msg->channel_id); | 1852 | chid = ntohl (msg->channel_id); |
1853 | 1853 | ||
1854 | /* Sanity check for duplicate channel IDs */ | 1854 | /* Sanity check for duplicate channel IDs */ |
@@ -1879,7 +1879,7 @@ GCCH_handle_local_create (struct CadetClient *c, | |||
1879 | GNUNET_break (0); | 1879 | GNUNET_break (0); |
1880 | return GNUNET_SYSERR; | 1880 | return GNUNET_SYSERR; |
1881 | } | 1881 | } |
1882 | ch->port = ntohl (msg->port); | 1882 | ch->port = msg->port; |
1883 | channel_set_options (ch, ntohl (msg->opt)); | 1883 | channel_set_options (ch, ntohl (msg->opt)); |
1884 | 1884 | ||
1885 | /* In unreliable channels, we'll use the DLL to buffer BCK data */ | 1885 | /* In unreliable channels, we'll use the DLL to buffer BCK data */ |
@@ -2149,7 +2149,7 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2149 | struct CadetChannel *ch; | 2149 | struct CadetChannel *ch; |
2150 | struct CadetClient *c; | 2150 | struct CadetClient *c; |
2151 | int new_channel; | 2151 | int new_channel; |
2152 | uint32_t port; | 2152 | struct GNUNET_HashCode *port; |
2153 | 2153 | ||
2154 | chid = ntohl (msg->chid); | 2154 | chid = ntohl (msg->chid); |
2155 | 2155 | ||
@@ -2166,7 +2166,7 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2166 | { | 2166 | { |
2167 | new_channel = GNUNET_NO; | 2167 | new_channel = GNUNET_NO; |
2168 | } | 2168 | } |
2169 | port = ntohl (msg->port); | 2169 | port = &msg->port; |
2170 | 2170 | ||
2171 | LOG (GNUNET_ERROR_TYPE_INFO, | 2171 | LOG (GNUNET_ERROR_TYPE_INFO, |
2172 | "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n", | 2172 | "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n", |
@@ -2176,9 +2176,9 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2176 | if (GNUNET_YES == new_channel || GCT_is_loopback (t)) | 2176 | if (GNUNET_YES == new_channel || GCT_is_loopback (t)) |
2177 | { | 2177 | { |
2178 | /* Find a destination client */ | 2178 | /* Find a destination client */ |
2179 | ch->port = port; | 2179 | ch->port = *port; |
2180 | LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port); | 2180 | LOG (GNUNET_ERROR_TYPE_DEBUG, " port %s\n", GNUNET_h2s (port)); |
2181 | c = GML_client_get_by_port (ch->port); | 2181 | c = GML_client_get_by_port (port); |
2182 | if (NULL == c) | 2182 | if (NULL == c) |
2183 | { | 2183 | { |
2184 | LOG (GNUNET_ERROR_TYPE_DEBUG, " no client has port registered\n"); | 2184 | LOG (GNUNET_ERROR_TYPE_DEBUG, " no client has port registered\n"); |
@@ -2371,6 +2371,7 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2371 | type = ntohs (message->type); | 2371 | type = ntohs (message->type); |
2372 | size = ntohs (message->size); | 2372 | size = ntohs (message->size); |
2373 | 2373 | ||
2374 | data_id = 0; | ||
2374 | switch (type) | 2375 | switch (type) |
2375 | { | 2376 | { |
2376 | case GNUNET_MESSAGE_TYPE_CADET_DATA: | 2377 | case GNUNET_MESSAGE_TYPE_CADET_DATA: |
@@ -2399,7 +2400,6 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2399 | { | 2400 | { |
2400 | struct GNUNET_CADET_ChannelCreate *cc_msg; | 2401 | struct GNUNET_CADET_ChannelCreate *cc_msg; |
2401 | cc_msg = (struct GNUNET_CADET_ChannelCreate *) message; | 2402 | cc_msg = (struct GNUNET_CADET_ChannelCreate *) message; |
2402 | data_id = ntohl (cc_msg->port); | ||
2403 | SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid)); | 2403 | SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid)); |
2404 | break; | 2404 | break; |
2405 | } | 2405 | } |
@@ -2409,12 +2409,10 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2409 | { | 2409 | { |
2410 | struct GNUNET_CADET_ChannelManage *m_msg; | 2410 | struct GNUNET_CADET_ChannelManage *m_msg; |
2411 | m_msg = (struct GNUNET_CADET_ChannelManage *) message; | 2411 | m_msg = (struct GNUNET_CADET_ChannelManage *) message; |
2412 | data_id = 0; | ||
2413 | SPRINTF (info, " 0x%08X", ntohl (m_msg->chid)); | 2412 | SPRINTF (info, " 0x%08X", ntohl (m_msg->chid)); |
2414 | break; | 2413 | break; |
2415 | } | 2414 | } |
2416 | default: | 2415 | default: |
2417 | data_id = 0; | ||
2418 | info[0] = '\0'; | 2416 | info[0] = '\0'; |
2419 | } | 2417 | } |
2420 | LOG (GNUNET_ERROR_TYPE_INFO, | 2418 | LOG (GNUNET_ERROR_TYPE_INFO, |
@@ -2540,8 +2538,9 @@ GCCH_2s (const struct CadetChannel *ch) | |||
2540 | if (NULL == ch) | 2538 | if (NULL == ch) |
2541 | return "(NULL Channel)"; | 2539 | return "(NULL Channel)"; |
2542 | 2540 | ||
2543 | SPRINTF (buf, "%s:%u gid:%X (%X / %X)", | 2541 | SPRINTF (buf, "%s:%s gid:%X (%X / %X)", |
2544 | GCT_2s (ch->t), ch->port, ch->gid, ch->lid_root, ch->lid_dest); | 2542 | GCT_2s (ch->t), GNUNET_h2s (&ch->port), |
2543 | ch->gid, ch->lid_root, ch->lid_dest); | ||
2545 | 2544 | ||
2546 | return buf; | 2545 | return buf; |
2547 | } | 2546 | } |