From 7a60a53dc6196477508fcdd1aef7994a2151814f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Aug 2011 21:05:33 +0000 Subject: [PATCH] improved client API --- src/transport/gnunet-service-transport-new.c | 2 +- .../gnunet-service-transport_clients.c | 114 +++++++++++++++++- .../gnunet-service-transport_clients.h | 99 ++++++++++++++- 3 files changed, 212 insertions(+), 3 deletions(-) diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c index 0be3f19c1..afbf328a5 100644 --- a/src/transport/gnunet-service-transport-new.c +++ b/src/transport/gnunet-service-transport-new.c @@ -79,7 +79,7 @@ static void process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) { - GST_clients_broadcast (hello); + GST_clients_broadcast (hello, GNUNET_NO); #if 0 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &transmit_our_hello_if_pong, diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 9fe367c16..aabd1f225 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -47,16 +47,128 @@ GST_clients_stop () } + +/** + * Initialize a normal client. We got an init message from this + * client, add him to the list of clients for broadcasting of inbound + * messages. + * + * @param cls unused + * @param client the client + * @param message the init message that was sent + */ +void +GST_clients_handle_init (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ +} + + +/** + * Client asked for transmission to a peer. Process the request. + * + * @param cls unused + * @param client the client + * @param message the send message that was sent + */ +void +GST_clients_handle_send (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ +} + + +/** + * Client asked for a quota change for a particular peer. Process the request. + * + * @param cls unused + * @param client the client + * @param message the quota changing message + */ +void +GST_clients_handle_set_quota (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ +} + + +/** + * Client asked to resolve an address. Process the request. + * + * @param cls unused + * @param client the client + * @param message the resolution request + */ +void +GST_clients_handle_address_lookup (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ +} + + +/** + * Client asked to obtain information about a peer's addresses. + * Process the request. + * + * @param cls unused + * @param client the client + * @param message the peer address information request + */ +void +GST_clients_handle_peer_address_lookup (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ +} + + +/** + * Client asked to obtain information about all addresses. + * Process the request. + * + * @param cls unused + * @param client the client + * @param message the peer address information request + */ +void +GST_clients_handle_address_iterate (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ +} + + /** * Broadcast the given message to all of our clients. * * @param msg message to broadcast + * @param candrop GNUNET_YES if the message can be dropped */ void -GST_clients_broadcast (const struct GNUNET_MessageHeader *msg) +GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, + int candrop) { } +/** + * Send the given message to a particular client + * + * @param client target of the message + * @param msg message to transmit + * @param candrop GNUNET_YES if the message can be dropped + */ +void +GST_clients_unicast (struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *msg, + int candrop) +{ +} + + /* end of file gnunet-service-transport_clients.c */ diff --git a/src/transport/gnunet-service-transport_clients.h b/src/transport/gnunet-service-transport_clients.h index aa696b1ab..3bd9c008c 100644 --- a/src/transport/gnunet-service-transport_clients.h +++ b/src/transport/gnunet-service-transport_clients.h @@ -46,13 +46,110 @@ void GST_clients_stop (void); +/** + * Initialize a normal client. We got an init message from this + * client, add him to the list of clients for broadcasting of inbound + * messages. + * + * @param cls unused + * @param client the client + * @param message the init message that was sent + */ +void +GST_clients_handle_init (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); + + +/** + * Client asked for transmission to a peer. Process the request. + * + * @param cls unused + * @param client the client + * @param message the send message that was sent + */ +void +GST_clients_handle_send (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); + + +/** + * Client asked for a quota change for a particular peer. Process the request. + * + * @param cls unused + * @param client the client + * @param message the quota changing message + */ +void +GST_clients_handle_set_quota (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); + + +/** + * Client asked to resolve an address. Process the request. + * + * @param cls unused + * @param client the client + * @param message the resolution request + */ +void +GST_clients_handle_address_lookup (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); + + +/** + * Client asked to obtain information about a peer's addresses. + * Process the request. + * + * @param cls unused + * @param client the client + * @param message the peer address information request + */ +void +GST_clients_handle_peer_address_lookup (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); + + +/** + * Client asked to obtain information about all addresses. + * Process the request. + * + * @param cls unused + * @param client the client + * @param message the peer address information request + */ +void +GST_clients_handle_address_iterate (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); + + /** * Broadcast the given message to all of our clients. * * @param msg message to broadcast + * @param candrop GNUNET_YES if the message can be dropped + */ +void +GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, + int candrop); + + +/** + * Send the given message to a particular client + * + * @param client target of the message + * @param msg message to transmit + * @param candrop GNUNET_YES if the message can be dropped */ void -GST_clients_broadcast (const struct GNUNET_MessageHeader *msg); +GST_clients_unicast (struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *msg, + int candrop); -- 2.25.1