From c0ad24645c062d3ce27fc5c3e85b08cafe1d4ad1 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 2 Mar 2007 14:35:57 +0000 Subject: Fixed ticket #156: Not enough memory to parse DNS packets in resolver (thanks Frank Wiersma) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1031 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib-util/include/pjlib-util/config.h | 9 +++++++++ pjlib-util/include/pjlib-util/dns.h | 20 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'pjlib-util/include') diff --git a/pjlib-util/include/pjlib-util/config.h b/pjlib-util/include/pjlib-util/config.h index 612f4bc0..f33ad4a8 100644 --- a/pjlib-util/include/pjlib-util/config.h +++ b/pjlib-util/include/pjlib-util/config.h @@ -169,6 +169,15 @@ #endif +/** + * Size of temporary pool buffer for parsing DNS packets in resolver. + * + * default: 4000 + */ +#ifndef PJ_DNS_RESOLVER_TMP_BUF_SIZE +# define PJ_DNS_RESOLVER_TMP_BUF_SIZE 4000 +#endif + /* ************************************************************************** * SCANNER CONFIGURATION diff --git a/pjlib-util/include/pjlib-util/dns.h b/pjlib-util/include/pjlib-util/dns.h index cebc20f8..dcea621a 100644 --- a/pjlib-util/include/pjlib-util/dns.h +++ b/pjlib-util/include/pjlib-util/dns.h @@ -25,7 +25,7 @@ * @brief Low level DNS message parsing and packetization. */ #include - +#include PJ_BEGIN_DECL @@ -258,7 +258,8 @@ typedef struct pj_dns_parsed_rr /** A Resource Data (PJ_DNS_TYPE_A, 1) */ struct a { - pj_str_t ip_addr;/**< IP host address string. */ + //pj_str_t ip_addr;/**< IP host address string. */ + pj_in_addr ip_addr; } a; } rdata; @@ -281,6 +282,19 @@ typedef struct pj_dns_parsed_packet } pj_dns_parsed_packet; +/** + * Option flags to be specified when calling #pj_dns_packet_dup() function. + * These flags can be combined with bitwise OR operation. + */ +enum pj_dns_dup_options +{ + PJ_DNS_NO_QD = 1, /**< Do not duplicate the query section. */ + PJ_DNS_NO_ANS = 2, /**< Do not duplicate the answer section. */ + PJ_DNS_NO_NS = 4, /**< Do not duplicate the NS section. */ + PJ_DNS_NO_AR = 8 /**< Do not duplicate the additional rec section */ +}; + + /** * Create DNS query packet to resolve the specified names. This function * can be used to build any types of DNS query, such as A record or DNS SRV @@ -331,10 +345,12 @@ PJ_DECL(pj_status_t) pj_dns_parse_packet(pj_pool_t *pool, * * @param pool The pool to allocate memory for the duplicated packet. * @param p The DNS packet to be cloned. + * @param options Option flags, from pj_dns_dup_options. * @param p_dst Pointer to store the cloned DNS packet. */ PJ_DECL(void) pj_dns_packet_dup(pj_pool_t *pool, const pj_dns_parsed_packet*p, + unsigned options, pj_dns_parsed_packet **p_dst); -- cgit v1.2.3