From: Christian Grothoff Date: Sat, 13 Aug 2011 21:59:41 +0000 (+0000) Subject: setup handlers X-Git-Tag: initial-import-from-subversion-38251~17361 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=06d594e14f81143df0197ce468bd82967471bcb4;p=oweals%2Fgnunet.git setup handlers --- diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c index d0ad2fbad..da0bfa6d3 100644 --- a/src/transport/gnunet-service-transport-new.c +++ b/src/transport/gnunet-service-transport-new.c @@ -354,11 +354,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { -#if 0 - static const struct GNUNET_SERVER_MessageHandler handlers[] = { - {NULL, NULL, 0, 0} - }; -#endif char *keyfile; /* setup globals */ diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 64592d5d6..f03c3a4d3 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -325,29 +325,6 @@ client_disconnect_notification (void *cls, } -/** - * Start handling requests from clients. - * - * @param server server used to accept clients from. - */ -void -GST_clients_start (struct GNUNET_SERVER_Handle *server) -{ - GNUNET_SERVER_disconnect_notify (server, - &client_disconnect_notification, NULL); -} - - -/** - * Stop processing clients. - */ -void -GST_clients_stop () -{ - /* nothing to do */ -} - - /** * Function called for each of our connected neighbours. Notify the * client about the existing neighbour. @@ -391,10 +368,10 @@ notify_client_about_neighbour (void *cls, * @param client the client * @param message the start message that was sent */ -void -GST_clients_handle_start (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) +static void +clients_handle_start (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { const struct StartMessage *start; struct TransportClient *tc; @@ -434,10 +411,10 @@ GST_clients_handle_start (void *cls, * @param client the client * @param message the HELLO message */ -void -GST_clients_handle_hello (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) +static void +clients_handle_hello (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { GST_validation_handle_hello (message); GNUNET_SERVER_receive_done (client, GNUNET_OK); @@ -493,10 +470,10 @@ handle_send_transmit_continuation (void *cls, * @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) +static void +clients_handle_send (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { const struct OutboundMessage *obm; const struct GNUNET_MessageHeader *obmm; @@ -563,10 +540,10 @@ GST_clients_handle_send (void *cls, * @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) +static void +clients_handle_set_quota (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { const struct QuotaSetMessage *qsm; @@ -622,10 +599,10 @@ transmit_address_to_client (void *cls, * @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) +static void +clients_handle_address_lookup (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { const struct AddressLookupMessage *alum; struct GNUNET_TRANSPORT_PluginFunctions *papi; @@ -734,10 +711,10 @@ send_address_to_client (void *cls, * @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) +static void +clients_handle_peer_address_lookup (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { const struct PeerAddressLookupMessage *peer_address_lookup; struct GNUNET_SERVER_TransmitContext *tc; @@ -791,10 +768,10 @@ output_addresses (void *cls, * @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) +static void +clients_handle_address_iterate (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) { struct GNUNET_SERVER_TransmitContext *tc; @@ -808,6 +785,40 @@ GST_clients_handle_address_iterate (void *cls, } +/** + * Start handling requests from clients. + * + * @param server server used to accept clients from. + */ +void +GST_clients_start (struct GNUNET_SERVER_Handle *server) +{ + static const struct GNUNET_SERVER_MessageHandler handlers[] = { + { &clients_handle_start, NULL, sizeof (struct StartMessage)}, + { &clients_handle_hello, NULL, 0}, + { &clients_handle_send, NULL, 0}, + { &clients_handle_set_quota, NULL, sizeof (struct QuotaSetMessage)}, + { &clients_handle_address_lookup, NULL, 0}, + { &clients_handle_peer_address_lookup, NULL, sizeof (struct PeerAddressLookupMessage)}, + { &clients_handle_address_iterate, NULL, sizeof (struct GNUNET_MessageHeader)}, + {NULL, NULL, 0, 0} + }; + GNUNET_SERVER_add_handlers (server, handlers); + GNUNET_SERVER_disconnect_notify (server, + &client_disconnect_notification, NULL); +} + + +/** + * Stop processing clients. + */ +void +GST_clients_stop () +{ + /* nothing to do */ +} + + /** * Broadcast the given message to all of our clients. * diff --git a/src/transport/gnunet-service-transport_clients.h b/src/transport/gnunet-service-transport_clients.h index a8ae14a53..a9ee55279 100644 --- a/src/transport/gnunet-service-transport_clients.h +++ b/src/transport/gnunet-service-transport_clients.h @@ -46,101 +46,6 @@ void GST_clients_stop (void); -/** - * Initialize a normal client. We got a start 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 start message that was sent - */ -void -GST_clients_handle_start (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message); - - -/** - * Client sent us a HELLO. Process the request. - * - * @param cls unused - * @param client the client - * @param message the HELLO message - */ -void -GST_clients_handle_hello (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. *