Dimax | 19 May 08:04 2015
Picon

DHCP problem with lwip 1.4.1

Hi,
I faced a problem with DHCP client in lwip 1.4.1 with one specific
router (not sure what exactly it's type is as it is installed at
customer's house).
Same router works fine with Windows PC, i.e. PC get's IP from router
and connects to the internet.

Below is the DHCP module trace. I wonder if this is one of:
- known issue in 1.4.1 fixed in latest
- issue with router not related to lwip
- unknown issue (bug)

Trace:
dhcp_start(netif=200100A4) et0
dhcp_start(): starting new DHCP client
dhcp_start(): starting DHCP configuration
dhcp_discover()
transaction id xid(4d9ba518)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs
dhcp_discover()
transaction id xid(958bf589)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
dhcp_discover: deleting()ing
(Continue reading)

Abdallah Aguerzame | 18 May 17:34 2015
Picon

LWIP TCP server for STM32f107 microcontroller

Dear all

I need to set my microcontroller stm32f107 as server so i can connect it with an IHM in a PC the IHM will be the client. Im new with LWIP stack and TCP/IP protocols, if any one can gave a clue where i can start. if there is an example that well be great.
thanks a lot

Sincerely

Abdallah

_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users
Robert Deschambault | 14 May 19:18 2015
Picon

Strategy Question for DHCP

I would like to know what is a good approach when developing an application for an embedded device that has it's IP address assigned by DHCP.  We only have the Ethernet link and a circuit breaker for power, no other reset buttons are available.

We currently wait for a number of DHCP timeouts and if we don't get configured, we failover to a static IP address.  The only way to get DHCP to assign an IP address after this is to drop the link.  The other problem is that all the devices failover to the same static IP address and we can have up to 12 devices on a managed switch.

Is that a good approach?  What if DHCP services appear later after the DHCP timeouts have occurred?  Can we detect something that could tell us to renegotiate the link without dropping the link?

Thanks,
Bob

--
Bob Deschambault
_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users
Justin Reinhart | 14 May 01:06 2015
Picon

LWIP LPCWare Example: Questions on Transmit PBUF Usage

Hello,

I'm using a version of lwip 1.4.1 ported to an NXP LPC18xx, the demo code of which can be had here. I'm essentially replicating their 'sa_tcpecho' project with my own project/board. So far, everything is working great except for transmission, and I had somewhat of a general question on transmit pbuf usage. This chip/example uses a DMA to fill pre-allocated pbufs with data.

The chip I'm using has a fast section of memory where receive pbufs are preallocated in lwipopts and my driver, and the example code above runs well executing a TCP echo. However, for the transmit function they simply pass it the receive pbuf (duh, echo). I'm wondering, if I have an array somewhere in slow memory that I want to transmit in response to the reception (call it Xmt.Data[100] with a length of Xmt.Length), how do I go about doing this? Do I use pbuf_alloc(PBUF_RAW, (u16_t) EMAC_ETH_MAX_FLEN, PBUF_POOL) and copy the data into this new pbuf from slow memory? If I've already got a pool, do I need to allocate/deallocate anything? Any demo code using a transmit pbuf or any personal experience would help me out a great deal in understanding transmit pbuf usage. Thanks in advance, and sorry for the text-full question.

enum echo_states
{
  ES_NONE = 0,
  ES_ACCEPTED,
  ES_RECEIVED,
  ES_CLOSING
};

struct echo_state
{
  u8_t state;
  u8_t retries;
  struct tcp_pcb *pcb;
  /* pbuf (chain) to recycle */
  struct pbuf *p;
};


err_t
echo_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
  struct echo_state *es;
  err_t ret_err;

  LWIP_ASSERT("arg != NULL",arg != NULL);
  es = (struct echo_state *)arg;
  if (p == NULL)
  {
    /* remote host closed connection */
    es->state = ES_CLOSING;
    if(es->p == NULL)
    {
       /* we're done sending, close it */
       echo_close(tpcb, es);
    }
    else
    {
      /* we're not done yet */
      tcp_sent(tpcb, echo_sent);
      echo_send(tpcb, es);
    }
    ret_err = ERR_OK;
  }
  else if(err != ERR_OK)
  {
    /* cleanup, for unkown reason */
    if (p != NULL)
    {
      es->p = NULL;
      pbuf_free(p);
    }
    ret_err = err;
  }
  else if(es->state == ES_ACCEPTED)
  {
    /* first data chunk in p->payload */
    es->state = ES_RECEIVED;
    /* store reference to incoming pbuf (chain) */
    es->p = p;
    /* install send completion notifier */
    tcp_sent(tpcb, echo_sent);

/* *******NEED TO BUILD DIFFERENT XMT MESSAGE HERE AND PASS CORRECT PBUF TO echo_send() ***** */

    echo_send(tpcb, es);
    ret_err = ERR_OK;
  }
  else if (es->state == ES_RECEIVED)
  {
    /* read some more data */
    if(es->p == NULL)
    {
      es->p = p;
      tcp_sent(tpcb, echo_sent);
      echo_send(tpcb, es);
    }
    else
    {
      struct pbuf *ptr;

      /* chain pbufs to the end of what we recv'ed previously  */
      ptr = es->p;
      pbuf_chain(ptr,p);
    }
    ret_err = ERR_OK;
  }
  else if(es->state == ES_CLOSING)
  {
    /* odd case, remote side closing twice, trash data */
    tcp_recved(tpcb, p->tot_len);
    es->p = NULL;
    pbuf_free(p);
    ret_err = ERR_OK;
  }
  else
  {
    /* unkown es->state, trash data  */
    tcp_recved(tpcb, p->tot_len);
    es->p = NULL;
    pbuf_free(p);
    ret_err = ERR_OK;
  }
  return ret_err;
}


