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