aboutsummaryrefslogtreecommitdiff
path: root/src/dns/dnsparser.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-15 10:52:06 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-15 10:52:06 +0000
commit3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8 (patch)
treeed49951102400f7086f4db23846fb7aaf32e5eb1 /src/dns/dnsparser.c
parent9e94c69b299f74ac88b14f92b7a01bba0c33a776 (diff)
downloadgnunet-3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8.tar.gz
gnunet-3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8.zip
-eliminating duplicate struct definitions
Diffstat (limited to 'src/dns/dnsparser.c')
-rw-r--r--src/dns/dnsparser.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 18ef4c219..68b882279 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -31,7 +31,7 @@
31#endif 31#endif
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33#include "gnunet_dnsparser_lib.h" 33#include "gnunet_dnsparser_lib.h"
34#include "dnsparser.h" 34#include "gnunet_tun_lib.h"
35 35
36 36
37/** 37/**
@@ -235,7 +235,7 @@ parse_query (const char *udp_payload,
235 struct GNUNET_DNSPARSER_Query *q) 235 struct GNUNET_DNSPARSER_Query *q)
236{ 236{
237 char *name; 237 char *name;
238 struct query_line ql; 238 struct GNUNET_TUN_DnsQueryLine ql;
239 239
240 name = parse_name (udp_payload, 240 name = parse_name (udp_payload,
241 udp_payload_length, 241 udp_payload_length,
@@ -243,7 +243,7 @@ parse_query (const char *udp_payload,
243 if (NULL == name) 243 if (NULL == name)
244 return GNUNET_SYSERR; 244 return GNUNET_SYSERR;
245 q->name = name; 245 q->name = name;
246 if (*off + sizeof (struct query_line) > udp_payload_length) 246 if (*off + sizeof (struct GNUNET_TUN_DnsQueryLine) > udp_payload_length)
247 return GNUNET_SYSERR; 247 return GNUNET_SYSERR;
248 memcpy (&ql, &udp_payload[*off], sizeof (ql)); 248 memcpy (&ql, &udp_payload[*off], sizeof (ql));
249 *off += sizeof (ql); 249 *off += sizeof (ql);
@@ -270,12 +270,12 @@ parse_record (const char *udp_payload,
270 struct GNUNET_DNSPARSER_Record *r) 270 struct GNUNET_DNSPARSER_Record *r)
271{ 271{
272 char *name; 272 char *name;
273 struct record_line rl; 273 struct GNUNET_TUN_DnsRecordLine rl;
274 size_t old_off; 274 size_t old_off;
275 struct soa_data soa; 275 struct GNUNET_TUN_DnsSoaRecord soa;
276 uint16_t mxpref; 276 uint16_t mxpref;
277 uint16_t data_len; 277 uint16_t data_len;
278 struct srv_data srv; 278 struct GNUNET_TUN_DnsSrvRecord srv;
279 char *ndup; 279 char *ndup;
280 char *tok; 280 char *tok;
281 281
@@ -285,7 +285,7 @@ parse_record (const char *udp_payload,
285 if (NULL == name) 285 if (NULL == name)
286 return GNUNET_SYSERR; 286 return GNUNET_SYSERR;
287 r->name = name; 287 r->name = name;
288 if (*off + sizeof (struct record_line) > udp_payload_length) 288 if (*off + sizeof (struct GNUNET_TUN_DnsRecordLine) > udp_payload_length)
289 return GNUNET_SYSERR; 289 return GNUNET_SYSERR;
290 memcpy (&rl, &udp_payload[*off], sizeof (rl)); 290 memcpy (&rl, &udp_payload[*off], sizeof (rl));
291 (*off) += sizeof (rl); 291 (*off) += sizeof (rl);
@@ -320,15 +320,15 @@ parse_record (const char *udp_payload,
320 off, 0); 320 off, 0);
321 if ( (NULL == r->data.soa->mname) || 321 if ( (NULL == r->data.soa->mname) ||
322 (NULL == r->data.soa->rname) || 322 (NULL == r->data.soa->rname) ||
323 (*off + sizeof (struct soa_data) > udp_payload_length) ) 323 (*off + sizeof (struct GNUNET_TUN_DnsSoaRecord) > udp_payload_length) )
324 return GNUNET_SYSERR; 324 return GNUNET_SYSERR;
325 memcpy (&soa, &udp_payload[*off], sizeof (struct soa_data)); 325 memcpy (&soa, &udp_payload[*off], sizeof (struct GNUNET_TUN_DnsSoaRecord));
326 r->data.soa->serial = ntohl (soa.serial); 326 r->data.soa->serial = ntohl (soa.serial);
327 r->data.soa->refresh = ntohl (soa.refresh); 327 r->data.soa->refresh = ntohl (soa.refresh);
328 r->data.soa->retry = ntohl (soa.retry); 328 r->data.soa->retry = ntohl (soa.retry);
329 r->data.soa->expire = ntohl (soa.expire); 329 r->data.soa->expire = ntohl (soa.expire);
330 r->data.soa->minimum_ttl = ntohl (soa.minimum); 330 r->data.soa->minimum_ttl = ntohl (soa.minimum);
331 (*off) += sizeof (struct soa_data); 331 (*off) += sizeof (struct GNUNET_TUN_DnsSoaRecord);
332 if (old_off + data_len != *off) 332 if (old_off + data_len != *off)
333 return GNUNET_SYSERR; 333 return GNUNET_SYSERR;
334 return GNUNET_OK; 334 return GNUNET_OK;
@@ -352,10 +352,10 @@ parse_record (const char *udp_payload,
352 if (NULL == strstr (r->name, "._")) 352 if (NULL == strstr (r->name, "._"))
353 return GNUNET_SYSERR; /* necessary string from "._$PROTO" not present */ 353 return GNUNET_SYSERR; /* necessary string from "._$PROTO" not present */
354 old_off = *off; 354 old_off = *off;
355 if (*off + sizeof (struct srv_data) > udp_payload_length) 355 if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > udp_payload_length)
356 return GNUNET_SYSERR; 356 return GNUNET_SYSERR;
357 memcpy (&srv, &udp_payload[*off], sizeof (struct srv_data)); 357 memcpy (&srv, &udp_payload[*off], sizeof (struct GNUNET_TUN_DnsSrvRecord));
358 (*off) += sizeof (struct srv_data); 358 (*off) += sizeof (struct GNUNET_TUN_DnsSrvRecord);
359 r->data.srv = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_SrvRecord)); 359 r->data.srv = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_SrvRecord));
360 r->data.srv->priority = ntohs (srv.prio); 360 r->data.srv->priority = ntohs (srv.prio);
361 r->data.srv->weight = ntohs (srv.weight); 361 r->data.srv->weight = ntohs (srv.weight);
@@ -685,9 +685,9 @@ add_query (char *dst,
685 const struct GNUNET_DNSPARSER_Query *query) 685 const struct GNUNET_DNSPARSER_Query *query)
686{ 686{
687 int ret; 687 int ret;
688 struct query_line ql; 688 struct GNUNET_TUN_DnsQueryLine ql;
689 689
690 ret = add_name (dst, dst_len - sizeof (struct query_line), off, query->name); 690 ret = add_name (dst, dst_len - sizeof (struct GNUNET_TUN_DnsQueryLine), off, query->name);
691 if (ret != GNUNET_OK) 691 if (ret != GNUNET_OK)
692 return ret; 692 return ret;
693 ql.type = htons (query->type); 693 ql.type = htons (query->type);
@@ -745,7 +745,7 @@ add_soa (char *dst,
745 size_t *off, 745 size_t *off,
746 const struct GNUNET_DNSPARSER_SoaRecord *soa) 746 const struct GNUNET_DNSPARSER_SoaRecord *soa)
747{ 747{
748 struct soa_data sd; 748 struct GNUNET_TUN_DnsSoaRecord sd;
749 int ret; 749 int ret;
750 750
751 if ( (GNUNET_OK != (ret = add_name (dst, 751 if ( (GNUNET_OK != (ret = add_name (dst,
@@ -757,7 +757,7 @@ add_soa (char *dst,
757 off, 757 off,
758 soa->rname)) ) ) 758 soa->rname)) ) )
759 return ret; 759 return ret;
760 if (*off + sizeof (struct soa_data) > dst_len) 760 if (*off + sizeof (struct GNUNET_TUN_DnsSoaRecord) > dst_len)
761 return GNUNET_NO; 761 return GNUNET_NO;
762 sd.serial = htonl (soa->serial); 762 sd.serial = htonl (soa->serial);
763 sd.refresh = htonl (soa->refresh); 763 sd.refresh = htonl (soa->refresh);
@@ -788,10 +788,10 @@ add_srv (char *dst,
788 size_t *off, 788 size_t *off,
789 const struct GNUNET_DNSPARSER_SrvRecord *srv) 789 const struct GNUNET_DNSPARSER_SrvRecord *srv)
790{ 790{
791 struct srv_data sd; 791 struct GNUNET_TUN_DnsSrvRecord sd;
792 int ret; 792 int ret;
793 793
794 if (*off + sizeof (struct srv_data) > dst_len) 794 if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > dst_len)
795 return GNUNET_NO; 795 return GNUNET_NO;
796 sd.prio = htons (srv->priority); 796 sd.prio = htons (srv->priority);
797 sd.weight = htons (srv->weight); 797 sd.weight = htons (srv->weight);
@@ -828,7 +828,7 @@ add_record (char *dst,
828 int ret; 828 int ret;
829 size_t start; 829 size_t start;
830 size_t pos; 830 size_t pos;
831 struct record_line rl; 831 struct GNUNET_TUN_DnsRecordLine rl;
832 char *name; 832 char *name;
833 833
834 start = *off; 834 start = *off;
@@ -842,14 +842,14 @@ add_record (char *dst,
842 record->data.srv->service, 842 record->data.srv->service,
843 record->data.srv->proto, 843 record->data.srv->proto,
844 record->data.srv->domain_name); 844 record->data.srv->domain_name);
845 ret = add_name (dst, dst_len - sizeof (struct record_line), off, name); 845 ret = add_name (dst, dst_len - sizeof (struct GNUNET_TUN_DnsRecordLine), off, name);
846 if (name != record->name) 846 if (name != record->name)
847 GNUNET_free (name); 847 GNUNET_free (name);
848 if (GNUNET_OK != ret) 848 if (GNUNET_OK != ret)
849 return ret; 849 return ret;
850 /* '*off' is now the position where we will need to write the record line */ 850 /* '*off' is now the position where we will need to write the record line */
851 851
852 pos = *off + sizeof (struct record_line); 852 pos = *off + sizeof (struct GNUNET_TUN_DnsRecordLine);
853 switch (record->type) 853 switch (record->type)
854 { 854 {
855 case GNUNET_DNSPARSER_TYPE_MX: 855 case GNUNET_DNSPARSER_TYPE_MX:
@@ -883,7 +883,7 @@ add_record (char *dst,
883 return GNUNET_NO; 883 return GNUNET_NO;
884 } 884 }
885 885
886 if (pos - (*off + sizeof (struct record_line)) > UINT16_MAX) 886 if (pos - (*off + sizeof (struct GNUNET_TUN_DnsRecordLine)) > UINT16_MAX)
887 { 887 {
888 /* record data too long */ 888 /* record data too long */
889 *off = start; 889 *off = start;
@@ -892,8 +892,8 @@ add_record (char *dst,
892 rl.type = htons (record->type); 892 rl.type = htons (record->type);
893 rl.class = htons (record->class); 893 rl.class = htons (record->class);
894 rl.ttl = htonl (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value_us / 1000LL / 1000LL); /* in seconds */ 894 rl.ttl = htonl (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value_us / 1000LL / 1000LL); /* in seconds */
895 rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct record_line)))); 895 rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct GNUNET_TUN_DnsRecordLine))));
896 memcpy (&dst[*off], &rl, sizeof (struct record_line)); 896 memcpy (&dst[*off], &rl, sizeof (struct GNUNET_TUN_DnsRecordLine));
897 *off = pos; 897 *off = pos;
898 return GNUNET_OK; 898 return GNUNET_OK;
899} 899}