Fixed IPv6 socket setup.

FossilOrigin-Name: 659f7ef49476b7ad20873cd79acf6ee47ad479b82169e252d75ba94b0ea4511b
This commit is contained in:
7u83@mail.ru 2016-03-06 11:44:48 +00:00
parent 47e9660366
commit 6e2f6bbe33
2 changed files with 11 additions and 9 deletions

View File

@ -389,8 +389,9 @@ static int init_listen_addrs()
}
if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4) {
sock_addrtostr(ifa->ifa_addr, str, 100,1);
*strchr(str, ':') = 0;
sock_addrtostr(ifa->ifa_addr, str, 100,0);
printf("The converter has %s\n",str);
// *strchr(str, ':') = 0;
conf_listen_addrs[ctr] =
(char *) cw_setstr((uint8_t **) & conf_listen_addrs[ctr],
(uint8_t *) str, strlen(str));
@ -398,9 +399,11 @@ static int init_listen_addrs()
ctr++;
}
#ifdef WITH_IPV6
if (ifa->ifa_addr->sa_family == AF_INET6 && conf_ipv6) {
sock_addrtostr(ifa->ifa_addr, str, 100,1);
sock_addrtostr(ifa->ifa_addr, str, 100,0);
printf("The converter has %s\n",str);
if (strncmp(str, "fe80:", 5) == 0) {
strcat(str, "%");
strcat(str, ifa->ifa_name);
@ -411,7 +414,6 @@ static int init_listen_addrs()
if (conf_listen_addrs[ctr])
ctr++;
}
#endif
}
conf_listen_addrs_len = ctr;
rc = 1;

View File

@ -245,7 +245,7 @@ int socklist_add_multicast(const char *addr, const char *port, int ac_proto)
/* bind address */
if (bind(sockfd, sa, sock_addrlen(sa)) < 0) {
close(sockfd);
cw_log(LOG_ERR, "Can't bind multicast %s: %s", addr,
cw_log(LOG_ERR, "Can't bind multicast %s: %s", addr,
strerror(errno));
continue;
}
@ -330,10 +330,10 @@ static int socklist_check_size()
}
int socklist_add_unicast(const char *addr, const char *port, int ac_proto)
{
if (!socklist_check_size())
return 0;
@ -377,7 +377,7 @@ int socklist_add_unicast(const char *addr, const char *port, int ac_proto)
/* bind address */
if (bind(sockfd, sa, sock_addrlen(sa)) < 0) {
close(sockfd);
cw_log(LOG_ERR, "Can't bind unicast socket %s: %s", addr,
cw_log(LOG_ERR, "Can't bind unicast socket %s: %s", addr,
strerror(errno));
continue;
}
@ -399,7 +399,7 @@ int socklist_add_unicast(const char *addr, const char *port, int ac_proto)
"Bound to: %s:%s (%i) on interface %s, netmask %s", addr,
port, sockfd, ifname, sock_addr2str(&netmask));
} else {
cw_log(LOG_INFO, "Bound to: %s:%s (%i) on interface %s", addr,
cw_log(LOG_INFO, "Bound to: [%s]:%s (%i) on interface %s", addr,
port, sockfd, ifname);
}
socklist_len++;