improve syslog

This commit is contained in:
Thomas Bernard 2020-06-08 13:17:16 +02:00
parent e39549d6bb
commit d2ee52e4d9
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 11 additions and 10 deletions

View File

@ -1215,7 +1215,7 @@ static void ssdpDiscover(int s, int ipv6, const char * search)
n = sendto_or_schedule(s, bufr, n, 0, (const struct sockaddr *)&sockudp_w,
ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
if (n < 0) {
syslog(LOG_ERR, "%s: sendto: %m", __func__);
syslog(LOG_ERR, "%s: sendto(s=%d, ipv6=%d): %m", __func__, s, ipv6);
}
}
}

View File

@ -38,6 +38,7 @@ extern struct lan_addr_list lan_addrs;
int
AddDropMulticastMembership(int s, struct lan_addr_s * lan_addr, int ipv6, int drop)
{
int ret = 0;
struct ip_mreq imr; /* Ip multicast membership */
#ifdef ENABLE_IPV6
struct ipv6_mreq mr;
@ -56,21 +57,21 @@ AddDropMulticastMembership(int s, struct lan_addr_s * lan_addr, int ipv6, int dr
if(setsockopt(s, IPPROTO_IPV6, drop ? IPV6_LEAVE_GROUP : IPV6_JOIN_GROUP,
&mr, sizeof(struct ipv6_mreq)) < 0)
{
syslog(LOG_ERR, "setsockopt(udp, %s)(%s, %s): %m",
drop ? "IPV6_LEAVE_GROUP" : "IPV6_JOIN_GROUP",
syslog(LOG_ERR, "setsockopt(s=%d, %s)(%s, %s): %m",
s, drop ? "IPV6_LEAVE_GROUP" : "IPV6_JOIN_GROUP",
LL_SSDP_MCAST_ADDR,
lan_addr->ifname);
return -1;
ret = -1;
}
inet_pton(AF_INET6, SL_SSDP_MCAST_ADDR, &mr.ipv6mr_multiaddr);
if(setsockopt(s, IPPROTO_IPV6, drop ? IPV6_LEAVE_GROUP : IPV6_JOIN_GROUP,
&mr, sizeof(struct ipv6_mreq)) < 0)
{
syslog(LOG_ERR, "setsockopt(udp, %s)(%s, %s): %m",
drop ? "IPV6_LEAVE_GROUP" : "IPV6_JOIN_GROUP",
syslog(LOG_ERR, "setsockopt(s=%d, %s)(%s, %s): %m",
s, drop ? "IPV6_LEAVE_GROUP" : "IPV6_JOIN_GROUP",
SL_SSDP_MCAST_ADDR,
lan_addr->ifname);
return -1;
ret = -1;
}
}
else
@ -89,8 +90,8 @@ AddDropMulticastMembership(int s, struct lan_addr_s * lan_addr, int ipv6, int dr
if (setsockopt(s, IPPROTO_IP, drop ? IP_DROP_MEMBERSHIP : IP_ADD_MEMBERSHIP,
(void *)&imr, sizeof(struct ip_mreq)) < 0)
{
syslog(LOG_ERR, "setsockopt(udp, %s)(%s): %m",
drop ? "IP_DROP_MEMBERSHIP" : "IP_ADD_MEMBERSHIP",
syslog(LOG_ERR, "setsockopt(s=%d, %s)(%s): %m",
s, drop ? "IP_DROP_MEMBERSHIP" : "IP_ADD_MEMBERSHIP",
lan_addr->ifname);
return -1;
}
@ -98,7 +99,7 @@ AddDropMulticastMembership(int s, struct lan_addr_s * lan_addr, int ipv6, int dr
}
#endif /* ENABLE_IPV6 */
return 0;
return ret;
}
int