From 03159254cee404b38587d2d13f46b5c4000976d1 Mon Sep 17 00:00:00 2001 From: sg Date: Sun, 22 Feb 2015 21:49:46 +0100 Subject: [PATCH] added proper accessor functions for pcb->multicast_ip (previously used by get/setsockopt only) --- CHANGELOG | 6 +++++- src/api/sockets.c | 10 +++++++--- src/include/lwip/udp.h | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 31b25961..e39e0bfa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -202,6 +202,10 @@ HISTORY ++ Bugfixes: + 2015-02-22: Simon Goldschmidt + * udp.h, sockets.c: added proper accessor functions for pcb->multicast_ip + (previously used by get/setsockopt only) + 2015-02-18: Simon Goldschmidt * sockets.c: Fixed select not reporting received FIN as 'readable' in certain rare cases (bug #43779: select(), close(), and TCP retransmission error) @@ -209,7 +213,7 @@ HISTORY 2015-02-17: Simon Goldschmidt * err.h, sockets.c, api_msg.c: fixed bug #38853 "connect() use a wrong errno": return ERR_ALREADY/EALRADY during connect, ERR_ISCONN/EISCONN when already - connected + connected 2015-02-17: Simon Goldschmidt * tcp_impl.h, tcp_out.c, tcp.c, api_msg.c: fixed bug #37614 "Errors from diff --git a/src/api/sockets.c b/src/api/sockets.c index d298096f..1e349212 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1784,7 +1784,7 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_UDP) { return ENOPROTOOPT; } - inet_addr_from_ipaddr((struct in_addr*)optval, &sock->conn->pcb.udp->multicast_ip); + inet_addr_from_ipaddr((struct in_addr*)optval, udp_get_multicast_netif_addr(sock->conn->pcb.udp)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_IF) = 0x%"X32_F"\n", s, *(u32_t *)optval)); break; @@ -2135,8 +2135,12 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_ sock->conn->pcb.udp->ttl = (u8_t)(*(u8_t*)optval); break; case IP_MULTICAST_IF: - LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct in_addr, NETCONN_UDP); - inet_addr_to_ipaddr(&sock->conn->pcb.udp->multicast_ip, (struct in_addr*)optval); + { + ip_addr_t if_addr; + LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct in_addr, NETCONN_UDP); + inet_addr_to_ipaddr(&if_addr, (struct in_addr*)optval); + udp_set_multicast_netif_addr(sock->conn->pcb.udp, &if_addr); + } break; case IP_MULTICAST_LOOP: LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, u8_t, NETCONN_UDP); diff --git a/src/include/lwip/udp.h b/src/include/lwip/udp.h index 24f84f4a..39c5a6a7 100644 --- a/src/include/lwip/udp.h +++ b/src/include/lwip/udp.h @@ -206,6 +206,11 @@ struct udp_pcb * udp_new_ip6(void); #endif /*LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ #endif /* LWIP_IPV6 */ +#if LWIP_IGMP +#define udp_set_multicast_netif_addr(pcb, ip4addr) ((pcb)->multicast_ip = *(ip4addr)) +#define udp_get_multicast_netif_addr(pcb) (&(pcb)->multicast_ip) +#endif /* LWIP_IGMP */ + #if UDP_DEBUG void udp_debug_print(struct udp_hdr *udphdr); #else