a29c63f8845f61d908f3d7e8aef0201811da4107
[oweals/gnunet.git] / src / mesh / mesh.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001 - 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  * @author Bartlomiej Polot
23  * @file mesh/mesh.h
24  */
25
26 #ifndef MESH_H_
27 #define MESH_H_
28 #include <stdint.h>
29
30 #include <gnunet_mesh_service.h>
31 #include "gnunet_common.h"
32
33 /******************************************************************************/
34 /********************      MESH NETWORK MESSAGES     **************************/
35 /******************************************************************************/
36 /* API CALL                         MESSAGE USED
37  * --------                         ------------
38  * connect                          GNUNET_MESH_Connect
39  * disconnect                       None (network level disconnect)
40  *
41  * tunnel_create                    GNUNET_MESH_TunnelMessage
42  * tunnel_destroy                   GNUNET_MESH_TunnelMessage
43  *
44  * peer_request_connect_add         GNUNET_MESH_ConnectPeer
45  * peer_request_connect_del         GNUNET_MESH_ConnectPeer
46  * peer_request_connect_by_type     GNUNET_MESH_ConnectPeerByType
47  *
48  * notify_transmit_ready            GNUNET_MESH_Control
49  * notify_transmit_ready_cancel     None
50  */
51
52
53 struct GNUNET_MESH_Connect {
54     /**
55      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
56      *
57      * Size: sizeof(struct GNUNET_MESH_Connect) + messages_subscribed * sizeof (message_type)
58      */
59     struct GNUNET_MessageHeader header;
60
61     /* uint16_t messages_subscribed[] */
62 };
63
64
65 /**
66  *
67  */
68 struct GNUNET_MESH_TunnelMessage {
69     /**
70      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
71      */
72     struct GNUNET_MessageHeader header;
73
74   /**
75    * ID of a tunnel controlled by this client.
76    */
77     uint32_t tunnel_id GNUNET_PACKED;
78 };
79
80
81 struct GNUNET_MESH_PeerControl {
82
83   /**
84    * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ADD|DEL] (client to service, client created tunnel)
85    * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOTIFY[CONNECT|DISCONNECT] (service to client)
86    * 
87    * Size: sizeof(struct GNUNET_MESH_PeerControl) 
88    */
89   struct GNUNET_MessageHeader header;
90
91   /**
92    * ID of a tunnel controlled by this client.
93    */
94     uint32_t tunnel_id GNUNET_PACKED;
95   
96   /**
97    * Peer to connect/disconnect.
98    */
99   struct GNUNET_PeerIdentity peer;
100 };
101
102
103
104
105 struct GNUNET_MESH_ConnectPeerByType {
106     /**
107      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE
108      */
109     struct GNUNET_MessageHeader header;
110
111   /**
112    * ID of a tunnel controlled by this client.
113    */
114     uint32_t tunnel_id GNUNET_PACKED;
115  
116   /**
117    * Type specification 
118    */
119     GNUNET_MESH_ApplicationType type;
120 };
121
122
123 struct GNUNET_MESH_RequestTransmitReady {
124     /**
125      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_REQUEST_TRANSMIT_READY
126      */
127     struct GNUNET_MessageHeader header;
128
129   /**
130    * ID of a tunnel controlled by this client.
131    */
132     uint32_t tunnel_id GNUNET_PACKED;
133
134   /**
135    * Size of message we would like to transmit to this tunnel
136    */
137     uint32_t msg_size GNUNET_PACKED; 
138 };
139
140 struct GNUNET_MESH_NotifyTransmitReady {
141     /**
142      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_NOTIFY_TRANSMIT_READY
143      */
144     struct GNUNET_MessageHeader header;
145
146   /**
147    * ID of a tunnel controlled by this client.
148    */
149     uint32_t tunnel_id GNUNET_PACKED;
150
151   /**
152    * Size of message we can now transmit to this tunnel
153    */
154     uint32_t msg_size GNUNET_PACKED; 
155 };
156
157
158 struct GNUNET_MESH_Data {
159     /**
160      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA (client to service, or service to client)
161      *
162      * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
163      */
164     struct GNUNET_MessageHeader header;
165
166   /**
167    * ID of a tunnel controlled by this client.
168    */
169     uint32_t tunnel_id GNUNET_PACKED;
170
171   /**
172    * Source or destination of the message (depending on direction).
173    */
174     struct GNUNET_PeerIdentity destination;
175
176     /* uint8_t data[] */
177 };
178
179
180 struct GNUNET_MESH_DataBroadcast {
181     /**
182      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST (client to service only, client created tunnel)
183      *
184      * Size: sizeof(struct GNUNET_MESH_DataBroadcast) + sizeof (data)
185      */
186     struct GNUNET_MessageHeader header;
187
188   /**
189    * ID of a tunnel controlled by this client.
190    */
191     uint32_t tunnel_id GNUNET_PACKED;
192
193     /* uint8_t data[] */
194 };
195
196
197 #endif