lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] sio.h Function Prototypes


From: Greg Smith
Subject: Re: [lwip-users] sio.h Function Prototypes
Date: Tue, 10 May 2016 15:24:36 +0000

Hi, Simon and Sylvain.

 

From: Sylvain Rochet [mailto:address@hidden
Sent: Friday, 06 May 2016 19:28

Hi,

 

On Fri, May 06, 2016 at 09:29:42PM +0200, address@hidden wrote:

> Greg Smith wrote:

> >In lwIP 2.0.0 Beta1, it has a prototype in sio.h for sio_write, which

> >I believe is the generic function name for the PPP output function.

>

> Not exactly. sio_write is used for PPP, for slipif and maybe for other

> netifs.

 

Not really, the last user of the SIO framework is SLIP. The SIO API sucks, I proposed my help to get rid of it in SLIP in <address@hidden> but the change was not acknowledged.

There are so many other changes in the PPP, that I, personally, have had to make enough changes that this would not bother me if it broke compatibility.  (It almost does anyway because sio_write() can be passed directly to pppos_create(), for example.)

 

> > Should this have a prototype of:

> >

> > u32_t sio_write(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx);

> >

> > instead of:

> >

> > u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);

> >

>

> No.

>

> > It seems the updates to PPP demand a ppp_pcb, instead of sio_fd_t.

> >

>

> Yes. But to write, you need a sio_fd_t. So you need an output function

> that maps to your sio_write function. See the win32 or unix port in

> contrib. If you don't want to keep sio_fd_t static (like these ports

> do, unfortunately), you can pass a "void* ctx_cb" that is passed to

> the output function to get what you need to call sio_write.

 

It doesn't work this way, PPPoS user must provide a serial output callback while calling pppos_create with a prototype matching pppos_output_cb_fn.

Yes, that was the problem I was running into.  pppos_create() needed a different prototype; sio_write() couldn't be changed (to type pppos_output_cb_fn) without causing lots of compiler errors.

 

/* PPPoS serial output callback function prototype */ typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx);

 

Feel free to do whatever you want with this callback ;-)

 

This is what lwip-contrib/ports/unix/proj/unixsim/simhost.c is doing, using a global variable:

 

static u32_t

ppp_output_cb(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx) {

  LWIP_UNUSED_ARG(pcb);

  LWIP_UNUSED_ARG(ctx);

  return sio_write(ppp_sio, data, len);

}

This is basically where I was headed myself, but it seems redundant; therefore, I was figuring I was doing something wrote.  Ideally, if I could get rid of sio.h altogether, that would seem to be cleaner.  Do you think that is possible in the current state of 2.0.0RC1?

Either way, for now, I'll do much like what you've listed here.

 

Thank you for all your help!

 

Sylvain

 

-- Greg




This email has been scanned for email related threats and delivered safely by Mimecast.
For more information please visit http://www.mimecast.com

reply via email to

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