diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-01-27 04:29:52 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-01-27 04:29:52 +0100 |
commit | 1c9f269ea5cadb20bb5f7fc209274ba5d6af4749 (patch) | |
tree | ce241e18c8db4876be1fd7ed4d7b7460994fd815 /src/cadet/gnunet-service-cadet.c | |
parent | f0b35049f6d9e743d2bc5fcf11664633d130d6fc (diff) | |
download | gnunet-1c9f269ea5cadb20bb5f7fc209274ba5d6af4749.tar.gz gnunet-1c9f269ea5cadb20bb5f7fc209274ba5d6af4749.zip |
in principle finished with #5385, could use some testing...
Diffstat (limited to 'src/cadet/gnunet-service-cadet.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet.c | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c index ef5fa6d7e..97950a18a 100644 --- a/src/cadet/gnunet-service-cadet.c +++ b/src/cadet/gnunet-service-cadet.c | |||
@@ -998,109 +998,6 @@ handle_info_tunnels (void *cls, | |||
998 | 998 | ||
999 | 999 | ||
1000 | /** | 1000 | /** |
1001 | * Update the message with information about the connection. | ||
1002 | * | ||
1003 | * @param cls a `struct GNUNET_CADET_LocalInfoTunnel` message to update | ||
1004 | * @param ct a connection about which we should store information in @a cls | ||
1005 | */ | ||
1006 | static void | ||
1007 | iter_connection (void *cls, | ||
1008 | struct CadetTConnection *ct) | ||
1009 | { | ||
1010 | struct GNUNET_CADET_LocalInfoTunnel *msg = cls; | ||
1011 | struct CadetConnection *cc = ct->cc; | ||
1012 | struct GNUNET_CADET_ConnectionTunnelIdentifier *h; | ||
1013 | |||
1014 | h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1]; | ||
1015 | h[msg->connections++] = *(GCC_get_id (cc)); | ||
1016 | } | ||
1017 | |||
1018 | |||
1019 | /** | ||
1020 | * Update the message with information about the channel. | ||
1021 | * | ||
1022 | * @param cls a `struct GNUNET_CADET_LocalInfoTunnel` message to update | ||
1023 | * @param ch a channel about which we should store information in @a cls | ||
1024 | */ | ||
1025 | static void | ||
1026 | iter_channel (void *cls, | ||
1027 | struct CadetChannel *ch) | ||
1028 | { | ||
1029 | struct GNUNET_CADET_LocalInfoTunnel *msg = cls; | ||
1030 | struct GNUNET_CADET_ConnectionTunnelIdentifier *h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1]; | ||
1031 | struct GNUNET_CADET_ChannelTunnelNumber *chn | ||
1032 | = (struct GNUNET_CADET_ChannelTunnelNumber *) &h[msg->connections]; | ||
1033 | |||
1034 | chn[msg->channels++] = GCCH_get_id (ch); | ||
1035 | } | ||
1036 | |||
1037 | |||
1038 | /** | ||
1039 | * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNEL request. | ||
1040 | * | ||
1041 | * @param cls Identification of the client. | ||
1042 | * @param msg The actual message. | ||
1043 | */ | ||
1044 | static void | ||
1045 | handle_info_tunnel (void *cls, | ||
1046 | const struct GNUNET_CADET_LocalInfo *msg) | ||
1047 | { | ||
1048 | struct CadetClient *c = cls; | ||
1049 | struct GNUNET_MQ_Envelope *env; | ||
1050 | struct GNUNET_CADET_LocalInfoTunnel *resp; | ||
1051 | struct CadetTunnel *t; | ||
1052 | struct CadetPeer *p; | ||
1053 | unsigned int ch_n; | ||
1054 | unsigned int c_n; | ||
1055 | |||
1056 | p = GCP_get (&msg->peer, | ||
1057 | GNUNET_NO); | ||
1058 | t = GCP_get_tunnel (p, | ||
1059 | GNUNET_NO); | ||
1060 | if (NULL == t) | ||
1061 | { | ||
1062 | /* We don't know the tunnel */ | ||
1063 | struct GNUNET_MQ_Envelope *env; | ||
1064 | struct GNUNET_CADET_LocalInfoTunnel *warn; | ||
1065 | |||
1066 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
1067 | "Tunnel to %s unknown\n", | ||
1068 | GNUNET_i2s_full (&msg->peer)); | ||
1069 | env = GNUNET_MQ_msg (warn, | ||
1070 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); | ||
1071 | warn->destination = msg->peer; | ||
1072 | GNUNET_MQ_send (c->mq, | ||
1073 | env); | ||
1074 | GNUNET_SERVICE_client_continue (c->client); | ||
1075 | return; | ||
1076 | } | ||
1077 | |||
1078 | /* Initialize context */ | ||
1079 | ch_n = GCT_count_channels (t); | ||
1080 | c_n = GCT_count_any_connections (t); | ||
1081 | env = GNUNET_MQ_msg_extra (resp, | ||
1082 | c_n * sizeof (struct GNUNET_CADET_ConnectionTunnelIdentifier) + | ||
1083 | ch_n * sizeof (struct GNUNET_CADET_ChannelTunnelNumber), | ||
1084 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); | ||
1085 | resp->destination = msg->peer; | ||
1086 | /* Do not reorder! #iter_channel needs counters in HBO! */ | ||
1087 | GCT_iterate_connections (t, | ||
1088 | &iter_connection, | ||
1089 | resp); | ||
1090 | GCT_iterate_channels (t, | ||
1091 | &iter_channel, | ||
1092 | resp); | ||
1093 | resp->connections = htonl (resp->connections); | ||
1094 | resp->channels = htonl (resp->channels); | ||
1095 | resp->cstate = htons (0); | ||
1096 | resp->estate = htons (GCT_get_estate (t)); | ||
1097 | GNUNET_MQ_send (c->mq, | ||
1098 | env); | ||
1099 | GNUNET_SERVICE_client_continue (c->client); | ||
1100 | } | ||
1101 | |||
1102 | |||
1103 | /** | ||
1104 | * Callback called when a client connects to the service. | 1001 | * Callback called when a client connects to the service. |
1105 | * | 1002 | * |
1106 | * @param cls closure for the service | 1003 | * @param cls closure for the service |
@@ -1438,10 +1335,6 @@ GNUNET_SERVICE_MAIN | |||
1438 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, | 1335 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, |
1439 | struct GNUNET_MessageHeader, | 1336 | struct GNUNET_MessageHeader, |
1440 | NULL), | 1337 | NULL), |
1441 | GNUNET_MQ_hd_fixed_size (info_tunnel, | ||
1442 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL, | ||
1443 | struct GNUNET_CADET_LocalInfo, | ||
1444 | NULL), | ||
1445 | GNUNET_MQ_handler_end ()); | 1338 | GNUNET_MQ_handler_end ()); |
1446 | 1339 | ||
1447 | /* end of gnunet-service-cadet-new.c */ | 1340 | /* end of gnunet-service-cadet-new.c */ |