finishing clients draft
[oweals/gnunet.git] / src / core / gnunet-service-core_clients.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file core/gnunet-service-core_clients.h
23  * @brief code for managing interactions with clients of core service
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_CORE_CLIENTS_H
27 #define GNUNET_SERVICE_CORE_CLIENTS_H
28
29 #include "gnunet_util_lib.h"
30 #include "gnunet_service_core.h"
31
32
33 /**
34  * Send a message to one of our clients.
35  *
36  * @param client target for the message
37  * @param msg message to transmit
38  * @param can_drop could this message be dropped if the
39  *        client's queue is getting too large?
40  */
41 void
42 GSC_CLIENTS_send_to_client (struct GNUNET_SERVER_Client *client,
43                             const struct GNUNET_MessageHeader *msg,
44                             int can_drop);
45
46
47 /**
48  * Notify a particular client about a change to existing connection to
49  * one of our neighbours (check if the client is interested).  Called
50  * from 'GSC_SESSIONS_notify_client_about_sessions'.
51  *
52  * @param client client to notify
53  * @param neighbour identity of the neighbour that changed status
54  * @param atsi performance information about neighbour
55  * @param atsi_count number of entries in 'ats' array
56  * @param tmap_old previous type map for the neighbour, NULL for disconnect
57  * @param tmap_new updated type map for the neighbour, NULL for disconnect
58  */
59 void
60 GDS_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
61                                            const struct GNUNET_PeerIdentity *neighbour,
62                                            const struct GNUNET_TRANSPORT_ATS_Information *atsi,
63                                            unsigned int atsi_count,
64                                            const struct GSC_TypeMap *tmap_old,
65                                            const struct GSC_TypeMap *tmap_new);
66
67
68 /**
69  * Notify all clients about a change to existing session.
70  * Called from SESSIONS whenever there is a change in sessions
71  * or types processed by the respective peer.
72  *
73  * @param neighbour identity of the neighbour that changed status
74  * @param atsi performance information about neighbour
75  * @param atsi_count number of entries in 'ats' array
76  * @param tmap_old previous type map for the neighbour, NULL for disconnect
77  * @param tmap_new updated type map for the neighbour, NULL for disconnect
78  */
79 void
80 GDS_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *neighbour,
81                                             const struct GNUNET_TRANSPORT_ATS_Information *atsi,
82                                             unsigned int atsi_count,
83                                             const struct GSC_TypeMap *tmap_old,
84                                             const struct GSC_TypeMap *tmap_new);
85
86
87 /**
88  * Deliver P2P message to interested clients. Caller must have checked
89  * that the sending peer actually lists the given message type as one 
90  * of its types.
91  *
92  * @param sender peer who sent us the message 
93  * @param atsi performance information about neighbour
94  * @param atsi_count number of entries in 'ats' array
95  * @param msg the message
96  * @param msize number of bytes to transmit
97  * @param options options for checking which clients should
98  *        receive the message
99  */
100 void
101 GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
102                              const struct GNUNET_TRANSPORT_ATS_Information *atsi,
103                              unsigned int atsi_count,
104                              const struct GNUNET_MessageHeader *msg,
105                              uint16_t msize,
106                              int options);
107
108
109 /**
110  * Tell a client that we are ready to receive the message.
111  *
112  * @param car request that is now ready; the responsibility
113  *        for the handle remains shared between CLIENTS
114  *        and SESSIONS after this call.
115  */
116 void
117 GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car);
118
119
120 /**
121  * Tell a client that we will never be ready to receive the
122  * given message in time (disconnect or timeout).
123  *
124  * @param car request that now permanently failed; the
125  *        responsibility for the handle is now returned
126  *        to CLIENTS (SESSIONS is done with it).
127  */
128 void
129 GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car);
130
131
132 /**
133  * Initialize clients subsystem.
134  *
135  * @param server handle to server clients connect to
136  */
137 void
138 GSC_CLIENTS_init (struct GNUNET_SERVER_Handle *server);
139
140
141 /**
142  * Shutdown clients subsystem.
143  */
144 void
145 GSC_CLIENTS_done (void);
146
147 #endif
148 /* end of gnunet-service-core_clients.h */