comparison freeDiameter/cnxctx.c @ 220:5f2ce627db3c

Try to fix the old bug on sctp_getpaddrs
author Sebastien Decugis <sdecugis@nict.go.jp>
date Fri, 19 Feb 2010 18:09:43 +0900
parents 5a1b93f59f8f
children 85dc47afeac7
comparison
equal deleted inserted replaced
219:e5bcc8c9322e 220:5f2ce627db3c
119 memset(&dummy, 0, sizeof(dummy)); 119 memset(&dummy, 0, sizeof(dummy));
120 sa->sa_family = family; 120 sa->sa_family = family;
121 } 121 }
122 if (sa->sa_family == AF_INET) { 122 if (sa->sa_family == AF_INET) {
123 ((sSA4 *)sa)->sin_port = htons(port); 123 ((sSA4 *)sa)->sin_port = htons(port);
124 cnx->cc_family = AF_INET;
124 } else { 125 } else {
125 ((sSA6 *)sa)->sin6_port = htons(port); 126 ((sSA6 *)sa)->sin6_port = htons(port);
127 cnx->cc_family = AF_INET6;
126 } 128 }
127 129
128 /* Create the socket */ 130 /* Create the socket */
129 CHECK_FCT_DO( fd_tcp_create_bind_server( &cnx->cc_socket, sa, sizeof(sSS) ), goto error ); 131 CHECK_FCT_DO( fd_tcp_create_bind_server( &cnx->cc_socket, sa, sizeof(sSS) ), goto error );
130 132
164 CHECK_PARAMS_DO( port, return NULL ); 166 CHECK_PARAMS_DO( port, return NULL );
165 167
166 /* The connection object */ 168 /* The connection object */
167 CHECK_MALLOC_DO( cnx = fd_cnx_init(0), return NULL ); 169 CHECK_MALLOC_DO( cnx = fd_cnx_init(0), return NULL );
168 170
171 if (fd_g_config->cnf_flags.no_ip6) {
172 cnx->cc_family = AF_INET;
173 } else {
174 cnx->cc_family = AF_INET6; /* can create socket for both IP and IPv6 */
175 }
176
169 /* Create the socket */ 177 /* Create the socket */
170 CHECK_FCT_DO( fd_sctp_create_bind_server( &cnx->cc_socket, ep_list, port ), goto error ); 178 CHECK_FCT_DO( fd_sctp_create_bind_server( &cnx->cc_socket, cnx->cc_family, ep_list, port ), goto error );
171 179
172 /* Generate the name for the connection object */ 180 /* Generate the name for the connection object */
173 snprintf(cnx->cc_id, sizeof(cnx->cc_id), "SCTP srv :%hu (%d)", port, cnx->cc_socket); 181 snprintf(cnx->cc_id, sizeof(cnx->cc_id), "SCTP srv :%hu (%d)", port, cnx->cc_socket);
174 182
175 cnx->cc_proto = IPPROTO_SCTP; 183 cnx->cc_proto = IPPROTO_SCTP;
226 fd_log_debug("].\n"); 234 fd_log_debug("].\n");
227 } 235 }
228 236
229 CHECK_MALLOC_DO( cli = fd_cnx_init(1), { shutdown(cli_sock, SHUT_RDWR); close(cli_sock); return NULL; } ); 237 CHECK_MALLOC_DO( cli = fd_cnx_init(1), { shutdown(cli_sock, SHUT_RDWR); close(cli_sock); return NULL; } );
230 cli->cc_socket = cli_sock; 238 cli->cc_socket = cli_sock;
239 cli->cc_family = serv->cc_family;
231 cli->cc_proto = serv->cc_proto; 240 cli->cc_proto = serv->cc_proto;
232 241
233 /* Set the timeout */ 242 /* Set the timeout */
234 fd_cnx_s_setto(cli->cc_socket); 243 fd_cnx_s_setto(cli->cc_socket);
235 244
294 303
295 /* Once the socket is created successfuly, prepare the remaining of the cnx */ 304 /* Once the socket is created successfuly, prepare the remaining of the cnx */
296 CHECK_MALLOC_DO( cnx = fd_cnx_init(1), { shutdown(sock, SHUT_RDWR); close(sock); return NULL; } ); 305 CHECK_MALLOC_DO( cnx = fd_cnx_init(1), { shutdown(sock, SHUT_RDWR); close(sock); return NULL; } );
297 306
298 cnx->cc_socket = sock; 307 cnx->cc_socket = sock;
308 cnx->cc_family = sa->sa_family;
299 cnx->cc_proto = IPPROTO_TCP; 309 cnx->cc_proto = IPPROTO_TCP;
300 310
301 /* Set the timeout */ 311 /* Set the timeout */
302 fd_cnx_s_setto(cnx->cc_socket); 312 fd_cnx_s_setto(cnx->cc_socket);
303 313
344 354
345 /* Once the socket is created successfuly, prepare the remaining of the cnx */ 355 /* Once the socket is created successfuly, prepare the remaining of the cnx */
346 CHECK_MALLOC_DO( cnx = fd_cnx_init(1), { shutdown(sock, SHUT_RDWR); close(sock); return NULL; } ); 356 CHECK_MALLOC_DO( cnx = fd_cnx_init(1), { shutdown(sock, SHUT_RDWR); close(sock); return NULL; } );
347 357
348 cnx->cc_socket = sock; 358 cnx->cc_socket = sock;
359 cnx->cc_family = no_ip6 ? AF_INET : AF_INET6;
349 cnx->cc_proto = IPPROTO_SCTP; 360 cnx->cc_proto = IPPROTO_SCTP;
350 361
351 /* Set the timeout */ 362 /* Set the timeout */
352 fd_cnx_s_setto(cnx->cc_socket); 363 fd_cnx_s_setto(cnx->cc_socket);
353 364
"Welcome to our mercurial repository"