paragraph for gnunet devs that don't know how to use the web
[oweals/gnunet.git] / src / psyc / psyc.h
1 /*
2  * This file is part of GNUnet
3  * Copyright (C) 2013 GNUnet e.V.
4  *
5  * GNUnet is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU Affero General Public License as published
7  * by the Free Software Foundation, either version 3 of the License,
8  * or (at your 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  * Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 /**
20  * @file psyc/psyc.h
21  * @brief Common type definitions for the PSYC service and API.
22  * @author Gabor X Toth
23  */
24
25 #ifndef PSYC_H
26 #define PSYC_H
27
28 #include "platform.h"
29 #include "gnunet_psyc_service.h"
30
31
32 int
33 GNUNET_PSYC_check_message_parts (uint16_t data_size, const char *data,
34                                  uint16_t *first_ptype, uint16_t *last_ptype);
35
36 void
37 GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind,
38                          const struct GNUNET_MessageHeader *msg);
39
40
41 enum MessageState
42 {
43   MSG_STATE_START    = 0,
44   MSG_STATE_HEADER   = 1,
45   MSG_STATE_METHOD   = 2,
46   MSG_STATE_MODIFIER = 3,
47   MSG_STATE_MOD_CONT = 4,
48   MSG_STATE_DATA     = 5,
49   MSG_STATE_END      = 6,
50   MSG_STATE_CANCEL   = 7,
51   MSG_STATE_ERROR    = 8,
52 };
53
54
55 enum MessageFragmentState
56 {
57   MSG_FRAG_STATE_START    = 0,
58   MSG_FRAG_STATE_HEADER   = 1,
59   MSG_FRAG_STATE_DATA     = 2,
60   MSG_FRAG_STATE_END      = 3,
61   MSG_FRAG_STATE_CANCEL   = 4,
62   MSG_FRAG_STATE_DROP     = 5,
63 };
64
65
66 GNUNET_NETWORK_STRUCT_BEGIN
67
68
69 /**** library -> service ****/
70
71
72 struct MasterStartRequest
73 {
74   /**
75    * Type: GNUNET_MESSAGE_TYPE_PSYC_MASTER_START
76    */
77   struct GNUNET_MessageHeader header;
78
79   uint32_t policy GNUNET_PACKED;
80
81   struct GNUNET_CRYPTO_EddsaPrivateKey channel_key;
82 };
83
84
85 struct SlaveJoinRequest
86 {
87   /**
88    * Type: GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN
89    */
90   struct GNUNET_MessageHeader header;
91
92   uint32_t relay_count GNUNET_PACKED;
93
94   struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key;
95
96   struct GNUNET_CRYPTO_EcdsaPrivateKey slave_key;
97
98   struct GNUNET_PeerIdentity origin;
99
100   uint32_t flags GNUNET_PACKED;
101
102   /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
103
104   /* Followed by struct GNUNET_MessageHeader join_msg */
105 };
106
107
108 struct ChannelMembershipStoreRequest
109 {
110   /**
111    * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_MEMBERSHIP_STORE
112    */
113   struct GNUNET_MessageHeader header;
114
115   uint32_t reserved GNUNET_PACKED;
116
117   uint64_t op_id GNUNET_PACKED;
118
119   struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key;
120
121   uint64_t announced_at GNUNET_PACKED;
122
123   uint64_t effective_since GNUNET_PACKED;
124
125   uint8_t did_join;
126 };
127
128
129 struct HistoryRequest
130 {
131   /**
132    * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_HISTORY_REQUEST
133    */
134   struct GNUNET_MessageHeader header;
135
136   uint32_t reserved GNUNET_PACKED;
137
138   /**
139    * ID for this operation.
140    */
141   uint64_t op_id GNUNET_PACKED;
142
143   uint64_t start_message_id GNUNET_PACKED;
144
145   uint64_t end_message_id GNUNET_PACKED;
146
147   uint64_t message_limit GNUNET_PACKED;
148 };
149
150
151 struct StateRequest
152 {
153   /**
154    * Types:
155    * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET
156    * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET_PREFIX
157    */
158   struct GNUNET_MessageHeader header;
159
160   uint32_t reserved GNUNET_PACKED;
161
162   /**
163    * ID for this operation.
164    */
165   uint64_t op_id GNUNET_PACKED;
166
167   /* Followed by NUL-terminated name. */
168 };
169
170
171 /**** service -> library ****/
172
173
174 GNUNET_NETWORK_STRUCT_END
175
176 #endif