- Timestamp:
- Mar 2, 2007 2:51:03 PM (18 years ago)
- Location:
- pjproject/branches/pjproject-0.5-stable
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/pjproject-0.5-stable/pjlib-util/include/pjlib-util/config.h
r974 r1033 170 170 171 171 172 /** 173 * Size of temporary pool buffer for parsing DNS packets in resolver. 174 * 175 * default: 4000 176 */ 177 #ifndef PJ_DNS_RESOLVER_TMP_BUF_SIZE 178 # define PJ_DNS_RESOLVER_TMP_BUF_SIZE 4000 179 #endif 180 172 181 173 182 /* ************************************************************************** -
pjproject/branches/pjproject-0.5-stable/pjlib-util/include/pjlib-util/dns.h
r974 r1033 26 26 */ 27 27 #include <pjlib-util/types.h> 28 28 #include <pj/sock.h> 29 29 30 30 PJ_BEGIN_DECL … … 259 259 /** A Resource Data (PJ_DNS_TYPE_A, 1) */ 260 260 struct a { 261 pj_ str_tip_addr;/**< IP host address string. */261 pj_in_addr ip_addr;/**< IP host address string. */ 262 262 } a; 263 263 … … 280 280 pj_dns_parsed_rr *arr; /**< Array of additional RR answer. */ 281 281 } pj_dns_parsed_packet; 282 283 284 /** 285 * Option flags to be specified when calling #pj_dns_packet_dup() function. 286 * These flags can be combined with bitwise OR operation. 287 */ 288 enum pj_dns_dup_options 289 { 290 PJ_DNS_NO_QD = 1, /**< Do not duplicate the query section. */ 291 PJ_DNS_NO_ANS = 2, /**< Do not duplicate the answer section. */ 292 PJ_DNS_NO_NS = 4, /**< Do not duplicate the NS section. */ 293 PJ_DNS_NO_AR = 8 /**< Do not duplicate the additional rec section */ 294 }; 282 295 283 296 … … 332 345 * @param pool The pool to allocate memory for the duplicated packet. 333 346 * @param p The DNS packet to be cloned. 347 * @param options Option flags, from pj_dns_dup_options. 334 348 * @param p_dst Pointer to store the cloned DNS packet. 335 349 */ 336 350 PJ_DECL(void) pj_dns_packet_dup(pj_pool_t *pool, 337 351 const pj_dns_parsed_packet*p, 352 unsigned options, 338 353 pj_dns_parsed_packet **p_dst); 339 354 -
pjproject/branches/pjproject-0.5-stable/pjlib-util/src/pjlib-util/dns.c
r974 r1033 341 341 /* Parse some well known records */ 342 342 if (rr->type == PJ_DNS_TYPE_A) { 343 pj_in_addr ip_addr; 344 345 pj_memcpy(&ip_addr, p, 4); 346 pj_strdup2(pool, &rr->rdata.a.ip_addr, pj_inet_ntoa(ip_addr)); 347 343 pj_memcpy(&rr->rdata.a.ip_addr, p, 4); 348 344 p += 4; 349 345 … … 588 584 pool, &dst->rdata.srv.target); 589 585 } else if (src->type == PJ_DNS_TYPE_A) { 590 pj_strdup(pool, &dst->rdata.a.ip_addr, &src->rdata.a.ip_addr);586 dst->rdata.a.ip_addr.s_addr = src->rdata.a.ip_addr.s_addr; 591 587 } else if (src->type == PJ_DNS_TYPE_CNAME) { 592 588 pj_strdup(pool, &dst->rdata.cname.name, &src->rdata.cname.name); … … 603 599 PJ_DEF(void) pj_dns_packet_dup(pj_pool_t *pool, 604 600 const pj_dns_parsed_packet*p, 601 unsigned options, 605 602 pj_dns_parsed_packet **p_dst) 606 603 { … … 631 628 632 629 /* Copy query section */ 633 if (p->hdr.qdcount ) {630 if (p->hdr.qdcount && (options & PJ_DNS_NO_QD)==0) { 634 631 dst->q = pj_pool_alloc(pool, p->hdr.qdcount * 635 632 sizeof(pj_dns_parsed_query)); … … 642 639 643 640 /* Copy answer section */ 644 if (p->hdr.anscount ) {641 if (p->hdr.anscount && (options & PJ_DNS_NO_ANS)==0) { 645 642 dst->ans = pj_pool_alloc(pool, p->hdr.anscount * 646 643 sizeof(pj_dns_parsed_rr)); … … 653 650 654 651 /* Copy NS section */ 655 if (p->hdr.nscount ) {652 if (p->hdr.nscount && (options & PJ_DNS_NO_NS)==0) { 656 653 dst->ns = pj_pool_alloc(pool, p->hdr.nscount * 657 654 sizeof(pj_dns_parsed_rr)); … … 664 661 665 662 /* Copy additional info section */ 666 if (p->hdr.arcount ) {663 if (p->hdr.arcount && (options & PJ_DNS_NO_AR)==0) { 667 664 dst->arr = pj_pool_alloc(pool, p->hdr.arcount * 668 665 sizeof(pj_dns_parsed_rr)); -
pjproject/branches/pjproject-0.5-stable/pjlib-util/src/pjlib-util/dns_dump.c
r974 r1033 116 116 rr->rdata.cname.name.ptr)); 117 117 } else if (rr->type == PJ_DNS_TYPE_A) { 118 PJ_LOG(3,(THIS_FILE, " IP address: %.*s", 119 (int)rr->rdata.a.ip_addr.slen, 120 rr->rdata.a.ip_addr.ptr)); 118 PJ_LOG(3,(THIS_FILE, " IP address: %s", 119 pj_inet_ntoa(rr->rdata.a.ip_addr))); 121 120 } 122 121 } -
pjproject/branches/pjproject-0.5-stable/pjlib-util/src/pjlib-util/resolver.c
r974 r1033 52 52 #define RES_BUF_SZ PJ_DNS_RESOLVER_RES_BUF_SIZE 53 53 #define UDPSZ PJ_DNS_RESOLVER_MAX_UDP_SIZE 54 #define TMP_SZ PJ_DNS_RESOLVER_TMP_BUF_SIZE 54 55 55 56 … … 162 163 pj_bool_t own_ioqueue; /**< Do we own ioqueue? */ 163 164 pj_ioqueue_t *ioqueue; /**< Ioqueue instance. */ 164 char tmp_pool[ 1500];/**< Temporary pool buffer. */165 char tmp_pool[TMP_SZ];/**< Temporary pool buffer. */ 165 166 166 167 /* Socket */ … … 994 995 } 995 996 996 /* Duplicate the packet */ 997 /* Duplicate the packet. 998 * We don't need to keep the query, NS, and AR sections from the packet, 999 * so exclude from duplication. 1000 */ 997 1001 res_pool = pj_pool_create_on_buf("respool", cache->buf, sizeof(cache->buf)); 998 1002 PJ_TRY { 999 1003 cache->pkt = NULL; 1000 pj_dns_packet_dup(res_pool, pkt, &cache->pkt); 1004 pj_dns_packet_dup(res_pool, pkt, 1005 PJ_DNS_NO_QD | PJ_DNS_NO_NS | PJ_DNS_NO_AR, 1006 &cache->pkt); 1001 1007 } 1002 1008 PJ_CATCH_ANY { … … 1223 1229 } 1224 1230 } 1225 1226 /* We don't need NS and query section in the packet, so trim them. */1227 dns_pkt->hdr.qdcount = 0;1228 dns_pkt->hdr.nscount = 0;1229 1231 1230 1232 /* Save/update response cache. */ -
pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsip/sip_resolve.c
r974 r1033 536 536 if (pj_stricmp(&rr->name, &query->srv[j].target_name)==0) { 537 537 unsigned cnt = query->srv[j].addr_cnt; 538 query->srv[j].addr[cnt] = pj_inet_addr(&rr->rdata.a.ip_addr);538 query->srv[j].addr[cnt].s_addr = rr->rdata.a.ip_addr.s_addr; 539 539 ++query->srv[j].addr_cnt; 540 540 ++query->host_resolved; … … 778 778 unsigned j; 779 779 780 query->srv[i].addr[query->srv[i].addr_cnt++] =781 p j_inet_addr(&pkt->ans[0].rdata.a.ip_addr);780 query->srv[i].addr[query->srv[i].addr_cnt++].s_addr = 781 pkt->ans[0].rdata.a.ip_addr.s_addr; 782 782 783 783 PJ_LOG(5,(query->objname, 784 "DNS A for %.*s: % .*s",784 "DNS A for %.*s: %s", 785 785 (int)query->srv[i].target_name.slen, 786 786 query->srv[i].target_name.ptr, 787 (int)pkt->ans[0].rdata.a.ip_addr.slen, 788 pkt->ans[0].rdata.a.ip_addr.ptr)); 787 pj_inet_ntoa(pkt->ans[0].rdata.a.ip_addr))); 789 788 790 789 /* Check for multiple IP addresses */ … … 792 791 query->srv[i].addr_cnt < ADDR_MAX_COUNT; ++j) 793 792 { 794 query->srv[i].addr[query->srv[i].addr_cnt++] =795 p j_inet_addr(&pkt->ans[j].rdata.a.ip_addr);793 query->srv[i].addr[query->srv[i].addr_cnt++].s_addr = 794 pkt->ans[j].rdata.a.ip_addr.s_addr; 796 795 797 796 PJ_LOG(5,(query->objname, 798 "Additional DNS A for %.*s: % .*s",797 "Additional DNS A for %.*s: %s", 799 798 (int)query->srv[i].target_name.slen, 800 799 query->srv[i].target_name.ptr, 801 (int)pkt->ans[j].rdata.a.ip_addr.slen, 802 pkt->ans[j].rdata.a.ip_addr.ptr)); 800 pj_inet_ntoa(pkt->ans[j].rdata.a.ip_addr))); 803 801 } 804 802 }
Note: See TracChangeset
for help on using the changeset viewer.