Changeset 472 for trunk/src/sh_calls.c
- Timestamp:
- May 29, 2015, 7:08:24 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_calls.c
r412 r472 153 153 reject = 1; 154 154 155 #if defined(USE_IPVX)156 155 if (0 == sh_ipvx_aton(str, &bind_addr)) 157 156 return -1; 158 #else159 if (0 == inet_aton(str, &(bind_addr.sin.sin_addr)))160 return -1;161 #endif162 157 163 158 use_bind_addr = 1; … … 170 165 { 171 166 int error; 167 int err_bind = 0; 172 168 long int val_retry = 0; 173 169 char errbuf[SH_ERRBUF_SIZE]; … … 177 173 errno = 0; 178 174 179 if ( 0 !=use_bind_addr)175 if (use_bind_addr) 180 176 { 181 177 int slen = SH_SS_LEN(bind_addr); 182 183 val_retry = bind(sockfd, sh_ipvx_sockaddr_cast(&bind_addr), slen); 178 struct sockaddr *b_addr = sh_ipvx_sockaddr_cast(&bind_addr); 179 180 if (bind_addr.ss_family == AF_INET) 181 b_addr->sa_family = AF_INET; 182 #if defined(USE_IPVX) 183 else 184 b_addr->sa_family = AF_INET6; 185 #endif 186 val_retry = bind(sockfd, b_addr, slen); 184 187 } 185 188 … … 190 193 } while (val_retry < 0 && (errno == EINTR || errno == EINPROGRESS)); 191 194 } 195 else 196 { 197 err_bind = 1; 198 } 192 199 193 200 error = errno; … … 195 202 long eport; 196 203 char eaddr[SH_IP_BUF]; 197 204 char emesg[SH_BUFSIZE]; 205 struct sockaddr *err_addr = serv_addr; 198 206 struct sh_sockaddr ss; 199 sh_ipvx_save(&ss, serv_addr->sa_family, serv_addr); 207 208 if (err_bind) 209 err_addr = sh_ipvx_sockaddr_cast(&bind_addr); 210 211 sh_ipvx_save(&ss, err_addr->sa_family, err_addr); 200 212 sh_ipvx_ntoa(eaddr, sizeof(eaddr), &ss); 201 213 202 if ( serv_addr->sa_family == AF_INET)214 if (err_addr->sa_family == AF_INET) 203 215 eport = (long) ntohs(((struct sockaddr_in *)serv_addr)->sin_port); 216 #if defined(USE_IPVX) 204 217 else 205 218 eport = (long) ntohs(((struct sockaddr_in6 *)serv_addr)->sin6_port); 206 207 sh_error_handle ((-1), file, line, error, MSG_ERR_CONNECT, 208 sh_error_message(error, errbuf, sizeof(errbuf)), 219 #endif 220 221 sl_strlcpy(emesg, sh_error_message(error, errbuf, sizeof(errbuf)), sizeof(emesg)); 222 sl_strlcat(emesg, 223 (err_addr->sa_family == AF_INET) ? _(", AF_INET") : _(", AF_INET6"), 224 sizeof(emesg)); 225 226 sl_strlcat(emesg, 227 (err_bind) ? _(", bind") : _(", connect"), 228 sizeof(emesg)); 229 230 sh_error_handle ((-1), file, line, error, MSG_ERR_CONNECT, 231 emesg, 209 232 (long) sockfd, eport, eaddr); 210 233 }
Note:
See TracChangeset
for help on using the changeset viewer.