void
echo_send(struct tcp_pcb *tpcb, struct echo_state *es)
{
  struct pbuf *ptr;
  err_t wr_err = ERR_OK;
 
  while ((wr_err == ERR_OK) &&
         (es->p != NULL) &&
         (es->p->len <= tcp_sndbuf(tpcb)))
  {
  ptr = es->p;

  /* enqueue data for transmission */
  wr_err = tcp_write(tpcb, ptr->payload, ptr->len, 1);
  if (wr_err == ERR_OK)
  {
     u16_t plen;
      u8_t freed;

     plen = ptr->len;
     /* continue with next pbuf in chain (if any) */
     es->p = ptr->next;
     if(es->p != NULL)
     {
       /* new reference! */
       pbuf_ref(es->p);
     }
     /* chop first pbuf from chain */
      do
      {
        /* try hard to free pbuf */
        freed = pbuf_free(ptr);
      }
      while(freed == 0);
     /* we can read more data now */
     tcp_recved(tpcb, plen);
   }
   else if(wr_err == ERR_MEM)
   {
      /* we are low on memory, try later / harder, defer to poll */
     es->p = ptr;
   }
   else
   {
     /* other problem ?? */
   }
  }
}

- Justin





_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users
Eric Pooch | 13 May 16:53 2015
Picon
Picon

Re: routing over PPP using lwip

Did you use:

netif_set_default(), specifying the PPP interface?
For some reason you can't negotiate the netmask in lwip PPP, so you have to use that function.

Sent from my iPhone

> On May 13, 2015, at 1:59 AM, Sylvain Rochet <gradator@...> wrote:
> 
> Hello Damien,
> 
>> On Tue, May 12, 2015 at 11:33:23PM +0000, COOKE, Damien wrote:
>> 
>> We have a system that we are using lwip for our tcp engine.  It is a 
>> system without an OS running on ARMV9 hardware.  It has a tcp 
>> connection to a server and a ppp connection to a peripheral client 
>> device.  The tcp connection to the server is faultless and the PPP 
>> connection comes up fine we can see ping packets between the client 
>> and the system over the ppp connection but we are unable to send 
>> packets over the ppp connection.  I suspect a routing issue and was 
>> wondering if anyone else had seen something like this and if someone 
>> could guide me as to where I should be looking to find my issues?
> 
> Which lwIP version are you using ?
> 
> Which PPP link protocol are you using ? PPPoS ? PPPoE ? PPPoL2TP ?
> 
> Are you trying to do SNAT ? lwIP doesn't support NAT at all.
> 
> Is LwIP IP routing enabled ?
> 
> Note that IP routing between Ethernet and PPPoS was recently fixed in 
> git master head.
> 
> Sylvain
> _______________________________________________
> lwip-users mailing list
> lwip-users@...
> https://lists.nongnu.org/mailman/listinfo/lwip-users
COOKE, Damien | 13 May 01:33 2015
Picon

