2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file stream/stream_protocol.h
23 * @brief P2P protocol for the stream connections
24 * @author Sree Harsha Totakura
27 #ifndef STREAM_PROTOCOL_H
28 #define STREAM_PROTOCOL_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include <sys/types.h>
40 #include "gnunet_stream_lib.h"
41 #include "gnunet_mesh_service.h"
45 * Stream message types
47 enum GNUNET_STREAM_MessageType
50 * Message containing data
52 GNUNET_STREAM_MESSAGE_DATA,
57 GNUNET_STREAM_MESSAGE_ACK,
60 * Handshake hello message
62 GNUNET_STREAM_MESSAGE_HELLO,
65 * Handshake hello acknowledgement message
67 GNUNET_STREAM_MESSAGE_HELLO_ACK,
72 GNUNET_STREAM_MESSAGE_RESET,
75 * Transmit close message (data transmission no longer possible after this
78 GNUNET_STREAM_MESSAGE_TRANSMIT_CLOSE,
81 * Transmit close acknowledgement message
83 GNUNET_STREAM_MESSAGE_TRANSMIT_CLOSE_ACK,
86 * Receive close message (data is no loger read by the receiver after this
89 GNUNET_STREAM_MESSAGE_RECEIVE_CLOSE,
92 * Receive close acknowledgement message
94 GNUNET_STREAM_MESSAGE_RECEIVE_CLOSE_ACK,
97 * Stream close message (data is no longer sent or read after this message)
99 GNUNET_STREAM_MESSAGE_CLOSE,
102 * Close acknowledgement message
104 GNUNET_STREAM_MESSAGE_CLOSE_ACK
109 * The stream message header
111 * The message can be of Data, Acknowledgement or both
113 struct GNUNET_STREAM_MessageHeader
116 * The GNUNET message header
118 struct GNUNET_MessageHeader header;
121 * A number which identifies a session
127 * ? Should we rather use the type field in GNUNET_MessageHeader ?
129 enum GNUNET_STREAM_MessageType type;
135 * The Data message, should be prefixed with stream header with its type set to
138 struct GNUNET_STREAM_DataMessage
141 * Sequence number; Always starts with 0 and should wrap around.
142 * Immune to Sequence Prediction Attack as we take cover under GNUNET's secure
148 * number of milliseconds to the soft deadline for sending acknowledgement
149 * measured from the time this message is received. It is optimal for the
150 * communication to send the ack within the soft deadline
152 uint16_t ack_deadline;
155 * The data should be appended here
160 * The Selective Acknowledgement Bitmap
162 * ? WARNING ? Possibility for Denial of Service ??
163 * ? Receiver may force the sender to mantain a buffer of ~ 64*64k !??
165 typedef uint64_t GNUNET_STREAM_AckBitmap;
169 * The Acknowledgment Message, should be prefixed with Stream Message header
170 * with its type set to GNUNET_STREAM_MESSAGE_ACK
172 struct GNUNET_STREAM_AckMessage
175 * The sequence number of the Data Message upto which the receiver has filled
176 * its buffer without any missing packets
181 * The Selective Acknowledgement Bitmap. Computed relative to the base_seq
182 * (bit n corresponds to the Data message with sequence number base_seq+n)
184 GNUNET_STREAM_AckBitmap bitmap;
189 * states in the Protocol
191 enum GNUNET_STREAM_State
193 GNUNET_STREAM_STATE_INIT,
195 GNUNET_STREAM_STATE_LISTEN,
197 GNUNET_STREAM_STATE_HANDSHAKE_WAIT,
199 GNUNET_STREAM_STATE_ESTABLISHED,
201 GNUNET_STREAM_STATE_RECEIVE_CLOSE_WAIT,
203 GNUNET_STREAM_STATE_RECEIVE_CLOSED,
205 GNUNET_STREAM_STATE_TRANSMIT_CLOSE_WAIT,
207 GNUNET_STREAM_STATE_TRANSMIT_CLOSED,
209 GNUNET_STREAM_STATE_CLOSE_WAIT,
211 GNUNET_STREAM_STATE_CLOSED
215 #if 0 /** keep Emacsens' auto-indent happy */
222 #endif /* STREAM_PROTOCOL_H */