2c260030d110fe3cc877e2037c527b44e5918da2
[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                       Server_disconnect
40  *
41  * peer_request_connect_any         GNUNET_MESH_ConnectPeer
42  * peer_request_connect_all         GNUNET_MESH_ConnectPeer
43  * peer_request_connect_add         GNUNET_MESH_ConnectPeer
44  * peer_request_connect_del         GNUNET_MESH_ConnectPeer
45  * peer_request_connect_by_type     GNUNET_MESH_ConnectPeerByType
46  * peer_request_connect_cancel      GNUNET_MESH_Control
47  *
48  * notify_transmit_ready            GNUNET_MESH_Control
49  * notify_transmit_ready_cancel     None
50  */
51
52 struct GNUNET_MESH_Connect {
53     /**
54      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
55      *
56      * Size: sizeof(struct GNUNET_MESH_Connect) + messages_subscribed * sizeof (message_type)
57      */
58     struct GNUNET_MessageHeader header;
59
60     /* uint16_t messages_subscribed[] */
61 };
62
63 struct GNUNET_MESH_ConnectPeer {
64     /**
65      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ANY|ALL|ADD|DEL]
66      * 
67      * Size: sizeof(struct GNUNET_MESH_ConnectPeer) + npeers * sizeof (struct GNUNET_PeerIdentity)
68      */
69     struct GNUNET_MessageHeader header;
70
71     /* struct GNUNET_PeerIdentity peers[] */
72 };
73
74 struct GNUNET_MESH_ConnectPeerByType {
75     /**
76      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE
77      */
78     struct GNUNET_MessageHeader header;
79
80     /* Type specification */
81     GNUNET_MESH_ApplicationType type;
82 };
83
84 struct GNUNET_MESH_Control {
85     /**
86      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL
87      *       GNUNET_MESSAGE_TYPE_MESH_LOCAL_TRANSMIT_READY
88      */
89     struct GNUNET_MessageHeader header;
90
91     uint32_t tunnel_id GNUNET_PACKED;
92     uint32_t variable GNUNET_PACKED; /* Size of data / connection ID */
93 };
94
95 struct GNUNET_MESH_TunnelEvent {
96     /**
97      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATED\DESTROYED]
98      */
99     struct GNUNET_MessageHeader header;
100
101     uint32_t tunnel_id GNUNET_PACKED;
102     uint32_t reason GNUNET_PACKED; /* incoming, connect, timeout, disconnect */
103 };
104
105 struct GNUNET_MESH_Data {
106     /**
107      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA
108      *
109      * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
110      */
111     struct GNUNET_MessageHeader header;
112
113     uint32_t tunnel_id GNUNET_PACKED;
114
115     struct GNUNET_PeerIdentity destination;
116
117     /* uint8_t data[] */
118 };
119
120 struct GNUNET_MESH_DataBroadcast {
121     /**
122      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST
123      *
124      * Size: sizeof(struct GNUNET_MESH_DataBroadcast) + sizeof (data)
125      */
126     struct GNUNET_MessageHeader header;
127
128     uint32_t tunnel_id GNUNET_PACKED;
129
130     /* uint8_t data[] */
131 };
132
133 #endif