diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-13 21:59:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-13 21:59:41 +0000 |
commit | 06d594e14f81143df0197ce468bd82967471bcb4 (patch) | |
tree | 9143722ac52023ad7db9237d2475f9bd7ba02d73 | |
parent | c01972f2300865e9750092d566da5b08a05c7b4f (diff) | |
download | gnunet-06d594e14f81143df0197ce468bd82967471bcb4.tar.gz gnunet-06d594e14f81143df0197ce468bd82967471bcb4.zip |
setup handlers
-rw-r--r-- | src/transport/gnunet-service-transport-new.c | 5 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 113 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.h | 95 |
3 files changed, 62 insertions, 151 deletions
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, | |||
354 | struct GNUNET_SERVER_Handle *server, | 354 | struct GNUNET_SERVER_Handle *server, |
355 | const struct GNUNET_CONFIGURATION_Handle *c) | 355 | const struct GNUNET_CONFIGURATION_Handle *c) |
356 | { | 356 | { |
357 | #if 0 | ||
358 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | ||
359 | {NULL, NULL, 0, 0} | ||
360 | }; | ||
361 | #endif | ||
362 | char *keyfile; | 357 | char *keyfile; |
363 | 358 | ||
364 | /* setup globals */ | 359 | /* 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 | |||
@@ -326,29 +326,6 @@ client_disconnect_notification (void *cls, | |||
326 | 326 | ||
327 | 327 | ||
328 | /** | 328 | /** |
329 | * Start handling requests from clients. | ||
330 | * | ||
331 | * @param server server used to accept clients from. | ||
332 | */ | ||
333 | void | ||
334 | GST_clients_start (struct GNUNET_SERVER_Handle *server) | ||
335 | { | ||
336 | GNUNET_SERVER_disconnect_notify (server, | ||
337 | &client_disconnect_notification, NULL); | ||
338 | } | ||
339 | |||
340 | |||
341 | /** | ||
342 | * Stop processing clients. | ||
343 | */ | ||
344 | void | ||
345 | GST_clients_stop () | ||
346 | { | ||
347 | /* nothing to do */ | ||
348 | } | ||
349 | |||
350 | |||
351 | /** | ||
352 | * Function called for each of our connected neighbours. Notify the | 329 | * Function called for each of our connected neighbours. Notify the |
353 | * client about the existing neighbour. | 330 | * client about the existing neighbour. |
354 | * | 331 | * |
@@ -391,10 +368,10 @@ notify_client_about_neighbour (void *cls, | |||
391 | * @param client the client | 368 | * @param client the client |
392 | * @param message the start message that was sent | 369 | * @param message the start message that was sent |
393 | */ | 370 | */ |
394 | void | 371 | static void |
395 | GST_clients_handle_start (void *cls, | 372 | clients_handle_start (void *cls, |
396 | struct GNUNET_SERVER_Client *client, | 373 | struct GNUNET_SERVER_Client *client, |
397 | const struct GNUNET_MessageHeader *message) | 374 | const struct GNUNET_MessageHeader *message) |
398 | { | 375 | { |
399 | const struct StartMessage *start; | 376 | const struct StartMessage *start; |
400 | struct TransportClient *tc; | 377 | struct TransportClient *tc; |
@@ -434,10 +411,10 @@ GST_clients_handle_start (void *cls, | |||
434 | * @param client the client | 411 | * @param client the client |
435 | * @param message the HELLO message | 412 | * @param message the HELLO message |
436 | */ | 413 | */ |
437 | void | 414 | static void |
438 | GST_clients_handle_hello (void *cls, | 415 | clients_handle_hello (void *cls, |
439 | struct GNUNET_SERVER_Client *client, | 416 | struct GNUNET_SERVER_Client *client, |
440 | const struct GNUNET_MessageHeader *message) | 417 | const struct GNUNET_MessageHeader *message) |
441 | { | 418 | { |
442 | GST_validation_handle_hello (message); | 419 | GST_validation_handle_hello (message); |
443 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 420 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -493,10 +470,10 @@ handle_send_transmit_continuation (void *cls, | |||
493 | * @param client the client | 470 | * @param client the client |
494 | * @param message the send message that was sent | 471 | * @param message the send message that was sent |
495 | */ | 472 | */ |
496 | void | 473 | static void |
497 | GST_clients_handle_send (void *cls, | 474 | clients_handle_send (void *cls, |
498 | struct GNUNET_SERVER_Client *client, | 475 | struct GNUNET_SERVER_Client *client, |
499 | const struct GNUNET_MessageHeader *message) | 476 | const struct GNUNET_MessageHeader *message) |
500 | { | 477 | { |
501 | const struct OutboundMessage *obm; | 478 | const struct OutboundMessage *obm; |
502 | const struct GNUNET_MessageHeader *obmm; | 479 | const struct GNUNET_MessageHeader *obmm; |
@@ -563,10 +540,10 @@ GST_clients_handle_send (void *cls, | |||
563 | * @param client the client | 540 | * @param client the client |
564 | * @param message the quota changing message | 541 | * @param message the quota changing message |
565 | */ | 542 | */ |
566 | void | 543 | static void |
567 | GST_clients_handle_set_quota (void *cls, | 544 | clients_handle_set_quota (void *cls, |
568 | struct GNUNET_SERVER_Client *client, | 545 | struct GNUNET_SERVER_Client *client, |
569 | const struct GNUNET_MessageHeader *message) | 546 | const struct GNUNET_MessageHeader *message) |
570 | { | 547 | { |
571 | const struct QuotaSetMessage *qsm; | 548 | const struct QuotaSetMessage *qsm; |
572 | 549 | ||
@@ -622,10 +599,10 @@ transmit_address_to_client (void *cls, | |||
622 | * @param client the client | 599 | * @param client the client |
623 | * @param message the resolution request | 600 | * @param message the resolution request |
624 | */ | 601 | */ |
625 | void | 602 | static void |
626 | GST_clients_handle_address_lookup (void *cls, | 603 | clients_handle_address_lookup (void *cls, |
627 | struct GNUNET_SERVER_Client *client, | 604 | struct GNUNET_SERVER_Client *client, |
628 | const struct GNUNET_MessageHeader *message) | 605 | const struct GNUNET_MessageHeader *message) |
629 | { | 606 | { |
630 | const struct AddressLookupMessage *alum; | 607 | const struct AddressLookupMessage *alum; |
631 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 608 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
@@ -734,10 +711,10 @@ send_address_to_client (void *cls, | |||
734 | * @param client the client | 711 | * @param client the client |
735 | * @param message the peer address information request | 712 | * @param message the peer address information request |
736 | */ | 713 | */ |
737 | void | 714 | static void |
738 | GST_clients_handle_peer_address_lookup (void *cls, | 715 | clients_handle_peer_address_lookup (void *cls, |
739 | struct GNUNET_SERVER_Client *client, | 716 | struct GNUNET_SERVER_Client *client, |
740 | const struct GNUNET_MessageHeader *message) | 717 | const struct GNUNET_MessageHeader *message) |
741 | { | 718 | { |
742 | const struct PeerAddressLookupMessage *peer_address_lookup; | 719 | const struct PeerAddressLookupMessage *peer_address_lookup; |
743 | struct GNUNET_SERVER_TransmitContext *tc; | 720 | struct GNUNET_SERVER_TransmitContext *tc; |
@@ -791,10 +768,10 @@ output_addresses (void *cls, | |||
791 | * @param client the client | 768 | * @param client the client |
792 | * @param message the peer address information request | 769 | * @param message the peer address information request |
793 | */ | 770 | */ |
794 | void | 771 | static void |
795 | GST_clients_handle_address_iterate (void *cls, | 772 | clients_handle_address_iterate (void *cls, |
796 | struct GNUNET_SERVER_Client *client, | 773 | struct GNUNET_SERVER_Client *client, |
797 | const struct GNUNET_MessageHeader *message) | 774 | const struct GNUNET_MessageHeader *message) |
798 | { | 775 | { |
799 | struct GNUNET_SERVER_TransmitContext *tc; | 776 | struct GNUNET_SERVER_TransmitContext *tc; |
800 | 777 | ||
@@ -809,6 +786,40 @@ GST_clients_handle_address_iterate (void *cls, | |||
809 | 786 | ||
810 | 787 | ||
811 | /** | 788 | /** |
789 | * Start handling requests from clients. | ||
790 | * | ||
791 | * @param server server used to accept clients from. | ||
792 | */ | ||
793 | void | ||
794 | GST_clients_start (struct GNUNET_SERVER_Handle *server) | ||
795 | { | ||
796 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | ||
797 | { &clients_handle_start, NULL, sizeof (struct StartMessage)}, | ||
798 | { &clients_handle_hello, NULL, 0}, | ||
799 | { &clients_handle_send, NULL, 0}, | ||
800 | { &clients_handle_set_quota, NULL, sizeof (struct QuotaSetMessage)}, | ||
801 | { &clients_handle_address_lookup, NULL, 0}, | ||
802 | { &clients_handle_peer_address_lookup, NULL, sizeof (struct PeerAddressLookupMessage)}, | ||
803 | { &clients_handle_address_iterate, NULL, sizeof (struct GNUNET_MessageHeader)}, | ||
804 | {NULL, NULL, 0, 0} | ||
805 | }; | ||
806 | GNUNET_SERVER_add_handlers (server, handlers); | ||
807 | GNUNET_SERVER_disconnect_notify (server, | ||
808 | &client_disconnect_notification, NULL); | ||
809 | } | ||
810 | |||
811 | |||
812 | /** | ||
813 | * Stop processing clients. | ||
814 | */ | ||
815 | void | ||
816 | GST_clients_stop () | ||
817 | { | ||
818 | /* nothing to do */ | ||
819 | } | ||
820 | |||
821 | |||
822 | /** | ||
812 | * Broadcast the given message to all of our clients. | 823 | * Broadcast the given message to all of our clients. |
813 | * | 824 | * |
814 | * @param msg message to broadcast | 825 | * @param msg message to broadcast |
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 | |||
@@ -47,101 +47,6 @@ GST_clients_stop (void); | |||
47 | 47 | ||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Initialize a normal client. We got a start message from this | ||
51 | * client, add him to the list of clients for broadcasting of inbound | ||
52 | * messages. | ||
53 | * | ||
54 | * @param cls unused | ||
55 | * @param client the client | ||
56 | * @param message the start message that was sent | ||
57 | */ | ||
58 | void | ||
59 | GST_clients_handle_start (void *cls, | ||
60 | struct GNUNET_SERVER_Client *client, | ||
61 | const struct GNUNET_MessageHeader *message); | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Client sent us a HELLO. Process the request. | ||
66 | * | ||
67 | * @param cls unused | ||
68 | * @param client the client | ||
69 | * @param message the HELLO message | ||
70 | */ | ||
71 | void | ||
72 | GST_clients_handle_hello (void *cls, | ||
73 | struct GNUNET_SERVER_Client *client, | ||
74 | const struct GNUNET_MessageHeader *message); | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Client asked for transmission to a peer. Process the request. | ||
79 | * | ||
80 | * @param cls unused | ||
81 | * @param client the client | ||
82 | * @param message the send message that was sent | ||
83 | */ | ||
84 | void | ||
85 | GST_clients_handle_send (void *cls, | ||
86 | struct GNUNET_SERVER_Client *client, | ||
87 | const struct GNUNET_MessageHeader *message); | ||
88 | |||
89 | |||
90 | /** | ||
91 | * Client asked for a quota change for a particular peer. Process the request. | ||
92 | * | ||
93 | * @param cls unused | ||
94 | * @param client the client | ||
95 | * @param message the quota changing message | ||
96 | */ | ||
97 | void | ||
98 | GST_clients_handle_set_quota (void *cls, | ||
99 | struct GNUNET_SERVER_Client *client, | ||
100 | const struct GNUNET_MessageHeader *message); | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Client asked to resolve an address. Process the request. | ||
105 | * | ||
106 | * @param cls unused | ||
107 | * @param client the client | ||
108 | * @param message the resolution request | ||
109 | */ | ||
110 | void | ||
111 | GST_clients_handle_address_lookup (void *cls, | ||
112 | struct GNUNET_SERVER_Client *client, | ||
113 | const struct GNUNET_MessageHeader *message); | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Client asked to obtain information about a peer's addresses. | ||
118 | * Process the request. | ||
119 | * | ||
120 | * @param cls unused | ||
121 | * @param client the client | ||
122 | * @param message the peer address information request | ||
123 | */ | ||
124 | void | ||
125 | GST_clients_handle_peer_address_lookup (void *cls, | ||
126 | struct GNUNET_SERVER_Client *client, | ||
127 | const struct GNUNET_MessageHeader *message); | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Client asked to obtain information about all addresses. | ||
132 | * Process the request. | ||
133 | * | ||
134 | * @param cls unused | ||
135 | * @param client the client | ||
136 | * @param message the peer address information request | ||
137 | */ | ||
138 | void | ||
139 | GST_clients_handle_address_iterate (void *cls, | ||
140 | struct GNUNET_SERVER_Client *client, | ||
141 | const struct GNUNET_MessageHeader *message); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Broadcast the given message to all of our clients. | 50 | * Broadcast the given message to all of our clients. |
146 | * | 51 | * |
147 | * @param msg message to broadcast | 52 | * @param msg message to broadcast |