diff options
author | xrs <xrs@mail36.net> | 2018-07-03 23:28:27 +0200 |
---|---|---|
committer | xrs <xrs@mail36.net> | 2018-07-03 23:28:27 +0200 |
commit | f293763907abc5e9da76adb44b9648eb43a56f57 (patch) | |
tree | e32e2cfb6f5312859087c2dc5f2e66e52a3bada3 /src | |
parent | bdb1ee3242fe915f2648295f7430fab70eb31121 (diff) | |
parent | 00fc4513ebdb851c79b8f7c2591dffb6bd70c5bd (diff) | |
download | gnunet-f293763907abc5e9da76adb44b9648eb43a56f57.tar.gz gnunet-f293763907abc5e9da76adb44b9648eb43a56f57.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/cadet_api.c | 1 | ||||
-rw-r--r-- | src/gns/gns_api.c | 7 | ||||
-rw-r--r-- | src/gns/gnunet-gns.c | 10 | ||||
-rw-r--r-- | src/gns/nss/nss_gns.c | 269 | ||||
-rw-r--r-- | src/gns/nss/nss_gns_query.c | 25 | ||||
-rw-r--r-- | src/gns/nss/nss_gns_query.h | 30 | ||||
-rw-r--r-- | src/identity-provider/plugin_rest_openid_connect.c | 15 | ||||
-rw-r--r-- | src/identity/identity_api_lookup.c | 8 | ||||
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 4 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps.c | 67 | ||||
-rw-r--r-- | src/rps/rps-test_util.c | 80 | ||||
-rw-r--r-- | src/set/gnunet-service-set_intersection.c | 19 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.c | 19 | ||||
-rw-r--r-- | src/util/.gitignore | 5 | ||||
-rw-r--r-- | src/util/Makefile.am | 16 | ||||
-rw-r--r-- | src/util/client.c | 13 | ||||
-rw-r--r-- | src/util/dnsparser.c | 9 | ||||
-rw-r--r-- | src/util/gnunet-timeout-w32.c | 191 | ||||
-rw-r--r-- | src/util/gnunet-timeout.c | 128 |
19 files changed, 690 insertions, 226 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 319279110..92dd39b97 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -841,6 +841,7 @@ handle_mq_error (void *cls, | |||
841 | h); | 841 | h); |
842 | GNUNET_MQ_destroy (h->mq); | 842 | GNUNET_MQ_destroy (h->mq); |
843 | h->mq = NULL; | 843 | h->mq = NULL; |
844 | GNUNET_assert (NULL == h->reconnect_task); | ||
844 | h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_time, | 845 | h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_time, |
845 | &reconnect_cbk, | 846 | &reconnect_cbk, |
846 | h); | 847 | h); |
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index 0ec9209da..3b658da92 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -232,7 +232,6 @@ reconnect (struct GNUNET_GNS_Handle *handle) | |||
232 | handle), | 232 | handle), |
233 | GNUNET_MQ_handler_end () | 233 | GNUNET_MQ_handler_end () |
234 | }; | 234 | }; |
235 | struct GNUNET_GNS_LookupRequest *lh; | ||
236 | 235 | ||
237 | GNUNET_assert (NULL == handle->mq); | 236 | GNUNET_assert (NULL == handle->mq); |
238 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 237 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -244,7 +243,9 @@ reconnect (struct GNUNET_GNS_Handle *handle) | |||
244 | handle); | 243 | handle); |
245 | if (NULL == handle->mq) | 244 | if (NULL == handle->mq) |
246 | return; | 245 | return; |
247 | for (lh = handle->lookup_head; NULL != lh; lh = lh->next) | 246 | for (struct GNUNET_GNS_LookupRequest *lh = handle->lookup_head; |
247 | NULL != lh; | ||
248 | lh = lh->next) | ||
248 | GNUNET_MQ_send_copy (handle->mq, | 249 | GNUNET_MQ_send_copy (handle->mq, |
249 | lh->env); | 250 | lh->env); |
250 | } | 251 | } |
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index 149c8a7bb..463348ed3 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -65,8 +65,9 @@ static struct GNUNET_GNS_LookupWithTldRequest *lr; | |||
65 | /** | 65 | /** |
66 | * Global return value. | 66 | * Global return value. |
67 | * 0 on success (default), | 67 | * 0 on success (default), |
68 | * 1 on internal failures, 2 on launch failure, | 68 | * 1 on internal failures |
69 | * 3 if the name is not a GNS-supported TLD, | 69 | * 2 on launch failure, |
70 | * 4 if the name is not a GNS-supported TLD, | ||
70 | */ | 71 | */ |
71 | static int global_ret; | 72 | static int global_ret; |
72 | 73 | ||
@@ -114,7 +115,7 @@ process_lookup_result (void *cls, | |||
114 | lr = NULL; | 115 | lr = NULL; |
115 | if (GNUNET_NO == was_gns) | 116 | if (GNUNET_NO == was_gns) |
116 | { | 117 | { |
117 | global_ret = 3; | 118 | global_ret = 4; /* not for GNS */ |
118 | GNUNET_SCHEDULER_shutdown (); | 119 | GNUNET_SCHEDULER_shutdown (); |
119 | return; | 120 | return; |
120 | } | 121 | } |
@@ -183,7 +184,6 @@ run (void *cls, | |||
183 | global_ret = 2; | 184 | global_ret = 2; |
184 | return; | 185 | return; |
185 | } | 186 | } |
186 | |||
187 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 187 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
188 | NULL); | 188 | NULL); |
189 | 189 | ||
diff --git a/src/gns/nss/nss_gns.c b/src/gns/nss/nss_gns.c index 9c9233d35..58aab47fd 100644 --- a/src/gns/nss/nss_gns.c +++ b/src/gns/nss/nss_gns.c | |||
@@ -54,121 +54,126 @@ | |||
54 | * @return a nss_status code | 54 | * @return a nss_status code |
55 | */ | 55 | */ |
56 | enum nss_status | 56 | enum nss_status |
57 | _nss_gns_gethostbyname2_r( | 57 | _nss_gns_gethostbyname2_r(const char *name, |
58 | const char *name, | 58 | int af, |
59 | int af, | 59 | struct hostent *result, |
60 | struct hostent * result, | 60 | char *buffer, |
61 | char *buffer, | 61 | size_t buflen, |
62 | size_t buflen, | 62 | int *errnop, |
63 | int *errnop, | 63 | int *h_errnop) |
64 | int *h_errnop) { | 64 | { |
65 | 65 | struct userdata u; | |
66 | struct userdata u; | 66 | enum nss_status status = NSS_STATUS_UNAVAIL; |
67 | enum nss_status status = NSS_STATUS_UNAVAIL; | 67 | int i; |
68 | int i; | 68 | size_t address_length; |
69 | size_t address_length, l, idx, astart; | 69 | size_t l; |
70 | 70 | size_t idx; | |
71 | if (af == AF_UNSPEC) | 71 | size_t astart; |
72 | |||
73 | if (af == AF_UNSPEC) | ||
72 | #ifdef NSS_IPV6_ONLY | 74 | #ifdef NSS_IPV6_ONLY |
73 | af = AF_INET6; | 75 | af = AF_INET6; |
74 | #else | 76 | #else |
75 | af = AF_INET; | 77 | af = AF_INET; |
76 | #endif | 78 | #endif |
77 | 79 | ||
78 | #ifdef NSS_IPV4_ONLY | 80 | #ifdef NSS_IPV4_ONLY |
79 | if (af != AF_INET) | 81 | if (af != AF_INET) |
80 | #elif NSS_IPV6_ONLY | 82 | #elif NSS_IPV6_ONLY |
81 | if (af != AF_INET6) | 83 | if (af != AF_INET6) |
82 | #else | 84 | #else |
83 | if (af != AF_INET && af != AF_INET6) | 85 | if ( (af != AF_INET) && |
86 | (af != AF_INET6) ) | ||
84 | #endif | 87 | #endif |
85 | { | 88 | { |
86 | *errnop = EINVAL; | 89 | *errnop = EINVAL; |
87 | *h_errnop = NO_RECOVERY; | 90 | *h_errnop = NO_RECOVERY; |
88 | 91 | ||
89 | goto finish; | 92 | goto finish; |
90 | } | 93 | } |
91 | |||
92 | address_length = af == AF_INET ? sizeof(ipv4_address_t) : sizeof(ipv6_address_t); | ||
93 | if (buflen < | ||
94 | sizeof(char*)+ /* alias names */ | ||
95 | strlen(name)+1) { /* official name */ | ||
96 | |||
97 | *errnop = ERANGE; | ||
98 | *h_errnop = NO_RECOVERY; | ||
99 | status = NSS_STATUS_TRYAGAIN; | ||
100 | |||
101 | goto finish; | ||
102 | } | ||
103 | |||
104 | u.count = 0; | ||
105 | u.data_len = 0; | ||
106 | |||
107 | i = gns_resolve_name(af, name, &u); | ||
108 | if (-3 == i) | ||
109 | { | ||
110 | status = NSS_STATUS_NOTFOUND; | ||
111 | goto finish; | ||
112 | } | ||
113 | if (-2 == i) | ||
114 | { | ||
115 | status = NSS_STATUS_UNAVAIL; | ||
116 | goto finish; | ||
117 | } | ||
118 | if ( (-1 == i) || | ||
119 | (u.count == 0) ) | ||
120 | { | ||
121 | *errnop = ETIMEDOUT; | ||
122 | *h_errnop = HOST_NOT_FOUND; | ||
123 | status = NSS_STATUS_NOTFOUND; | ||
124 | goto finish; | ||
125 | } | ||
126 | |||
127 | |||
128 | /* Alias names */ | ||
129 | *((char**) buffer) = NULL; | ||
130 | result->h_aliases = (char**) buffer; | ||
131 | idx = sizeof(char*); | ||
132 | |||
133 | /* Official name */ | ||
134 | strcpy(buffer+idx, name); | ||
135 | result->h_name = buffer+idx; | ||
136 | idx += strlen(name)+1; | ||
137 | |||
138 | ALIGN(idx); | ||
139 | |||
140 | result->h_addrtype = af; | ||
141 | result->h_length = address_length; | ||
142 | |||
143 | /* Check if there's enough space for the addresses */ | ||
144 | if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1)) { | ||
145 | *errnop = ERANGE; | ||
146 | *h_errnop = NO_RECOVERY; | ||
147 | status = NSS_STATUS_TRYAGAIN; | ||
148 | goto finish; | ||
149 | } | ||
150 | 94 | ||
95 | address_length = (af == AF_INET) ? sizeof(ipv4_address_t) : sizeof(ipv6_address_t); | ||
96 | if (buflen < | ||
97 | sizeof(char*)+ /* alias names */ | ||
98 | strlen(name)+1) | ||
99 | { /* official name */ | ||
100 | *errnop = ERANGE; | ||
101 | *h_errnop = NO_RECOVERY; | ||
102 | status = NSS_STATUS_TRYAGAIN; | ||
103 | |||
104 | goto finish; | ||
105 | } | ||
106 | u.count = 0; | ||
107 | u.data_len = 0; | ||
108 | i = gns_resolve_name (af, | ||
109 | name, | ||
110 | &u); | ||
111 | if (-3 == i) | ||
112 | { | ||
113 | status = NSS_STATUS_NOTFOUND; | ||
114 | goto finish; | ||
115 | } | ||
116 | if (-2 == i) | ||
117 | { | ||
118 | status = NSS_STATUS_UNAVAIL; | ||
119 | goto finish; | ||
120 | } | ||
121 | if ( (-1 == i) || | ||
122 | (u.count == 0) ) | ||
123 | { | ||
124 | *errnop = ETIMEDOUT; | ||
125 | *h_errnop = HOST_NOT_FOUND; | ||
126 | status = NSS_STATUS_NOTFOUND; | ||
127 | goto finish; | ||
128 | } | ||
129 | /* Alias names */ | ||
130 | *((char**) buffer) = NULL; | ||
131 | result->h_aliases = (char**) buffer; | ||
132 | idx = sizeof(char*); | ||
133 | |||
134 | /* Official name */ | ||
135 | strcpy (buffer+idx, | ||
136 | name); | ||
137 | result->h_name = buffer+idx; | ||
138 | idx += strlen (name)+1; | ||
139 | |||
140 | ALIGN(idx); | ||
141 | |||
142 | result->h_addrtype = af; | ||
143 | result->h_length = address_length; | ||
144 | |||
145 | /* Check if there's enough space for the addresses */ | ||
146 | if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1)) | ||
147 | { | ||
148 | *errnop = ERANGE; | ||
149 | *h_errnop = NO_RECOVERY; | ||
150 | status = NSS_STATUS_TRYAGAIN; | ||
151 | goto finish; | ||
152 | } | ||
151 | /* Addresses */ | 153 | /* Addresses */ |
152 | astart = idx; | 154 | astart = idx; |
153 | l = u.count*address_length; | 155 | l = u.count*address_length; |
154 | if (0 != l) | 156 | if (0 != l) |
155 | memcpy(buffer+astart, &u.data, l); | 157 | memcpy (buffer+astart, |
156 | /* address_length is a multiple of 32bits, so idx is still aligned | 158 | &u.data, |
157 | * correctly */ | 159 | l); |
158 | idx += l; | 160 | /* address_length is a multiple of 32bits, so idx is still aligned |
159 | 161 | * correctly */ | |
160 | /* Address array address_length is always a multiple of 32bits */ | 162 | idx += l; |
161 | for (i = 0; i < u.count; i++) | 163 | |
162 | ((char**) (buffer+idx))[i] = buffer+astart+address_length*i; | 164 | /* Address array address_length is always a multiple of 32bits */ |
163 | ((char**) (buffer+idx))[i] = NULL; | 165 | for (i = 0; i < u.count; i++) |
164 | result->h_addr_list = (char**) (buffer+idx); | 166 | ((char**) (buffer+idx))[i] = buffer+astart+address_length*i; |
165 | 167 | ((char**) (buffer+idx))[i] = NULL; | |
166 | status = NSS_STATUS_SUCCESS; | 168 | result->h_addr_list = (char**) (buffer+idx); |
169 | |||
170 | status = NSS_STATUS_SUCCESS; | ||
167 | 171 | ||
168 | finish: | 172 | finish: |
169 | return status; | 173 | return status; |
170 | } | 174 | } |
171 | 175 | ||
176 | |||
172 | /** | 177 | /** |
173 | * The gethostbyname hook executed by nsswitch | 178 | * The gethostbyname hook executed by nsswitch |
174 | * | 179 | * |
@@ -176,29 +181,28 @@ finish: | |||
176 | * @param result the result hostent | 181 | * @param result the result hostent |
177 | * @param buffer the result buffer | 182 | * @param buffer the result buffer |
178 | * @param buflen length of the buffer | 183 | * @param buflen length of the buffer |
179 | * @param errnop idk | 184 | * @param errnop[out] the low-level error code to return to the application |
180 | * @param h_errnop idk | 185 | * @param h_errnop idk |
181 | * @return a nss_status code | 186 | * @return a nss_status code |
182 | */ | 187 | */ |
183 | enum nss_status | 188 | enum nss_status |
184 | _nss_gns_gethostbyname_r ( | 189 | _nss_gns_gethostbyname_r (const char *name, |
185 | const char *name, | 190 | struct hostent *result, |
186 | struct hostent *result, | 191 | char *buffer, |
187 | char *buffer, | 192 | size_t buflen, |
188 | size_t buflen, | 193 | int *errnop, |
189 | int *errnop, | 194 | int *h_errnop) |
190 | int *h_errnop) { | 195 | { |
191 | 196 | return _nss_gns_gethostbyname2_r (name, | |
192 | return _nss_gns_gethostbyname2_r( | 197 | AF_UNSPEC, |
193 | name, | 198 | result, |
194 | AF_UNSPEC, | 199 | buffer, |
195 | result, | 200 | buflen, |
196 | buffer, | 201 | errnop, |
197 | buflen, | 202 | h_errnop); |
198 | errnop, | ||
199 | h_errnop); | ||
200 | } | 203 | } |
201 | 204 | ||
205 | |||
202 | /** | 206 | /** |
203 | * The gethostbyaddr hook executed by nsswitch | 207 | * The gethostbyaddr hook executed by nsswitch |
204 | * We can't do this so we always return NSS_STATUS_UNAVAIL | 208 | * We can't do this so we always return NSS_STATUS_UNAVAIL |
@@ -209,23 +213,22 @@ _nss_gns_gethostbyname_r ( | |||
209 | * @param result the result hostent | 213 | * @param result the result hostent |
210 | * @param buffer the result buffer | 214 | * @param buffer the result buffer |
211 | * @param buflen length of the buffer | 215 | * @param buflen length of the buffer |
212 | * @param errnop idk | 216 | * @param errnop[out] the low-level error code to return to the application |
213 | * @param h_errnop idk | 217 | * @param h_errnop idk |
214 | * @return NSS_STATUS_UNAVAIL | 218 | * @return NSS_STATUS_UNAVAIL |
215 | */ | 219 | */ |
216 | enum nss_status | 220 | enum nss_status |
217 | _nss_gns_gethostbyaddr_r( | 221 | _nss_gns_gethostbyaddr_r (const void* addr, |
218 | const void* addr, | 222 | int len, |
219 | int len, | 223 | int af, |
220 | int af, | 224 | struct hostent *result, |
221 | struct hostent *result, | 225 | char *buffer, |
222 | char *buffer, | 226 | size_t buflen, |
223 | size_t buflen, | 227 | int *errnop, |
224 | int *errnop, | 228 | int *h_errnop) |
225 | int *h_errnop) { | 229 | { |
226 | 230 | *errnop = EINVAL; | |
227 | *errnop = EINVAL; | 231 | *h_errnop = NO_RECOVERY; |
228 | *h_errnop = NO_RECOVERY; | 232 | //NOTE we allow to leak this into DNS so no NOTFOUND |
229 | //NOTE we allow to leak this into DNS so no NOTFOUND | 233 | return NSS_STATUS_UNAVAIL; |
230 | return NSS_STATUS_UNAVAIL; | ||
231 | } | 234 | } |
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c index 094e25ed5..867ead624 100644 --- a/src/gns/nss/nss_gns_query.c +++ b/src/gns/nss/nss_gns_query.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -48,14 +48,16 @@ gns_resolve_name (int af, | |||
48 | { | 48 | { |
49 | if (-1 == asprintf (&cmd, | 49 | if (-1 == asprintf (&cmd, |
50 | "%s -t AAAA -u %s\n", | 50 | "%s -t AAAA -u %s\n", |
51 | "gnunet-gns -r", name)) | 51 | "gnunet-gns -r", |
52 | name)) | ||
52 | return -1; | 53 | return -1; |
53 | } | 54 | } |
54 | else | 55 | else |
55 | { | 56 | { |
56 | if (-1 == asprintf (&cmd, | 57 | if (-1 == asprintf (&cmd, |
57 | "%s %s\n", | 58 | "%s %s\n", |
58 | "gnunet-gns -r -u", name)) | 59 | "gnunet-gns -r -u", |
60 | name)) | ||
59 | return -1; | 61 | return -1; |
60 | } | 62 | } |
61 | if (NULL == (p = popen (cmd, "r"))) | 63 | if (NULL == (p = popen (cmd, "r"))) |
@@ -63,7 +65,9 @@ gns_resolve_name (int af, | |||
63 | free (cmd); | 65 | free (cmd); |
64 | return -1; | 66 | return -1; |
65 | } | 67 | } |
66 | while (NULL != fgets (line, sizeof(line), p)) | 68 | while (NULL != fgets (line, |
69 | sizeof(line), | ||
70 | p)) | ||
67 | { | 71 | { |
68 | if (u->count >= MAX_ENTRIES) | 72 | if (u->count >= MAX_ENTRIES) |
69 | break; | 73 | break; |
@@ -72,7 +76,9 @@ gns_resolve_name (int af, | |||
72 | line[strlen(line)-1] = '\0'; | 76 | line[strlen(line)-1] = '\0'; |
73 | if (AF_INET == af) | 77 | if (AF_INET == af) |
74 | { | 78 | { |
75 | if (inet_pton(af, line, &(u->data.ipv4[u->count]))) | 79 | if (inet_pton(af, |
80 | line, | ||
81 | &u->data.ipv4[u->count])) | ||
76 | { | 82 | { |
77 | u->count++; | 83 | u->count++; |
78 | u->data_len += sizeof(ipv4_address_t); | 84 | u->data_len += sizeof(ipv4_address_t); |
@@ -86,7 +92,9 @@ gns_resolve_name (int af, | |||
86 | } | 92 | } |
87 | else if (AF_INET6 == af) | 93 | else if (AF_INET6 == af) |
88 | { | 94 | { |
89 | if (inet_pton(af, line, &(u->data.ipv6[u->count]))) | 95 | if (inet_pton(af, |
96 | line, | ||
97 | &u->data.ipv6[u->count])) | ||
90 | { | 98 | { |
91 | u->count++; | 99 | u->count++; |
92 | u->data_len += sizeof(ipv6_address_t); | 100 | u->data_len += sizeof(ipv6_address_t); |
@@ -105,7 +113,10 @@ gns_resolve_name (int af, | |||
105 | if (4 == ret) | 113 | if (4 == ret) |
106 | return -2; /* not for GNS */ | 114 | return -2; /* not for GNS */ |
107 | if (3 == ret) | 115 | if (3 == ret) |
108 | return -3; /* timeout */ | 116 | return -3; /* timeout -> not found */ |
117 | if ( (2 == ret) || (1 == ret) ) | ||
118 | return -2; /* launch failure -> service unavailable */ | ||
109 | return 0; | 119 | return 0; |
110 | } | 120 | } |
121 | |||
111 | /* end of nss_gns_query.c */ | 122 | /* end of nss_gns_query.c */ |
diff --git a/src/gns/nss/nss_gns_query.h b/src/gns/nss/nss_gns_query.h index bb04f9004..48cab4b22 100644 --- a/src/gns/nss/nss_gns_query.h +++ b/src/gns/nss/nss_gns_query.h | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -26,25 +26,30 @@ | |||
26 | /* Maximum number of entries to return */ | 26 | /* Maximum number of entries to return */ |
27 | #define MAX_ENTRIES 16 | 27 | #define MAX_ENTRIES 16 |
28 | 28 | ||
29 | typedef struct { | 29 | typedef struct |
30 | uint32_t address; | 30 | { |
31 | uint32_t address; | ||
31 | } ipv4_address_t; | 32 | } ipv4_address_t; |
32 | 33 | ||
33 | typedef struct { | 34 | |
34 | uint8_t address[16]; | 35 | typedef struct |
36 | { | ||
37 | uint8_t address[16]; | ||
35 | } ipv6_address_t; | 38 | } ipv6_address_t; |
36 | 39 | ||
37 | 40 | ||
38 | struct userdata { | 41 | struct userdata |
42 | { | ||
39 | int count; | 43 | int count; |
40 | int data_len; /* only valid when doing reverse lookup */ | 44 | int data_len; /* only valid when doing reverse lookup */ |
41 | union { | 45 | union { |
42 | ipv4_address_t ipv4[MAX_ENTRIES]; | 46 | ipv4_address_t ipv4[MAX_ENTRIES]; |
43 | ipv6_address_t ipv6[MAX_ENTRIES]; | 47 | ipv6_address_t ipv6[MAX_ENTRIES]; |
44 | char *name[MAX_ENTRIES]; | 48 | char *name[MAX_ENTRIES]; |
45 | } data; | 49 | } data; |
46 | }; | 50 | }; |
47 | 51 | ||
52 | |||
48 | /** | 53 | /** |
49 | * Wrapper function that uses gnunet-gns cli tool to resolve | 54 | * Wrapper function that uses gnunet-gns cli tool to resolve |
50 | * an IPv4/6 address. | 55 | * an IPv4/6 address. |
@@ -54,8 +59,9 @@ struct userdata { | |||
54 | * @param u the userdata (result struct) | 59 | * @param u the userdata (result struct) |
55 | * @return -1 on error else 0 | 60 | * @return -1 on error else 0 |
56 | */ | 61 | */ |
57 | int gns_resolve_name(int af, | 62 | int |
58 | const char *name, | 63 | gns_resolve_name(int af, |
59 | struct userdata *userdata); | 64 | const char *name, |
65 | struct userdata *userdata); | ||
60 | 66 | ||
61 | #endif | 67 | #endif |
diff --git a/src/identity-provider/plugin_rest_openid_connect.c b/src/identity-provider/plugin_rest_openid_connect.c index d87a345cf..9c2f7fb3d 100644 --- a/src/identity-provider/plugin_rest_openid_connect.c +++ b/src/identity-provider/plugin_rest_openid_connect.c | |||
@@ -732,6 +732,8 @@ cookie_identity_interpretation (struct RequestHandle *handle) | |||
732 | { | 732 | { |
733 | handle->oidc->login_identity = strtok(handle->oidc->login_identity, OIDC_COOKIE_HEADER_INFORMATION_KEY); | 733 | handle->oidc->login_identity = strtok(handle->oidc->login_identity, OIDC_COOKIE_HEADER_INFORMATION_KEY); |
734 | handle->oidc->login_identity = GNUNET_strdup(handle->oidc->login_identity); | 734 | handle->oidc->login_identity = GNUNET_strdup(handle->oidc->login_identity); |
735 | } else { | ||
736 | handle->oidc->login_identity = NULL; | ||
735 | } | 737 | } |
736 | } | 738 | } |
737 | else | 739 | else |
@@ -1014,10 +1016,11 @@ login_check (void *cls) | |||
1014 | return; | 1016 | return; |
1015 | } | 1017 | } |
1016 | } | 1018 | } |
1017 | handle->emsg = GNUNET_strdup("invalid_cookie"); | 1019 | //handle->emsg = GNUNET_strdup("invalid_cookie"); |
1018 | handle->edesc = GNUNET_strdup( | 1020 | //handle->edesc = GNUNET_strdup( |
1019 | "The cookie of the login identity is not valid"); | 1021 | // "The cookie of the login identity is not valid"); |
1020 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | 1022 | //GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); |
1023 | GNUNET_SCHEDULER_add_now (&login_redirection,handle); | ||
1021 | return; | 1024 | return; |
1022 | } | 1025 | } |
1023 | } | 1026 | } |
@@ -1359,8 +1362,8 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1359 | 1362 | ||
1360 | current_time = GNUNET_new(struct GNUNET_TIME_Absolute); | 1363 | current_time = GNUNET_new(struct GNUNET_TIME_Absolute); |
1361 | *current_time = GNUNET_TIME_relative_to_absolute ( | 1364 | *current_time = GNUNET_TIME_relative_to_absolute ( |
1362 | GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_get_minute_ (), | 1365 | GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_get_second_ (), |
1363 | 30)); | 1366 | 5)); |
1364 | last_time = GNUNET_CONTAINER_multihashmap_get(OIDC_identity_login_time, &cache_key); | 1367 | last_time = GNUNET_CONTAINER_multihashmap_get(OIDC_identity_login_time, &cache_key); |
1365 | if (NULL != last_time) | 1368 | if (NULL != last_time) |
1366 | { | 1369 | { |
diff --git a/src/identity/identity_api_lookup.c b/src/identity/identity_api_lookup.c index 593a5dbb0..25aec8ede 100644 --- a/src/identity/identity_api_lookup.c +++ b/src/identity/identity_api_lookup.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -131,6 +131,12 @@ GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
131 | el->identity = GNUNET_IDENTITY_connect (cfg, | 131 | el->identity = GNUNET_IDENTITY_connect (cfg, |
132 | &identity_cb, | 132 | &identity_cb, |
133 | el); | 133 | el); |
134 | if (NULL == el->identity) | ||
135 | { | ||
136 | GNUNET_free (el->name); | ||
137 | GNUNET_free (el); | ||
138 | return NULL; | ||
139 | } | ||
134 | return el; | 140 | return el; |
135 | } | 141 | } |
136 | 142 | ||
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 16f23e86c..ec73f1803 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -888,6 +888,7 @@ shutdown_op (void *cls) | |||
888 | if (NULL != post_test_task) | 888 | if (NULL != post_test_task) |
889 | { | 889 | { |
890 | GNUNET_SCHEDULER_cancel (post_test_task); | 890 | GNUNET_SCHEDULER_cancel (post_test_task); |
891 | post_test_task = NULL; | ||
891 | } | 892 | } |
892 | if (NULL != churn_task) | 893 | if (NULL != churn_task) |
893 | { | 894 | { |
@@ -899,6 +900,7 @@ shutdown_op (void *cls) | |||
899 | if (NULL != rps_peers[i].rps_handle) | 900 | if (NULL != rps_peers[i].rps_handle) |
900 | { | 901 | { |
901 | GNUNET_RPS_disconnect (rps_peers[i].rps_handle); | 902 | GNUNET_RPS_disconnect (rps_peers[i].rps_handle); |
903 | rps_peers[i].rps_handle = NULL; | ||
902 | } | 904 | } |
903 | if (NULL != rps_peers[i].op) | 905 | if (NULL != rps_peers[i].op) |
904 | { | 906 | { |
@@ -2570,7 +2572,7 @@ test_run (void *cls, | |||
2570 | if (NULL != churn_task) | 2572 | if (NULL != churn_task) |
2571 | GNUNET_SCHEDULER_cancel (churn_task); | 2573 | GNUNET_SCHEDULER_cancel (churn_task); |
2572 | post_test_task = GNUNET_SCHEDULER_add_delayed (timeout, &post_test_op, NULL); | 2574 | post_test_task = GNUNET_SCHEDULER_add_delayed (timeout, &post_test_op, NULL); |
2573 | timeout = GNUNET_TIME_relative_multiply (timeout, 1 + (0.1 * num_peers)); | 2575 | timeout = GNUNET_TIME_relative_multiply (timeout, 1.2 + (0.01 * num_peers)); |
2574 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL); | 2576 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL); |
2575 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 2577 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); |
2576 | 2578 | ||
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 84fb33be2..db09c68d2 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -1045,12 +1045,10 @@ restore_valid_peers () | |||
1045 | */ | 1045 | */ |
1046 | void | 1046 | void |
1047 | Peers_initialise (char* fn_valid_peers, | 1047 | Peers_initialise (char* fn_valid_peers, |
1048 | struct GNUNET_CADET_Handle *cadet_h, | 1048 | struct GNUNET_CADET_Handle *cadet_h) |
1049 | const struct GNUNET_PeerIdentity *own_id) | ||
1050 | { | 1049 | { |
1051 | filename_valid_peers = GNUNET_strdup (fn_valid_peers); | 1050 | filename_valid_peers = GNUNET_strdup (fn_valid_peers); |
1052 | cadet_handle = cadet_h; | 1051 | cadet_handle = cadet_h; |
1053 | own_identity = *own_id; | ||
1054 | peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); | 1052 | peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); |
1055 | valid_peers = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); | 1053 | valid_peers = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); |
1056 | restore_valid_peers (); | 1054 | restore_valid_peers (); |
@@ -1136,14 +1134,12 @@ Peers_get_valid_peers (PeersIterator iterator, | |||
1136 | * @param peer the new #GNUNET_PeerIdentity | 1134 | * @param peer the new #GNUNET_PeerIdentity |
1137 | * | 1135 | * |
1138 | * @return #GNUNET_YES if peer was inserted | 1136 | * @return #GNUNET_YES if peer was inserted |
1139 | * #GNUNET_NO otherwise (if peer was already known or | 1137 | * #GNUNET_NO otherwise |
1140 | * peer was #own_identity) | ||
1141 | */ | 1138 | */ |
1142 | int | 1139 | int |
1143 | Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) | 1140 | Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) |
1144 | { | 1141 | { |
1145 | if ( (GNUNET_YES == Peers_check_peer_known (peer)) || | 1142 | if (GNUNET_YES == Peers_check_peer_known (peer)) |
1146 | (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, &own_identity)) ) | ||
1147 | { | 1143 | { |
1148 | return GNUNET_NO; /* We already know this peer - nothing to do */ | 1144 | return GNUNET_NO; /* We already know this peer - nothing to do */ |
1149 | } | 1145 | } |
@@ -1161,8 +1157,7 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl | |||
1161 | * | 1157 | * |
1162 | * @param peer the peer whose liveliness is to be checked | 1158 | * @param peer the peer whose liveliness is to be checked |
1163 | * @return #GNUNET_YES if peer had to be inserted | 1159 | * @return #GNUNET_YES if peer had to be inserted |
1164 | * #GNUNET_NO otherwise (if peer was already known or | 1160 | * #GNUNET_NO otherwise |
1165 | * peer was #own_identity) | ||
1166 | */ | 1161 | */ |
1167 | int | 1162 | int |
1168 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) | 1163 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) |
@@ -1170,10 +1165,6 @@ Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) | |||
1170 | struct PeerContext *peer_ctx; | 1165 | struct PeerContext *peer_ctx; |
1171 | int ret; | 1166 | int ret; |
1172 | 1167 | ||
1173 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, &own_identity)) | ||
1174 | { | ||
1175 | return GNUNET_NO; | ||
1176 | } | ||
1177 | ret = Peers_insert_peer (peer); | 1168 | ret = Peers_insert_peer (peer); |
1178 | peer_ctx = get_peer_ctx (peer); | 1169 | peer_ctx = get_peer_ctx (peer); |
1179 | if (GNUNET_NO == Peers_check_peer_flag (peer, Peers_ONLINE)) | 1170 | if (GNUNET_NO == Peers_check_peer_flag (peer, Peers_ONLINE)) |
@@ -1666,10 +1657,11 @@ Peers_cleanup_destroyed_channel (void *cls, | |||
1666 | { | 1657 | { |
1667 | struct GNUNET_PeerIdentity *peer = cls; | 1658 | struct GNUNET_PeerIdentity *peer = cls; |
1668 | struct PeerContext *peer_ctx; | 1659 | struct PeerContext *peer_ctx; |
1660 | uint32_t *channel_flag; | ||
1669 | 1661 | ||
1670 | if (GNUNET_NO == Peers_check_peer_known (peer)) | 1662 | if (GNUNET_NO == Peers_check_peer_known (peer)) |
1671 | {/* We don't want to implicitly create a context that we're about to kill */ | 1663 | {/* We don't want to implicitly create a context that we're about to kill */ |
1672 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1664 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1673 | "channel (%s) without associated context was destroyed\n", | 1665 | "channel (%s) without associated context was destroyed\n", |
1674 | GNUNET_i2s (peer)); | 1666 | GNUNET_i2s (peer)); |
1675 | return; | 1667 | return; |
@@ -1697,12 +1689,16 @@ Peers_cleanup_destroyed_channel (void *cls, | |||
1697 | if (NULL != peer_ctx->send_channel) | 1689 | if (NULL != peer_ctx->send_channel) |
1698 | { | 1690 | { |
1699 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | 1691 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); |
1692 | channel_flag = Peers_get_channel_flag (&peer_ctx->peer_id, Peers_CHANNEL_ROLE_SENDING); | ||
1693 | Peers_set_channel_flag (channel_flag, Peers_CHANNEL_DESTROING); | ||
1700 | peer_ctx->send_channel = NULL; | 1694 | peer_ctx->send_channel = NULL; |
1701 | peer_ctx->mq = NULL; | 1695 | peer_ctx->mq = NULL; |
1702 | } | 1696 | } |
1703 | if (NULL != peer_ctx->recv_channel) | 1697 | if (NULL != peer_ctx->recv_channel) |
1704 | { | 1698 | { |
1705 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); | 1699 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); |
1700 | channel_flag = Peers_get_channel_flag (&peer_ctx->peer_id, Peers_CHANNEL_ROLE_RECEIVING); | ||
1701 | Peers_set_channel_flag (channel_flag, Peers_CHANNEL_DESTROING); | ||
1706 | peer_ctx->recv_channel = NULL; | 1702 | peer_ctx->recv_channel = NULL; |
1707 | } | 1703 | } |
1708 | /* Set the #Peers_ONLINE flag accordingly */ | 1704 | /* Set the #Peers_ONLINE flag accordingly */ |
@@ -1786,10 +1782,6 @@ Peers_schedule_operation (const struct GNUNET_PeerIdentity *peer, | |||
1786 | struct PeerPendingOp pending_op; | 1782 | struct PeerPendingOp pending_op; |
1787 | struct PeerContext *peer_ctx; | 1783 | struct PeerContext *peer_ctx; |
1788 | 1784 | ||
1789 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, &own_identity)) | ||
1790 | { | ||
1791 | return GNUNET_NO; | ||
1792 | } | ||
1793 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); | 1785 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); |
1794 | 1786 | ||
1795 | //TODO if LIVE/ONLINE execute immediately | 1787 | //TODO if LIVE/ONLINE execute immediately |
@@ -3368,9 +3360,7 @@ handle_peer_pull_reply (void *cls, | |||
3368 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set, | 3360 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set, |
3369 | &peers[i]) | 3361 | &peers[i]) |
3370 | && GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set, | 3362 | && GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set, |
3371 | &peers[i]) | 3363 | &peers[i])) |
3372 | && 0 != GNUNET_CRYPTO_cmp_peer_identity (&peers[i], | ||
3373 | &own_identity)) | ||
3374 | { | 3364 | { |
3375 | tmp_att_peer = GNUNET_new (struct AttackedPeer); | 3365 | tmp_att_peer = GNUNET_new (struct AttackedPeer); |
3376 | tmp_att_peer->peer_id = peers[i]; | 3366 | tmp_att_peer->peer_id = peers[i]; |
@@ -3382,21 +3372,17 @@ handle_peer_pull_reply (void *cls, | |||
3382 | continue; | 3372 | continue; |
3383 | } | 3373 | } |
3384 | #endif /* ENABLE_MALICIOUS */ | 3374 | #endif /* ENABLE_MALICIOUS */ |
3385 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, | 3375 | /* Make sure we 'know' about this peer */ |
3386 | &peers[i])) | 3376 | (void) Peers_insert_peer (&peers[i]); |
3387 | { | ||
3388 | /* Make sure we 'know' about this peer */ | ||
3389 | (void) Peers_insert_peer (&peers[i]); | ||
3390 | 3377 | ||
3391 | if (GNUNET_YES == Peers_check_peer_valid (&peers[i])) | 3378 | if (GNUNET_YES == Peers_check_peer_valid (&peers[i])) |
3392 | { | 3379 | { |
3393 | CustomPeerMap_put (pull_map, &peers[i]); | 3380 | CustomPeerMap_put (pull_map, &peers[i]); |
3394 | } | 3381 | } |
3395 | else | 3382 | else |
3396 | { | 3383 | { |
3397 | Peers_schedule_operation (&peers[i], insert_in_pull_map); | 3384 | Peers_schedule_operation (&peers[i], insert_in_pull_map); |
3398 | (void) Peers_issue_peer_liveliness_check (&peers[i]); | 3385 | (void) Peers_issue_peer_liveliness_check (&peers[i]); |
3399 | } | ||
3400 | } | 3386 | } |
3401 | } | 3387 | } |
3402 | 3388 | ||
@@ -3831,10 +3817,8 @@ do_round (void *cls) | |||
3831 | for (i = 0; i < a_peers; i++) | 3817 | for (i = 0; i < a_peers; i++) |
3832 | { | 3818 | { |
3833 | peer = view_array[permut[i]]; | 3819 | peer = view_array[permut[i]]; |
3834 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peer)) // TODO | 3820 | // FIXME if this fails schedule/loop this for later |
3835 | { // FIXME if this fails schedule/loop this for later | 3821 | send_push (&peer); |
3836 | send_push (&peer); | ||
3837 | } | ||
3838 | } | 3822 | } |
3839 | 3823 | ||
3840 | /* Send PULL requests */ | 3824 | /* Send PULL requests */ |
@@ -3852,8 +3836,7 @@ do_round (void *cls) | |||
3852 | for (i = first_border; i < second_border; i++) | 3836 | for (i = first_border; i < second_border; i++) |
3853 | { | 3837 | { |
3854 | peer = view_array[permut[i]]; | 3838 | peer = view_array[permut[i]]; |
3855 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peer) && | 3839 | if ( GNUNET_NO == Peers_check_peer_flag (&peer, Peers_PULL_REPLY_PENDING)) |
3856 | GNUNET_NO == Peers_check_peer_flag (&peer, Peers_PULL_REPLY_PENDING)) // TODO | ||
3857 | { // FIXME if this fails schedule/loop this for later | 3840 | { // FIXME if this fails schedule/loop this for later |
3858 | send_pull_request (&peer); | 3841 | send_pull_request (&peer); |
3859 | } | 3842 | } |
@@ -4367,7 +4350,7 @@ run (void *cls, | |||
4367 | 4350 | ||
4368 | 4351 | ||
4369 | peerinfo_handle = GNUNET_PEERINFO_connect (cfg); | 4352 | peerinfo_handle = GNUNET_PEERINFO_connect (cfg); |
4370 | Peers_initialise (fn_valid_peers, cadet_handle, &own_identity); | 4353 | Peers_initialise (fn_valid_peers, cadet_handle); |
4371 | GNUNET_free (fn_valid_peers); | 4354 | GNUNET_free (fn_valid_peers); |
4372 | 4355 | ||
4373 | /* Initialise sampler */ | 4356 | /* Initialise sampler */ |
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index d47e4952f..08fe96097 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c | |||
@@ -31,6 +31,17 @@ | |||
31 | 31 | ||
32 | #define LOG(kind, ...) GNUNET_log_from(kind,"rps-test_util",__VA_ARGS__) | 32 | #define LOG(kind, ...) GNUNET_log_from(kind,"rps-test_util",__VA_ARGS__) |
33 | 33 | ||
34 | #define B2B_PAT "%c%c%c%c%c%c%c%c" | ||
35 | #define B2B(byte) \ | ||
36 | (byte & 0x80 ? '1' : '0'), \ | ||
37 | (byte & 0x40 ? '1' : '0'), \ | ||
38 | (byte & 0x20 ? '1' : '0'), \ | ||
39 | (byte & 0x10 ? '1' : '0'), \ | ||
40 | (byte & 0x08 ? '1' : '0'), \ | ||
41 | (byte & 0x04 ? '1' : '0'), \ | ||
42 | (byte & 0x02 ? '1' : '0'), \ | ||
43 | (byte & 0x01 ? '1' : '0') | ||
44 | |||
34 | #ifndef TO_FILE | 45 | #ifndef TO_FILE |
35 | #define TO_FILE | 46 | #define TO_FILE |
36 | #endif /* TO_FILE */ | 47 | #endif /* TO_FILE */ |
@@ -155,6 +166,9 @@ to_file_raw (const char *file_name, const char *buf, size_t size_buf) | |||
155 | 166 | ||
156 | return; | 167 | return; |
157 | } | 168 | } |
169 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
170 | "Wrote %u bytes raw.\n", | ||
171 | size_written); | ||
158 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) | 172 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) |
159 | LOG (GNUNET_ERROR_TYPE_WARNING, | 173 | LOG (GNUNET_ERROR_TYPE_WARNING, |
160 | "Unable to close file\n"); | 174 | "Unable to close file\n"); |
@@ -180,6 +194,8 @@ to_file_raw_unaligned (const char *file_name, | |||
180 | // num_bits_buf_unaligned = bits_needed % 8; | 194 | // num_bits_buf_unaligned = bits_needed % 8; |
181 | // return; | 195 | // return; |
182 | //} | 196 | //} |
197 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
198 | "Was asked to write %u bits\n", bits_needed); | ||
183 | 199 | ||
184 | char buf_write[size_buf + 1]; | 200 | char buf_write[size_buf + 1]; |
185 | const unsigned bytes_iter = (0 != bits_needed % 8? | 201 | const unsigned bytes_iter = (0 != bits_needed % 8? |
@@ -187,6 +203,14 @@ to_file_raw_unaligned (const char *file_name, | |||
187 | bits_needed/8); | 203 | bits_needed/8); |
188 | // TODO what if no iteration happens? | 204 | // TODO what if no iteration happens? |
189 | unsigned size_buf_write = 0; | 205 | unsigned size_buf_write = 0; |
206 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
207 | "num_bits_buf_unaligned: %u\n", | ||
208 | num_bits_buf_unaligned); | ||
209 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
210 | "ua args: size_buf: %u, bits_needed: %u -> iter: %u\n", | ||
211 | size_buf, | ||
212 | bits_needed, | ||
213 | bytes_iter); | ||
190 | buf_write[0] = buf_unaligned; | 214 | buf_write[0] = buf_unaligned; |
191 | /* Iterate over input bytes */ | 215 | /* Iterate over input bytes */ |
192 | for (unsigned i = 0; i < bytes_iter; i++) | 216 | for (unsigned i = 0; i < bytes_iter; i++) |
@@ -227,17 +251,57 @@ to_file_raw_unaligned (const char *file_name, | |||
227 | { | 251 | { |
228 | num_bits_needed_iter = 8; | 252 | num_bits_needed_iter = 8; |
229 | } | 253 | } |
254 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
255 | "number of bits needed in this iteration: %u\n", | ||
256 | num_bits_needed_iter); | ||
230 | mask_bits_needed_iter = ((char) 1 << num_bits_needed_iter) - 1; | 257 | mask_bits_needed_iter = ((char) 1 << num_bits_needed_iter) - 1; |
258 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
259 | "mask needed bits (current iter): "B2B_PAT"\n", | ||
260 | B2B(mask_bits_needed_iter)); | ||
261 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
262 | "Unaligned byte: "B2B_PAT" (%u bits)\n", | ||
263 | B2B(buf_unaligned), | ||
264 | num_bits_buf_unaligned); | ||
231 | byte_input = buf[i]; | 265 | byte_input = buf[i]; |
266 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
267 | "next whole input byte: "B2B_PAT"\n", | ||
268 | B2B(byte_input)); | ||
232 | byte_input &= mask_bits_needed_iter; | 269 | byte_input &= mask_bits_needed_iter; |
233 | num_bits_to_align = 8 - num_bits_buf_unaligned; | 270 | num_bits_to_align = 8 - num_bits_buf_unaligned; |
271 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
272 | "input byte, needed bits: "B2B_PAT"\n", | ||
273 | B2B(byte_input)); | ||
274 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
275 | "number of bits needed to align unaligned bit: %u\n", | ||
276 | num_bits_to_align); | ||
234 | num_bits_to_move = min (num_bits_to_align, num_bits_needed_iter); | 277 | num_bits_to_move = min (num_bits_to_align, num_bits_needed_iter); |
278 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
279 | "number of bits of new byte to move: %u\n", | ||
280 | num_bits_to_move); | ||
235 | mask_input_to_move = ((char) 1 << num_bits_to_move) - 1; | 281 | mask_input_to_move = ((char) 1 << num_bits_to_move) - 1; |
282 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
283 | "mask of bits of new byte to take for moving: "B2B_PAT"\n", | ||
284 | B2B(mask_input_to_move)); | ||
236 | bits_to_move = byte_input & mask_input_to_move; | 285 | bits_to_move = byte_input & mask_input_to_move; |
286 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
287 | "masked bits of new byte to take for moving: "B2B_PAT"\n", | ||
288 | B2B(bits_to_move)); | ||
237 | distance_shift_bits = num_bits_buf_unaligned; | 289 | distance_shift_bits = num_bits_buf_unaligned; |
290 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
291 | "distance needed to shift bits to their correct spot: %u\n", | ||
292 | distance_shift_bits); | ||
238 | bits_moving = bits_to_move << distance_shift_bits; | 293 | bits_moving = bits_to_move << distance_shift_bits; |
294 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
295 | "shifted, masked bits of new byte being moved: "B2B_PAT"\n", | ||
296 | B2B(bits_moving)); | ||
239 | byte_to_fill = buf_unaligned | bits_moving; | 297 | byte_to_fill = buf_unaligned | bits_moving; |
240 | if (num_bits_buf_unaligned + num_bits_needed_iter > 8) | 298 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
299 | "byte being filled: "B2B_PAT"\n", | ||
300 | B2B(byte_to_fill)); | ||
301 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
302 | "pending bytes: %u\n", | ||
303 | num_bits_buf_unaligned + num_bits_needed_iter); | ||
304 | if (num_bits_buf_unaligned + num_bits_needed_iter >= 8) | ||
241 | { | 305 | { |
242 | /* buf_unaligned was aligned by filling | 306 | /* buf_unaligned was aligned by filling |
243 | * -> can be written to storage */ | 307 | * -> can be written to storage */ |
@@ -246,10 +310,22 @@ to_file_raw_unaligned (const char *file_name, | |||
246 | 310 | ||
247 | /* store the leftover, unaligned bits in buffer */ | 311 | /* store the leftover, unaligned bits in buffer */ |
248 | mask_input_leftover = mask_bits_needed_iter & (~ mask_input_to_move); | 312 | mask_input_leftover = mask_bits_needed_iter & (~ mask_input_to_move); |
313 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
314 | "mask of leftover bits of new byte: "B2B_PAT"\n", | ||
315 | B2B(mask_input_leftover)); | ||
249 | byte_input_leftover = byte_input & mask_input_leftover; | 316 | byte_input_leftover = byte_input & mask_input_leftover; |
317 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
318 | "masked, leftover bits of new byte: "B2B_PAT"\n", | ||
319 | B2B(byte_input_leftover)); | ||
250 | num_bits_leftover = num_bits_needed_iter - num_bits_to_move; | 320 | num_bits_leftover = num_bits_needed_iter - num_bits_to_move; |
251 | num_bits_discard = 8 - num_bits_needed_iter; | 321 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
322 | "number of unaligned bits left: %u\n", | ||
323 | num_bits_leftover); | ||
324 | //num_bits_discard = 8 - num_bits_needed_iter; | ||
252 | byte_unaligned_new = byte_input_leftover >> num_bits_to_move; | 325 | byte_unaligned_new = byte_input_leftover >> num_bits_to_move; |
326 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
327 | "new unaligned byte: "B2B_PAT"\n", | ||
328 | B2B(byte_unaligned_new)); | ||
253 | buf_unaligned = byte_unaligned_new; | 329 | buf_unaligned = byte_unaligned_new; |
254 | num_bits_buf_unaligned = num_bits_leftover % 8; | 330 | num_bits_buf_unaligned = num_bits_leftover % 8; |
255 | } | 331 | } |
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index 254763b45..1083384f5 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -23,6 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_util_lib.h" | 25 | #include "gnunet_util_lib.h" |
26 | #include "gnunet_statistics_service.h" | ||
26 | #include "gnunet-service-set.h" | 27 | #include "gnunet-service-set.h" |
27 | #include "gnunet_block_lib.h" | 28 | #include "gnunet_block_lib.h" |
28 | #include "gnunet-service-set_protocol.h" | 29 | #include "gnunet-service-set_protocol.h" |
@@ -215,6 +216,10 @@ send_client_removed_element (struct Operation *op, | |||
215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
216 | "Sending removed element (size %u) to client\n", | 217 | "Sending removed element (size %u) to client\n", |
217 | element->size); | 218 | element->size); |
219 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
220 | "# Element removed messages sent", | ||
221 | 1, | ||
222 | GNUNET_NO); | ||
218 | GNUNET_assert (0 != op->client_request_id); | 223 | GNUNET_assert (0 != op->client_request_id); |
219 | ev = GNUNET_MQ_msg_extra (rm, | 224 | ev = GNUNET_MQ_msg_extra (rm, |
220 | element->size, | 225 | element->size, |
@@ -406,6 +411,10 @@ fail_intersection_operation (struct Operation *op) | |||
406 | 411 | ||
407 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 412 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
408 | "Intersection operation failed\n"); | 413 | "Intersection operation failed\n"); |
414 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
415 | "# Intersection operations failed", | ||
416 | 1, | ||
417 | GNUNET_NO); | ||
409 | if (NULL != op->state->my_elements) | 418 | if (NULL != op->state->my_elements) |
410 | { | 419 | { |
411 | GNUNET_CONTAINER_multihashmap_destroy (op->state->my_elements); | 420 | GNUNET_CONTAINER_multihashmap_destroy (op->state->my_elements); |
@@ -466,6 +475,10 @@ send_bloomfilter (struct Operation *op) | |||
466 | op); | 475 | op); |
467 | 476 | ||
468 | /* send our Bloom filter */ | 477 | /* send our Bloom filter */ |
478 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
479 | "# Intersection Bloom filters sent", | ||
480 | 1, | ||
481 | GNUNET_NO); | ||
469 | chunk_size = 60 * 1024 - sizeof (struct BFMessage); | 482 | chunk_size = 60 * 1024 - sizeof (struct BFMessage); |
470 | if (bf_size <= chunk_size) | 483 | if (bf_size <= chunk_size) |
471 | { | 484 | { |
@@ -534,6 +547,10 @@ send_client_done_and_destroy (void *cls) | |||
534 | 547 | ||
535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
536 | "Intersection succeeded, sending DONE to local client\n"); | 549 | "Intersection succeeded, sending DONE to local client\n"); |
550 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
551 | "# Intersection operations succeeded", | ||
552 | 1, | ||
553 | GNUNET_NO); | ||
537 | ev = GNUNET_MQ_msg (rm, | 554 | ev = GNUNET_MQ_msg (rm, |
538 | GNUNET_MESSAGE_TYPE_SET_RESULT); | 555 | GNUNET_MESSAGE_TYPE_SET_RESULT); |
539 | rm->request_id = htonl (op->client_request_id); | 556 | rm->request_id = htonl (op->client_request_id); |
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index c3c14f1ba..c1268948a 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -758,8 +758,8 @@ get_order_from_difference (unsigned int diff) | |||
758 | */ | 758 | */ |
759 | static int | 759 | static int |
760 | send_full_element_iterator (void *cls, | 760 | send_full_element_iterator (void *cls, |
761 | const struct GNUNET_HashCode *key, | 761 | const struct GNUNET_HashCode *key, |
762 | void *value) | 762 | void *value) |
763 | { | 763 | { |
764 | struct Operation *op = cls; | 764 | struct Operation *op = cls; |
765 | struct GNUNET_SET_ElementMessage *emsg; | 765 | struct GNUNET_SET_ElementMessage *emsg; |
@@ -1371,7 +1371,8 @@ send_client_element (struct Operation *op, | |||
1371 | * | 1371 | * |
1372 | * @param op operation | 1372 | * @param op operation |
1373 | */ | 1373 | */ |
1374 | void destroy_channel (struct Operation *op) | 1374 | static void |
1375 | destroy_channel (struct Operation *op) | ||
1375 | { | 1376 | { |
1376 | struct GNUNET_CADET_Channel *channel; | 1377 | struct GNUNET_CADET_Channel *channel; |
1377 | 1378 | ||
@@ -1404,7 +1405,11 @@ send_client_done (void *cls) | |||
1404 | 1405 | ||
1405 | if (PHASE_DONE != op->state->phase) { | 1406 | if (PHASE_DONE != op->state->phase) { |
1406 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1407 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1407 | "union operation failed\n"); | 1408 | "Union operation failed\n"); |
1409 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
1410 | "# Union operations failed", | ||
1411 | 1, | ||
1412 | GNUNET_NO); | ||
1408 | ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT); | 1413 | ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT); |
1409 | rm->result_status = htons (GNUNET_SET_STATUS_FAILURE); | 1414 | rm->result_status = htons (GNUNET_SET_STATUS_FAILURE); |
1410 | rm->request_id = htonl (op->client_request_id); | 1415 | rm->request_id = htonl (op->client_request_id); |
@@ -1416,6 +1421,10 @@ send_client_done (void *cls) | |||
1416 | 1421 | ||
1417 | op->state->client_done_sent = GNUNET_YES; | 1422 | op->state->client_done_sent = GNUNET_YES; |
1418 | 1423 | ||
1424 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
1425 | "# Union operations succeeded", | ||
1426 | 1, | ||
1427 | GNUNET_NO); | ||
1419 | LOG (GNUNET_ERROR_TYPE_INFO, | 1428 | LOG (GNUNET_ERROR_TYPE_INFO, |
1420 | "Signalling client that union operation is done\n"); | 1429 | "Signalling client that union operation is done\n"); |
1421 | ev = GNUNET_MQ_msg (rm, | 1430 | ev = GNUNET_MQ_msg (rm, |
diff --git a/src/util/.gitignore b/src/util/.gitignore index 8e7093568..7b190ca76 100644 --- a/src/util/.gitignore +++ b/src/util/.gitignore | |||
@@ -69,4 +69,7 @@ perf_crypto_hash | |||
69 | perf_crypto_symmetric | 69 | perf_crypto_symmetric |
70 | perf_crypto_rsa | 70 | perf_crypto_rsa |
71 | perf_crypto_ecc_dlog | 71 | perf_crypto_ecc_dlog |
72 | test_hexcoder test_regex test_tun | 72 | test_hexcoder |
73 | test_regex | ||
74 | test_tun | ||
75 | gnunet-timeout | ||
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index ec7bcb016..4ae073c2c 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -166,6 +166,7 @@ lib_LTLIBRARIES = libgnunetutil.la | |||
166 | 166 | ||
167 | libexec_PROGRAMS = \ | 167 | libexec_PROGRAMS = \ |
168 | gnunet-service-resolver \ | 168 | gnunet-service-resolver \ |
169 | gnunet-timeout \ | ||
169 | $(W32CONSOLEHELPER) | 170 | $(W32CONSOLEHELPER) |
170 | 171 | ||
171 | bin_SCRIPTS =\ | 172 | bin_SCRIPTS =\ |
@@ -192,6 +193,15 @@ endif | |||
192 | endif | 193 | endif |
193 | 194 | ||
194 | 195 | ||
196 | if !MINGW | ||
197 | gnunet_timeout_SOURCES = \ | ||
198 | gnunet-timeout.c | ||
199 | else | ||
200 | gnunet_timeout_SOURCES = \ | ||
201 | gnunet-timeout-w32.c | ||
202 | endif | ||
203 | |||
204 | |||
195 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' | 205 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' |
196 | 206 | ||
197 | gnunet-qr: gnunet-qr.py.in Makefile | 207 | gnunet-qr: gnunet-qr.py.in Makefile |
@@ -334,12 +344,12 @@ test_hexcoder_LDADD = \ | |||
334 | test_tun_SOURCES = \ | 344 | test_tun_SOURCES = \ |
335 | test_tun.c | 345 | test_tun.c |
336 | test_tun_LDADD = \ | 346 | test_tun_LDADD = \ |
337 | libgnunetutil.la | 347 | libgnunetutil.la |
338 | 348 | ||
339 | test_regex_SOURCES = \ | 349 | test_regex_SOURCES = \ |
340 | test_regex.c | 350 | test_regex.c |
341 | test_regex_LDADD = \ | 351 | test_regex_LDADD = \ |
342 | libgnunetutil.la | 352 | libgnunetutil.la |
343 | 353 | ||
344 | test_os_start_process_SOURCES = \ | 354 | test_os_start_process_SOURCES = \ |
345 | test_os_start_process.c | 355 | test_os_start_process.c |
@@ -622,4 +632,4 @@ EXTRA_DIST = \ | |||
622 | test_resolver_api_data.conf \ | 632 | test_resolver_api_data.conf \ |
623 | test_service_data.conf \ | 633 | test_service_data.conf \ |
624 | test_speedup_data.conf \ | 634 | test_speedup_data.conf \ |
625 | gnunet-qr.py.in | 635 | gnunet-qr.py.in |
diff --git a/src/util/client.c b/src/util/client.c index 44e326eab..1f569255a 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -721,6 +721,17 @@ test_service_configuration (const char *service_name, | |||
721 | &unixpath)) && | 721 | &unixpath)) && |
722 | (0 < strlen (unixpath))) | 722 | (0 < strlen (unixpath))) |
723 | ret = GNUNET_OK; | 723 | ret = GNUNET_OK; |
724 | else if ((GNUNET_OK == | ||
725 | GNUNET_CONFIGURATION_have_value (cfg, | ||
726 | service_name, | ||
727 | "UNIXPATH"))) | ||
728 | { | ||
729 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | ||
730 | service_name, | ||
731 | "UNIXPATH", | ||
732 | _("not a valid filename")); | ||
733 | return GNUNET_SYSERR; /* UNIXPATH specified but invalid! */ | ||
734 | } | ||
724 | GNUNET_free_non_null (unixpath); | 735 | GNUNET_free_non_null (unixpath); |
725 | #endif | 736 | #endif |
726 | 737 | ||
diff --git a/src/util/dnsparser.c b/src/util/dnsparser.c index 57d0a014c..6fb6d657f 100644 --- a/src/util/dnsparser.c +++ b/src/util/dnsparser.c | |||
@@ -11,7 +11,7 @@ | |||
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 | */ |
@@ -956,8 +956,11 @@ GNUNET_DNSPARSER_builder_add_name (char *dst, | |||
956 | len = dot - idna_name; | 956 | len = dot - idna_name; |
957 | if ( (len >= 64) || (0 == len) ) | 957 | if ( (len >= 64) || (0 == len) ) |
958 | { | 958 | { |
959 | GNUNET_break (0); | 959 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
960 | goto fail; /* segment too long or empty */ | 960 | "Invalid DNS name `%s': label with %u characters encountered\n", |
961 | name, | ||
962 | len); | ||
963 | goto fail; /* label too long or empty */ | ||
961 | } | 964 | } |
962 | dst[pos++] = (char) (uint8_t) len; | 965 | dst[pos++] = (char) (uint8_t) len; |
963 | GNUNET_memcpy (&dst[pos], | 966 | GNUNET_memcpy (&dst[pos], |
diff --git a/src/util/gnunet-timeout-w32.c b/src/util/gnunet-timeout-w32.c new file mode 100644 index 000000000..78b268fe2 --- /dev/null +++ b/src/util/gnunet-timeout-w32.c | |||
@@ -0,0 +1,191 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010 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, or | ||
8 | (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 | /** | ||
20 | * @file src/util/gnunet-timeout-w32.c | ||
21 | * @brief small tool starting a child process, waiting that it terminates or killing it after a given timeout period | ||
22 | * @author LRN | ||
23 | */ | ||
24 | |||
25 | #include <windows.h> | ||
26 | #include <sys/types.h> | ||
27 | #include <stdio.h> | ||
28 | |||
29 | int | ||
30 | main (int argc, char *argv[]) | ||
31 | { | ||
32 | int i; | ||
33 | DWORD wait_result; | ||
34 | wchar_t *commandline; | ||
35 | wchar_t **wargv; | ||
36 | wchar_t *arg; | ||
37 | unsigned int cmdlen; | ||
38 | STARTUPINFOW start; | ||
39 | PROCESS_INFORMATION proc; | ||
40 | |||
41 | wchar_t wpath[MAX_PATH + 1]; | ||
42 | |||
43 | wchar_t *pathbuf; | ||
44 | DWORD pathbuf_len, alloc_len; | ||
45 | wchar_t *ptr; | ||
46 | wchar_t *non_const_filename; | ||
47 | wchar_t *wcmd; | ||
48 | int wargc; | ||
49 | int timeout = 0; | ||
50 | ssize_t wrote; | ||
51 | |||
52 | HANDLE job; | ||
53 | |||
54 | if (argc < 3) | ||
55 | { | ||
56 | printf | ||
57 | ("arg 1: timeout in sec., arg 2: executable, arg<n> arguments\n"); | ||
58 | exit (1); | ||
59 | } | ||
60 | |||
61 | timeout = atoi (argv[1]); | ||
62 | |||
63 | if (timeout == 0) | ||
64 | timeout = 600; | ||
65 | |||
66 | commandline = GetCommandLineW (); | ||
67 | if (commandline == NULL) | ||
68 | { | ||
69 | printf ("Failed to get commandline: %lu\n", GetLastError ()); | ||
70 | exit (2); | ||
71 | } | ||
72 | |||
73 | wargv = CommandLineToArgvW (commandline, &wargc); | ||
74 | if (wargv == NULL || wargc <= 1) | ||
75 | { | ||
76 | printf ("Failed to get parse commandline: %lu\n", GetLastError ()); | ||
77 | exit (3); | ||
78 | } | ||
79 | |||
80 | job = CreateJobObject (NULL, NULL); | ||
81 | if (job == NULL) | ||
82 | { | ||
83 | printf ("Failed to create a job: %lu\n", GetLastError ()); | ||
84 | exit (4); | ||
85 | } | ||
86 | |||
87 | pathbuf_len = GetEnvironmentVariableW (L"PATH", (wchar_t *) &pathbuf, 0); | ||
88 | |||
89 | alloc_len = pathbuf_len + 1; | ||
90 | |||
91 | pathbuf = malloc (alloc_len * sizeof (wchar_t)); | ||
92 | |||
93 | ptr = pathbuf; | ||
94 | |||
95 | alloc_len = GetEnvironmentVariableW (L"PATH", ptr, pathbuf_len); | ||
96 | |||
97 | cmdlen = wcslen (wargv[2]); | ||
98 | if (cmdlen < 5 || wcscmp (&wargv[2][cmdlen - 4], L".exe") != 0) | ||
99 | { | ||
100 | non_const_filename = malloc (sizeof (wchar_t) * (cmdlen + 5)); | ||
101 | swprintf (non_const_filename, cmdlen + 5, L"%S.exe", wargv[2]); | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | non_const_filename = wcsdup (wargv[2]); | ||
106 | } | ||
107 | |||
108 | /* Check that this is the full path. If it isn't, search. */ | ||
109 | if (non_const_filename[1] == L':') | ||
110 | swprintf (wpath, sizeof (wpath) / sizeof (wchar_t), L"%S", non_const_filename); | ||
111 | else if (!SearchPathW | ||
112 | (pathbuf, non_const_filename, NULL, sizeof (wpath) / sizeof (wchar_t), | ||
113 | wpath, NULL)) | ||
114 | { | ||
115 | printf ("Failed to get find executable: %lu\n", GetLastError ()); | ||
116 | exit (5); | ||
117 | } | ||
118 | free (pathbuf); | ||
119 | free (non_const_filename); | ||
120 | |||
121 | cmdlen = wcslen (wpath) + 4; | ||
122 | i = 3; | ||
123 | while (NULL != (arg = wargv[i++])) | ||
124 | cmdlen += wcslen (arg) + 4; | ||
125 | |||
126 | wcmd = malloc (sizeof (wchar_t) * (cmdlen + 1)); | ||
127 | wrote = 0; | ||
128 | i = 2; | ||
129 | while (NULL != (arg = wargv[i++])) | ||
130 | { | ||
131 | /* This is to escape trailing slash */ | ||
132 | wchar_t arg_lastchar = arg[wcslen (arg) - 1]; | ||
133 | if (wrote == 0) | ||
134 | { | ||
135 | wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"\"%S%S\" ", wpath, | ||
136 | arg_lastchar == L'\\' ? L"\\" : L""); | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | if (wcschr (arg, L' ') != NULL) | ||
141 | wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"\"%S%S\"%S", arg, | ||
142 | arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" "); | ||
143 | else | ||
144 | wrote += swprintf (&wcmd[wrote], cmdlen + 1 - wrote, L"%S%S%S", arg, | ||
145 | arg_lastchar == L'\\' ? L"\\" : L"", i == wargc ? L"" : L" "); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | LocalFree (wargv); | ||
150 | |||
151 | memset (&start, 0, sizeof (start)); | ||
152 | start.cb = sizeof (start); | ||
153 | |||
154 | if (!CreateProcessW (wpath, wcmd, NULL, NULL, TRUE, CREATE_SUSPENDED, | ||
155 | NULL, NULL, &start, &proc)) | ||
156 | { | ||
157 | wprintf (L"Failed to get spawn process `%S' with arguments `%S': %lu\n", wpath, wcmd, GetLastError ()); | ||
158 | exit (6); | ||
159 | } | ||
160 | |||
161 | AssignProcessToJobObject (job, proc.hProcess); | ||
162 | |||
163 | ResumeThread (proc.hThread); | ||
164 | CloseHandle (proc.hThread); | ||
165 | |||
166 | free (wcmd); | ||
167 | |||
168 | wait_result = WaitForSingleObject (proc.hProcess, timeout * 1000); | ||
169 | if (wait_result == WAIT_OBJECT_0) | ||
170 | { | ||
171 | DWORD status; | ||
172 | wait_result = GetExitCodeProcess (proc.hProcess, &status); | ||
173 | CloseHandle (proc.hProcess); | ||
174 | if (wait_result != 0) | ||
175 | { | ||
176 | printf ("Test process exited with result %lu\n", status); | ||
177 | TerminateJobObject (job, status); | ||
178 | exit (status); | ||
179 | } | ||
180 | printf ("Test process exited (failed to obtain exit status)\n"); | ||
181 | TerminateJobObject (job, 0); | ||
182 | exit (0); | ||
183 | } | ||
184 | printf ("Child processes were killed after timeout of %u seconds\n", | ||
185 | timeout); | ||
186 | TerminateJobObject (job, 1); | ||
187 | CloseHandle (proc.hProcess); | ||
188 | exit (1); | ||
189 | } | ||
190 | |||
191 | /* end of timeout_watchdog_w32.c */ | ||
diff --git a/src/util/gnunet-timeout.c b/src/util/gnunet-timeout.c new file mode 100644 index 000000000..8dfb6ad17 --- /dev/null +++ b/src/util/gnunet-timeout.c | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010 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, or | ||
8 | (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 | /** | ||
20 | * @file src/util/gnunet-timeout.c | ||
21 | * @brief small tool starting a child process, waiting that it terminates or killing it after a given timeout period | ||
22 | * @author Matthias Wachs | ||
23 | */ | ||
24 | |||
25 | #include <sys/types.h> | ||
26 | #include <sys/wait.h> | ||
27 | #include <signal.h> | ||
28 | #include <stdio.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <unistd.h> | ||
31 | |||
32 | static pid_t child; | ||
33 | |||
34 | |||
35 | static void | ||
36 | sigchld_handler (int val) | ||
37 | { | ||
38 | int status = 0; | ||
39 | int ret = 0; | ||
40 | |||
41 | (void) val; | ||
42 | waitpid (child, | ||
43 | &status, | ||
44 | 0); | ||
45 | if (WIFEXITED (status) != 0) | ||
46 | { | ||
47 | ret = WEXITSTATUS (status); | ||
48 | fprintf (stderr, | ||
49 | "Process exited with result %u\n", | ||
50 | ret); | ||
51 | exit (ret); /* return same status code */ | ||
52 | } | ||
53 | if (WIFSIGNALED (status) != 0) | ||
54 | { | ||
55 | ret = WTERMSIG (status); | ||
56 | fprintf (stderr, | ||
57 | "Process received signal %u\n", | ||
58 | ret); | ||
59 | kill (getpid (), | ||
60 | ret); /* kill self with the same signal */ | ||
61 | } | ||
62 | exit (-1); | ||
63 | } | ||
64 | |||
65 | |||
66 | static void | ||
67 | sigint_handler (int val) | ||
68 | { | ||
69 | kill (0, | ||
70 | val); | ||
71 | exit (val); | ||
72 | } | ||
73 | |||
74 | |||
75 | int | ||
76 | main (int argc, | ||
77 | char *argv[]) | ||
78 | { | ||
79 | int timeout = 0; | ||
80 | pid_t gpid = 0; | ||
81 | |||
82 | if (argc < 3) | ||
83 | { | ||
84 | fprintf (stderr, | ||
85 | "arg 1: timeout in sec., arg 2: executable, arg<n> arguments\n"); | ||
86 | exit (-1); | ||
87 | } | ||
88 | |||
89 | timeout = atoi (argv[1]); | ||
90 | |||
91 | if (timeout == 0) | ||
92 | timeout = 600; | ||
93 | |||
94 | /* with getpgid() it does not compile, but getpgrp is the BSD version and working */ | ||
95 | gpid = getpgrp (); | ||
96 | |||
97 | signal (SIGCHLD, sigchld_handler); | ||
98 | signal (SIGABRT, sigint_handler); | ||
99 | signal (SIGFPE, sigint_handler); | ||
100 | signal (SIGILL, sigint_handler); | ||
101 | signal (SIGINT, sigint_handler); | ||
102 | signal (SIGSEGV, sigint_handler); | ||
103 | signal (SIGTERM, sigint_handler); | ||
104 | |||
105 | child = fork (); | ||
106 | if (child == 0) | ||
107 | { | ||
108 | /* int setpgrp(pid_t pid, pid_t pgid); is not working on this machine */ | ||
109 | //setpgrp (0, pid_t gpid); | ||
110 | if (-1 != gpid) | ||
111 | setpgid (0, gpid); | ||
112 | execvp (argv[2], | ||
113 | &argv[2]); | ||
114 | exit (-1); | ||
115 | } | ||
116 | if (child > 0) | ||
117 | { | ||
118 | sleep (timeout); | ||
119 | printf ("Child processes were killed after timeout of %u seconds\n", | ||
120 | timeout); | ||
121 | kill (0, | ||
122 | SIGTERM); | ||
123 | exit (3); | ||
124 | } | ||
125 | exit (-1); | ||
126 | } | ||
127 | |||
128 | /* end of timeout_watchdog.c */ | ||