routing over PPP using lwip

Hi All,
We have a system that we are using lwip for our tcp engine.  It is a system without an OS running on ARMV9 hardware.  It has a tcp connection to a server and a ppp connection to  a peripheral client device.  The tcp connection to the server is faultless and the PPP connection comes up fine we can see ping packets between the client and the system over the ppp connection but we are unable to send packets over the ppp connection.  I suspect a routing issue and was wondering if anyone else had seen something like this and if someone could guide me as to where I should be looking to find my issues?
 
Regards
Damien
 
 
 
Damien Cooke
Hospitality & Stadiums / Arenas
NCR Corporation
 
 
 
 
_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users
Info | 12 May 15:22 2015
Picon

Single connection with "httpd" web server

Hi all

I'm using the "httpd" (httpd.c) web server from the lwIP contribution
package on top of the lwIP 1.4.1 . The web server is running well
without any problems. I activated the LWIP_HTTPD_SUPPORT_11_KEEPALIVE
macro to keep a connection to web server open. This also works like
excepted. Now I would like to limit the number of connections to one,
that means only one user can connect to the web server (and can make
changes on the configuration of the embedded system). I think it should
be implemented in the http_accept() in such a way, that any new
connection is denied if already a connection is open.
Is this correct or how do I implement such a behaviour ? Any suggestion
would helpful.

Kind regards,
Roland
Sandra Gilge | 12 May 13:46 2015

dns_gethostbyname

Hallo Krzysztof,

sorry for mispelling your name the last time. And sorry for my stupid
question.
I didn't think of creating MY OWN function which then calls
dns_gethostbyname.

Now it works. Here's the way I implemented it:
typedef struct
{
    err_t               ret;
    const char*         hostname;
    ip_addr_t*          addr;
    dns_found_callback  found;
    void*               callback_arg;
}LWIP_GetHostByNameType;

void LWIP_HostByNameCallback(void* arg)
{
    LWIP_GetHostByNameType *parameter = arg;    
    parameter->ret = dns_gethostbyname(parameter->hostname, parameter->addr,
parameter->found, parameter->callback_arg);
}

/* With this function dns_gethostbyname is called in the tcpip thread
context */
err_t LWIP_GetHostByName(const char *hostname, ip_addr_t *addr,
dns_found_callback found, void *callback_arg)
{
    LWIP_GetHostByNameType parameter;
    parameter.hostname = hostname;
    parameter.addr = addr;
    parameter.found = found;
    parameter.callback_arg = callback_arg;
    tcpip_callback_with_block(LWIP_HostByNameCallback, (void*)&parameter,
1);
    return parameter.ret;
}

Best regards,
Sandra

-----Ursprüngliche Nachricht-----
Von: lwip-users-bounces+sgilge=adatis.com@...
[mailto:lwip-users-bounces+sgilge=adatis.com@...] Im
Auftrag von
lwip-users-request@...
Gesendet: Samstag, 9. Mai 2015 18:00
An: lwip-users@...
Betreff: lwip-users Digest, Vol 141, Issue 15

Send lwip-users mailing list submissions to
	lwip-users@...

To subscribe or unsubscribe via the World Wide Web, visit
	https://lists.nongnu.org/mailman/listinfo/lwip-users
or, via email, send a message with subject or body 'help' to
	lwip-users-request@...

You can reach the person managing the list at
	lwip-users-owner@...

When replying, please edit your Subject line so it is more specific than
"Re: Contents of lwip-users digest..."

Today's Topics:

   1. Re: Lwip with two ethernet ports (Eason)
   2. Re: Lwip with two ethernet ports (goldsimon@...)
   3. Re: dns_gethostbyname (Krzysztof Weso?owski)
   4. Re: Lwip with two ethernet ports (Eason)

----------------------------------------------------------------------

Message: 1
Date: Fri, 8 May 2015 08:54:40 -0700 (MST)
From: Eason <u9411071@...>
To: lwip-users@...
Subject: Re: [lwip-users] Lwip with two ethernet ports
Message-ID: <1431100480939-24414.post@...>
Content-Type: text/plain; charset=us-ascii

Hi Sergio, forgive my worst codes and poor lwip background, I study it for
only two weeks.

