mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 01:23:48 +08:00
allow multicast socket options IP_MULTICAST_TTL, IP_MULTICAST_IF and IP_MULTICAST_LOOP to be used without IGMP
This commit is contained in:
@@ -102,6 +102,9 @@
|
||||
#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
|
||||
#error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS)
|
||||
#error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h"
|
||||
#endif
|
||||
#if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
|
||||
#error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
|
||||
#endif
|
||||
|
||||
@@ -101,7 +101,7 @@ struct ip_globals ip_data;
|
||||
/** The IP header ID of the next outgoing IP packet */
|
||||
static u16_t ip_id;
|
||||
|
||||
#if LWIP_IGMP
|
||||
#if LWIP_MULTICAST_TX_OPTIONS
|
||||
/** The default netif used for multicast */
|
||||
static struct netif* ip4_default_multicast_netif;
|
||||
|
||||
@@ -111,7 +111,7 @@ ip4_set_default_multicast_netif(struct netif* default_multicast_netif)
|
||||
{
|
||||
ip4_default_multicast_netif = default_multicast_netif;
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
/**
|
||||
* Finds the appropriate network interface for a given IP address. It
|
||||
@@ -895,11 +895,11 @@ err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_add
|
||||
LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()"));
|
||||
return netif_loop_output(netif, p);
|
||||
}
|
||||
#if LWIP_IGMP
|
||||
#if LWIP_MULTICAST_TX_OPTIONS
|
||||
if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) {
|
||||
netif_loop_output(netif, p);
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
#endif /* ENABLE_LOOPBACK */
|
||||
#if IP_FRAG
|
||||
/* don't fragment if interface has mtu set to 0 [loopif] */
|
||||
|
||||
@@ -551,13 +551,13 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
|
||||
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
|
||||
struct netif *netif;
|
||||
const ip_addr_t *dst_ip_route = dst_ip;
|
||||
#if LWIP_IPV6 && LWIP_IPV4 && LWIP_IGMP
|
||||
#if LWIP_IPV6 && LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS
|
||||
ip_addr_t dst_ip_tmp;
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV4 && LWIP_IGMP */
|
||||
#endif /* LWIP_IPV6 && LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n"));
|
||||
|
||||
#if LWIP_IPV6 || (LWIP_IPV4 && LWIP_IGMP)
|
||||
#if LWIP_IPV6 || (LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS)
|
||||
if (ip_addr_ismulticast(dst_ip_route)) {
|
||||
#if LWIP_IPV6
|
||||
if (PCB_ISIPV6(pcb)) {
|
||||
@@ -566,7 +566,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
|
||||
} else
|
||||
#endif /* LWIP_IPV6 */
|
||||
{
|
||||
#if LWIP_IPV4 && LWIP_IGMP
|
||||
#if LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS
|
||||
/* IPv4 does not use source-based routing by default, so we use an
|
||||
administratively selected interface for multicast by default.
|
||||
However, this can be overridden by setting an interface address
|
||||
@@ -575,10 +575,10 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
|
||||
!ip4_addr_cmp(&pcb->multicast_ip, IP4_ADDR_BROADCAST)) {
|
||||
dst_ip_route = ip4_2_ip(&pcb->multicast_ip, &dst_ip_tmp);
|
||||
}
|
||||
#endif /* LWIP_IPV4 && LWIP_IGMP */
|
||||
#endif /* LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS */
|
||||
}
|
||||
}
|
||||
#endif /* LWIP_IPV6 || LWIP_IGMP */
|
||||
#endif /* LWIP_IPV6 || (LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS) */
|
||||
|
||||
/* find the outgoing network interface for this packet */
|
||||
netif = ip_route(PCB_ISIPV6(pcb), &pcb->local_ip, dst_ip_route);
|
||||
@@ -758,11 +758,11 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d
|
||||
udphdr->chksum = 0x0000;
|
||||
|
||||
/* Multicast Loop? */
|
||||
#if (LWIP_IPV4 && LWIP_IGMP) || (LWIP_IPV6 && LWIP_IPV6_MLD)
|
||||
#if (LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS) || (LWIP_IPV6 && LWIP_IPV6_MLD)
|
||||
if (((pcb->flags & UDP_FLAGS_MULTICAST_LOOP) != 0) && ip_addr_ismulticast(dst_ip)) {
|
||||
q->flags |= PBUF_FLAG_MCASTLOOP;
|
||||
}
|
||||
#endif /* (LWIP_IPV4 && LWIP_IGMP) || (LWIP_IPV6 && LWIP_IPV6_MLD) */
|
||||
#endif /* (LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS) || (LWIP_IPV6 && LWIP_IPV6_MLD) */
|
||||
|
||||
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len));
|
||||
|
||||
@@ -846,11 +846,11 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d
|
||||
}
|
||||
|
||||
/* Determine TTL to use */
|
||||
#if LWIP_IGMP
|
||||
#if LWIP_MULTICAST_TX_OPTIONS
|
||||
ttl = (ip_addr_ismulticast(dst_ip) ? pcb->mcast_ttl : pcb->ttl);
|
||||
#else
|
||||
#else /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
ttl = pcb->ttl;
|
||||
#endif
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum));
|
||||
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,0x%02"X16_F",)\n", (u16_t)ip_proto));
|
||||
|
||||
Reference in New Issue
Block a user