lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Problem about the loopback


From: Aimar
Subject: Re: [lwip-users] Problem about the loopback
Date: Wed, 7 Sep 2011 10:36:25 +0800 (CST)

Hi, Kieran,
     I still get a little bit confused. If you don't swap them, the condition pcb->local_port == dest in the function lwip_udp_input will not be met. Does the pcb->local_port be modified somewhere? I show my code as below, could you help me check?
 
char test_data[10] = {'t', 'h', 'i','s','a','t','e','s','t','\0'};
char test_rcv_data[10];
const struct sockaddr test_sockaddr = {0, PF_INET, 0x30, 0x10, 0x7F, 0x00, 0x00, 0x01, 0,};
struct sockaddr test_rcv_sockaddr = {0, PF_INET, 0x30, 0x10, 0x7F, 0x00, 0x00, 0x01, 0,};
static int soc = -1;

void test_send(void)
{
 lwip_sendto(soc, test_data, sizeof(test_data), 0,  &test_sockaddr, sizeof(test_sockaddr));
}
void test_recv(void)
{
 int ret;
 socklen_t rcv_len;
 soc = lwip_socket(2, 2, 0);
  ret = lwip_recvfrom(soc, test_rcv_data, sizeof(test_rcv_data), 0, &test_rcv_sockaddr, &rcv_len);
}
void task1(void)
{
     while(1)
     {
                ......
                test_recv();
                ......
     }
}
void task2(void)
{
     while(1)
     {
              ......
              test_send();
              ......
      }
}
 
The task1 will run firstly.
 
 
 
BR
Aimar

At 2011-09-06 17:02:55,"Kieran Mansley" <address@hidden> wrote: >On Tue, 2011-09-06 at 10:47 +0800, Aimar wrote: >> Dear Kieran, >>          Thanks for your reply. Actually I think this compare should >> be used to confirm if the destination port in the UDP head of the >> incoming packet which is from the remote host is equal to the local >> port. In normal situation the remote host will pepare this, but when >> sending a packet to the address 127.0.0.1 and the netif receive this >> packet, it should swap the destination port and the source port in the >> UDP head, shouldn't it? > >Why?  We wouldn't swap them if they were going out over the physical >network, and the loopback route is no different in this respect. > >Kieran > > >_______________________________________________ >lwip-users mailing list >address@hidden >https://lists.nongnu.org/mailman/listinfo/lwip-users



reply via email to

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