38b9f93b1267008a7b6d8d4948926ac9467825f9
[oweals/gnunet.git] / src / transport / communicator.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009-2014 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 transport/communicator.h
21  * @brief common internal definitions for communicator services
22  * @author Christian Grothoff
23  */
24 #ifndef COMMUNICATOR_H
25 #define COMMUNICAOTR_H
26
27 #include "gnunet_util_lib.h"
28 #include "gnunet_protocols.h"
29
30 GNUNET_NETWORK_STRUCT_BEGIN
31
32 /**
33  * Message used to tell a communicator about a successful
34  * key exchange.
35  *
36  * Note that this style of KX acknowledgement typically only applies
37  * for communicators where the underlying network protocol is
38  * unidirectional and/or lacks cryptography.  Furthermore, this is
39  * just the recommended "generic" style, communicators are always free
40  * to implement original designs that better fit their requirements.
41  */
42 struct GNUNET_TRANSPORT_CommunicatorGenericKXConfirmation
43 {
44   /**
45    * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_KX_CONFIRMATION
46    */
47   struct GNUNET_MessageHeader header;
48
49   /**
50    * Timestamp from the original sender which identifies the original KX.
51    */
52   struct GNUNET_TIME_AbsoluteNBO monotonic_time;
53
54   /**
55    * How long does the receiver of the KX believe that the address
56    * on which the KX was received will continue to be valid.
57    */
58   struct GNUNET_TIME_RelativeNBO validity;
59
60   /**
61    * Hash of the shared secret. Specific hash function may depend on
62    * the communicator's protocol details.
63    */
64   struct GNUNET_HashCode token;
65 };
66
67
68 /**
69  * Message used to tell a communicator about the receiver's
70  * flow control limits and to acknowledge receipt of certain
71  * messages.
72  *
73  * Note that a sender MAY choose to violate the flow-control
74  * limits provided in this message by a receiver, which may
75  * result in messages being lost (after all, transport is an
76  * unreliable channel).  So if the sender violates these
77  * constraints, it should expect that the receive will simply
78  * discard the (partially) received "old" messages.
79  *
80  * This way, if a sender or receiver crashes, there is no protocol
81  * violation.
82  *
83  * Note that this style of flow control typically only applies
84  * for communicators where the underlying network protocol does
85  * not already implement flow control.  Furthermore, this is
86  * just the recommended "generic" style, communicators are always
87  * free to implement original designs that better fit their
88  * requirements.
89  */
90 struct GNUNET_TRANSPORT_CommunicatorGenericFCLimits
91 {
92   /**
93    * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_FC_LIMITS
94    */
95   struct GNUNET_MessageHeader header;
96
97   /**
98    * Maximum number of messages beyond the acknowledged message
99    * number that can still be transmitted concurrently without
100    * further acknowledgements.
101    */
102   uint32_t msg_window_size;
103
104   /**
105    * Up to which message number were all messages received.
106    */
107   uint64_t msg_cummulative_ack;
108
109   /**
110    * Maximum number of payload bytes beyond the acknowledged
111    * number of bytes can still be transmitted without further
112    * acknowledgements.
113    */
114   uint64_t bytes_window_size;
115
116   /**
117    * Cummulative acknowledgement for number of bytes received.
118    */
119   uint64_t bytes_cummulative_ack;
120
121   /**
122    * Followed by a variable-size bitfield for messages received
123    * beyond @e msg_cummulative_ack. Index at offset 0 must thus
124    * be zero, otherwise @e msg_cummulative_ack should be
125    * increased.  Note that this field can be overall of 0 bytes.
126    * The variable-size bitfield must be a multiple of 64 bits
127    * long.
128    */
129   /* uint64_t msg_selective_ack_field[]; */
130 };
131
132
133
134
135
136 GNUNET_NETWORK_STRUCT_END
137
138 /* end of communicator.h */
139 #endif