diff options
Diffstat (limited to 'src/transport/transport_api_blacklist.c')
-rw-r--r-- | src/transport/transport_api_blacklist.c | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c index f04def49d..45d9bcf29 100644 --- a/src/transport/transport_api_blacklist.c +++ b/src/transport/transport_api_blacklist.c | |||
@@ -34,7 +34,8 @@ | |||
34 | /** | 34 | /** |
35 | * Handle for blacklisting requests. | 35 | * Handle for blacklisting requests. |
36 | */ | 36 | */ |
37 | struct GNUNET_TRANSPORT_Blacklist { | 37 | struct GNUNET_TRANSPORT_Blacklist |
38 | { | ||
38 | /** | 39 | /** |
39 | * Connection to transport service. | 40 | * Connection to transport service. |
40 | */ | 41 | */ |
@@ -64,7 +65,7 @@ struct GNUNET_TRANSPORT_Blacklist { | |||
64 | * @param br overall handle | 65 | * @param br overall handle |
65 | */ | 66 | */ |
66 | static void | 67 | static void |
67 | reconnect(struct GNUNET_TRANSPORT_Blacklist *br); | 68 | reconnect (struct GNUNET_TRANSPORT_Blacklist *br); |
68 | 69 | ||
69 | 70 | ||
70 | /** | 71 | /** |
@@ -74,21 +75,21 @@ reconnect(struct GNUNET_TRANSPORT_Blacklist *br); | |||
74 | * @param bm query | 75 | * @param bm query |
75 | */ | 76 | */ |
76 | static void | 77 | static void |
77 | handle_query(void *cls, | 78 | handle_query (void *cls, |
78 | const struct BlacklistMessage *bm) | 79 | const struct BlacklistMessage *bm) |
79 | { | 80 | { |
80 | struct GNUNET_TRANSPORT_Blacklist *br = cls; | 81 | struct GNUNET_TRANSPORT_Blacklist *br = cls; |
81 | struct GNUNET_MQ_Envelope *env; | 82 | struct GNUNET_MQ_Envelope *env; |
82 | struct BlacklistMessage *res; | 83 | struct BlacklistMessage *res; |
83 | 84 | ||
84 | GNUNET_break(0 == ntohl(bm->is_allowed)); | 85 | GNUNET_break (0 == ntohl (bm->is_allowed)); |
85 | env = GNUNET_MQ_msg(res, | 86 | env = GNUNET_MQ_msg (res, |
86 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY); | 87 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY); |
87 | res->is_allowed = htonl(br->cb(br->cb_cls, | 88 | res->is_allowed = htonl (br->cb (br->cb_cls, |
88 | &bm->peer)); | 89 | &bm->peer)); |
89 | res->peer = bm->peer; | 90 | res->peer = bm->peer; |
90 | GNUNET_MQ_send(br->mq, | 91 | GNUNET_MQ_send (br->mq, |
91 | env); | 92 | env); |
92 | } | 93 | } |
93 | 94 | ||
94 | /** | 95 | /** |
@@ -100,12 +101,12 @@ handle_query(void *cls, | |||
100 | * @param error error code | 101 | * @param error error code |
101 | */ | 102 | */ |
102 | static void | 103 | static void |
103 | mq_error_handler(void *cls, | 104 | mq_error_handler (void *cls, |
104 | enum GNUNET_MQ_Error error) | 105 | enum GNUNET_MQ_Error error) |
105 | { | 106 | { |
106 | struct GNUNET_TRANSPORT_Blacklist *br = cls; | 107 | struct GNUNET_TRANSPORT_Blacklist *br = cls; |
107 | 108 | ||
108 | reconnect(br); | 109 | reconnect (br); |
109 | } | 110 | } |
110 | 111 | ||
111 | 112 | ||
@@ -115,31 +116,31 @@ mq_error_handler(void *cls, | |||
115 | * @param br overall handle | 116 | * @param br overall handle |
116 | */ | 117 | */ |
117 | static void | 118 | static void |
118 | reconnect(struct GNUNET_TRANSPORT_Blacklist *br) | 119 | reconnect (struct GNUNET_TRANSPORT_Blacklist *br) |
119 | { | 120 | { |
120 | struct GNUNET_MQ_MessageHandler handlers[] = { | 121 | struct GNUNET_MQ_MessageHandler handlers[] = { |
121 | GNUNET_MQ_hd_fixed_size(query, | 122 | GNUNET_MQ_hd_fixed_size (query, |
122 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY, | 123 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY, |
123 | struct BlacklistMessage, | 124 | struct BlacklistMessage, |
124 | br), | 125 | br), |
125 | GNUNET_MQ_handler_end() | 126 | GNUNET_MQ_handler_end () |
126 | }; | 127 | }; |
127 | struct GNUNET_MQ_Envelope *env; | 128 | struct GNUNET_MQ_Envelope *env; |
128 | struct GNUNET_MessageHeader *req; | 129 | struct GNUNET_MessageHeader *req; |
129 | 130 | ||
130 | if (NULL != br->mq) | 131 | if (NULL != br->mq) |
131 | GNUNET_MQ_destroy(br->mq); | 132 | GNUNET_MQ_destroy (br->mq); |
132 | br->mq = GNUNET_CLIENT_connect(br->cfg, | 133 | br->mq = GNUNET_CLIENT_connect (br->cfg, |
133 | "transport", | 134 | "transport", |
134 | handlers, | 135 | handlers, |
135 | &mq_error_handler, | 136 | &mq_error_handler, |
136 | br); | 137 | br); |
137 | if (NULL == br->mq) | 138 | if (NULL == br->mq) |
138 | return; | 139 | return; |
139 | env = GNUNET_MQ_msg(req, | 140 | env = GNUNET_MQ_msg (req, |
140 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT); | 141 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT); |
141 | GNUNET_MQ_send(br->mq, | 142 | GNUNET_MQ_send (br->mq, |
142 | env); | 143 | env); |
143 | } | 144 | } |
144 | 145 | ||
145 | 146 | ||
@@ -158,22 +159,22 @@ reconnect(struct GNUNET_TRANSPORT_Blacklist *br) | |||
158 | * @return NULL on error, otherwise handle for cancellation | 159 | * @return NULL on error, otherwise handle for cancellation |
159 | */ | 160 | */ |
160 | struct GNUNET_TRANSPORT_Blacklist * | 161 | struct GNUNET_TRANSPORT_Blacklist * |
161 | GNUNET_TRANSPORT_blacklist(const struct GNUNET_CONFIGURATION_Handle *cfg, | 162 | GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, |
162 | GNUNET_TRANSPORT_BlacklistCallback cb, | 163 | GNUNET_TRANSPORT_BlacklistCallback cb, |
163 | void *cb_cls) | 164 | void *cb_cls) |
164 | { | 165 | { |
165 | struct GNUNET_TRANSPORT_Blacklist *br; | 166 | struct GNUNET_TRANSPORT_Blacklist *br; |
166 | 167 | ||
167 | br = GNUNET_new(struct GNUNET_TRANSPORT_Blacklist); | 168 | br = GNUNET_new (struct GNUNET_TRANSPORT_Blacklist); |
168 | br->cfg = cfg; | 169 | br->cfg = cfg; |
169 | br->cb = cb; | 170 | br->cb = cb; |
170 | br->cb_cls = cb_cls; | 171 | br->cb_cls = cb_cls; |
171 | reconnect(br); | 172 | reconnect (br); |
172 | if (NULL == br->mq) | 173 | if (NULL == br->mq) |
173 | { | 174 | { |
174 | GNUNET_free(br); | 175 | GNUNET_free (br); |
175 | return NULL; | 176 | return NULL; |
176 | } | 177 | } |
177 | return br; | 178 | return br; |
178 | } | 179 | } |
179 | 180 | ||
@@ -185,10 +186,10 @@ GNUNET_TRANSPORT_blacklist(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
185 | * @param br handle of the request that is to be cancelled | 186 | * @param br handle of the request that is to be cancelled |
186 | */ | 187 | */ |
187 | void | 188 | void |
188 | GNUNET_TRANSPORT_blacklist_cancel(struct GNUNET_TRANSPORT_Blacklist *br) | 189 | GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br) |
189 | { | 190 | { |
190 | GNUNET_MQ_destroy(br->mq); | 191 | GNUNET_MQ_destroy (br->mq); |
191 | GNUNET_free(br); | 192 | GNUNET_free (br); |
192 | } | 193 | } |
193 | 194 | ||
194 | 195 | ||