aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 6c7e135ce..89feffbd8 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -78,6 +78,39 @@ struct SessionConnectMessage
78}; 78};
79 79
80 80
81struct SessionDisconnectMessage
82{
83 /**
84 * Header of type 'GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT'
85 */
86 struct GNUNET_MessageHeader header;
87
88 /**
89 * Always zero.
90 */
91 uint32_t reserved GNUNET_PACKED;
92
93 /**
94 * Purpose of the signature. Extends over the timestamp.
95 * Purpose should be GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DISCONNECT.
96 */
97 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
98
99 /**
100 * Absolute time at the sender. Only the most recent connect
101 * message implies which session is preferred by the sender.
102 */
103 struct GNUNET_TIME_AbsoluteNBO timestamp;
104
105 /**
106 * Signature of the peer that sends us the disconnect. Only
107 * valid if the timestamp is AFTER the timestamp from the
108 * corresponding 'CONNECT' message.
109 */
110 struct GNUNET_CRYPTO_RsaSignature signature;
111};
112
113
81/** 114/**
82 * For each neighbour we keep a list of messages 115 * For each neighbour we keep a list of messages
83 * that we still want to transmit to the neighbour. 116 * that we still want to transmit to the neighbour.
@@ -1023,7 +1056,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
1023{ 1056{
1024 struct NeighbourMapEntry *n; 1057 struct NeighbourMapEntry *n;
1025 struct GNUNET_TRANSPORT_PluginFunctions *papi; 1058 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1026 struct GNUNET_MessageHeader disconnect_msg; 1059 struct SessionDisconnectMessage disconnect_msg;
1027 1060
1028 GNUNET_assert (neighbours != NULL); 1061 GNUNET_assert (neighbours != NULL);
1029 1062
@@ -1033,8 +1066,17 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
1033 if (GNUNET_YES == n->is_connected) 1066 if (GNUNET_YES == n->is_connected)
1034 { 1067 {
1035 /* we're actually connected, send DISCONNECT message */ 1068 /* we're actually connected, send DISCONNECT message */
1036 disconnect_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); 1069 disconnect_msg.header.size = htons (sizeof (struct SessionDisconnectMessage));
1037 disconnect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 1070 disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1071 disconnect_msg.reserved = htonl (0);
1072 disconnect_msg.purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
1073 sizeof (struct GNUNET_TIME_AbsoluteNBO));
1074 disconnect_msg.purpose.purpose = htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
1075 disconnect_msg.timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1076 GNUNET_assert (GNUNET_OK ==
1077 GNUNET_CRYPTO_rsa_sign (GST_my_private_key,
1078 &disconnect_msg.purpose,
1079 &disconnect_msg.signature));
1038 papi = GST_plugins_find (n->plugin_name); 1080 papi = GST_plugins_find (n->plugin_name);
1039 if (papi != NULL) 1081 if (papi != NULL)
1040 papi->send (papi->cls, target, (const void *) &disconnect_msg, 1082 papi->send (papi->cls, target, (const void *) &disconnect_msg,