lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] multiple interfaces and multicast routing (outgoing)


From: Artem Pisarenko
Subject: [lwip-users] multiple interfaces and multicast routing (outgoing)
Date: Mon, 24 Dec 2012 10:25:53 +0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2

I have two netifs and want to send multicast udp datagrams on second one. How should I setup connection properly ?
I tried a lot of combinations:

Case #1 (no default netif):
outgoing_conn = netconn_new(NETCONN_UDP);
netconn_bind(outgoing_netconn, &netif2.ip_addr, 0);
netconn_connect(outgoing_netconn, &multicast_group_ipaddr, multicast_group_port);
netconn_send(outgoing_netconn, outgoing_udp_buf); // returns ERR_RTE

Case #2 (no default netif):
outgoing_conn = netconn_new(NETCONN_UDP);
netconn_connect(outgoing_netconn, &multicast_group_ipaddr, multicast_group_port);
netconn_send(outgoing_netconn, outgoing_udp_buf); // returns ERR_RTE

Case #3 (no default netif):
outgoing_conn = netconn_new(NETCONN_UDP);
netconn_join_leave_group(outgoing_conn, &multicast_group_ipaddr, &netif2.ip_addr, NETCONN_JOIN); netconn_connect(outgoing_netconn, &multicast_group_ipaddr, multicast_group_port);
netconn_send(outgoing_netconn, outgoing_udp_buf); // returns ERR_RTE

Case #4 (no default netif):
outgoing_conn = netconn_new(NETCONN_UDP);
netconn_bind(outgoing_netconn, &netif2.ip_addr, 0);
netconn_join_leave_group(outgoing_conn, &multicast_group_ipaddr, &netif2.ip_addr, NETCONN_JOIN); netconn_connect(outgoing_netconn, &multicast_group_ipaddr, multicast_group_port);
netconn_send(outgoing_netconn, outgoing_udp_buf); // returns ERR_RTE

Case #5 (netif1 set default):
outgoing_conn = netconn_new(NETCONN_UDP);
netconn_join_leave_group(outgoing_conn, &multicast_group_ipaddr, &netif2.ip_addr, NETCONN_JOIN); netconn_connect(outgoing_netconn, &multicast_group_ipaddr, multicast_group_port); netconn_send(outgoing_netconn, outgoing_udp_buf); // sends through first netif

Case #6 (netif1 set default):
outgoing_conn = netconn_new(NETCONN_UDP);
netconn_bind(outgoing_netconn, &netif2.ip_addr, 0);
netconn_join_leave_group(outgoing_conn, &multicast_group_ipaddr, &netif2.ip_addr, NETCONN_JOIN); netconn_connect(outgoing_netconn, &multicast_group_ipaddr, multicast_group_port);
netconn_send(outgoing_netconn, outgoing_udp_buf); // returns ERR_VAL

Case #7 (netif1 set default):
outgoing_conn = netconn_new(NETCONN_UDP);
netconn_bind(outgoing_netconn, &netif2.ip_addr, 0);
netconn_connect(outgoing_netconn, &multicast_group_ipaddr, multicast_group_port);
netconn_send(outgoing_netconn, outgoing_udp_buf); // returns ERR_VAL

I found solution here: http://lists.gnu.org/archive/html/lwip-users/2007-05/msg00038.html. But setting netif2 default isn't correct in general case.

I think problem comes from wrong IPv4 routing in lwip code.
udp_sendto() function:

#if LWIP_IPV6 || LWIP_IGMP
  if (ipX_addr_ismulticast(PCB_ISIPV6(pcb), dst_ip_route)) {
    /* For multicast, find a netif based on source address. */
#if LWIP_IPV6
    if (PCB_ISIPV6(pcb)) {
      dst_ip_route = &pcb->local_ip;
    } else
#endif /* LWIP_IPV6 */
    {
#if LWIP_IGMP
      dst_ip_route = ip_2_ipX(&pcb->multicast_ip);
#endif /* LWIP_IGMP */
    }
  }
#endif /* LWIP_IPV6 || LWIP_IGMP */

  /* find the outgoing network interface for this packet */
  netif = ipX_route(PCB_ISIPV6(pcb), &pcb->local_ip, dst_ip_route);

Firstly, first comment is wrong about IPv4. Secondly, pcb->multicast_ip is set only in lwip_setsockopt() and it's value is always zero in my case. Thirdly, even if pcb->multicast_ip was set to correct address, ip_route (IPv4) can't find correct netif based on multicast address only.

---
Regards, Artem




reply via email to

[Prev in Thread] Current Thread [Next in Thread]