[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19666 - gnunet/src/stream
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19666 - gnunet/src/stream |
Date: |
Fri, 3 Feb 2012 11:11:23 +0100 |
Author: grothoff
Date: 2012-02-03 11:11:23 +0100 (Fri, 03 Feb 2012)
New Revision: 19666
Modified:
gnunet/src/stream/stream_api.c
Log:
-misc stream hxing
Modified: gnunet/src/stream/stream_api.c
===================================================================
--- gnunet/src/stream/stream_api.c 2012-02-03 10:01:23 UTC (rev 19665)
+++ gnunet/src/stream/stream_api.c 2012-02-03 10:11:23 UTC (rev 19666)
@@ -296,43 +296,119 @@
* @param tunnel connection to the other end
* @param tunnel_ctx place to store local state associated with the tunnel
* @param sender who sent the message
- * @param message the actual message
+ * @param ack the actual message
* @param atsi performance data for the connection
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
-handle_ack (void *cls,
+handle_ack (struct STREAM_Socket *socket,
struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_STREAM_AckMessage *ack,
const struct GNUNET_ATS_Information*atsi)
{
+ return GNUNET_OK;
+}
+
+
+/**
+ * Message Handler for mesh
+ *
+ * @param cls the 'struct GNUNET_STREAM_Socket'
+ * @param tunnel connection to the other end
+ * @param tunnel_ctx unused
+ * @param sender who sent the message
+ * @param message the actual message
+ * @param atsi performance data for the connection
+ * @return GNUNET_OK to keep the connection open,
+ * GNUNET_SYSERR to close it (signal serious error)
+ */
+static int
+client_handle_ack (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
+ const struct GNUNET_PeerIdentity *sender,
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_ATS_Information*atsi)
+{
struct GNUNET_STREAM_Socket *socket = cls;
const struct GNUNET_STREAM_AckMessage *ack = (const struct
GNUNET_STREAM_AckMessage *) message;
+
+ return handle_ack (socket, tunnel, sender, ack, atsi);
+}
+
+/**
+ * Message Handler for mesh
+ *
+ * @param cls the server's listen socket
+ * @param tunnel connection to the other end
+ * @param tunnel_ctx pointer to the 'struct GNUNET_STREAM_Socket*'
+ * @param sender who sent the message
+ * @param message the actual message
+ * @param atsi performance data for the connection
+ * @return GNUNET_OK to keep the connection open,
+ * GNUNET_SYSERR to close it (signal serious error)
+ */
+static int
+server_handle_ack (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
+ const struct GNUNET_PeerIdentity *sender,
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_ATS_Information*atsi)
+{
+ struct GNUNET_STREAM_Socket *socket = *tunnel_ctx;
+ const struct GNUNET_STREAM_AckMessage *ack = (const struct
GNUNET_STREAM_AckMessage *) message;
+
+ return handle_ack (socket, tunnel, sender, ack, atsi);
}
-static struct GNUNET_MESH_MessageHandler message_handlers[] = {
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_DATA, 0},
- {&handle_ack, GNUNET_MESSAGE_TYPE_STREAM_ACK, sizeof (struct
GNUNET_STREAM_AckMessage) },
- {&handle_hello, GNUNET_MESSAGE_TYPE_STREAM_HELLO, 0},
- {&handle_hello_ack, GNUNET_MESSAGE_TYPE_STREAM_HELLO_ACK, 0},
- {&handle_reset, GNUNET_MESSAGE_TYPE_STREAM_RESET, 0},
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE, 0},
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE_ACK, 0},
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE, 0},
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE_ACK, 0},
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE, 0},
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_CLOSE, 0},
- {&handle_data, GNUNET_MESSAGE_TYPE_STREAM_CLOSE_ACK, 0},
+/**
+ * For client message handlers, the stream socket is in the
+ * closure argument.
+ */
+static struct GNUNET_MESH_MessageHandler client_message_handlers[] = {
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_DATA, 0},
+ {&client_handle_ack, GNUNET_MESSAGE_TYPE_STREAM_ACK, sizeof (struct
GNUNET_STREAM_AckMessage) },
+ {&client_handle_hello, GNUNET_MESSAGE_TYPE_STREAM_HELLO, 0},
+ {&client_handle_hello_ack, GNUNET_MESSAGE_TYPE_STREAM_HELLO_ACK, 0},
+ {&client_handle_reset, GNUNET_MESSAGE_TYPE_STREAM_RESET, 0},
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE, 0},
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE_ACK, 0},
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE, 0},
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE_ACK, 0},
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE, 0},
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_CLOSE, 0},
+ {&client_handle_data, GNUNET_MESSAGE_TYPE_STREAM_CLOSE_ACK, 0},
{NULL, 0, 0}
};
/**
+ * For server message handlers, the stream socket is in the
+ * tunnel context, and the listen socket in the closure argument.
+ */
+static struct GNUNET_MESH_MessageHandler server_message_handlers[] = {
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_DATA, 0},
+ {&server_handle_ack, GNUNET_MESSAGE_TYPE_STREAM_ACK, sizeof (struct
GNUNET_STREAM_AckMessage) },
+ {&server_handle_hello, GNUNET_MESSAGE_TYPE_STREAM_HELLO, 0},
+ {&server_handle_hello_ack, GNUNET_MESSAGE_TYPE_STREAM_HELLO_ACK, 0},
+ {&server_handle_reset, GNUNET_MESSAGE_TYPE_STREAM_RESET, 0},
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE, 0},
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_TRANSMIT_CLOSE_ACK, 0},
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE, 0},
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE_ACK, 0},
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_RECEIVE_CLOSE, 0},
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_CLOSE, 0},
+ {&server_handle_data, GNUNET_MESSAGE_TYPE_STREAM_CLOSE_ACK, 0},
+ {NULL, 0, 0}
+};
+
+
+/**
* Function called when our target peer is connected to our tunnel
*
* @param peer the peer identity of the target
@@ -521,7 +597,7 @@
* @return initial tunnel context for the tunnel
* (can be NULL -- that's not an error)
*/
-static void
+static void *
new_tunnel_notify (void *cls,
struct GNUNET_MESH_Tunnel *tunnel,
const struct GNUNET_PeerIdentity *initiator,
@@ -551,6 +627,7 @@
{
make_state_transition (socket);
}
+ return socket;
}
@@ -571,7 +648,8 @@
const struct GNUNET_MESH_Tunnel *tunnel,
void *tunnel_ctx)
{
- struct GNUNET_STREAM_Socket *socket;
+ struct GNUNET_STREAM_ListenSocket *lsocket = cls;
+ struct GNUNET_STREAM_Socket *socket = tunnel_ctx;
socket = find_socket (tunnel);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19666 - gnunet/src/stream,
gnunet <=