lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] ppp-new IP forwarding only works one direction (Ethernet to


From: LMao
Subject: [lwip-users] ppp-new IP forwarding only works one direction (Ethernet to PPP)
Date: Wed, 9 Apr 2014 18:47:43 +0000

Hi Sylvain,

I try to get IP forwarding work between two interfaces - Ethernet and PPP. So 
far, I can see it works in one direction, i.e., Packets from Ethernet can be 
forward to PPP, but it seems lwIP stack silently drop the packets in the 
opposite direction, i.e., from PPP to Ethernet. Can you think of any reason 
causing the problem?

In order to forward packets between two interfaces, I slightly modified 
ip_forward function in ip4.c. As shown in the following code snippet, I 
eliminate the call to ip_route function. Instead, I just route traffic from one 
interface to the other interface and also print out debug message showing which 
interface is used for forwarding (either Ethernet interface "em" or PPP 
interface "pp" as shown in the log at the bottom.)

// -----------------------------------------------------
// !!! Really bad action !!! Hacking lwIP stack for experiement only
// -----------------------------------------------------
#if 0
  /* Find network interface where to forward this IP packet to. */
  netif = ip_route(ip_current_dest_addr());
  if (netif == NULL) {
    LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 
%"U16_F".%"U16_F".%"U16_F".%"U16_F" found\n",
      ip4_addr1_16(ip_current_dest_addr()), 
ip4_addr2_16(ip_current_dest_addr()),
      ip4_addr3_16(ip_current_dest_addr()), 
ip4_addr4_16(ip_current_dest_addr())));
    /* @todo: send ICMP_DUR_NET? */
    goto return_noroute;
  }
#endif

  for (netif = netif_list; netif != NULL; netif = netif->next) 
  {
    if (netif != inp)
    {
      LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forward packets to interface.%c%c\n",
        netif->name[0], netif->name[1]));
      break;
    }
  }
// -----------------------------------------------------
// !!! Really bad action !!! Hacking lwIP stack for experiement only
// -----------------------------------------------------



My test setup is like this:

                        Ethernet                                                
PPP
             PC   -------------  My gateway device  --------  Linux PPP server
192.168.0.211       192.168.0.50        192.168.1.105       192.168.1.106

I ping from my PC to the PPP server. Here's some logging messages showing the 
modified ip_forward function works as expected.

ip_input: iphdr->dest 0x6a01a8c0 netif->ip_addr 0x3200a8c0 (0x1a8c0, 0xa8c0, 
0x6a000000)
ip_input: iphdr->dest 0x6a01a8c0 netif->ip_addr 0x6901a8c0 (0x6a01a8c0, 
0x6901a8c0, 0x0)
ip_input: packet not for us.
ip_forward: forward packets to interface.pp
ip_forward: forwarding packet to 192.168.1.106
ip_input: iphdr->dest 0xd300a8c0 netif->ip_addr 0x6901a8c0 (0xd300a8c0, 
0x6901a8c0, 0x0)
ip_input: iphdr->dest 0xd300a8c0 netif->ip_addr 0x3200a8c0 (0xa8c0, 0xa8c0, 
0xd3000000)
ip_input: packet not for us.
ip_forward: forward packets to interface.em
ip_forward: forwarding packet to 192.168.0.211

I captured PPP traffic on the serial port and also captured Ethernet traffic 
using Wireshark. I can clearly see PPP traffic on both directions(into and out 
from the PPP server) and they are correct frames as expected. However, the 
traffic from PPP server to my PC NEVER showed up in Wireshark. It seems lwIP 
silently drop those packets. What should I do to find out the cause of the 
problem?

Thanks,

Charles




reply via email to

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