aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_signatures.h6
-rw-r--r--src/transport/gnunet-service-transport.c4
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c48
3 files changed, 49 insertions, 9 deletions
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h
index c54df3e85..580282d82 100644
--- a/src/include/gnunet_signatures.h
+++ b/src/include/gnunet_signatures.h
@@ -48,11 +48,9 @@ extern "C"
48#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN 1 48#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN 1
49 49
50/** 50/**
51 * Signature for confirming that this peer connected to another peer 51 * Signature for confirming that this peer intends to disconnect.
52 * using a particular address (LEGACY)
53 */ 52 */
54#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING 2 53#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DISCONNECT 2
55
56 54
57/** 55/**
58 * Purpose is to set a session key. 56 * Purpose is to set a session key.
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index d1ef887fd..4687a0907 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -205,8 +205,8 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
205 * * way to communicate with this peer (other peer switched transport) */ 205 * * way to communicate with this peer (other peer switched transport) */
206 break; 206 break;
207 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: 207 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
208 /* TODO: do some validation to prevent an attacker from sending 208 /* FIXME: do some validation to prevent an attacker from sending
209 * a fake disconnect message... */ 209 * a fake disconnect message... */
210 GST_neighbours_force_disconnect (peer); 210 GST_neighbours_force_disconnect (peer);
211 break; 211 break;
212 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE: 212 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE:
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,