aboutsummaryrefslogtreecommitdiff
path: root/src/dns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-17 21:00:58 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-17 21:00:58 +0000
commit8c4f13e5109054a8f7ad3555b6db51c81eec5e0b (patch)
tree55aa82541d4c148148bcf50e7c59bfa17ed950ab /src/dns
parenta7a20387006a89cd13fd122e0262dd59957bc6d0 (diff)
downloadgnunet-8c4f13e5109054a8f7ad3555b6db51c81eec5e0b.tar.gz
gnunet-8c4f13e5109054a8f7ad3555b6db51c81eec5e0b.zip
-adding libidn--towards fixing #2475
Diffstat (limited to 'src/dns')
-rw-r--r--src/dns/Makefile.am3
-rw-r--r--src/dns/dnsparser.c28
2 files changed, 30 insertions, 1 deletions
diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am
index 6e543e07f..42d0c5bd1 100644
--- a/src/dns/Makefile.am
+++ b/src/dns/Makefile.am
@@ -83,7 +83,8 @@ gnunet_service_dns_DEPENDENCIES = \
83libgnunetdnsparser_la_SOURCES = \ 83libgnunetdnsparser_la_SOURCES = \
84 dnsparser.c 84 dnsparser.c
85libgnunetdnsparser_la_LIBADD = \ 85libgnunetdnsparser_la_LIBADD = \
86 $(top_builddir)/src/util/libgnunetutil.la $(XLIB) 86 $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
87 -lidn
87libgnunetdnsparser_la_LDFLAGS = \ 88libgnunetdnsparser_la_LDFLAGS = \
88 $(GN_LIB_LDFLAGS) \ 89 $(GN_LIB_LDFLAGS) \
89 -version-info 0:0:0 90 -version-info 0:0:0
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 4b0c03a77..c61c78164 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -25,11 +25,39 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include <idna.h>
29#if WINDOWS
30#include <idn-free.h>
31#endif
28#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
29#include "gnunet_dnsparser_lib.h" 33#include "gnunet_dnsparser_lib.h"
30#include "dnsparser.h" 34#include "dnsparser.h"
31 35
32 36
37/**
38 * Check if a label in UTF-8 format can be coded into valid IDNA.
39 * This can fail if the ASCII-conversion becomes longer than 63 characters.
40 *
41 * @param label label to check (UTF-8 string)
42 * @return GNUNET_OK if the label can be converted to IDNA,
43 * GNUNET_SYSERR if the label is not valid for DNS names
44 */
45int
46GNUNET_DNSPARSER_check_label (const char *label)
47{
48 char *output;
49
50 if (IDNA_SUCCESS !=
51 idna_to_ascii_8z (label, &output, IDNA_USE_STD3_ASCII_RULES))
52 return GNUNET_SYSERR;
53#if WINDOWS
54 idn_free (output);
55#else
56 free (output);
57#endif
58 return GNUNET_OK;
59}
60
33 61
34/** 62/**
35 * Parse name inside of a DNS query or record. 63 * Parse name inside of a DNS query or record.