aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorch3 <buenger@mytum.de>2023-09-08 14:33:37 +0200
committerch3 <buenger@mytum.de>2024-04-26 19:04:58 +0200
commit215d96cbba7d0c2c6254158eda688030674241b9 (patch)
tree2726a1d2951eac4fafc452731272d1ca5dfbe7e1 /src
parenta233ae770cf647bacf3e34c39ed68e2cb422b473 (diff)
downloadgnunet-215d96cbba7d0c2c6254158eda688030674241b9.tar.gz
gnunet-215d96cbba7d0c2c6254158eda688030674241b9.zip
cong: Incorporate changes from last feedback
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_core_underlay.h77
1 files changed, 30 insertions, 47 deletions
diff --git a/src/include/gnunet_core_underlay.h b/src/include/gnunet_core_underlay.h
index ce7442627..12ec0c9af 100644
--- a/src/include/gnunet_core_underlay.h
+++ b/src/include/gnunet_core_underlay.h
@@ -24,9 +24,9 @@
24 * @author Julius Bünger 24 * @author Julius Bünger
25 * 25 *
26 * @file 26 * @file
27 * API of the services underlying core (transport or libp2p) 27 * API of the services underlying core (transport, libp2p, ...)
28 * 28 *
29 * @defgroup CONG COre Next Generation service 29 * @defgroup CORE
30 * Secure Communication with other peers 30 * Secure Communication with other peers
31 * 31 *
32 * @see [Documentation](https://gnunet.org/core-service) TODO 32 * @see [Documentation](https://gnunet.org/core-service) TODO
@@ -64,16 +64,17 @@ struct GNUNET_CORE_UNDERLAY_Handle;
64 * peer connected to us. 64 * peer connected to us.
65 * 65 *
66 * @param cls closure 66 * @param cls closure
67 * @param peer the identity of the peer that connected; this 67 * @param peer_cls closure returned by #GNUNET_CORE_UNDERLAY_connect_to_peer
68 * pointer will remain valid until the disconnect, hence 68 * @param num_addresses number of addresses of the connecting peer
69 * applications do not necessarily have to make a copy 69 * @param addresses address URIs of the connecting peer
70 * of the value if they only need it until disconnect
71 * @param mq message queue to use to transmit to @a peer 70 * @param mq message queue to use to transmit to @a peer
72 * @return closure to use in MQ handlers 71 * @return closure to use in MQ handlers
73 */ 72 */
74typedef void *(*GNUNET_CORE_UNDERLAY_NotifyConnect) ( 73typedef void *(*GNUNET_CORE_UNDERLAY_NotifyConnect) (
75 void *cls, 74 void *cls,
76 const struct GNUNET_PeerIdentity *peer, 75 void *peer_cls,
76 uint32_t num_addresses;
77 const char *addresses[static num_addresses],
77 struct GNUNET_MQ_Handle *mq); 78 struct GNUNET_MQ_Handle *mq);
78 79
79 80
@@ -84,13 +85,11 @@ typedef void *(*GNUNET_CORE_UNDERLAY_NotifyConnect) (
84 * henceforth. 85 * henceforth.
85 * 86 *
86 * @param cls closure from #GNUNET_CORE_UNDERLAY_connect 87 * @param cls closure from #GNUNET_CORE_UNDERLAY_connect
87 * @param peer the peer that disconnected
88 * @param handlers_cls closure of the handlers, was returned from the 88 * @param handlers_cls closure of the handlers, was returned from the
89 * connect notification callback 89 * connect notification callback
90 */ 90 */
91typedef void (*GNUNET_CORE_UNDERLAY_NotifyDisconnect) ( 91typedef void (*GNUNET_CORE_UNDERLAY_NotifyDisconnect) (
92 void *cls, 92 void *cls,
93 const struct GNUNET_PeerIdentity *peer,
94 void *handler_cls); 93 void *handler_cls);
95 94
96 95
@@ -99,16 +98,12 @@ typedef void (*GNUNET_CORE_UNDERLAY_NotifyDisconnect) (
99 * update its peer identity accordingly. 98 * update its peer identity accordingly.
100 * 99 *
101 * @param cls closure from #GNUNET_CORE_UNDERLAY_connect 100 * @param cls closure from #GNUNET_CORE_UNDERLAY_connect
102 * @param addresses Array of underlay addresses TODO see what formats libp2p support 101 * @param network_location_hash hash of the address URIs representing our
103 * @param num_addresses Length of the array 102 * current network location
104 * @param handler_cls IF NECESSARY closure of the handlers, was returned from
105 * the connect notification callback
106 */ 103 */
107typedef void (*GNUNET_CORE_UNDERLAY_NotifyAddressChange) ( 104typedef void (*GNUNET_CORE_UNDERLAY_NotifyAddressChange) (
108 void *cls, 105 void *cls,
109 const struct GNUNET_TRANSPORT_AddressIdentifier *addresses, 106 struct GNUNET_HashCode network_location_hash);
110 uint32_t num_addresses,
111 /*void *handler_cls*/);
112 107
113 108
114/** 109/**
@@ -116,25 +111,22 @@ typedef void (*GNUNET_CORE_UNDERLAY_NotifyAddressChange) (
116 * complete (or fail) asynchronously. 111 * complete (or fail) asynchronously.
117 * 112 *
118 * @param cfg configuration to use 113 * @param cfg configuration to use
119 * @param self our own identity (API should check that it matches 114 * @param handlers array of message handlers or NULL; note that the closures
120 * the identity found by core underlay), or NULL (no check) @param 115 * provided will be ignored and replaced with the respective
121 * handlers array of message handlers; note that the closures 116 * return value from @a nc
122 * provided will be ignored and replaced with the respective return 117 * @param cls closure for the @a nc, @a nd and @a na callbacks
123 * value from @a nc @param handlers array with handlers to call
124 * when we receive messages, or NULL @param cls closure for the @a
125 * nc, @a nd and @a neb callbacks
126 * @param nc function to call on connect events, or NULL 118 * @param nc function to call on connect events, or NULL
127 * @param nd function to call on disconnect events, or NULL 119 * @param nd function to call on disconnect events, or NULL
128 * @param neb function to call if we have excess bandwidth to a peer, or NULL 120 * @param na function to call on address changes, or NULL
129 * @return NULL on error 121 * @return NULL on error
130 */ 122 */
131struct GNUNET_CORE_UNDERLAY_Handle * 123struct GNUNET_CORE_UNDERLAY_Handle *
132GNUNET_CORE_UNDERLAY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 124GNUNET_CORE_UNDERLAY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
133 const struct GNUNET_PeerIdentity *self,
134 const struct GNUNET_MQ_MessageHandler *handlers, 125 const struct GNUNET_MQ_MessageHandler *handlers,
135 void *cls, 126 void *cls,
136 GNUNET_CORE_UNDERLAY_NotifyConnect nc, 127 GNUNET_CORE_UNDERLAY_NotifyConnect nc,
137 GNUNET_CORE_UNDERLAY_NotifyDisconnect nd); 128 GNUNET_CORE_UNDERLAY_NotifyDisconnect nd,
129 GNUNET_CORE_UNDERLAY_NotifyAddressChange na);
138 130
139 131
140/** 132/**
@@ -163,36 +155,27 @@ GNUNET_CORE_UNDERLAY_disconnect (struct GNUNET_CORE_UNDERLAY_Handle *handle);
163 * be full and CORE UNDERLAY will stop providing messages to CORE for @a 155 * be full and CORE UNDERLAY will stop providing messages to CORE for @a
164 * pid. 156 * pid.
165 * 157 *
166 * @param ch core handle 158 * @param ch core underlay handle
167 * @param pid which peer was the message from that was fully processed by CORE 159 * @param pid which peer was the message from that was fully processed by CORE
168 */ 160 */
169void 161void
170GNUNET_CORE_UNDERLAY_receive_continue (struct GNUNET_CORE_UNDERLAY_Handle *ch, 162GNUNET_CORE_UNDERLAY_receive_continue (struct GNUNET_CORE_UNDERLAY_Handle *ch);
171 const struct GNUNET_PeerIdentity *pid);
172 163
173 164
174/** 165/**
175 * Checks if a given peer is connected to us and get the message queue. 166 * Instruct the underlay to try to connect to another peer.
176 * Convenience function.
177 * 167 *
178 * @param handle connection to core underlay service 168 * Once the connection was successful, the #GNUNET_CORE_UNDERLAY_NotifyConnect
179 * @param peer the peer to check 169 * will be called with a mq towards the peer.
180 * @return NULL if disconnected, otherwise message queue for @a peer
181 */
182struct GNUNET_MQ_Handle *
183GNUNET_CORE_UNDERLAY_get_mq (struct GNUNET_CORE_UNDERLAY_Handle *handle,
184 const struct GNUNET_PeerIdentity *peer);
185
186
187/**
188 * Pass the our new Peer ID to the core underlay.
189 * 170 *
190 * @param handle connection to core underlay service 171 * @param ch core underlay handle
191 * @param peer our new Peer ID 172 * @param peer_address URI of the peer to connect to
173 * @return peer_closure given to #GNUNET_CORE_UNDERLAY_NotifyConnect once the
174 * connection was established
192 */ 175 */
193void 176void *
194GNUNET_CORE_UNDERLAY_update_pid (struct GNUNET_CORE_UNDERLAY_Handle *handle, 177GNUNET_CORE_UNDERLAY_connect_to_peer (struct GNUNET_CORE_UNDERLAY_Handle *ch,
195 const struct GNUNET_PeerIdentity *peer); 178 const char *peer_address);
196 179
197 180
198#if 0 /* keep Emacsens' auto-indent happy */ 181#if 0 /* keep Emacsens' auto-indent happy */