Changeset 1744 for pjproject/trunk
- Timestamp:
- Jan 24, 2008 7:59:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c
r1714 r1744 71 71 af==PJ_AF_UNSPEC, PJ_EINVAL); 72 72 73 /* Check if nodename is IP address */ 74 pj_bzero(&ai[0], sizeof(ai[0])); 75 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 76 if (pj_inet_pton(af, nodename, pj_sockaddr_get_addr(&ai[0].ai_addr)) 77 == PJ_SUCCESS) 78 { 79 pj_str_t tmp; 80 81 tmp.ptr = ai[0].ai_canonname; 82 pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); 83 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 84 *count = 1; 85 86 return PJ_SUCCESS; 87 } 88 73 89 /* Copy node name to null terminated string. */ 74 90 if (nodename->slen >= PJ_MAX_HOSTNAME) … … 119 135 #else /* PJ_SOCK_HAS_GETADDRINFO */ 120 136 121 PJ_ASSERT_RETURN(count, PJ_EINVAL); 137 PJ_ASSERT_RETURN(count && *count, PJ_EINVAL); 138 139 /* Check if nodename is IP address */ 140 pj_bzero(&ai[0], sizeof(ai[0])); 141 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 142 if (pj_inet_pton(af, nodename, pj_sockaddr_get_addr(&ai[0].ai_addr)) 143 == PJ_SUCCESS) 144 { 145 pj_str_t tmp; 146 147 tmp.ptr = ai[0].ai_canonname; 148 pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); 149 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 150 *count = 1; 151 152 return PJ_SUCCESS; 153 } 122 154 123 155 if (af == PJ_AF_INET || af == PJ_AF_UNSPEC) {
Note: See TracChangeset
for help on using the changeset viewer.