comparison freeDiameter/p_cnx.c @ 370:06692259d788

Enforce address family from config when connecting to a peer
author Sebastien Decugis <sdecugis@nict.go.jp>
date Mon, 05 Jul 2010 11:07:02 +0900
parents 5df55136361b
children 2687aa506ef6
comparison
equal deleted inserted replaced
369:350e1cca3782 370:06692259d788
85 memset(&hints, 0, sizeof(hints)); 85 memset(&hints, 0, sizeof(hints));
86 hints.ai_flags = AI_ADDRCONFIG; 86 hints.ai_flags = AI_ADDRCONFIG;
87 ret = getaddrinfo(peer->p_hdr.info.pi_diamid, NULL, &hints, &ai); 87 ret = getaddrinfo(peer->p_hdr.info.pi_diamid, NULL, &hints, &ai);
88 if (ret) { 88 if (ret) {
89 fd_log_debug("Unable to resolve address for peer '%s' (%s), aborting\n", peer->p_hdr.info.pi_diamid, gai_strerror(ret)); 89 fd_log_debug("Unable to resolve address for peer '%s' (%s), aborting\n", peer->p_hdr.info.pi_diamid, gai_strerror(ret));
90 fd_psm_terminate( peer, NULL ); 90 if (ret != EAI_AGAIN)
91 fd_psm_terminate( peer, NULL );
91 return 0; 92 return 0;
92 } 93 }
93 94
94 for (aip = ai; aip != NULL; aip = aip->ai_next) { 95 for (aip = ai; aip != NULL; aip = aip->ai_next) {
95 CHECK_FCT( fd_ep_add_merge( &peer->p_hdr.info.pi_endpoints, aip->ai_addr, aip->ai_addrlen, EP_FL_DISC ) ); 96 CHECK_FCT( fd_ep_add_merge( &peer->p_hdr.info.pi_endpoints, aip->ai_addr, aip->ai_addrlen, EP_FL_DISC ) );
102 CHECK_FCT( fd_ep_filter_family( 103 CHECK_FCT( fd_ep_filter_family(
103 &peer->p_hdr.info.pi_endpoints, 104 &peer->p_hdr.info.pi_endpoints,
104 (peer->p_hdr.info.config.pic_flags.pro3 == PI_P3_IP) ? 105 (peer->p_hdr.info.config.pic_flags.pro3 == PI_P3_IP) ?
105 AF_INET 106 AF_INET
106 : AF_INET6)); 107 : AF_INET6));
108 }
109 if (fd_g_config->cnf_flags.no_ip4) {
110 CHECK_FCT( fd_ep_filter_family(
111 &peer->p_hdr.info.pi_endpoints,
112 AF_INET6));
113 }
114 if (fd_g_config->cnf_flags.no_ip6) {
115 CHECK_FCT( fd_ep_filter_family(
116 &peer->p_hdr.info.pi_endpoints,
117 AF_INET));
107 } 118 }
108 119
109 /* Now check we have at least one address to attempt */ 120 /* Now check we have at least one address to attempt */
110 if (FD_IS_LIST_EMPTY(&peer->p_hdr.info.pi_endpoints)) { 121 if (FD_IS_LIST_EMPTY(&peer->p_hdr.info.pi_endpoints)) {
111 fd_log_debug("No address %savailable to connect to peer '%s', aborting\n", peer->p_hdr.info.config.pic_flags.pro3 ? "in the configured family " : "", peer->p_hdr.info.pi_diamid); 122 fd_log_debug("No address %savailable to connect to peer '%s', aborting\n", peer->p_hdr.info.config.pic_flags.pro3 ? "in the configured family " : "", peer->p_hdr.info.pi_diamid);
"Welcome to our mercurial repository"