Re: RFFR

Frédéric Raynal <[email protected]>
Newsgroups gmane.comp.security.libnet
Message-ID <20040124065908.A27815@batman>
On Thu, Jan 22, 2004 at 11:52:55AM -0500, Kathleen Poulsen wrote:
> do you have and alternate suggestion for not consuming
> a file descriptor for each context?


I think I have found a trick to do it. Just need time to code it, but
I prefer to explain it here before.

Ok, we keep the current API for both libnet_init() and libnet_write().
But internally, libnet_init() will do nothing about its "device"
argument, except copy it in libnet_t (that is already done that way).

I will add 3 functions :
  - libnet_device_t* libnet_init_device(char *device, int type); 
    Get a socket. If type is RAW, we dont care about the device, but
    we need a socket anyway: it will be stored in libnet_device_t.

  - int libnet_destroy_device(libnet_device_t* dev);
    For memory management

  - int libnet_write2dev(libnet_device_t *dev, libnet_t *l);
    Write the packet described in l to dev



When libnet_write() will be rewritten with something like:

libnet_write(libnet_t *l)
{
    int ret;
    libnet_device_t* dev = libnet_init_device(l->device, l->type);

    ret = libnet_write2dev(dev, l);

    libnet_destroy_device(dev);

    return ret;
}

This is just an example, as return value will probably need to be
adjusted in case the lokkup of the device failed.

Anyway, with this solution, we keep the current API. Yes, it cant be
considered as optimization since there is one more memory
allocation/free ... but since opening and closing a socket for each
packet we want to send wad already not very optimal ;-/


Comments ?

	Fred Raynal

> 
> kathleen
> 
> On Thu, Jan 22, 2004 at 09:13:04AM -0800, Aaron Turner wrote:
> > On Thu, Jan 22, 2004 at 09:01:33AM +0100, Frédéric Raynal wrote:
> > > On Wed, Jan 21, 2004 at 09:54:37AM -0500, Kathleen Poulsen wrote:
> > > > 
> > > > 1 file descriptor per interface rather than per context (i think
> > > > this is underway).
> > > 
> > > Yep.
> > > 
> > > Note that it will very certainly break the current API :-(
> > 
> > Breaking the API is bad.  People still haven't recovered (ie: ported all
> > the code) from the last API.  I can't speak for anyone other then
> > myself, but I can say that I will have to seriously consider switching
> > to something other then libnet if the API breaks and there is no simple
> > means for the current and new API's to co-exist on the same box.  I just
> > can't keep expecting my users to keep jumping through hoops to compile
> > my code like that.
> > 
> > -- 
> > Aaron Turner <aturner at pobox.com|synfin.net>  http://synfin.net/
> > They that can give up essential liberty to obtain a little temporary 
> > safety deserve neither liberty nor safety. -- Benjamin Franklin
> > All emails are PGP signed; a lack of a signature indicates a forgery.
> 
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.