setup handlers
authorChristian Grothoff <christian@grothoff.org>
Sat, 13 Aug 2011 21:59:41 +0000 (21:59 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 13 Aug 2011 21:59:41 +0000 (21:59 +0000)
src/transport/gnunet-service-transport-new.c
src/transport/gnunet-service-transport_clients.c
src/transport/gnunet-service-transport_clients.h

index d0ad2fbad18346b15eb7f4b9b9d335e7cb702c84..da0bfa6d336cf7130111d666fe86b7601d3797bf 100644 (file)
@@ -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 */
index 64592d5d64384a74da9287747a0a0d1d3e5c3893..f03c3a4d3c9aeac1f16573f005d677d9b525550c 100644 (file)
@@ -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.
  *
index a8ae14a53adec40066eaa191e4d75ca6bb275a80..a9ee55279103373aab22702f1201968cff9b87e8 100644 (file)
@@ -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.
  *