diff options
Diffstat (limited to 'src')
-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 |
4 files changed, 44 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 = \ | |||
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 | ||