summaryrefslogtreecommitdiff
path: root/src/transport/transport_api_offer_hello.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport_api_offer_hello.c')
-rw-r--r--src/transport/transport_api_offer_hello.c81
1 files changed, 39 insertions, 42 deletions
diff --git a/src/transport/transport_api_offer_hello.c b/src/transport/transport_api_offer_hello.c
index c4432af93..89f8d463d 100644
--- a/src/transport/transport_api_offer_hello.c
+++ b/src/transport/transport_api_offer_hello.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file transport/transport_api_offer_hello.c 22 * @file transport/transport_api_offer_hello.c
@@ -33,9 +33,7 @@
33/** 33/**
34 * Entry in linked list for all offer-HELLO requests. 34 * Entry in linked list for all offer-HELLO requests.
35 */ 35 */
36struct GNUNET_TRANSPORT_OfferHelloHandle 36struct GNUNET_TRANSPORT_OfferHelloHandle {
37{
38
39 /** 37 /**
40 * Transport service handle we use for transmission. 38 * Transport service handle we use for transmission.
41 */ 39 */
@@ -50,7 +48,6 @@ struct GNUNET_TRANSPORT_OfferHelloHandle
50 * Closure for @e cont 48 * Closure for @e cont
51 */ 49 */
52 void *cls; 50 void *cls;
53
54}; 51};
55 52
56 53
@@ -60,13 +57,13 @@ struct GNUNET_TRANSPORT_OfferHelloHandle
60 * @param cls the handle for the operation 57 * @param cls the handle for the operation
61 */ 58 */
62static void 59static void
63finished_hello (void *cls) 60finished_hello(void *cls)
64{ 61{
65 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls; 62 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls;
66 63
67 if (NULL != ohh->cont) 64 if (NULL != ohh->cont)
68 ohh->cont (ohh->cls); 65 ohh->cont(ohh->cls);
69 GNUNET_TRANSPORT_offer_hello_cancel (ohh); 66 GNUNET_TRANSPORT_offer_hello_cancel(ohh);
70} 67}
71 68
72 69
@@ -78,51 +75,51 @@ finished_hello (void *cls)
78 * @param cfg configuration 75 * @param cfg configuration
79 * @param hello the hello message 76 * @param hello the hello message
80 * @param cont continuation to call when HELLO has been sent, 77 * @param cont continuation to call when HELLO has been sent,
81 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail 78 * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail
82 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success 79 * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success
83 * @param cont_cls closure for @a cont 80 * @param cont_cls closure for @a cont
84 * @return a `struct GNUNET_TRANSPORT_OfferHelloHandle` handle or NULL on failure, 81 * @return a `struct GNUNET_TRANSPORT_OfferHelloHandle` handle or NULL on failure,
85 * in case of failure @a cont will not be called 82 * in case of failure @a cont will not be called
86 * 83 *
87 */ 84 */
88struct GNUNET_TRANSPORT_OfferHelloHandle * 85struct GNUNET_TRANSPORT_OfferHelloHandle *
89GNUNET_TRANSPORT_offer_hello (const struct GNUNET_CONFIGURATION_Handle *cfg, 86GNUNET_TRANSPORT_offer_hello(const struct GNUNET_CONFIGURATION_Handle *cfg,
90 const struct GNUNET_MessageHeader *hello, 87 const struct GNUNET_MessageHeader *hello,
91 GNUNET_SCHEDULER_TaskCallback cont, 88 GNUNET_SCHEDULER_TaskCallback cont,
92 void *cont_cls) 89 void *cont_cls)
93{ 90{
94 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh 91 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh
95 = GNUNET_new (struct GNUNET_TRANSPORT_OfferHelloHandle); 92 = GNUNET_new(struct GNUNET_TRANSPORT_OfferHelloHandle);
96 struct GNUNET_MQ_Envelope *env; 93 struct GNUNET_MQ_Envelope *env;
97 struct GNUNET_PeerIdentity peer; 94 struct GNUNET_PeerIdentity peer;
98 95
99 if (GNUNET_OK != 96 if (GNUNET_OK !=
100 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello, 97 GNUNET_HELLO_get_id((const struct GNUNET_HELLO_Message *)hello,
101 &peer)) 98 &peer))
102 { 99 {
103 GNUNET_break (0); 100 GNUNET_break(0);
104 GNUNET_free (ohh); 101 GNUNET_free(ohh);
105 return NULL; 102 return NULL;
106 } 103 }
107 ohh->mq = GNUNET_CLIENT_connect (cfg, 104 ohh->mq = GNUNET_CLIENT_connect(cfg,
108 "transport", 105 "transport",
109 NULL, 106 NULL,
110 NULL, 107 NULL,
111 ohh); 108 ohh);
112 if (NULL == ohh->mq) 109 if (NULL == ohh->mq)
113 { 110 {
114 GNUNET_free (ohh); 111 GNUNET_free(ohh);
115 return NULL; 112 return NULL;
116 } 113 }
117 ohh->cont = cont; 114 ohh->cont = cont;
118 ohh->cls = cont_cls; 115 ohh->cls = cont_cls;
119 GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO); 116 GNUNET_break(ntohs(hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
120 env = GNUNET_MQ_msg_copy (hello); 117 env = GNUNET_MQ_msg_copy(hello);
121 GNUNET_MQ_notify_sent (env, 118 GNUNET_MQ_notify_sent(env,
122 &finished_hello, 119 &finished_hello,
123 ohh); 120 ohh);
124 GNUNET_MQ_send (ohh->mq, 121 GNUNET_MQ_send(ohh->mq,
125 env); 122 env);
126 return ohh; 123 return ohh;
127} 124}
128 125
@@ -133,10 +130,10 @@ GNUNET_TRANSPORT_offer_hello (const struct GNUNET_CONFIGURATION_Handle *cfg,
133 * @param ohh the handle for the operation to cancel 130 * @param ohh the handle for the operation to cancel
134 */ 131 */
135void 132void
136GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh) 133GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
137{ 134{
138 GNUNET_MQ_destroy (ohh->mq); 135 GNUNET_MQ_destroy(ohh->mq);
139 GNUNET_free (ohh); 136 GNUNET_free(ohh);
140} 137}
141 138
142 139