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