My boss assign me a strange project, he wants lwip doing a simple job as a
router, and this device have two ethernet ports, but it has only one network
interface card, the device maybe route for different network segment, eg:
192.168.1.2 send data to 172.16.0.101

As you say, lwip can not route?? But I find a ip_forward function that can
foward packet to other interface, it support routing service, isn't it?? 

Thank you for your lwip teaching.

--
View this message in context:
http://lwip.100.n7.nabble.com/Lwip-with-two-ethernet-ports-tp24405p24414.htm
l
Sent from the lwip-users mailing list archive at Nabble.com.

------------------------------

Message: 2
Date: Fri, 08 May 2015 20:43:14 +0200
From: "goldsimon@..." <goldsimon@...>
To: Mailing list for lwIP users <lwip-users@...>
Subject: Re: [lwip-users] Lwip with two ethernet ports
Message-ID: <554D03C2.6060808@...>
Content-Type: text/plain; charset=windows-1252; format=flowed

Eason wrote:
> My boss assign me a strange project, he wants lwip doing a simple job 
> as a router, and this device have two ethernet ports, but it has only 
> one network interface card, the device maybe route for different network
segment, eg:
> 192.168.1.2 send data to 172.16.0.101

I see what you're talking about. lwIP might do the job, but having only
1 hardware interface and 2 netifs, you have to program some extra
(custom) logic to ensure that packets are fed into the correct netif. 
You only have one RX ISR, so you might need to check the destination address
and decide for one of the two netifs before calling netif->input().

Simon

------------------------------

Message: 3
Date: Fri, 8 May 2015 23:18:21 +0200
From: Krzysztof Weso?owski <kwesoly@...>
To: Mailing list for lwIP users <lwip-users@...>
Subject: Re: [lwip-users] dns_gethostbyname
Message-ID:
	<CAPrKjpaJNkF_bdZYEqCUuZFdz+kqgEc2NEq-RHsRTKF8NpPXNQ@...>
Content-Type: text/plain; charset="iso-8859-1"

On Tue, May 5, 2015 at 11:27 AM, Sandra Gilge <sgilge@...> wrote:

> Hallo Christoph,
>
> I think the tcpip_callback_with_block is the right solution for me. 
> Many thanks for that hint.
>
> But I wonder how I can pass several parameters to dns_gethostbyname then.
> Is
> it done in a struct?
> Dns_gethostbyname has four parameters:
> dns_gethostbyname (const char *hostname, struct ip_addr *addr, 
> dns_found_callback  found,
>                 void *callback_arg)
>
> As far as I understand a message is sent to tcpip_thread with 
> functionpointer and pointer to parameter as payload of that message.
>

Hello,

Yes you can use struct to pass multiple arguments via void * argument.
struct can be global or dynamically allocated, or if you use blocking
version ( tcpip_callback_with_block (,,1)) you can place struct on stack in
calling thread.

Regards,
Krzysztof Wesolowski
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.nongnu.org/archive/html/lwip-users/attachments/20150508/2d0737
45/attachment.html>

------------------------------

Message: 4
Date: Fri, 8 May 2015 21:00:10 -0700 (MST)
From: Eason <u9411071@...>
To: lwip-users@...
Subject: Re: [lwip-users] Lwip with two ethernet ports
Message-ID: <1431144010292-24420.post@...>
Content-Type: text/plain; charset=us-ascii

Hi Simon, I have some questions.

I add the second interface(struct netif* xnetif_1) by using
netif_add(xnetif_1, &ipaddr, &netmask, &gw, NULL, ethernetif_init,
tcpip_input);, and I don't set it to default interface, isn't it? No metter
what I add, I just set default interface on first interface(struct netif*
xnetif_0).

In ip_input(), it forwards packets to correct interface if the packets are
not for currently interface, so I shouldn't edit any other codes? Or designe
a routing table?

--
View this message in context:
http://lwip.100.n7.nabble.com/Lwip-with-two-ethernet-ports-tp24405p24420.htm
l
Sent from the lwip-users mailing list archive at Nabble.com.

------------------------------

_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users

End of lwip-users Digest, Vol 141, Issue 15
*******************************************
Picon

problem after a packet loss event

