Merge branch 'master' of gnunet.org:gnunet
[oweals/gnunet.git] / src / nat / gnunet-service-nat_externalip.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2015, 2016, 2017 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14     
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/>.
17 */
18 /**
19  * Code to figure out what our external IPv4 address(es) might
20  * be (external IPv4s are what is seen on the rest of the Internet).
21  *
22  * This can be implemented using different methods, and we allow
23  * the main service to be notified about changes to what we believe
24  * is our external IPv4 address.  
25  *
26  * Note that this is explicitly only about NATed systems; if one
27  * of our network interfaces has a global IP address this does
28  * not count as "external".
29  *
30  * @file nat/gnunet-service-nat_externalip.h
31  * @brief Functions for monitoring external IPv4 addresses
32  * @author Christian Grothoff
33  */
34 #ifndef GNUNET_SERVICE_NAT_EXTERNALIP_H
35 #define GNUNET_SERVICE_NAT_EXTERNALIP_H
36
37 #include "platform.h"
38
39
40 /**
41  * We have changed our opinion about being NATed in the first
42  * place. Adapt our probing.
43  *
44  * @param have_nat #GNUNET_YES if we believe we are behind NAT
45  */
46 void
47 GN_nat_status_changed (int have_nat);
48
49
50 /**
51  * Function we call when we believe our external IPv4 address changed.
52  *
53  * @param cls closure
54  * @param ip address to add/remove
55  * @param add_remove #GNUNET_YES to add, #GNUNET_NO to remove
56  */
57 typedef void
58 (*GN_NotifyExternalIPv4Change)(void *cls,
59                                const struct in_addr *ip,
60                                int add_remove);
61
62
63 /**
64  * Handle to monitor for external IP changes.
65  */
66 struct GN_ExternalIPMonitor;
67
68
69 /**
70  * Start monitoring external IPv4 addresses.
71  *
72  * @param cb function to call on changes
73  * @param cb_cls closure for @a cb
74  * @return handle to cancel
75  */
76 struct GN_ExternalIPMonitor *
77 GN_external_ipv4_monitor_start (GN_NotifyExternalIPv4Change cb,
78                                 void *cb_cls);
79
80
81 /**
82  * Stop calling monitor.
83  *
84  * @param mon monitor to call
85  */
86 void
87 GN_external_ipv4_monitor_stop (struct GN_ExternalIPMonitor *mon);
88
89
90 #endif