aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_local.h
blob: 22a8f8e6d5809941325ee1e9bf326f079f2f23cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
     This file is part of GNUnet.
     (C) 2013 Christian Grothoff (and other contributing authors)

     GNUnet is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published
     by the Free Software Foundation; either version 3, or (at your
     option) any later version.

     GNUnet is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with GNUnet; see the file COPYING.  If not, write to the
     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
*/

/**
 * @file mesh/gnunet-service-mesh_local.h
 * @brief mesh service; dealing with local clients
 * @author Bartlomiej Polot
 *
 * All functions in this file should use the prefix GML (Gnunet Mesh Local)
 */

#ifndef GNUNET_SERVICE_MESH_LOCAL_H
#define GNUNET_SERVICE_MESH_LOCAL_H

#ifdef __cplusplus
extern "C"
{
#if 0                           /* keep Emacsens' auto-indent happy */
}
#endif
#endif

#include "platform.h"
#include "gnunet_util_lib.h"

#include "gnunet-service-mesh_channel.h"

/**
 * Struct containing information about a client of the service
 */
struct MeshClient;

/******************************************************************************/
/********************************    API    ***********************************/
/******************************************************************************/

/**
 * Initialize server subsystem.
 *
 * @param handle Server handle.
 */
void
GML_init (struct GNUNET_SERVER_Handle *handle);

/**
 * Install server (service) handlers and start listening to clients.
 */
void
GML_start (void);

/**
 * Shutdown server.
 */
void
GML_shutdown (void);

/**
 * Get a chennel from a client
 *
 * @param client the client to check
 * @param chid Channel ID
 *
 * @return non-NULL if channel exists in the global DLL
 */
struct MeshChannel *
GML_channel_get (struct MeshClient *client, uint32_t chid);

/**
 * Check if client has registered with the service and has not disconnected
 *
 * @param client the client to check
 *
 * @return non-NULL if client exists in the global DLL
 */
struct MeshClient *
GML_client_get (struct GNUNET_SERVER_Client *client);

/**
 * Find a client that has opened a port
 *
 * @param port Port to check.
 *
 * @return non-NULL if a client has the port.
 */
struct MeshClient *
GML_client_get_by_port (uint32_t port);

/**
 * Deletes a tunnel from a client (either owner or destination).
 *
 * @param c Client whose tunnel to delete.
 * @param ch Channel which should be deleted.
 */
void
GML_client_delete_channel (struct MeshClient *c, struct MeshChannel *ch);

/**
 * Build a local ACK message and send it to a local client, if needed.
 *
 * If the client was already allowed to send data, do nothing.
 *
 * @param ch Channel on which to send the ACK.
 * @param c Client to whom send the ACK.
 * @param fwd Set to GNUNET_YES for FWD ACK (dest->root)
 */
void
GML_send_ack (struct MeshChannel *ch, int fwd);

/**
 * Notify the appropriate client that a new incoming channel was created.
 *
 * @param ch Channel that was created.
 */
void
GML_send_channel_create (struct MeshClient *c,
                         uint32_t id, uint32_t port, uint32_t opt,
                         struct GNUNET_PeerIdentity *peer);

/**
 * Notify a client that a channel is no longer valid.
 *
 * @param c Client.
 * @param id ID of the channel that is destroyed.
 */
void
GML_send_channel_destroy (struct MeshClient *c, uint32_t id);

/**
 * Modify the mesh message TID from global to local and send to client.
 *
 * @param ch Channel on which to send the message.
 * @param msg Message to modify and send.
 * @param c Client to send to.
 * @param tid Tunnel ID to use (c can be both owner and client).
 */
void
GML_send_data (struct MeshChannel *ch,
               const struct GNUNET_MESH_Data *msg,
               struct MeshClient *c, MESH_ChannelNumber id);


#if 0                           /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
}
#endif

/* ifndef GNUNET_MESH_SERVICE_LOCAL_H */
#endif
/* end of gnunet-mesh-service_LOCAL.h */