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.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/transport/transport_api_offer_hello.c b/src/transport/transport_api_offer_hello.c
index 89f8d463d..eb342f57c 100644
--- a/src/transport/transport_api_offer_hello.c
+++ b/src/transport/transport_api_offer_hello.c
@@ -33,7 +33,8 @@
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{
37 /** 38 /**
38 * Transport service handle we use for transmission. 39 * Transport service handle we use for transmission.
39 */ 40 */
@@ -57,13 +58,13 @@ struct GNUNET_TRANSPORT_OfferHelloHandle {
57 * @param cls the handle for the operation 58 * @param cls the handle for the operation
58 */ 59 */
59static void 60static void
60finished_hello(void *cls) 61finished_hello (void *cls)
61{ 62{
62 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls; 63 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls;
63 64
64 if (NULL != ohh->cont) 65 if (NULL != ohh->cont)
65 ohh->cont(ohh->cls); 66 ohh->cont (ohh->cls);
66 GNUNET_TRANSPORT_offer_hello_cancel(ohh); 67 GNUNET_TRANSPORT_offer_hello_cancel (ohh);
67} 68}
68 69
69 70
@@ -83,43 +84,43 @@ finished_hello(void *cls)
83 * 84 *
84 */ 85 */
85struct GNUNET_TRANSPORT_OfferHelloHandle * 86struct GNUNET_TRANSPORT_OfferHelloHandle *
86GNUNET_TRANSPORT_offer_hello(const struct GNUNET_CONFIGURATION_Handle *cfg, 87GNUNET_TRANSPORT_offer_hello (const struct GNUNET_CONFIGURATION_Handle *cfg,
87 const struct GNUNET_MessageHeader *hello, 88 const struct GNUNET_MessageHeader *hello,
88 GNUNET_SCHEDULER_TaskCallback cont, 89 GNUNET_SCHEDULER_TaskCallback cont,
89 void *cont_cls) 90 void *cont_cls)
90{ 91{
91 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh 92 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh
92 = GNUNET_new(struct GNUNET_TRANSPORT_OfferHelloHandle); 93 = GNUNET_new (struct GNUNET_TRANSPORT_OfferHelloHandle);
93 struct GNUNET_MQ_Envelope *env; 94 struct GNUNET_MQ_Envelope *env;
94 struct GNUNET_PeerIdentity peer; 95 struct GNUNET_PeerIdentity peer;
95 96
96 if (GNUNET_OK != 97 if (GNUNET_OK !=
97 GNUNET_HELLO_get_id((const struct GNUNET_HELLO_Message *)hello, 98 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello,
98 &peer)) 99 &peer))
99 { 100 {
100 GNUNET_break(0); 101 GNUNET_break (0);
101 GNUNET_free(ohh); 102 GNUNET_free (ohh);
102 return NULL; 103 return NULL;
103 } 104 }
104 ohh->mq = GNUNET_CLIENT_connect(cfg, 105 ohh->mq = GNUNET_CLIENT_connect (cfg,
105 "transport", 106 "transport",
106 NULL, 107 NULL,
107 NULL, 108 NULL,
108 ohh); 109 ohh);
109 if (NULL == ohh->mq) 110 if (NULL == ohh->mq)
110 { 111 {
111 GNUNET_free(ohh); 112 GNUNET_free (ohh);
112 return NULL; 113 return NULL;
113 } 114 }
114 ohh->cont = cont; 115 ohh->cont = cont;
115 ohh->cls = cont_cls; 116 ohh->cls = cont_cls;
116 GNUNET_break(ntohs(hello->type) == GNUNET_MESSAGE_TYPE_HELLO); 117 GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
117 env = GNUNET_MQ_msg_copy(hello); 118 env = GNUNET_MQ_msg_copy (hello);
118 GNUNET_MQ_notify_sent(env, 119 GNUNET_MQ_notify_sent (env,
119 &finished_hello, 120 &finished_hello,
120 ohh); 121 ohh);
121 GNUNET_MQ_send(ohh->mq, 122 GNUNET_MQ_send (ohh->mq,
122 env); 123 env);
123 return ohh; 124 return ohh;
124} 125}
125 126
@@ -130,10 +131,11 @@ GNUNET_TRANSPORT_offer_hello(const struct GNUNET_CONFIGURATION_Handle *cfg,
130 * @param ohh the handle for the operation to cancel 131 * @param ohh the handle for the operation to cancel
131 */ 132 */
132void 133void
133GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh) 134GNUNET_TRANSPORT_offer_hello_cancel (struct
135 GNUNET_TRANSPORT_OfferHelloHandle *ohh)
134{ 136{
135 GNUNET_MQ_destroy(ohh->mq); 137 GNUNET_MQ_destroy (ohh->mq);
136 GNUNET_free(ohh); 138 GNUNET_free (ohh);
137} 139}
138 140
139 141