diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2021-07-06 15:58:36 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2021-07-06 15:58:36 +0200 |
commit | 064113c2465826a6038a996b0e4cbc967e888b80 (patch) | |
tree | cb47257a85dd9614bc18f702757a0cc66cd406e0 /src/dhtu/plugin_dhtu_ip.c | |
parent | b6521e32a295a0b96e7de2455b33744a16bab948 (diff) | |
download | gnunet-064113c2465826a6038a996b0e4cbc967e888b80.tar.gz gnunet-064113c2465826a6038a996b0e4cbc967e888b80.zip |
-parsing for ip plugin
Diffstat (limited to 'src/dhtu/plugin_dhtu_ip.c')
-rw-r--r-- | src/dhtu/plugin_dhtu_ip.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c index 554c096e1..f6ceabc2c 100644 --- a/src/dhtu/plugin_dhtu_ip.c +++ b/src/dhtu/plugin_dhtu_ip.c | |||
@@ -111,6 +111,11 @@ struct Plugin | |||
111 | * Callbacks into the DHT. | 111 | * Callbacks into the DHT. |
112 | */ | 112 | */ |
113 | struct GNUNET_DHTU_PluginEnvironment *env; | 113 | struct GNUNET_DHTU_PluginEnvironment *env; |
114 | |||
115 | /** | ||
116 | * Port we bind to. FIXME: initialize... | ||
117 | */ | ||
118 | char *my_port; | ||
114 | }; | 119 | }; |
115 | 120 | ||
116 | 121 | ||
@@ -166,7 +171,59 @@ static void | |||
166 | ip_try_connect (void *cls, | 171 | ip_try_connect (void *cls, |
167 | const char *address) | 172 | const char *address) |
168 | { | 173 | { |
169 | GNUNET_break (0); | 174 | struct Plugin *plugin = cls; |
175 | char *colon; | ||
176 | const char *port; | ||
177 | char *addr; | ||
178 | struct addrinfo hints = { | ||
179 | .ai_flags = AI_NUMERICHOST | AI_NUMERICSERV | ||
180 | }; | ||
181 | struct addrinfo *result = NULL; | ||
182 | |||
183 | if (0 != | ||
184 | strncmp (address, | ||
185 | "ip+", | ||
186 | strlen ("ip+"))) | ||
187 | { | ||
188 | GNUNET_break (0); | ||
189 | return; | ||
190 | } | ||
191 | address += strlen ("ip+"); | ||
192 | if (0 != | ||
193 | strncmp (address, | ||
194 | "udp://", | ||
195 | strlen ("udp://"))) | ||
196 | { | ||
197 | GNUNET_break (0); | ||
198 | return; | ||
199 | } | ||
200 | address += strlen ("udp://"); | ||
201 | addr = GNUNET_strdup (address); | ||
202 | colon = strchr (addr, ':'); | ||
203 | if (NULL == colon) | ||
204 | { | ||
205 | port = plugin->my_port; | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | *colon = '\0'; | ||
210 | port = colon + 1; | ||
211 | } | ||
212 | if (0 != | ||
213 | getaddrinfo (addr, | ||
214 | port, | ||
215 | &hints, | ||
216 | &result)) | ||
217 | { | ||
218 | GNUNET_break (0); | ||
219 | GNUNET_free (addr); | ||
220 | return; | ||
221 | } | ||
222 | GNUNET_free (addr); | ||
223 | (void) result->ai_addr; // FIXME: use! | ||
224 | |||
225 | // FIXME: create target, etc. | ||
226 | freeaddrinfo (result); | ||
170 | } | 227 | } |
171 | 228 | ||
172 | 229 | ||
@@ -255,6 +312,9 @@ libgnunet_plugin_dhtu_ip_init (void *cls) | |||
255 | 312 | ||
256 | plugin = GNUNET_new (struct Plugin); | 313 | plugin = GNUNET_new (struct Plugin); |
257 | plugin->env = env; | 314 | plugin->env = env; |
315 | // FIXME: port configuration? | ||
316 | // FIXME: figure out our own IP addresses... | ||
317 | // FIXME: bind, start receive loop | ||
258 | api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); | 318 | api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); |
259 | api->cls = plugin; | 319 | api->cls = plugin; |
260 | api->sign = &ip_sign; | 320 | api->sign = &ip_sign; |