lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] [lwip] eZ80 port


From: Robert
Subject: [lwip-users] [lwip] eZ80 port
Date: Wed, 08 Jan 2003 23:30:07 -0000

I have completed the port of lwIP to the eZ80 to the point of having 
working code.  At this point I am making changes to my "OS" and adding 
"application" level code for functionality.  I put these in quotes, 
because in an embedded/tightly coupled system, it's not always easy to 
tell where the stack/OS/application boundaries are.  I am using the "Raw 
TCP/IP interface to lwIP", BTW.  My ping time are around 8 msec over a 
local LAN, BTW.

I thought it might be interesting to add something that worked sort of
like inetd in UNIX.  That is, some code that listened for new connections,
and when established, hooked the connection up with the right code for
functionality.  This way, something like IP wrappers, could be done in one
place.  I was very pleased and surprised to find that lwIP has part of
this already implemented.  I find that if a pcb is in the listen mode, a
new connection to the port will create a new pcb and pass that to the
accept function.  So I think I will just setup listening pcb's for each
port I want to support, instead of an "IP_PORT_ANY" type of thing.  
(Note, I made up the term "IP_PORT_ANY", no such animal exists in lwIP at
the moment as far as I can tell.)  After all, it's not like I am bringing
in code from a disk drive or something, all my code will be in ROM, there
is no disk or file system in my product.

I have "stats" turned on and am watching "stats.mem.used".  It does not
seem to change when a pcb is allocated for a second connection the the
port.  This surprises me, perhaps pcb's are allocated in large blocks, so
getting a second one does not affect the used figure, or perhaps pcb
allocations are not recorded in the stats.  If anyone knows the answer to
this I would like to hear about it.

I am also curious what, if anything, I should do with my code.  I was
thinking that a UNIX-style patch file might work for the base package, a
full file for cs8900.asm cs8900if.c and cs8900if.h.  eZ80 developers might
prefer I remove unused parts of the lwIP package and zip up the rest,
since they would typically develop on Windows. Is there an interest in
posting these files on the lwIP web site?  If so, where do I send them? I
am considering releasing the modified stack along with my OS code, also.  
There are not very many good alternatives for the eZ80 at the moment, and
nothing that is open source that I can find.  Of course I would need a
cool name for the package...:)

I did have a question about how to close a connection from within the 
"recv" callback function.  I am using the following code, if anyone knows 
if this is the recommended way or not, I would appreciate hearing from 
them.  I used the code from the poll callback routine in the sample code 
as a guide.


  if( !memcmp( p->payload, "exit", 4 ) ) {
    close_conn(pcb, es);
    tcp_abort(pcb);
    return ERR_ABRT;
  }

where close_conn() is the following, taken for the sample code:

static void close_conn(struct tcp_pcb *pcb, struct echo_state *es)
{
  tcp_arg(pcb, NULL);
  tcp_sent(pcb, NULL);  
  tcp_recv(pcb, NULL);
  if(es != NULL) {
    pbuf_free(es->p);
    mem_free(es);
  }
  tcp_close(pcb);
}

-- 
Best Regards,
Robert Laughlin


[This message was sent through the lwip discussion list.]




reply via email to

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