Merge remote-tracking branch 'origin/master' into identity_oidc
[oweals/gnunet.git] / src / nat / gnunet-service-nat_mini.c
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2011-2014, 2016 GNUnet e.V.
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file nat/gnunet-service-nat_mini.c
23  * @brief functions for interaction with miniupnp; tested with miniupnpc 1.5
24  * @author Christian Grothoff
25  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_nat_service.h"
29 #include "gnunet-service-nat_mini.h"
30 #include "nat.h"
31
32 #define LOG(kind,...) GNUNET_log_from (kind, "nat", __VA_ARGS__)
33
34 /**
35  * How long do we give upnpc to create a mapping?
36  */
37 #define MAP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
38
39 /**
40  * How long do we give upnpc to remove a mapping?
41  */
42 #define UNMAP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
43
44 /**
45  * How often do we check for changes in the mapping?
46  */
47 #define MAP_REFRESH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
48
49
50 /* ************************* external-ip calling ************************ */
51
52 /**
53  * Opaque handle to cancel "GNUNET_NAT_mini_get_external_ipv4" operation.
54  */
55 struct GNUNET_NAT_ExternalHandle
56 {
57
58   /**
59    * Function to call with the result.
60    */
61   GNUNET_NAT_IPCallback cb;
62
63   /**
64    * Closure for @e cb.
65    */
66   void *cb_cls;
67
68   /**
69    * Read task.
70    */
71   struct GNUNET_SCHEDULER_Task *task;
72
73   /**
74    * Handle to `external-ip` process.
75    */
76   struct GNUNET_OS_Process *eip;
77
78   /**
79    * Handle to stdout pipe of `external-ip`.
80    */
81   struct GNUNET_DISK_PipeHandle *opipe;
82
83   /**
84    * Read handle of @e opipe.
85    */
86   const struct GNUNET_DISK_FileHandle *r;
87
88   /**
89    * Number of bytes in @e buf that are valid.
90    */
91   size_t off;
92
93   /**
94    * Destination of our read operation (output of 'external-ip').
95    */
96   char buf[17];
97
98   /**
99    * Error code for better debugging and user feedback
100    */
101   enum GNUNET_NAT_StatusCode ret;
102 };
103
104
105 /**
106  * Read the output of `external-ip` into `buf`.  When complete, parse
107  * the address and call our callback.
108  *
109  * @param cls the `struct GNUNET_NAT_ExternalHandle`
110  */
111 static void
112 read_external_ipv4 (void *cls)
113 {
114   struct GNUNET_NAT_ExternalHandle *eh = cls;
115   ssize_t ret;
116   struct in_addr addr;
117
118   eh->task = NULL;
119   ret = GNUNET_DISK_file_read (eh->r,
120                                &eh->buf[eh->off],
121                                sizeof (eh->buf) - eh->off);
122   if (ret > 0)
123   {
124     /* try to read more */
125     eh->off += ret;
126     eh->task
127       = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
128                                         eh->r,
129                                         &read_external_ipv4,
130                                         eh);
131     return;
132   }
133   eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_OUTPUT_INVALID;
134   if ( (eh->off > 7) &&
135        (eh->buf[eh->off - 1] == '\n') )
136   {
137     eh->buf[eh->off - 1] = '\0';
138     if (1 == inet_pton (AF_INET,
139                         eh->buf,
140                         &addr))
141     {
142       if (0 == addr.s_addr)
143         eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID;       /* got 0.0.0.0 */
144       else
145         eh->ret = GNUNET_NAT_ERROR_SUCCESS;
146     }
147   }
148   eh->cb (eh->cb_cls,
149           (GNUNET_NAT_ERROR_SUCCESS == eh->ret) ? &addr : NULL,
150           eh->ret);
151   GNUNET_NAT_mini_get_external_ipv4_cancel_ (eh);
152 }
153
154
155 /**
156  * (Asynchronously) signal error invoking `external-ip` to client.
157  *
158  * @param cls the `struct GNUNET_NAT_ExternalHandle` (freed)
159  */
160 static void
161 signal_external_ip_error (void *cls)
162 {
163   struct GNUNET_NAT_ExternalHandle *eh = cls;
164
165   eh->task = NULL;
166   eh->cb (eh->cb_cls,
167           NULL,
168           eh->ret);
169   GNUNET_free (eh);
170 }
171
172
173 /**
174  * Try to get the external IPv4 address of this peer.
175  *
176  * @param cb function to call with result
177  * @param cb_cls closure for @a cb
178  * @return handle for cancellation (can only be used until @a cb is called), never NULL
179  */
180 struct GNUNET_NAT_ExternalHandle *
181 GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb,
182                                     void *cb_cls)
183 {
184   struct GNUNET_NAT_ExternalHandle *eh;
185
186   eh = GNUNET_new (struct GNUNET_NAT_ExternalHandle);
187   eh->cb = cb;
188   eh->cb_cls = cb_cls;
189   eh->ret = GNUNET_NAT_ERROR_SUCCESS;
190   if (GNUNET_SYSERR ==
191       GNUNET_OS_check_helper_binary ("external-ip",
192                                      GNUNET_NO,
193                                      NULL))
194   {
195     LOG (GNUNET_ERROR_TYPE_INFO,
196          _("`external-ip' command not found\n"));
197     eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND;
198     eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error,
199                                          eh);
200     return eh;
201   }
202   LOG (GNUNET_ERROR_TYPE_DEBUG,
203        "Running `external-ip' to determine our external IP\n");
204   eh->opipe = GNUNET_DISK_pipe (GNUNET_YES,
205                                 GNUNET_YES,
206                                 GNUNET_NO,
207                                 GNUNET_YES);
208   if (NULL == eh->opipe)
209   {
210     eh->ret = GNUNET_NAT_ERROR_IPC_FAILURE;
211     eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error,
212                                          eh);
213     return eh;
214   }
215   eh->eip =
216       GNUNET_OS_start_process (GNUNET_NO,
217                                0,
218                                NULL,
219                                eh->opipe,
220                                NULL,
221                                "external-ip",
222                                "external-ip",
223                                NULL);
224   if (NULL == eh->eip)
225   {
226     GNUNET_DISK_pipe_close (eh->opipe);
227     eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED;
228     eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error,
229                                          eh);
230     return eh;
231   }
232   GNUNET_DISK_pipe_close_end (eh->opipe,
233                               GNUNET_DISK_PIPE_END_WRITE);
234   eh->r = GNUNET_DISK_pipe_handle (eh->opipe,
235                                    GNUNET_DISK_PIPE_END_READ);
236   eh->task
237     = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
238                                       eh->r,
239                                       &read_external_ipv4,
240                                       eh);
241   return eh;
242 }
243
244
245 /**
246  * Cancel operation.
247  *
248  * @param eh operation to cancel
249  */
250 void
251 GNUNET_NAT_mini_get_external_ipv4_cancel_ (struct GNUNET_NAT_ExternalHandle *eh)
252 {
253   if (NULL != eh->eip)
254   {
255     (void) GNUNET_OS_process_kill (eh->eip,
256                                    SIGKILL);
257     GNUNET_break (GNUNET_OK ==
258                   GNUNET_OS_process_wait (eh->eip));
259     GNUNET_OS_process_destroy (eh->eip);
260   }
261   if (NULL != eh->opipe)
262   {
263     GNUNET_DISK_pipe_close (eh->opipe);
264     eh->opipe = NULL;
265   }
266   if (NULL != eh->task)
267   {
268     GNUNET_SCHEDULER_cancel (eh->task);
269     eh->task = NULL;
270   }
271   GNUNET_free (eh);
272 }
273
274
275 /* ************************* upnpc calling ************************ */
276
277
278 /**
279  * Handle to a mapping created with upnpc.
280  */
281 struct GNUNET_NAT_MiniHandle
282 {
283
284   /**
285    * Function to call on mapping changes.
286    */
287   GNUNET_NAT_MiniAddressCallback ac;
288
289   /**
290    * Closure for @e ac.
291    */
292   void *ac_cls;
293
294   /**
295    * Command used to install the map.
296    */
297   struct GNUNET_OS_CommandHandle *map_cmd;
298
299   /**
300    * Command used to refresh our map information.
301    */
302   struct GNUNET_OS_CommandHandle *refresh_cmd;
303
304   /**
305    * Command used to remove the mapping.
306    */
307   struct GNUNET_OS_CommandHandle *unmap_cmd;
308
309   /**
310    * Our current external mapping (if we have one).
311    */
312   struct sockaddr_in current_addr;
313
314   /**
315    * We check the mapping periodically to see if it
316    * still works.  This task triggers the check.
317    */
318   struct GNUNET_SCHEDULER_Task *refresh_task;
319
320   /**
321    * Are we mapping TCP or UDP?
322    */
323   int is_tcp;
324
325   /**
326    * Did we succeed with creating a mapping?
327    */
328   int did_map;
329
330   /**
331    * Did we find our mapping during refresh scan?
332    */
333   int found;
334
335   /**
336    * Which port are we mapping?
337    */
338   uint16_t port;
339
340 };
341
342
343 /**
344  * Run "upnpc -l" to find out if our mapping changed.
345  *
346  * @param cls the `struct GNUNET_NAT_MiniHandle`
347  */
348 static void
349 do_refresh (void *cls);
350
351
352 /**
353  * Process the output from the "upnpc -r" command.
354  *
355  * @param cls the `struct GNUNET_NAT_MiniHandle`
356  * @param line line of output, NULL at the end
357  */
358 static void
359 process_map_output (void *cls,
360                     const char *line);
361
362
363 /**
364  * Run "upnpc -r" to map our internal port.
365  *
366  * @param mini our handle
367  */
368 static void
369 run_upnpc_r (struct GNUNET_NAT_MiniHandle *mini)
370 {
371   char pstr[6];
372
373   GNUNET_snprintf (pstr,
374                    sizeof (pstr),
375                    "%u",
376                    (unsigned int) mini->port);
377   mini->map_cmd
378     = GNUNET_OS_command_run (&process_map_output,
379                              mini,
380                              MAP_TIMEOUT,
381                              "upnpc",
382                              "upnpc",
383                              "-r",
384                              pstr,
385                              mini->is_tcp ? "tcp" : "udp",
386                              NULL);
387   if (NULL == mini->map_cmd)
388   {
389     mini->ac (mini->ac_cls,
390               GNUNET_SYSERR,
391               NULL,
392               0,
393               GNUNET_NAT_ERROR_UPNPC_FAILED);
394     return;
395   }
396 }
397
398
399 /**
400  * Process the output from "upnpc -l" to see if our
401  * external mapping changed.  If so, do the notifications.
402  *
403  * @param cls the `struct GNUNET_NAT_MiniHandle`
404  * @param line line of output, NULL at the end
405  */
406 static void
407 process_refresh_output (void *cls,
408                         const char *line)
409 {
410   struct GNUNET_NAT_MiniHandle *mini = cls;
411   char pstr[9];
412   const char *s;
413   unsigned int nport;
414   struct in_addr exip;
415
416   if (NULL == line)
417   {
418     GNUNET_OS_command_stop (mini->refresh_cmd);
419     mini->refresh_cmd = NULL;
420     if (GNUNET_NO == mini->found)
421     {
422       /* mapping disappeared, try to re-create */
423       if (GNUNET_YES == mini->did_map)
424       {
425         mini->ac (mini->ac_cls,
426                   GNUNET_NO,
427                   (const struct sockaddr *) &mini->current_addr,
428                   sizeof (mini->current_addr),
429                   GNUNET_NAT_ERROR_SUCCESS);
430         mini->did_map = GNUNET_NO;
431       }
432       run_upnpc_r (mini);
433     }
434     return;
435   }
436   if (! mini->did_map)
437     return;                     /* never mapped, won't find our mapping anyway */
438
439   /* we're looking for output of the form:
440    * "ExternalIPAddress = 12.134.41.124" */
441
442   s = strstr (line,
443               "ExternalIPAddress = ");
444   if (NULL != s)
445   {
446     s += strlen ("ExternalIPAddress = ");
447     if (1 != inet_pton (AF_INET,
448                         s,
449                         &exip))
450       return;                   /* skip */
451     if (exip.s_addr == mini->current_addr.sin_addr.s_addr)
452       return;                   /* no change */
453     /* update mapping */
454     mini->ac (mini->ac_cls,
455               GNUNET_NO,
456               (const struct sockaddr *) &mini->current_addr,
457               sizeof (mini->current_addr),
458               GNUNET_NAT_ERROR_SUCCESS);
459     mini->current_addr.sin_addr = exip;
460     mini->ac (mini->ac_cls,
461               GNUNET_YES,
462               (const struct sockaddr *) &mini->current_addr,
463               sizeof (mini->current_addr),
464               GNUNET_NAT_ERROR_SUCCESS);
465     return;
466   }
467   /*
468    * we're looking for output of the form:
469    *
470    * "0 TCP  3000->192.168.2.150:3000  'libminiupnpc' ''"
471    * "1 UDP  3001->192.168.2.150:3001  'libminiupnpc' ''"
472    *
473    * the pattern we look for is:
474    *
475    * "%s TCP  PORT->STRING:OURPORT *" or
476    * "%s UDP  PORT->STRING:OURPORT *"
477    */
478   GNUNET_snprintf (pstr,
479                    sizeof (pstr),
480                    ":%u ",
481                    mini->port);
482   if (NULL == (s = strstr (line, "->")))
483     return;                     /* skip */
484   if (NULL == strstr (s, pstr))
485     return;                     /* skip */
486   if (1 !=
487       SSCANF (line,
488               (mini->is_tcp) ? "%*u TCP  %u->%*s:%*u %*s" :
489               "%*u UDP  %u->%*s:%*u %*s", &nport))
490     return;                     /* skip */
491   mini->found = GNUNET_YES;
492   if (nport == ntohs (mini->current_addr.sin_port))
493     return;                     /* no change */
494
495   /* external port changed, update mapping */
496   mini->ac (mini->ac_cls,
497             GNUNET_NO,
498             (const struct sockaddr *) &mini->current_addr,
499             sizeof (mini->current_addr),
500             GNUNET_NAT_ERROR_SUCCESS);
501   mini->current_addr.sin_port = htons ((uint16_t) nport);
502   mini->ac (mini->ac_cls,
503             GNUNET_YES,
504             (const struct sockaddr *) &mini->current_addr,
505             sizeof (mini->current_addr),
506             GNUNET_NAT_ERROR_SUCCESS);
507 }
508
509
510 /**
511  * Run "upnpc -l" to find out if our mapping changed.
512  *
513  * @param cls the 'struct GNUNET_NAT_MiniHandle'
514  */
515 static void
516 do_refresh (void *cls)
517 {
518   struct GNUNET_NAT_MiniHandle *mini = cls;
519   int ac;
520
521   mini->refresh_task
522     = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
523                                     &do_refresh,
524                                     mini);
525   LOG (GNUNET_ERROR_TYPE_DEBUG,
526        "Running `upnpc' to check if our mapping still exists\n");
527   mini->found = GNUNET_NO;
528   ac = GNUNET_NO;
529   if (NULL != mini->map_cmd)
530   {
531     /* took way too long, abort it! */
532     GNUNET_OS_command_stop (mini->map_cmd);
533     mini->map_cmd = NULL;
534     ac = GNUNET_YES;
535   }
536   if (NULL != mini->refresh_cmd)
537   {
538     /* took way too long, abort it! */
539     GNUNET_OS_command_stop (mini->refresh_cmd);
540     mini->refresh_cmd = NULL;
541     ac = GNUNET_YES;
542   }
543   mini->refresh_cmd
544     = GNUNET_OS_command_run (&process_refresh_output,
545                              mini,
546                              MAP_TIMEOUT,
547                              "upnpc",
548                              "upnpc",
549                              "-l",
550                              NULL);
551   if (GNUNET_YES == ac)
552     mini->ac (mini->ac_cls,
553               GNUNET_SYSERR,
554               NULL,
555               0,
556               GNUNET_NAT_ERROR_UPNPC_TIMEOUT);
557 }
558
559
560 /**
561  * Process the output from the 'upnpc -r' command.
562  *
563  * @param cls the `struct GNUNET_NAT_MiniHandle`
564  * @param line line of output, NULL at the end
565  */
566 static void
567 process_map_output (void *cls,
568                     const char *line)
569 {
570   struct GNUNET_NAT_MiniHandle *mini = cls;
571   const char *ipaddr;
572   char *ipa;
573   const char *pstr;
574   unsigned int port;
575
576   if (NULL == line)
577   {
578     GNUNET_OS_command_stop (mini->map_cmd);
579     mini->map_cmd = NULL;
580     if (GNUNET_YES != mini->did_map)
581       mini->ac (mini->ac_cls,
582                 GNUNET_SYSERR,
583                 NULL,
584                 0,
585                 GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED);
586     if (NULL == mini->refresh_task)
587       mini->refresh_task
588         = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
589                                         &do_refresh,
590                                         mini);
591     return;
592   }
593   /*
594    * The upnpc output we're after looks like this:
595    *
596    * "external 87.123.42.204:3000 TCP is redirected to internal 192.168.2.150:3000"
597    */
598   if ((NULL == (ipaddr = strstr (line, " "))) ||
599       (NULL == (pstr = strstr (ipaddr, ":"))) ||
600       (1 != SSCANF (pstr + 1, "%u", &port)))
601   {
602     return;                     /* skip line */
603   }
604   ipa = GNUNET_strdup (ipaddr + 1);
605   strstr (ipa, ":")[0] = '\0';
606   if (1 != inet_pton (AF_INET,
607                       ipa,
608                       &mini->current_addr.sin_addr))
609   {
610     GNUNET_free (ipa);
611     return;                     /* skip line */
612   }
613   GNUNET_free (ipa);
614
615   mini->current_addr.sin_port = htons (port);
616   mini->current_addr.sin_family = AF_INET;
617 #if HAVE_SOCKADDR_IN_SIN_LEN
618   mini->current_addr.sin_len = sizeof (struct sockaddr_in);
619 #endif
620   mini->did_map = GNUNET_YES;
621   mini->ac (mini->ac_cls,
622             GNUNET_YES,
623             (const struct sockaddr *) &mini->current_addr,
624             sizeof (mini->current_addr),
625             GNUNET_NAT_ERROR_SUCCESS);
626 }
627
628
629 /**
630  * Start mapping the given port using (mini)upnpc.  This function
631  * should typically not be used directly (it is used within the
632  * general-purpose #GNUNET_NAT_register() code).  However, it can be
633  * used if specifically UPnP-based NAT traversal is to be used or
634  * tested.
635  *
636  * @param port port to map
637  * @param is_tcp #GNUNET_YES to map TCP, #GNUNET_NO for UDP
638  * @param ac function to call with mapping result
639  * @param ac_cls closure for @a ac
640  * @return NULL on error (no 'upnpc' installed)
641  */
642 struct GNUNET_NAT_MiniHandle *
643 GNUNET_NAT_mini_map_start (uint16_t port,
644                            int is_tcp,
645                            GNUNET_NAT_MiniAddressCallback ac,
646                            void *ac_cls)
647 {
648   struct GNUNET_NAT_MiniHandle *ret;
649
650   if (GNUNET_SYSERR ==
651       GNUNET_OS_check_helper_binary ("upnpc",
652                                      GNUNET_NO,
653                                      NULL))
654   {
655     LOG (GNUNET_ERROR_TYPE_INFO,
656          _("`upnpc' command not found\n"));
657     ac (ac_cls,
658         GNUNET_SYSERR,
659         NULL, 0,
660         GNUNET_NAT_ERROR_UPNPC_NOT_FOUND);
661     return NULL;
662   }
663   LOG (GNUNET_ERROR_TYPE_DEBUG,
664        "Running `upnpc' to install mapping\n");
665   ret = GNUNET_new (struct GNUNET_NAT_MiniHandle);
666   ret->ac = ac;
667   ret->ac_cls = ac_cls;
668   ret->is_tcp = is_tcp;
669   ret->port = port;
670   ret->refresh_task =
671     GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
672                                   &do_refresh,
673                                   ret);
674   run_upnpc_r (ret);
675   return ret;
676 }
677
678
679 /**
680  * Process output from our 'unmap' command.
681  *
682  * @param cls the `struct GNUNET_NAT_MiniHandle`
683  * @param line line of output, NULL at the end
684  */
685 static void
686 process_unmap_output (void *cls,
687                       const char *line)
688 {
689   struct GNUNET_NAT_MiniHandle *mini = cls;
690
691   if (NULL == line)
692   {
693     LOG (GNUNET_ERROR_TYPE_DEBUG,
694          "UPnP unmap done\n");
695     GNUNET_OS_command_stop (mini->unmap_cmd);
696     mini->unmap_cmd = NULL;
697     GNUNET_free (mini);
698     return;
699   }
700   /* we don't really care about the output... */
701 }
702
703
704 /**
705  * Remove a mapping created with (mini)upnpc.  Calling
706  * this function will give 'upnpc' 1s to remove tha mapping,
707  * so while this function is non-blocking, a task will be
708  * left with the scheduler for up to 1s past this call.
709  *
710  * @param mini the handle
711  */
712 void
713 GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
714 {
715   char pstr[6];
716
717   if (NULL != mini->refresh_task)
718   {
719     GNUNET_SCHEDULER_cancel (mini->refresh_task);
720     mini->refresh_task = NULL;
721   }
722   if (NULL != mini->refresh_cmd)
723   {
724     GNUNET_OS_command_stop (mini->refresh_cmd);
725     mini->refresh_cmd = NULL;
726   }
727   if (NULL != mini->map_cmd)
728   {
729     GNUNET_OS_command_stop (mini->map_cmd);
730     mini->map_cmd = NULL;
731   }
732   if (GNUNET_NO == mini->did_map)
733   {
734     GNUNET_free (mini);
735     return;
736   }
737   mini->ac (mini->ac_cls,
738             GNUNET_NO,
739             (const struct sockaddr *) &mini->current_addr,
740             sizeof (mini->current_addr),
741             GNUNET_NAT_ERROR_SUCCESS);
742   /* Note: oddly enough, deletion uses the external port whereas
743    * addition uses the internal port; this rarely matters since they
744    * often are the same, but it might... */
745   GNUNET_snprintf (pstr,
746                    sizeof (pstr),
747                    "%u",
748                    (unsigned int) ntohs (mini->current_addr.sin_port));
749   LOG (GNUNET_ERROR_TYPE_DEBUG,
750        "Unmapping port %u with UPnP\n",
751        ntohs (mini->current_addr.sin_port));
752   mini->unmap_cmd
753     = GNUNET_OS_command_run (&process_unmap_output,
754                              mini,
755                              UNMAP_TIMEOUT,
756                              "upnpc",
757                              "upnpc",
758                              "-d",
759                              pstr,
760                              mini->is_tcp ? "tcp" : "udp",
761                              NULL);
762 }
763
764
765 /* end of gnunet-service-nat_mini.c */