glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / include / gnunet_transport_hello_service.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009-2016 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
16 /**
17  * @author Christian Grothoff
18  *
19  * @file
20  * obtain information about our current address
21  *
22  * @defgroup transport  Transport service
23  * address information
24  *
25  * @see [Documentation](https://gnunet.org/transport-service)
26  *
27  * @{
28  */
29 #ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H
30 #define GNUNET_TRANSPORT_HELLO_SERVICE_H
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0                           /* keep Emacsens' auto-indent happy */
36 }
37 #endif
38 #endif
39
40 #include "gnunet_util_lib.h"
41 #include "gnunet_ats_service.h"
42
43 /**
44  * Version number of the transport API.
45  */
46 #define GNUNET_TRANSPORT_HELLO_VERSION 0x00000000
47
48
49 /**
50  * Some addresses contain sensitive information or are
51  * not suitable for global distribution.  We use address
52  * classes to filter addresses by which domain they make
53  * sense to be used in.  These are used in a bitmask.
54  */
55 enum GNUNET_TRANSPORT_AddressClass
56 {
57
58   /**
59    * No address.
60    */
61   GNUNET_TRANSPORT_AC_NONE = 0,
62
63   /**
64    * Addresses that fall into no other category
65    * (i.e. incoming which we cannot use elsewhere).
66    */
67   GNUNET_TRANSPORT_AC_OTHER = 1,
68
69   /**
70    * Addresses that are global and are insensitive
71    * (i.e. IPv4).
72    */
73   GNUNET_TRANSPORT_AC_GLOBAL = 2,
74
75   /**
76    * Addresses that are global and are sensitive
77    * (i.e. IPv6 with our MAC).
78    */
79   GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE = 4,
80
81   /**
82    * Addresses useful in the local wired network,
83    * i.e. a MAC.  Sensitive, but obvious to people nearby.
84    * Useful for broadcasts.
85    */
86   GNUNET_TRANSPORT_AC_LAN = 8,
87
88   /**
89    * Addresses useful in the local wireless network,
90    * i.e. a MAC.  Sensitive, but obvious to people nearby.
91    * Useful for broadcasts.
92    */
93   GNUNET_TRANSPORT_AC_WLAN = 16,
94
95   /**
96    * Addresses useful in the local bluetooth network.  Sensitive, but
97    * obvious to people nearby.  Useful for broadcasts.
98    */
99   GNUNET_TRANSPORT_AC_BT = 32,
100
101   /**
102    * Bitmask for "any" address.
103    */
104   GNUNET_TRANSPORT_AC_ANY = 65535
105   
106 };
107
108
109 /**
110  * Function called whenever there is an update to the
111  * HELLO of this peer.
112  *
113  * @param cls closure
114  * @param hello our updated HELLO
115  */
116 typedef void
117 (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
118                                          const struct GNUNET_MessageHeader *hello);
119
120
121 /**
122  * Handle to cancel a #GNUNET_TRANSPORT_hello_get() operation.
123  */
124 struct GNUNET_TRANSPORT_HelloGetHandle;
125
126
127 /**
128  * Obtain updates on changes to the HELLO message for this peer. The callback
129  * given in this function is never called synchronously.
130  *
131  * @param cfg configuration to use
132  * @param ac which network type should the addresses from the HELLO belong to?
133  * @param rec function to call with the HELLO
134  * @param rec_cls closure for @a rec
135  * @return handle to cancel the operation
136  */
137 struct GNUNET_TRANSPORT_HelloGetHandle *
138 GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
139                             enum GNUNET_TRANSPORT_AddressClass ac,
140                             GNUNET_TRANSPORT_HelloUpdateCallback rec,
141                             void *rec_cls);
142
143
144 /**
145  * Stop receiving updates about changes to our HELLO message.
146  *
147  * @param ghh handle to cancel
148  */
149 void
150 GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh);
151
152
153 /**
154  * Function with addresses found in a HELLO.
155  *
156  * @param cls closure
157  * @param peer identity of the peer
158  * @param address the address (UTF-8, 0-terminated)
159  * @param nt network type of the address
160  * @param expiration when does this address expire?
161  */
162 typedef void
163 (*GNUNET_TRANSPORT_AddressCallback) (void *cls,
164                                      const struct GNUNET_PeerIdentity *peer,
165                                      const char *address,
166                                      enum GNUNET_ATS_Network_Type nt,
167                                      struct GNUNET_TIME_Absolute expiration);
168
169
170 /**
171  * Parse a HELLO message that we have received into its
172  * constituent addresses.
173  *
174  * @param hello message to parse
175  * @param cb function to call on each address found
176  * @param cb_cls closure for @a cb
177  * @return #GNUNET_OK if hello was well-formed, #GNUNET_SYSERR if not
178  */
179 int
180 GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello,
181                               GNUNET_TRANSPORT_AddressCallback cb,
182                               void *cb_cls);
183
184
185 #if 0                           /* keep Emacsens' auto-indent happy */
186 {
187 #endif
188 #ifdef __cplusplus
189 }
190 #endif
191
192 /* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */
193 #endif
194
195 /** @} */  /* end of group */
196
197 /* end of gnunet_transport_hello_service.h */