Changeset 3049 for pjproject/trunk
- Timestamp:
- Jan 8, 2010 10:02:51 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_resolve.c
r2394 r3049 199 199 /* No type or explicit port is specified, and the address is 200 200 * not IP address. 201 * In this case, full resolution must be performed.201 * In this case, full NAPTR resolution must be performed. 202 202 * But we don't support it (yet). 203 203 */ … … 226 226 */ 227 227 if (ip_addr_ver || resolver->res == NULL) { 228 229 char ip_addr[PJ_INET6_ADDRSTRLEN]; 230 int af; 231 pj_addrinfo ai; 232 unsigned count; 228 char addr_str[PJ_INET6_ADDRSTRLEN+10]; 233 229 pj_uint16_t srv_port; 234 230 235 if (!ip_addr_ver) { 236 PJ_LOG(5,(THIS_FILE, 231 if (ip_addr_ver != 0) { 232 /* Target is an IP address, no need to resolve */ 233 if (ip_addr_ver == 4) { 234 svr_addr.entry[0].addr.addr.sa_family = pj_AF_INET(); 235 pj_inet_aton(&target->addr.host, 236 &svr_addr.entry[0].addr.ipv4.sin_addr); 237 } else { 238 svr_addr.entry[0].addr.addr.sa_family = pj_AF_INET6(); 239 pj_inet_pton(pj_AF_INET6(), &target->addr.host, 240 &svr_addr.entry[0].addr.ipv4.sin_addr); 241 } 242 } else { 243 pj_addrinfo ai; 244 unsigned count; 245 int af; 246 247 PJ_LOG(5,(THIS_FILE, 237 248 "DNS resolver not available, target '%.*s:%d' type=%s " 238 "will be resolved with get hostbyname()",249 "will be resolved with getaddrinfo()", 239 250 target->addr.host.slen, 240 251 target->addr.host.ptr, 241 252 target->addr.port, 242 253 pjsip_transport_get_type_name(target->type))); 254 255 if (type & PJSIP_TRANSPORT_IPV6) { 256 af = pj_AF_INET6(); 257 } else { 258 af = pj_AF_INET(); 259 } 260 261 /* Resolve */ 262 count = 1; 263 status = pj_getaddrinfo(af, &target->addr.host, &count, &ai); 264 if (status != PJ_SUCCESS) 265 goto on_error; 266 267 svr_addr.entry[0].addr.addr.sa_family = (pj_uint16_t)af; 268 pj_memcpy(&svr_addr.entry[0].addr, &ai.ai_addr, 269 sizeof(pj_sockaddr)); 243 270 } 244 271 245 /* Set the port number if not specified.*/272 /* Set the port number */ 246 273 if (target->addr.port == 0) { 247 274 srv_port = (pj_uint16_t) … … 250 277 srv_port = (pj_uint16_t)target->addr.port; 251 278 } 252 253 if (type & PJSIP_TRANSPORT_IPV6) { 254 af = pj_AF_INET6(); 255 } else { 256 af = pj_AF_INET(); 257 } 258 259 /* Resolve */ 260 count = 1; 261 status = pj_getaddrinfo(af, &target->addr.host, &count, &ai); 262 if (status != PJ_SUCCESS) 263 goto on_error; 264 265 svr_addr.entry[0].addr.addr.sa_family = (pj_uint16_t)af; 266 pj_memcpy(&svr_addr.entry[0].addr, &ai.ai_addr, sizeof(pj_sockaddr)); 267 268 if (af == pj_AF_INET6()) { 269 svr_addr.entry[0].addr.ipv6.sin6_port = pj_htons(srv_port); 270 } else { 271 svr_addr.entry[0].addr.ipv4.sin_port = pj_htons(srv_port); 272 } 279 pj_sockaddr_set_port(&svr_addr.entry[0].addr, srv_port); 273 280 274 281 /* Call the callback. */ 275 282 PJ_LOG(5,(THIS_FILE, 276 283 "Target '%.*s:%d' type=%s resolved to " 277 "'%s :%d' type=%s (%s)",284 "'%s' type=%s (%s)", 278 285 (int)target->addr.host.slen, 279 286 target->addr.host.ptr, 280 287 target->addr.port, 281 288 pjsip_transport_get_type_name(target->type), 282 pj_inet_ntop2(af, pj_sockaddr_get_addr(&svr_addr.entry[0].addr), 283 ip_addr, sizeof(ip_addr)), 284 srv_port, 289 pj_sockaddr_print(&svr_addr.entry[0].addr, addr_str, 290 sizeof(addr_str), 3), 285 291 pjsip_transport_get_type_name(type), 286 292 pjsip_transport_get_type_desc(type)));
Note: See TracChangeset
for help on using the changeset viewer.