diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-17 21:00:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-17 21:00:58 +0000 |
commit | 8c4f13e5109054a8f7ad3555b6db51c81eec5e0b (patch) | |
tree | 55aa82541d4c148148bcf50e7c59bfa17ed950ab | |
parent | a7a20387006a89cd13fd122e0262dd59957bc6d0 (diff) | |
download | gnunet-8c4f13e5109054a8f7ad3555b6db51c81eec5e0b.tar.gz gnunet-8c4f13e5109054a8f7ad3555b6db51c81eec5e0b.zip |
-adding libidn--towards fixing #2475
-rw-r--r-- | configure.ac | 26 | ||||
-rw-r--r-- | src/dns/Makefile.am | 3 | ||||
-rw-r--r-- | src/dns/dnsparser.c | 28 | ||||
-rw-r--r-- | src/include/gnunet_dnsparser_lib.h | 12 | ||||
-rw-r--r-- | src/include/gnunet_gns_service.h | 2 |
5 files changed, 70 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 0bedbaca9..28a23f8f0 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -370,6 +370,32 @@ then | |||
370 | else | 370 | else |
371 | AM_CONDITIONAL(HAVE_LIBCURL, false) | 371 | AM_CONDITIONAL(HAVE_LIBCURL, false) |
372 | fi | 372 | fi |
373 | |||
374 | |||
375 | # libidn | ||
376 | AC_MSG_CHECKING([if Libidn can be used]) | ||
377 | AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]], | ||
378 | [Support IDN (needs GNU Libidn)]), | ||
379 | libidn=$withval, libidn=yes) | ||
380 | if test "$libidn" != "no"; then | ||
381 | if test "$libidn" != "yes"; then | ||
382 | LDFLAGS="${LDFLAGS} -L$libidn/lib" | ||
383 | CPPFLAGS="${CPPFLAGS} -I$libidn/include" | ||
384 | fi | ||
385 | AC_CHECK_HEADER(idna.h, | ||
386 | AC_CHECK_LIB(idn, stringprep_check_version, | ||
387 | [libidn=yes LIBS="${LIBS} -lidn"], libidn=no), | ||
388 | libidn=no) | ||
389 | fi | ||
390 | if test "$libidn" != "no" ; then | ||
391 | AC_DEFINE(LIBIDN, 1, [Define to 1 if you want IDN support.]) | ||
392 | else | ||
393 | AC_MSG_FAILURE([Libidn not found]) | ||
394 | fi | ||
395 | AC_MSG_RESULT($libidn) | ||
396 | |||
397 | |||
398 | |||
373 | # restore LIBS | 399 | # restore LIBS |
374 | LIBS=$SAVE_LIBS | 400 | LIBS=$SAVE_LIBS |
375 | 401 | ||
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 = \ | |||
83 | libgnunetdnsparser_la_SOURCES = \ | 83 | libgnunetdnsparser_la_SOURCES = \ |
84 | dnsparser.c | 84 | dnsparser.c |
85 | libgnunetdnsparser_la_LIBADD = \ | 85 | libgnunetdnsparser_la_LIBADD = \ |
86 | $(top_builddir)/src/util/libgnunetutil.la $(XLIB) | 86 | $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \ |
87 | -lidn | ||
87 | libgnunetdnsparser_la_LDFLAGS = \ | 88 | libgnunetdnsparser_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 | */ | ||
45 | int | ||
46 | GNUNET_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. |
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h index 328a2286a..19148bd3d 100644 --- a/src/include/gnunet_dnsparser_lib.h +++ b/src/include/gnunet_dnsparser_lib.h | |||
@@ -479,6 +479,18 @@ struct GNUNET_DNSPARSER_Packet | |||
479 | 479 | ||
480 | 480 | ||
481 | /** | 481 | /** |
482 | * Check if a label in UTF-8 format can be coded into valid IDNA. | ||
483 | * This can fail if the ASCII-conversion becomes longer than 63 characters. | ||
484 | * | ||
485 | * @param label label to check (UTF-8 string) | ||
486 | * @return GNUNET_OK if the label can be converted to IDNA, | ||
487 | * GNUNET_SYSERR if the label is not valid for DNS names | ||
488 | */ | ||
489 | int | ||
490 | GNUNET_DNSPARSER_check_label (const char *label); | ||
491 | |||
492 | |||
493 | /** | ||
482 | * Parse a UDP payload of a DNS packet in to a nice struct for further | 494 | * Parse a UDP payload of a DNS packet in to a nice struct for further |
483 | * processing and manipulation. | 495 | * processing and manipulation. |
484 | * | 496 | * |
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h index 3e3d140b9..ac9e2d006 100644 --- a/src/include/gnunet_gns_service.h +++ b/src/include/gnunet_gns_service.h | |||
@@ -109,6 +109,8 @@ enum GNUNET_GNS_RecordType | |||
109 | 109 | ||
110 | /* struct vpn_data */ | 110 | /* struct vpn_data */ |
111 | GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN, | 111 | GNUNET_GNS_RECORD_VPN = GNUNET_NAMESTORE_TYPE_VPN, |
112 | |||
113 | /* revocation */ | ||
112 | GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV | 114 | GNUNET_GNS_RECORD_REV = GNUNET_NAMESTORE_TYPE_REV |
113 | }; | 115 | }; |
114 | 116 | ||