Mercurial > hg > freeDiameter
comparison freeDiameter/server.c @ 378:41e3c2a3721c
Replaced old mechanism to discover local addresses by a call to getifaddrs, lot cleaner!
Should close #4
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Mon, 05 Jul 2010 16:21:22 +0900 |
parents | 5df55136361b |
children | 478173cb832a |
comparison
equal
deleted
inserted
replaced
377:7c0ddec9ab42 | 378:41e3c2a3721c |
---|---|
267 CHECK_MALLOC( s = new_serv(IPPROTO_SCTP, 0) ); | 267 CHECK_MALLOC( s = new_serv(IPPROTO_SCTP, 0) ); |
268 CHECK_MALLOC( s->conn = fd_cnx_serv_sctp(fd_g_config->cnf_port, FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints) ? NULL : &fd_g_config->cnf_endpoints) ); | 268 CHECK_MALLOC( s->conn = fd_cnx_serv_sctp(fd_g_config->cnf_port, FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints) ? NULL : &fd_g_config->cnf_endpoints) ); |
269 fd_list_insert_before( &FD_SERVERS, &s->chain ); | 269 fd_list_insert_before( &FD_SERVERS, &s->chain ); |
270 CHECK_POSIX( pthread_create( &s->thr, NULL, serv_th, s ) ); | 270 CHECK_POSIX( pthread_create( &s->thr, NULL, serv_th, s ) ); |
271 | 271 |
272 /* Retrieve the list of endpoints if it was empty */ | |
273 if (empty_conf_ep) { | |
274 (void) fd_cnx_getendpoints(s->conn, &fd_g_config->cnf_endpoints, NULL); | |
275 if (TRACE_BOOL(FULL)){ | |
276 fd_log_debug(" Local server address(es) :\n"); | |
277 fd_ep_dump( 5, &fd_g_config->cnf_endpoints ); | |
278 } | |
279 } | |
280 | |
281 /* Create the server on secure port */ | 272 /* Create the server on secure port */ |
282 CHECK_MALLOC( s = new_serv(IPPROTO_SCTP, 1) ); | 273 CHECK_MALLOC( s = new_serv(IPPROTO_SCTP, 1) ); |
283 CHECK_MALLOC( s->conn = fd_cnx_serv_sctp(fd_g_config->cnf_port_tls, FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints) ? NULL : &fd_g_config->cnf_endpoints) ); | 274 CHECK_MALLOC( s->conn = fd_cnx_serv_sctp(fd_g_config->cnf_port_tls, FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints) ? NULL : &fd_g_config->cnf_endpoints) ); |
284 fd_list_insert_before( &FD_SERVERS, &s->chain ); | 275 fd_list_insert_before( &FD_SERVERS, &s->chain ); |
285 CHECK_POSIX( pthread_create( &s->thr, NULL, serv_th, s ) ); | 276 CHECK_POSIX( pthread_create( &s->thr, NULL, serv_th, s ) ); |
341 CHECK_POSIX( pthread_create( &s->thr, NULL, serv_th, s ) ); | 332 CHECK_POSIX( pthread_create( &s->thr, NULL, serv_th, s ) ); |
342 } | 333 } |
343 } | 334 } |
344 } | 335 } |
345 | 336 |
337 /* Now, if we still have not got the list of local adresses, try to read it from the kernel directly */ | |
338 if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) { | |
339 CHECK_FCT(fd_cnx_get_local_eps(&fd_g_config->cnf_endpoints)); | |
340 if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) { | |
341 TRACE_DEBUG(INFO, "Unable to find the addresses of the local system. Please use \"ListenOn\" parameter in the configuration."); | |
342 return EINVAL; | |
343 } | |
344 } | |
345 if (TRACE_BOOL(FULL)){ | |
346 fd_log_debug(" Local server address(es) :\n"); | |
347 fd_ep_dump( 5, &fd_g_config->cnf_endpoints ); | |
348 } | |
346 return 0; | 349 return 0; |
347 } | 350 } |
348 | 351 |
349 /* Terminate all the servers */ | 352 /* Terminate all the servers */ |
350 int fd_servers_stop() | 353 int fd_servers_stop() |