Commit 2b314427 authored by Pekka Pessi's avatar Pekka Pessi

tport_type_udp.c: made IP_ADD_MEMBERSHIP as portable

darcs-hash:20071119200109-55b16-9592308b0a1369513fcd342c7c029c83450481ef.gz
parent 9b63a81e
......@@ -134,25 +134,25 @@ int tport_udp_init_primary(tport_primary_t *pri,
/* Try to join to the multicast group */
/* Bind to the SIP address like
<sip:88.77.66.55:5060;maddr=224.0.1.75;transport=udp> */
struct ip_mreqn imr[1];
struct in_addr address;
struct ip_mreq imr[1];
struct in_addr iface;
memset(imr, 0, sizeof imr);
imr->imr_multiaddr = su->su_sin.sin_addr;
if (host_is_ip4_address(tpn->tpn_canon) &&
inet_pton(AF_INET, tpn->tpn_canon, &address) > 0) {
imr->imr_address = address;
inet_pton(AF_INET, tpn->tpn_canon, &iface) > 0) {
imr->imr_interface = iface;
}
if (setsockopt(s, SOL_IP, IP_ADD_MEMBERSHIP, imr, (sizeof imr)) < 0) {
if (setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, imr, (sizeof imr)) < 0) {
SU_DEBUG_3(("setsockopt(%s): %s\n",
"IP_ADD_MEMBERSHIP", su_strerror(su_errno())));
}
#if HAVE_IP_MULTICAST_LOOP
else
if (setsockopt(s, SOL_IP, IP_MULTICAST_LOOP, &one, sizeof one) < 0) {
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &one, sizeof one) < 0) {
SU_DEBUG_3(("setsockopt(%s): %s\n",
"IP_MULTICAST_LOOP", su_strerror(su_errno())));
}
......@@ -162,7 +162,7 @@ int tport_udp_init_primary(tport_primary_t *pri,
#if HAVE_IP_RECVERR
if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6) {
if (setsockopt(s, SOL_IP, IP_RECVERR, &one, sizeof(one)) < 0) {
if (setsockopt(s, IPPROTO_IP, IP_RECVERR, &one, sizeof(one)) < 0) {
if (ai->ai_family == AF_INET)
SU_DEBUG_3(("setsockopt(%s): %s\n",
"IPVRECVERR", su_strerror(su_errno())));
......@@ -172,7 +172,7 @@ int tport_udp_init_primary(tport_primary_t *pri,
#endif
#if HAVE_IPV6_RECVERR
if (ai->ai_family == AF_INET6) {
if (setsockopt(s, SOL_IPV6, IPV6_RECVERR, &one, sizeof(one)) < 0)
if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVERR, &one, sizeof(one)) < 0)
SU_DEBUG_3(("setsockopt(IPV6_RECVERR): %s\n", su_strerror(su_errno())));
events |= SU_WAIT_ERR;
}
......@@ -449,10 +449,10 @@ int tport_udp_error(tport_t const *self, su_sockaddr_t name[1])
for (c = CMSG_FIRSTHDR(msg); c; c = CMSG_NXTHDR(msg, c)) {
if (0
#if HAVE_IP_RECVERR
|| (c->cmsg_level == SOL_IP && c->cmsg_type == IP_RECVERR)
|| (c->cmsg_level == IPPROTO_IP && c->cmsg_type == IP_RECVERR)
#endif
#if HAVE_IPV6_RECVERR
|| (c->cmsg_level == SOL_IPV6 && c->cmsg_type == IPV6_RECVERR)
|| (c->cmsg_level == IPPROTO_IPV6 && c->cmsg_type == IPV6_RECVERR)
#endif
) {
char info[128];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment