lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] help request; need to get a grip of lwIP


From: mcondarelli
Subject: Re: [lwip-users] help request; need to get a grip of lwIP
Date: Thu, 17 Nov 2011 00:21:49 +0100 (CET)

Thanks,
I already had tentatively done that.
Confirmation is always good ;)

Anyways I need to insist:
Is there a reasonably complete application_set / manual somewhere?

I already saw what's in contrib/apps, but all those so not seem to be complete.

I will need to have several apps to coexist and there's a lot to learn.
Trial-and-error isn't very efficient.

Regards.
Mauro

----- Messaggio originale -----
> Mauro,
> 
> If you're using a static IP address, you need to call netif_set_up
> yourself
> once you've set the static IP in the netif. If you're using DHCP or
> AutoIP
> these both call netif_set_up and so it will happen automatically once
> an IP
> address is established by these methods.
> 
> Bill
> 
> >-----Original Message-----
> >From: address@hidden
> >[mailto:address@hidden On
> >Behalf Of address@hidden
> >Sent: Wednesday, November 16, 2011 4:35 PM
> >To: Mailing list for lwIP users
> >Subject: Re: [lwip-users] help request; need to get a grip of lwIP
> >
> >Real sorry.
> >I sent the message before it was finished.
> >Continuation follows below.
> >
> >Regards
> >Mauro
> >
> >----- Messaggio originale -----
> >> Hi,
> >> I'm struggling with my first lwIP port.
> >> I need to implement a few services, mostly based on TCP.
> >>
> >> One of the first things I need to do is to create a socket to allow
> >> remote to connect, when this happens I should start sending some
> >> logging messages over the socket.
> >> If none is connected messages are silently discarded.
> >>
> >> My real problem is to get to the first stage of the connection.
> >>
> >> For some tests I used apps/tcpecho_raw as template.
> >>
> >> My main program calls (no prior lwIP code) the function
> >> IP_start(0).
> >>
> >> ---------------------------------------------------------------
> >> struct netif netif;
> >>
> >> /* static port number; workaround for lwIP slipif deficencies */
> >> int slipif_port = -1;
> >>
> >> static void ip_init(void *param)
> >> {
> >> IP4_ADDR(&gw, 192, 168, 0, 1);
> >> IP4_ADDR(&ipaddr, 192, 168, 0, 2);
> >> IP4_ADDR(&netmask, 255, 255, 255, 0);
> >>
> >> netif_add(&netif, &ipaddr, &netmask, &gw, NULL, slipif_init,
> >> tcpip_input);
> >> nmea_init();
> >> }
> >>
> >> error_t IP_start(u8_t port)
> >> {
> >> if (slipif_port != -1)
> >> {
> >> main_debug_printf("IP_start: already initialized!\r\n");
> >> return FAILURE;
> >> }
> >> slipif_port = port;
> >>
> >> tcpip_init(ip_init, NULL);
> >> return SUCCESS;
> >> }
> >> ---------------------------------------------------------------
> >> nmea_init() is the function that initializes my application
> >> ---------------------------------------------------------------
> >---------------------------------------------------------------
> >void nmea_init(void)
> >{
> >   LWIP_DEBUGF(N_DEBUG, ("nmea_init: start\r\n"));
> >   nmea_pcb = tcp_new();
> >   if (nmea_pcb != NULL)
> >   {
> >      err_t err;
> >
> >      err = tcp_bind(nmea_pcb, IP_ADDR_ANY, 1000);
> >      if (err == ERR_OK)
> >      {
> >         LWIP_DEBUGF(N_DEBUG, ("nmea_init: bound\r\n"));
> >
> >         nmea_pcb = tcp_listen(nmea_pcb);
> >         tcp_accept(nmea_pcb, nmea_accept);
> >         LWIP_DEBUGF(N_DEBUG, ("nmea_init: waiting for
> >connection\r\n"));
> >      }
> >      else
> >      {
> >         LWIP_DEBUGF(N_DEBUG, ("nmea_init: unable to bind\r\n"));
> >      }
> >   }
> >   else
> >   {
> >      LWIP_DEBUGF(N_DEBUG, ("nmea_init: unable to allocate
> >      pcb\r\n"));
> >   }
> >}
> >---------------------------------------------------------------
> >The function nmea_accept() is never called.
> >I traced the error down to lwip/core/ipv4/ip.c where the test:
> >---------------------------------------------------------------
> >      /* interface is up and configured? */
> >      if ((netif_is_up(netif)) &&
> >      (!ip_addr_isany(&(netif->ip_addr)))) {
> >        /* unicast to this interface address? */
> >        if (ip_addr_cmp(&current_iphdr_dest, &(netif->ip_addr)) ||
> >            /* or broadcast on this interface network address? */
> >            ip_addr_isbroadcast(&current_iphdr_dest, netif)) {
> >          LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on
> >          interface
> >%c%c\n",
> >              netif->name[0], netif->name[1]));
> >          /* break out of for loop */
> >          break;
> >        }
> >---------------------------------------------------------------
> >fails because netif_is_up(netif) returns FALSE.
> >
> >Struct netif appears to contain the right values, but I'm obviously
> >missing some needed initialization.
> >
> >Can someone point me to some complete initialization fitting my
> >cases?
> >I will try debugging through the code and I believe I can find out
> >which
> >function does the required initialization, but it's far from being an
> >efficient process.
> >
> >I really need to get a grip on the various programming interfaces
> >lwIP
> >has, possibly mixing them in a sensible way.
> >
> >I will need to implement several semi-unrelated services all
> >insisting
> >on the same SLIP connection; some of them are best suited for the RAW
> >interface while some other would prefer a connection; is it possible
> >to
> >mix (on different applications, of course)?
> >
> >TiA
> >Mauro
> >
> >
> >_______________________________________________
> >lwip-users mailing list
> >address@hidden
> >https://lists.nongnu.org/mailman/listinfo/lwip-users
> 
> 
> _______________________________________________
> 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]