diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-24 10:05:43 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-24 10:05:43 +0000 |
commit | 38be3ab6333e09e5689b4626bf9caa93bd1bbfba (patch) | |
tree | af3d6d4ccf52490ce788713e35d533aeaff74606 /src/include/gnunet_dnsparser_lib.h | |
parent | 8babf5f841c8d364a0ab271e395f7e9a0e9b2632 (diff) | |
download | gnunet-38be3ab6333e09e5689b4626bf9caa93bd1bbfba.tar.gz gnunet-38be3ab6333e09e5689b4626bf9caa93bd1bbfba.zip |
-expose API for parsing individual DNS record types
Diffstat (limited to 'src/include/gnunet_dnsparser_lib.h')
-rw-r--r-- | src/include/gnunet_dnsparser_lib.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h index 8e00aa248..2d3a26215 100644 --- a/src/include/gnunet_dnsparser_lib.h +++ b/src/include/gnunet_dnsparser_lib.h | |||
@@ -545,5 +545,101 @@ GNUNET_DNSPARSER_builder_add_srv (char *dst, | |||
545 | size_t *off, | 545 | size_t *off, |
546 | const struct GNUNET_DNSPARSER_SrvRecord *srv); | 546 | const struct GNUNET_DNSPARSER_SrvRecord *srv); |
547 | 547 | ||
548 | /* ***************** low-level parsing API ******************** */ | ||
549 | |||
550 | /** | ||
551 | * Parse a DNS record entry. | ||
552 | * | ||
553 | * @param udp_payload entire UDP payload | ||
554 | * @param udp_payload_length length of @a udp_payload | ||
555 | * @param off pointer to the offset of the record to parse in the udp_payload (to be | ||
556 | * incremented by the size of the record) | ||
557 | * @param r where to write the record information | ||
558 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the record is malformed | ||
559 | */ | ||
560 | int | ||
561 | GNUNET_DNSPARSER_parse_record (const char *udp_payload, | ||
562 | size_t udp_payload_length, | ||
563 | size_t *off, | ||
564 | struct GNUNET_DNSPARSER_Record *r); | ||
565 | |||
566 | |||
567 | /** | ||
568 | * Parse name inside of a DNS query or record. | ||
569 | * | ||
570 | * @param udp_payload entire UDP payload | ||
571 | * @param udp_payload_length length of @a udp_payload | ||
572 | * @param off pointer to the offset of the name to parse in the udp_payload (to be | ||
573 | * incremented by the size of the name) | ||
574 | * @return name as 0-terminated C string on success, NULL if the payload is malformed | ||
575 | */ | ||
576 | char * | ||
577 | GNUNET_DNSPARSER_parse_name (const char *udp_payload, | ||
578 | size_t udp_payload_length, | ||
579 | size_t *off); | ||
580 | |||
581 | |||
582 | /** | ||
583 | * Parse a DNS query entry. | ||
584 | * | ||
585 | * @param udp_payload entire UDP payload | ||
586 | * @param udp_payload_length length of @a udp_payload | ||
587 | * @param off pointer to the offset of the query to parse in the udp_payload (to be | ||
588 | * incremented by the size of the query) | ||
589 | * @param q where to write the query information | ||
590 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the query is malformed | ||
591 | */ | ||
592 | int | ||
593 | GNUNET_DNSPARSER_parse_query (const char *udp_payload, | ||
594 | size_t udp_payload_length, | ||
595 | size_t *off, | ||
596 | struct GNUNET_DNSPARSER_Query *q); | ||
597 | |||
598 | /** | ||
599 | * Parse a DNS SOA record. | ||
600 | * | ||
601 | * @param udp_payload reference to UDP packet | ||
602 | * @param udp_payload_length length of @a udp_payload | ||
603 | * @param off pointer to the offset of the query to parse in the SOA record (to be | ||
604 | * incremented by the size of the record), unchanged on error | ||
605 | * @return the parsed SOA record, NULL on error | ||
606 | */ | ||
607 | struct GNUNET_DNSPARSER_SoaRecord * | ||
608 | GNUNET_DNSPARSER_parse_soa (const char *udp_payload, | ||
609 | size_t udp_payload_length, | ||
610 | size_t *off); | ||
611 | |||
612 | |||
613 | /** | ||
614 | * Parse a DNS MX record. | ||
615 | * | ||
616 | * @param udp_payload reference to UDP packet | ||
617 | * @param udp_payload_length length of @a udp_payload | ||
618 | * @param off pointer to the offset of the query to parse in the MX record (to be | ||
619 | * incremented by the size of the record), unchanged on error | ||
620 | * @return the parsed MX record, NULL on error | ||
621 | */ | ||
622 | struct GNUNET_DNSPARSER_MxRecord * | ||
623 | GNUNET_DNSPARSER_parse_mx (const char *udp_payload, | ||
624 | size_t udp_payload_length, | ||
625 | size_t *off); | ||
626 | |||
627 | |||
628 | /** | ||
629 | * Parse a DNS SRV record. | ||
630 | * | ||
631 | * @param r_name name of the SRV record | ||
632 | * @param udp_payload reference to UDP packet | ||
633 | * @param udp_payload_length length of @a udp_payload | ||
634 | * @param off pointer to the offset of the query to parse in the SRV record (to be | ||
635 | * incremented by the size of the record), unchanged on error | ||
636 | * @return the parsed SRV record, NULL on error | ||
637 | */ | ||
638 | struct GNUNET_DNSPARSER_SrvRecord * | ||
639 | GNUNET_DNSPARSER_parse_srv (const char *r_name, | ||
640 | const char *udp_payload, | ||
641 | size_t udp_payload_length, | ||
642 | size_t *off); | ||
643 | |||
548 | 644 | ||
549 | #endif | 645 | #endif |