[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33565 - in gnunet/src: dns gns gnsrecord include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33565 - in gnunet/src: dns gns gnsrecord include |
Date: |
Fri, 6 Jun 2014 14:20:59 +0200 |
Author: grothoff
Date: 2014-06-06 14:20:59 +0200 (Fri, 06 Jun 2014)
New Revision: 33565
Modified:
gnunet/src/dns/dnsparser.c
gnunet/src/dns/gnunet-dns-monitor.c
gnunet/src/gns/gnunet-service-gns_resolver.c
gnunet/src/gnsrecord/plugin_gnsrecord_dns.c
gnunet/src/include/gnunet_dnsparser_lib.h
Log:
towards sanity in SRV handling
Modified: gnunet/src/dns/dnsparser.c
===================================================================
--- gnunet/src/dns/dnsparser.c 2014-06-06 12:01:32 UTC (rev 33564)
+++ gnunet/src/dns/dnsparser.c 2014-06-06 12:20:59 UTC (rev 33565)
@@ -143,9 +143,6 @@
if (NULL == srv)
return;
GNUNET_free_non_null (srv->target);
- GNUNET_free_non_null (srv->domain_name);
- GNUNET_free_non_null (srv->proto);
- GNUNET_free_non_null (srv->service);
GNUNET_free (srv);
}
@@ -489,7 +486,6 @@
/**
* Parse a DNS SRV record.
*
- * @param r_name name of the SRV record
* @param udp_payload reference to UDP packet
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the query to parse in the SRV record
(to be
@@ -497,21 +493,14 @@
* @return the parsed SRV record, NULL on error
*/
struct GNUNET_DNSPARSER_SrvRecord *
-GNUNET_DNSPARSER_parse_srv (const char *r_name,
- const char *udp_payload,
+GNUNET_DNSPARSER_parse_srv (const char *udp_payload,
size_t udp_payload_length,
size_t *off)
{
struct GNUNET_DNSPARSER_SrvRecord *srv;
struct GNUNET_TUN_DnsSrvRecord srv_bin;
size_t old_off;
- char *ndup;
- char *tok;
- if ('_' != *r_name)
- return NULL; /* all valid srv names must start with "_" */
- if (NULL == strstr (r_name, "._"))
- return NULL; /* necessary string from "._$PROTO" not present */
old_off = *off;
if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > udp_payload_length)
return NULL;
@@ -523,32 +512,6 @@
srv->priority = ntohs (srv_bin.prio);
srv->weight = ntohs (srv_bin.weight);
srv->port = ntohs (srv_bin.port);
- /* parse 'data.hostname' into components, which are
- "_$SERVICE._$PROTO.$DOMAIN_NAME" */
- ndup = GNUNET_strdup (r_name);
- tok = strtok (ndup, ".");
- GNUNET_assert (NULL != tok);
- GNUNET_assert ('_' == *tok);
- srv->service = GNUNET_strdup (&tok[1]);
- tok = strtok (NULL, ".");
- if ( (NULL == tok) || ('_' != *tok) )
- {
- GNUNET_DNSPARSER_free_srv (srv);
- GNUNET_free (ndup);
- *off = old_off;
- return NULL;
- }
- srv->proto = GNUNET_strdup (&tok[1]);
- tok = strtok (NULL, ".");
- if (NULL == tok)
- {
- GNUNET_DNSPARSER_free_srv (srv);
- GNUNET_free (ndup);
- *off = old_off;
- return NULL;
- }
- srv->domain_name = GNUNET_strdup (tok);
- GNUNET_free (ndup);
srv->target = GNUNET_DNSPARSER_parse_name (udp_payload,
udp_payload_length,
off);
@@ -683,8 +646,7 @@
}
return GNUNET_OK;
case GNUNET_DNSPARSER_TYPE_SRV:
- r->data.srv = GNUNET_DNSPARSER_parse_srv (r->name,
- udp_payload,
+ r->data.srv = GNUNET_DNSPARSER_parse_srv (udp_payload,
udp_payload_length,
off);
if ( (NULL == r->data.srv) ||
@@ -1102,22 +1064,12 @@
size_t start;
size_t pos;
struct GNUNET_TUN_DnsRecordLine rl;
- char *name;
start = *off;
- /* for SRV records, we can create the name from the details
- of the record if needed */
- name = record->name;
- if ( (GNUNET_DNSPARSER_TYPE_SRV == record->type) &&
- (NULL == name) )
- GNUNET_asprintf (&name,
- "_%s._%s.%s",
- record->data.srv->service,
- record->data.srv->proto,
- record->data.srv->domain_name);
- ret = GNUNET_DNSPARSER_builder_add_name (dst, dst_len - sizeof (struct
GNUNET_TUN_DnsRecordLine), off, name);
- if (name != record->name)
- GNUNET_free (name);
+ ret = GNUNET_DNSPARSER_builder_add_name (dst,
+ dst_len - sizeof (struct
GNUNET_TUN_DnsRecordLine),
+ off,
+ record->name);
if (GNUNET_OK != ret)
return ret;
/* '*off' is now the position where we will need to write the record line */
Modified: gnunet/src/dns/gnunet-dns-monitor.c
===================================================================
--- gnunet/src/dns/gnunet-dns-monitor.c 2014-06-06 12:01:32 UTC (rev 33564)
+++ gnunet/src/dns/gnunet-dns-monitor.c 2014-06-06 12:20:59 UTC (rev 33565)
@@ -164,7 +164,7 @@
(unsigned int) record->data.soa->refresh,
(unsigned int) record->data.soa->retry,
(unsigned int) record->data.soa->expire,
- (unsigned int) record->data.soa->minimum_ttl);
+ (unsigned int) record->data.soa->minimum_ttl);
format = tmp;
}
break;
@@ -186,10 +186,7 @@
else
{
GNUNET_asprintf (&tmp,
- "service: %s, protocol: %s, domain_name = %s, priority
%u, weight = %s, port = %u, target = %s",
- record->data.srv->service,
- record->data.srv->proto,
- record->data.srv->domain_name,
+ "priority %u, weight = %s, port = %u, target = %s",
(unsigned int) record->data.srv->priority,
(unsigned int) record->data.srv->weight,
(unsigned int) record->data.srv->port,
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2014-06-06 12:01:32 UTC
(rev 33564)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2014-06-06 12:20:59 UTC
(rev 33565)
@@ -1628,8 +1628,7 @@
struct GNUNET_DNSPARSER_SrvRecord *srv;
off = 0;
- srv = GNUNET_DNSPARSER_parse_srv (rh->name,
- rd[i].data,
+ srv = GNUNET_DNSPARSER_parse_srv (rd[i].data,
rd[i].data_size,
&off);
if ( (NULL == srv) ||
@@ -1639,7 +1638,6 @@
}
else
{
- srv->domain_name = translate_dot_plus (rh, srv->domain_name);
srv->target = translate_dot_plus (rh, srv->target);
scratch_start = scratch_off;
if (GNUNET_OK !=
Modified: gnunet/src/gnsrecord/plugin_gnsrecord_dns.c
===================================================================
--- gnunet/src/gnsrecord/plugin_gnsrecord_dns.c 2014-06-06 12:01:32 UTC (rev
33564)
+++ gnunet/src/gnsrecord/plugin_gnsrecord_dns.c 2014-06-06 12:20:59 UTC (rev
33565)
@@ -209,8 +209,7 @@
size_t off;
off = 0;
- srv = GNUNET_DNSPARSER_parse_srv ("+", /* FIXME: is this OK? */
- data,
+ srv = GNUNET_DNSPARSER_parse_srv (data,
data_size,
&off);
if ( (NULL == srv) ||
@@ -222,13 +221,11 @@
return NULL;
}
GNUNET_asprintf (&result,
- "%d %d %d _%s._%s.%s",
+ "%d %d %d %s",
srv->priority,
srv->weight,
srv->port,
- srv->service,
- srv->proto,
- srv->domain_name);
+ srv->target);
GNUNET_DNSPARSER_free_srv (srv);
return result;
}
@@ -536,8 +533,10 @@
return GNUNET_OK;
}
case GNUNET_DNSPARSER_TYPE_SRV:
- GNUNET_break (0); // FIXME: not implemented!
- return GNUNET_SYSERR;
+ {
+ GNUNET_break (0); // FIXME: not implemented!
+ return GNUNET_SYSERR;
+ }
case GNUNET_DNSPARSER_TYPE_TXT:
*data = GNUNET_strdup (s);
*data_size = strlen (s);
Modified: gnunet/src/include/gnunet_dnsparser_lib.h
===================================================================
--- gnunet/src/include/gnunet_dnsparser_lib.h 2014-06-06 12:01:32 UTC (rev
33564)
+++ gnunet/src/include/gnunet_dnsparser_lib.h 2014-06-06 12:20:59 UTC (rev
33565)
@@ -109,45 +109,12 @@
/**
- * Information from SRV records (RFC 2782). The 'service', 'proto'
- * and 'domain_name' fields together give the DNS-name which for SRV
- * records is of the form "_$SERVICE._$PROTO.$DOMAIN_NAME". The DNS
- * parser provides the full name in `struct DNSPARSER_Record` and the
- * individual components in the respective fields of this struct.
- * When serializing, you CAN set the 'name' field of 'struct
- * GNUNET_DNSPARSER_Record' to NULL, in which case the DNSPARSER code
- * will populate 'name' from the 'service', 'proto' and 'domain_name'
- * fields in this struct.
+ * Information from SRV records (RFC 2782).
*/
struct GNUNET_DNSPARSER_SrvRecord
{
/**
- * Service name without the underscore (!). Note that RFC 6335 clarifies the
- * set of legal characters for service names.
- * In UTF-8 format. The library will convert from and to DNS-IDNA
- * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an
- * individual label is well-formed. If a given name is not well-formed,
- * creating the DNS packet will fail.
- */
- char *service;
-
- /**
- * Transport protocol (typcially "tcp" or "udp", but others might be
allowed).
- * Without the underscore (!).
- */
- char *proto;
-
- /**
- * Domain name for which the record is valid
- * In UTF-8 format. The library will convert from and to DNS-IDNA
- * as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an
- * individual label is well-formed. If a given name is not well-formed,
- * creating the DNS packet will fail.
- */
- char *domain_name;
-
- /**
* Hostname offering the service.
* In UTF-8 format. The library will convert from and to DNS-IDNA
* as necessary. Use #GNUNET_DNSPARSER_check_label() to test if an
@@ -834,7 +801,6 @@
/**
* Parse a DNS SRV record.
*
- * @param r_name name of the SRV record
* @param udp_payload reference to UDP packet
* @param udp_payload_length length of @a udp_payload
* @param off pointer to the offset of the query to parse in the SRV record
(to be
@@ -842,8 +808,7 @@
* @return the parsed SRV record, NULL on error
*/
struct GNUNET_DNSPARSER_SrvRecord *
-GNUNET_DNSPARSER_parse_srv (const char *r_name,
- const char *udp_payload,
+GNUNET_DNSPARSER_parse_srv (const char *udp_payload,
size_t udp_payload_length,
size_t *off);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33565 - in gnunet/src: dns gns gnsrecord include,
gnunet <=