Changeset 3044 for pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c
- Timestamp:
- Jan 4, 2010 4:54:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c
r2394 r3044 74 74 /* Check if nodename is IP address */ 75 75 pj_bzero(&ai[0], sizeof(ai[0])); 76 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 77 if (pj_inet_pton(af, nodename, pj_sockaddr_get_addr(&ai[0].ai_addr)) 78 == PJ_SUCCESS) 79 { 80 pj_str_t tmp; 81 82 tmp.ptr = ai[0].ai_canonname; 83 pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); 84 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 85 *count = 1; 86 87 return PJ_SUCCESS; 76 if (af == PJ_AF_UNSPEC) { 77 if (pj_inet_pton(PJ_AF_INET, nodename, 78 &ai[0].ai_addr.ipv4.sin_addr) == PJ_SUCCESS) 79 { 80 af = PJ_AF_INET; 81 } 82 else if (pj_inet_pton(PJ_AF_INET6, nodename, 83 &ai[0].ai_addr.ipv6.sin6_addr) == PJ_SUCCESS) 84 { 85 af = PJ_AF_INET6; 86 } 87 88 if (af != PJ_AF_UNSPEC) { 89 pj_str_t tmp; 90 91 tmp.ptr = ai[0].ai_canonname; 92 pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); 93 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 94 *count = 1; 95 96 return PJ_SUCCESS; 97 } 88 98 } 89 99 … … 122 132 PJ_ASSERT_ON_FAIL(res->ai_addrlen <= sizeof(pj_sockaddr), continue); 123 133 pj_memcpy(&ai[i].ai_addr, res->ai_addr, res->ai_addrlen); 134 PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr); 124 135 125 136 /* Next slot */ … … 140 151 /* Check if nodename is IP address */ 141 152 pj_bzero(&ai[0], sizeof(ai[0])); 142 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 143 if (pj_inet_pton(af, nodename, pj_sockaddr_get_addr(&ai[0].ai_addr)) 144 == PJ_SUCCESS) 145 { 146 pj_str_t tmp; 147 148 tmp.ptr = ai[0].ai_canonname; 149 pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); 150 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 151 *count = 1; 152 153 return PJ_SUCCESS; 153 if (af == PJ_AF_UNSPEC) { 154 if (pj_inet_pton(PJ_AF_INET, nodename, 155 &ai[0].ai_addr.ipv4.sin_addr) == PJ_SUCCESS) 156 { 157 af = PJ_AF_INET; 158 } 159 else if (pj_inet_pton(PJ_AF_INET6, nodename, 160 &ai[0].ai_addr.ipv6.sin6_addr) == PJ_SUCCESS) 161 { 162 af = PJ_AF_INET6; 163 } 164 165 if (af != PJ_AF_UNSPEC) { 166 pj_str_t tmp; 167 168 tmp.ptr = ai[0].ai_canonname; 169 pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); 170 ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; 171 *count = 1; 172 173 return PJ_SUCCESS; 174 } 154 175 } 155 176 … … 181 202 pj_memcpy(&ai[*count].ai_addr.ipv4.sin_addr, 182 203 he.h_addr_list[i], he.h_length); 204 PJ_SOCKADDR_RESET_LEN(&ai[*count].ai_addr); 183 205 184 206 (*count)++;
Note: See TracChangeset
for help on using the changeset viewer.