Changed message declaration location, added api messages
[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  * TODO:
26  * - API messages!
27  */
28
29 #ifndef MESH_H_
30 #define MESH_H_
31 #include <stdint.h>
32 #include "gnunet_common.h"
33
34 /******************************************************************************/
35 /********************      MESH NETWORK MESSAGES     **************************/
36 /******************************************************************************/
37 /* API CALL                         MESSAGE USED
38  * --------                         ------------
39  * connect                          GNUNET_MESH_Connect    / Server_connect? FIXME
40  * disconnect                       GNUNET_MESH_Disconnect / Server_disconnect? FIXME
41  * 
42  * peer_request_connect_any         GNUNET_MESH_ConnectPeer
43  * peer_request_connect_all         GNUNET_MESH_ConnectPeer
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  * peer_request_connect_cancel      GNUNET_MESH_Control
48  * 
49  * notify_tranmit_ready             GNUNET_MESH_Control? FIXME
50  * notify_tranmit_ready_cancel      GNUNET_MESH_Control? FIXME
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 // struct GNUNET_MESH_Disconnect {
65 //     /**
66 //      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DISCONNECT
67 //      */
68 //     struct GNUNET_MessageHeader header;
69 //
70 // };
71
72 struct GNUNET_MESH_ConnectPeer {
73     /**
74      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ANY|ALL|ADD|DEL]
75      * 
76      * Size: sizeof(struct GNUNET_MESH_ConnectPeer) + npeers * sizeof (struct GNUNET_PeerIdentity)
77      */
78     struct GNUNET_MessageHeader header;
79
80     /* struct GNUNET_PeerIdentity peers[] */
81 };
82
83 struct GNUNET_MESH_ConnectPeerByType {
84     /**
85      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE
86      */
87     struct GNUNET_MessageHeader header;
88
89     /* FIXME Type specification */
90     uint32_t type;
91 };
92
93 struct GNUNET_MESH_Control {
94     /**
95      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL
96      *       more? transmit_ready?
97      */
98     struct GNUNET_MessageHeader header;
99
100     uint32_t tunnel_id GNUNET_PACKED;
101     uint32_t variable GNUNET_PACKED; /* Size of data to transmit? */
102 };
103
104 struct GNUNET_MESH_TunnelEvent {
105     /**
106      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATED\DESTROYED]
107      */
108     struct GNUNET_MessageHeader header;
109
110     uint32_t tunnel_id GNUNET_PACKED;
111     uint32_t reason GNUNET_PACKED; /* incoming, connect, timeout, disconnect */
112 };
113
114 struct GNUNET_MESH_Data {
115     /**
116      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA
117      *
118      * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
119      */
120     struct GNUNET_MessageHeader header;
121
122     uint32_t tunnel_id GNUNET_PACKED;
123
124     /* FIXME: Broadcast? New Type / NULL destination ? */
125     /* FIXME: Reverese order for alignment? 1st ID, 2nd t_id? */
126     struct GNUNET_PeerIdentity destination GNUNET_PACKED;
127
128     /* uint8_t data[] */
129 };
130
131 #endif