struct udp_pcb.multicast_ip must be an ip_addr_t, too, to completely avoid temporary storage

This commit is contained in:
goldsimon 2015-09-24 14:55:55 +02:00
parent e11e12f01d
commit 99d2e5233d
2 changed files with 6 additions and 10 deletions

View File

@ -570,9 +570,6 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ #endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
struct netif *netif; struct netif *netif;
const ip_addr_t *dst_ip_route = dst_ip; const ip_addr_t *dst_ip_route = dst_ip;
#if LWIP_IPV6 && LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS
ip_addr_t dst_ip_tmp;
#endif /* LWIP_IPV6 && LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS */
if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) { if ((pcb == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
return ERR_VAL; return ERR_VAL;
@ -594,10 +591,9 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
administratively selected interface for multicast by default. administratively selected interface for multicast by default.
However, this can be overridden by setting an interface address However, this can be overridden by setting an interface address
in pcb->multicast_ip that is used for routing. */ in pcb->multicast_ip that is used for routing. */
if (!ip4_addr_isany(&pcb->multicast_ip) && if (!ip_addr_isany(&pcb->multicast_ip) &&
!ip4_addr_cmp(&pcb->multicast_ip, IP4_ADDR_BROADCAST)) { !ip4_addr_cmp(ip_2_ip4(&pcb->multicast_ip), IP4_ADDR_BROADCAST)) {
ip_addr_copy_from_ip4(dst_ip_tmp, pcb->multicast_ip); dst_ip_route = & pcb->multicast_ip;
dst_ip_route = &dst_ip_tmp;
} }
#endif /* LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS */ #endif /* LWIP_IPV4 && LWIP_MULTICAST_TX_OPTIONS */
} }

View File

@ -102,7 +102,7 @@ struct udp_pcb {
#if LWIP_MULTICAST_TX_OPTIONS #if LWIP_MULTICAST_TX_OPTIONS
/** outgoing network interface for multicast packets */ /** outgoing network interface for multicast packets */
ip4_addr_t multicast_ip; ip_addr_t multicast_ip;
/** TTL for outgoing multicast packets */ /** TTL for outgoing multicast packets */
u8_t mcast_ttl; u8_t mcast_ttl;
#endif /* LWIP_MULTICAST_TX_OPTIONS */ #endif /* LWIP_MULTICAST_TX_OPTIONS */
@ -169,8 +169,8 @@ struct udp_pcb * udp_new_ip6(void);
#endif /* LWIP_IPV6 */ #endif /* LWIP_IPV6 */
#if LWIP_MULTICAST_TX_OPTIONS #if LWIP_MULTICAST_TX_OPTIONS
#define udp_set_multicast_netif_addr(pcb, ip4addr) do { (pcb)->multicast_ip = *(ip4addr); } while(0) #define udp_set_multicast_netif_addr(pcb, ip4addr) ip_addr_copy_from_ip4((pcb)->multicast_ip, *(ip4addr))
#define udp_get_multicast_netif_addr(pcb) (&(pcb)->multicast_ip) #define udp_get_multicast_netif_addr(pcb) ip_2_ip4(&(pcb)->multicast_ip)
#define udp_set_multicast_ttl(pcb, value) do { (pcb)->mcast_ttl = value; } while(0) #define udp_set_multicast_ttl(pcb, value) do { (pcb)->mcast_ttl = value; } while(0)
#define udp_get_multicast_ttl(pcb) ((pcb)->mcast_ttl) #define udp_get_multicast_ttl(pcb) ((pcb)->mcast_ttl)
#endif /* LWIP_MULTICAST_TX_OPTIONS */ #endif /* LWIP_MULTICAST_TX_OPTIONS */