aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-01-10 23:18:38 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-01-10 23:18:38 +0000
commita068d3a7e4b75a913ccdc4f4606a470c30d5f9e3 (patch)
treef333a0ce61f19f47c8fbc967fbc008fd7dc7771a /src
parentf1a1df54b3f8e8bfde67df67dcc59e9135110fca (diff)
downloadgnunet-a068d3a7e4b75a913ccdc4f4606a470c30d5f9e3.tar.gz
gnunet-a068d3a7e4b75a913ccdc4f4606a470c30d5f9e3.zip
stream P2P protocol message specification
Diffstat (limited to 'src')
-rw-r--r--src/stream/stream_protocol.h190
1 files changed, 190 insertions, 0 deletions
diff --git a/src/stream/stream_protocol.h b/src/stream/stream_protocol.h
new file mode 100644
index 000000000..20dae355b
--- /dev/null
+++ b/src/stream/stream_protocol.h
@@ -0,0 +1,190 @@
1/*
2 This file is part of GNUnet.
3 (C) 2012 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 * @file stream/stream_protocol.h
23 * @brief P2P protocol for the stream connections
24 * @author Sree Harsha Totakura
25 */
26
27#ifndef STREAM_PROTOCOL_H
28#define STREAM_PROTOCOL_H
29
30#ifdef __cplusplus
31extern "C"
32{
33#if 0 /* keep Emacsens' auto-indent happy */
34}
35#endif
36#endif
37
38#include <sys/types.h>
39
40#include "gnunet_stream_lib.h"
41#include "gnunet_mesh_service.h"
42
43
44/**
45 * Stream message types
46 */
47enum GNUNET_STREAM_MessageType
48 {
49 /**
50 * Message containing data
51 */
52 GNUNET_STREAM_MESSAGE_DATA,
53
54 /**
55 * ACK message
56 */
57 GNUNET_STREAM_MESSAGE_ACK,
58
59 /**
60 * Handshake hello message
61 */
62 GNUNET_STREAM_MESSAGE_HELLO,
63
64 /**
65 * Handshake hello acknowledgement message
66 */
67 GNUNET_STREAM_MESSAGE_HELLO_ACK,
68
69 /**
70 * Transmit close message (data transmission no longer possible after this
71 * message)
72 */
73 GNUNET_STREAM_MESSAGE_TRANSMIT_CLOSE,
74
75 /**
76 * Transmit close acknowledgement message
77 */
78 GNUNET_STREAM_MESSAGE_TRANSMIT_CLOSE_ACK,
79
80 /**
81 * Receive close message (data is no loger read by the receiver after this
82 * message)
83 */
84 GNUNET_STREAM_MESSAGE_RECEIVE_CLOSE,
85
86 /**
87 * Receive close acknowledgement message
88 */
89 GNUNET_STREAM_MESSAGE_RECEIVE_CLOSE_ACK,
90
91 /**
92 * Stream close message (data is no longer sent or read after this message)
93 */
94 GNUNET_STREAM_MESSAGE_CLOSE,
95
96 /**
97 * Close acknowledgement message
98 */
99 GNUNET_STREAM_MESSAGE_CLOSE_ACK
100 };
101
102
103/**
104 * The stream message header
105 *
106 * The message can be of Data, Acknowledgement or both
107 */
108struct GNUNET_STREAM_MessageHeader
109{
110 /**
111 * The GNUNET message header
112 */
113 struct GNUNET_MessageHeader header;
114
115 /**
116 * A number which identifies a session
117 */
118 uint16_t session_id;
119
120 /**
121 * The message type
122 * ? Should we rather use the type field in GNUNET_MessageHeader ?
123 */
124 enum GNUNET_STREAM_MessageType type;
125
126};
127
128
129/**
130 * The Data message, should be prefixed with stream header with its type set to
131 * GNUNET_STREAM_Data
132 */
133struct GNUNET_STREAM_DataMessage
134{
135 /**
136 * Sequence number; Always starts with 0 and should wrap around.
137 * Immune to Sequence Prediction Attack as we take cover under GNUNET's secure
138 * messaging
139 */
140 uint32_t seq;
141
142 /**
143 * number of milliseconds to the soft deadline for sending acknowledgement
144 * measured from the time this message is received. It is optimal for the
145 * communication to send the ack within the soft deadline
146 */
147 uint16_t ack_deadline;
148
149 /**
150 * The data should be appended here
151 */
152};
153
154/**
155 * The Selective Acknowledgement Bitmap
156 *
157 * ? WARNING ? Possibility for Denial of Service ??
158 * ? Receiver may force the sender to mantain a buffer of ~ 64*64k !??
159 */
160typedef uint64_t GNUNET_STREAM_AckBitmap;
161
162
163/**
164 * The Acknowledgment Message, should be prefixed with Stream Message header
165 * with its type set to GNUNET_STREAM_MESSAGE_ACK
166 */
167struct GNUNET_STREAM_AckMessage
168{
169 /**
170 * The sequence number of the Data Message upto which the receiver has filled
171 * its buffer without any missing packets
172 */
173 uint32_t base_seq;
174
175 /**
176 * The Selective Acknowledgement Bitmap. Computed relative to the base_seq
177 * (bit n corresponds to the Data message with sequence number base_seq+n)
178 */
179 GNUNET_STREAM_AckBitmap bitmap;
180};
181
182
183#if 0 /** keep Emacsens' auto-indent happy */
184{
185#endif
186#ifdef __cplusplus
187}
188#endif
189
190#endif /* STREAM_PROTOCOL_H */