diff options
Diffstat (limited to 'src/gns/nss/nss_gns_query.c')
-rw-r--r-- | src/gns/nss/nss_gns_query.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c index 4700100b5..867ead624 100644 --- a/src/gns/nss/nss_gns_query.c +++ b/src/gns/nss/nss_gns_query.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012 GNUnet e.V. | 3 | Copyright (C) 2012 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
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 | 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 General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | #include <string.h> | 18 | #include <string.h> |
21 | #include <stdio.h> | 19 | #include <stdio.h> |
@@ -50,14 +48,16 @@ gns_resolve_name (int af, | |||
50 | { | 48 | { |
51 | if (-1 == asprintf (&cmd, | 49 | if (-1 == asprintf (&cmd, |
52 | "%s -t AAAA -u %s\n", | 50 | "%s -t AAAA -u %s\n", |
53 | "gnunet-gns -r", name)) | 51 | "gnunet-gns -r", |
52 | name)) | ||
54 | return -1; | 53 | return -1; |
55 | } | 54 | } |
56 | else | 55 | else |
57 | { | 56 | { |
58 | if (-1 == asprintf (&cmd, | 57 | if (-1 == asprintf (&cmd, |
59 | "%s %s\n", | 58 | "%s %s\n", |
60 | "gnunet-gns -r -u", name)) | 59 | "gnunet-gns -r -u", |
60 | name)) | ||
61 | return -1; | 61 | return -1; |
62 | } | 62 | } |
63 | if (NULL == (p = popen (cmd, "r"))) | 63 | if (NULL == (p = popen (cmd, "r"))) |
@@ -65,7 +65,9 @@ gns_resolve_name (int af, | |||
65 | free (cmd); | 65 | free (cmd); |
66 | return -1; | 66 | return -1; |
67 | } | 67 | } |
68 | while (NULL != fgets (line, sizeof(line), p)) | 68 | while (NULL != fgets (line, |
69 | sizeof(line), | ||
70 | p)) | ||
69 | { | 71 | { |
70 | if (u->count >= MAX_ENTRIES) | 72 | if (u->count >= MAX_ENTRIES) |
71 | break; | 73 | break; |
@@ -74,7 +76,9 @@ gns_resolve_name (int af, | |||
74 | line[strlen(line)-1] = '\0'; | 76 | line[strlen(line)-1] = '\0'; |
75 | if (AF_INET == af) | 77 | if (AF_INET == af) |
76 | { | 78 | { |
77 | if (inet_pton(af, line, &(u->data.ipv4[u->count]))) | 79 | if (inet_pton(af, |
80 | line, | ||
81 | &u->data.ipv4[u->count])) | ||
78 | { | 82 | { |
79 | u->count++; | 83 | u->count++; |
80 | u->data_len += sizeof(ipv4_address_t); | 84 | u->data_len += sizeof(ipv4_address_t); |
@@ -88,7 +92,9 @@ gns_resolve_name (int af, | |||
88 | } | 92 | } |
89 | else if (AF_INET6 == af) | 93 | else if (AF_INET6 == af) |
90 | { | 94 | { |
91 | if (inet_pton(af, line, &(u->data.ipv6[u->count]))) | 95 | if (inet_pton(af, |
96 | line, | ||
97 | &u->data.ipv6[u->count])) | ||
92 | { | 98 | { |
93 | u->count++; | 99 | u->count++; |
94 | u->data_len += sizeof(ipv6_address_t); | 100 | u->data_len += sizeof(ipv6_address_t); |
@@ -107,7 +113,10 @@ gns_resolve_name (int af, | |||
107 | if (4 == ret) | 113 | if (4 == ret) |
108 | return -2; /* not for GNS */ | 114 | return -2; /* not for GNS */ |
109 | if (3 == ret) | 115 | if (3 == ret) |
110 | return -3; /* timeout */ | 116 | return -3; /* timeout -> not found */ |
117 | if ( (2 == ret) || (1 == ret) ) | ||
118 | return -2; /* launch failure -> service unavailable */ | ||
111 | return 0; | 119 | return 0; |
112 | } | 120 | } |
121 | |||
113 | /* end of nss_gns_query.c */ | 122 | /* end of nss_gns_query.c */ |