[Winpcap-users] How to combine pcap_next_ex with poll/select in cygwin

S A sagarwal10 at hotmail.com
Wed Dec 12 19:21:24 GMT 2007


Hi all
   
My question is about trying to figure out how to use winpcap and poll ()/select () together                                                                            in a cygwin environment.
    
The Linux program I'm trying to port, waits for a telnet connection to establish  a connection to a 
user on a local port number (i.e. localhost). The user can then choose to send/receive raw packets 
(of any ethernet type - hence the need for raw sockets via winpcap) on any of the network devices 
on the machine. 

My dilemma is how to make the poll/select call i use (to wait for an incoming telnet connection
and further interaction with the user) and combine it with using pcap_next_ex() to receive
raw packets.

I know very little of windows but I understand both winpcap & cygwin poll (winsup/cygwin/select.cc
right?) use a call "WaitForMultipleObjects ()" to sleep and wait for new receive events. Is there a way
I can translate a winpcap socket pcap_t handle into an fd that I could pass to the poll/select fd list?
Or vice versa - translate cygwin fd's into pcap handles?

(Although the brief browsing I did in the winpcap sources I only saw a call to WaitForSingleObject() though)

My only other options (none of which I like) are:

1. Use threads. Multiple processes won't work because the telnet program and the raw socket
   program would have to interact with each other - and wouldn't that mean more localhost connections
   unless I use some kind of proc or ioctl interface?

2. Use winpcap to also receive IP packets and thus handle the telnet protocol in my program.
    However this is unnnecessarily complex and I don't even see the pcap_findalldevs
    presenting me with a localhost device (i.e. the equivalent of the "loopback" or "lo" netdev in linux).

3. Use a maximum wait time on both the poll call and the pcap_next_ex call. I'm afraid my
    program will get sluggish and also eat up a lot of CPU cycles.

Any recommendations on what to do or more code to look at are greatly welcomed. Thanks!
And thanks for all the great open source work.


_________________________________________________________________
Share life as it happens with the new Windows Live.
http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_122007
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20071212/0f0bee84/attachment.htm


More information about the Winpcap-users mailing list