Hi users,
my system is composed by a PC sending a large volume of data via tcpip to a board with a Xilinx Zynq. Zynq has LwIP 1.4.0 running in raw mode without OS. I am working with TCP_WND = 8192 and TCP_MSS = 1460, without jumbo frame because Zynq doesn't  support them. PC sends 307200 byte in almost 5.5 mSec and all is working good until there is a packet loss event. The ACKs sended by Zynq are very quick, almost tens of microsecond from last packet received from PC. 
I have attached a capture file from Wireshark. Ip 10.1.0.10 is PC, embedded board has ip address 10.1.0.20. At packet 651 (time 0.147032) Zynq sends two duplicated ACK (I think that probably there is a packet loss...) and PC performs a fast retransmission,  then Zynq send another dup ACK and after the throughput go down from 55 MByte/sec to 15 KB/sec.
I see that the ACKs sended by Zynq are delayed about 120-130 mSec, the tcp_window of Zynq is reduced at 2352 byte, and PC wait for Zynq's ACK to send new packets, even if a window of 2352 can receive a 1.5KB packet.

I don't understand why PC wait for an ACK to send new data and why Zynq acknowledges packtes with a large delay.

This strange (for me) situation is permanent, when transmission ends the tcp window of Zynq remain 2352, and if I perform a new transmission from PC the behaviour is the same, with a throughput very low. To restore system I must reset my board.

I don't know if this is a normal situation, I need to have high throughput even with packet loss event.

Your help will be greatly appreciated

Regards,

Fabrizio

Attachment (packet_loss.pcap): application/octet-stream, 1024 KiB
_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users
jo.van.montfort1 | 8 May 11:22 2015
Picon

RFC1867 HTTP file upload - rawAPI

How to use RFC1867 with sequential- or socket API? I have an example with rawAPI. I tried with sequential API but it seems to lose connection after first "Content-Disposition:".
_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users
宜申林 | 8 May 06:28 2015
Picon

Lwip with two ethernet ports

Hi, I have some problems about lwip with two ethernet ports and it only has one network interface card(NIC).

I handle a project that want to use one NIC to support two ethernet ports, I add the second netif and initialize it.

    struct netif* xnetif_0;
    struct netif* xnetif_1;
    ip_addr_t ipaddr, netmask, gw;

/*set all to zero*/
    ip_addr_set_zero(&ipaddr);
    ip_addr_set_zero(&netmask);
    ip_addr_set_zero(&gw);

#ifdef CFG_NET_ETHERNET_IPADDR
    ipaddr_aton(CFG_NET_ETHERNET_IPADDR, &ipaddr); //default "192.168.1.1"
    ipaddr_aton(CFG_NET_ETHERNET_NETMASK, &netmask); //default "255.255.255.0"
    ipaddr_aton(CFG_NET_ETHERNET_GATEWAY, &gw); //default "192.168.1.254"
#endif // CFG_NET_ETHERNET_IPADDR

//ethernetif_init(xnetif_0);
//ethernetif_init(xnetif_1);

//eth0
    netif_set_default(netif_add(xnetif_0, &ipaddr, &netmask, &gw, NULL, ethernetif_init,               tcpip_input));
    netif_set_up(xnetif_0);

//eth 1
    netif_set_default(netif_add(xnetif_1, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input));
    netif_set_up(xnetif_1);

eth0 and eth1 are both read .ini file to access the ip, netmask and gw, 

/********device_1********/
//eth0
ip: 192.168.191.220
netmask: 255.255.255.0
gw: 192.168.191.254

//eth1
ip: 172.16.0.101
netmask: 255.255.0.0
gw: 172.16.0.254
/********device_1********/

/********device_2********/
//eth0
ip: 192.168.191.199
netmask: 255.255.255.0
gw: 192.168.191.254
/********device_2********/

//my PC
ip: 172.16.0.102
netmask: 255.255.0.0
gw: 172.16.0.101



PC<---->eth1[device_1]eth1<---->device_2

After coding, l use PC to ping eth1(device_1), it's OK, but I ping eth0(device_1) and device_2 has some problems.

Problem 1:
The ICMP packet loss on etharp_output,  why the gw of packet is chaged to default (255.255.0.0)??

Problem 1:
If I ping device2(192.168.191.199), ip_forward have worked exectly, but the packet does not send to etharp_send_ip(), is it relate about arp_table??
_______________________________________________
lwip-users mailing list
lwip-users@...
https://lists.nongnu.org/mailman/listinfo/lwip-users

Gmane