- Timestamp:
- Nov 20, 2007 9:47:32 AM (17 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/include/pjlib-util/dns.h
r1032 r1587 42 42 * This module provides low-level services to parse and packetize DNS queries 43 43 * and responses. The functions support building a DNS query packet and parse 44 * the data in the DNS response. 44 * the data in the DNS response. This implementation conforms to the 45 * following specifications: 46 * - RFC 1035: DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION 47 * - RFC 1886: DNS Extensions to support IP version 6 45 48 * 46 49 * To create a DNS query packet, application should call #pj_dns_make_query() … … 259 262 /** A Resource Data (PJ_DNS_TYPE_A, 1) */ 260 263 struct a { 261 pj_in_addr ip_addr;/**< IP host address string.*/264 pj_in_addr ip_addr;/**< IPv4 address in network byte order. */ 262 265 } a; 266 267 /** AAAA Resource Data (PJ_DNS_TYPE_AAAA, 28) */ 268 struct aaaa { 269 pj_in6_addr ip_addr;/**< IPv6 address in network byte order. */ 270 } aaaa; 263 271 264 272 } rdata; -
pjproject/trunk/pjlib-util/include/pjlib-util/srv_resolver.h
r1357 r1587 76 76 77 77 /** 78 * Flags to be specified when starting the DNS SRV query. 79 */ 80 enum pj_dns_srv_option 81 { 82 /** 83 * Specify if the resolver should fallback with DNS A 84 * resolution when the SRV resolution fails. This option may 85 * be specified together with PJ_DNS_SRV_FALLBACK_AAAA to 86 * make the resolver fallback to AAAA if SRV resolution fails, 87 * and then to DNS A resolution if the AAAA resolution fails. 88 */ 89 PJ_DNS_SRV_FALLBACK_A = 1, 90 91 /** 92 * Specify if the resolver should fallback with DNS AAAA 93 * resolution when the SRV resolution fails. This option may 94 * be specified together with PJ_DNS_SRV_FALLBACK_A to 95 * make the resolver fallback to AAAA if SRV resolution fails, 96 * and then to DNS A resolution if the AAAA resolution fails. 97 */ 98 PJ_DNS_SRV_FALLBACK_AAAA = 2, 99 100 /** 101 * Specify if the resolver should try to resolve with DNS AAAA 102 * resolution first of each targets in the DNS SRV record. If 103 * this option is not specified, the SRV resolver will query 104 * the DNS A record for the target instead. 105 */ 106 PJ_DNS_SRV_RESOLVE_AAAA = 4 107 108 } pj_dns_srv_option; 109 110 111 /** 78 112 * This structure represents DNS SRV records as the result of DNS SRV 79 113 * resolution using #pj_dns_srv_resolve(). … … 86 120 /** Address records. */ 87 121 struct 88 v{122 { 89 123 /** Server priority (the lower the higher the priority). */ 90 124 unsigned priority; … … 126 160 * @param pool Memory pool used to allocate memory for the query. 127 161 * @param resolver The resolver instance. 128 * @param fallback_a Specify if the resolver should fallback with DNS A 129 * resolution when the SRV resolution fails. 162 * @param option Option flags, which can be constructed from 163 * #pj_dns_srv_option bitmask. Note that this argument 164 * was called "fallback_a" in pjsip version 0.8.0 and 165 * older, but the new option should be backward 166 * compatible with existing applications. If application 167 * specifies PJ_TRUE as "fallback_a" value, it will 168 * correspond to PJ_DNS_SRV_FALLBACK_A option. 130 169 * @param token Arbitrary data to be associated with this query when 131 170 * the calback is called. … … 143 182 pj_pool_t *pool, 144 183 pj_dns_resolver *resolver, 145 pj_bool_t fallback_a,184 unsigned option, 146 185 void *token, 147 186 pj_dns_srv_resolver_cb *cb, -
pjproject/trunk/pjlib-util/src/pjlib-util/dns.c
r1364 r1587 30 30 switch (type) { 31 31 case PJ_DNS_TYPE_A: return "A"; 32 case PJ_DNS_TYPE_AAAA: return "AAAA"; 32 33 case PJ_DNS_TYPE_SRV: return "SRV"; 33 34 case PJ_DNS_TYPE_NS: return "NS"; … … 346 347 pj_memcpy(&rr->rdata.a.ip_addr, p, 4); 347 348 p += 4; 349 350 } else if (rr->type == PJ_DNS_TYPE_AAAA) { 351 pj_memcpy(&rr->rdata.aaaa.ip_addr, p, 16); 352 p += 16; 348 353 349 354 } else if (rr->type == PJ_DNS_TYPE_CNAME || … … 592 597 } else if (src->type == PJ_DNS_TYPE_A) { 593 598 dst->rdata.a.ip_addr.s_addr = src->rdata.a.ip_addr.s_addr; 599 } else if (src->type == PJ_DNS_TYPE_AAAA) { 600 pj_memcpy(&dst->rdata.aaaa.ip_addr, &src->rdata.aaaa.ip_addr, 601 sizeof(pj_in6_addr)); 594 602 } else if (src->type == PJ_DNS_TYPE_CNAME) { 595 603 pj_strdup(pool, &dst->rdata.cname.name, &src->rdata.cname.name); -
pjproject/trunk/pjlib-util/src/pjlib-util/dns_dump.c
r1031 r1587 118 118 PJ_LOG(3,(THIS_FILE, " IP address: %s", 119 119 pj_inet_ntoa(rr->rdata.a.ip_addr))); 120 } else if (rr->type == PJ_DNS_TYPE_AAAA) { 121 char addr[PJ_INET6_ADDRSTRLEN]; 122 PJ_LOG(3,(THIS_FILE, " IPv6 address: %s", 123 pj_inet_ntop(pj_AF_INET6(), &rr->rdata.aaaa.ip_addr, 124 addr, sizeof(addr)))); 120 125 } 121 126 } -
pjproject/trunk/pjlib-util/src/pjlib-util/srv_resolver.c
r1383 r1587 56 56 57 57 /* Original request: */ 58 pj_bool_t fallback_a;58 unsigned option; 59 59 pj_str_t full_name; 60 60 pj_str_t domain_part; … … 86 86 pj_pool_t *pool, 87 87 pj_dns_resolver *resolver, 88 pj_bool_t fallback_a,88 unsigned option, 89 89 void *token, 90 90 pj_dns_srv_resolver_cb *cb, … … 117 117 query_job->token = token; 118 118 query_job->cb = cb; 119 query_job-> fallback_a = fallback_a;119 query_job->option = option; 120 120 query_job->full_name = target_name; 121 121 query_job->domain_part.ptr = target_name.ptr + len; … … 418 418 419 419 /* Trigger error when fallback is disabled */ 420 if (query_job->fallback_a == PJ_FALSE) { 420 if ((query_job->option & 421 (PJ_DNS_SRV_FALLBACK_A | PJ_DNS_SRV_FALLBACK_AAAA)) == 0) 422 { 421 423 goto on_error; 422 424 } -
pjproject/trunk/pjlib/src/pj/sock_bsd.c
r1585 r1587 308 308 { 309 309 PJ_ASSERT_RETURN(src && dst && size, PJ_EINVAL); 310 311 *dst = '\0'; 312 310 313 PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL); 311 314
Note: See TracChangeset
for help on using the changeset viewer.