Kismet Wireless

Kismet Forums


Posted by:dragorn
Subject:packet source without file descriptor
Date:18:17:55 27/07/2009

> > > I'm working on a new packet source in a server plugin and ran into a small problem. I would like Poll() to directly call userspace code that does not require a file descriptor, but it seems that Poll() never gets called unless FetchDescriptor() returns a valid file descriptor. Is there an easy way around this? Thanks!
> >
> > Nothing comes to mind, unfortunately. select() is deeply ingrained in how kismet expects things to happen. you could try to fake it with a pipe you manually raise hot, though that's really really ugly.
> >
> > -m
> Thanks, Mike! What do you think about opening /dev/null? I suppose my Poll() would get called more frequently that way, but most of the time it will just do a quick check to see if there is anything to pull off a ring buffer.

I wouldn't do that, you'll slam up to 100% CPU load at all times.

If you really need to fake a pollable fd, look at how, for example, the cygwin_utils stuff does it - assuming you have a thread or something that's doing your work, then you'd make a pipe, feed that fd to select() via the fetchdescriptor on your source, and when your thread has data it wants to feed into the select loop, write one byte to it (and have your fetch function read that byte off to put the FD low again).

It's a bit of a hack, but it's pretty much the best way to do it, you definitely don't want to feed it an always-hot FD


Reply to this message