[openbeosnetteam] Re: skeleton sockets fd support driver

  • From: philippe.houdoin@xxxxxxx
  • To: openbeosnetteam@xxxxxxxxxxxxx
  • Date: Thu, 28 Feb 2002 11:54:04 +0100 (MET)

Marcus said:
>> Here is the result:
>> http://philippe.houdoin.free.fr/phil/beos/openbeos/net_kit.zip
>
> Looks like this will work. it would be interesting to know if
> the R5 kernel will call the Select and Deselect hooks
> if you use select on the file descriptor.

Axel wrote:
> [...] it depends on the kernel if select() would work.
> AFAIK the PostgreSQL port did this.

Seem that R5 *BONE* kernel does, at least:

$ lib_tester
socket(AF_INET, SOCK_STREAM, 0) -> 3
connect(3, INADDR_LOOPBACK, 21) failed!
select_test_thread: triggering 1 select event...
socket 3 ready to read.  

And net_stack_driver generate these messages in /var/log/syslog (BeOS drivers 
developers always have "syslog_debug true" option, right!?):

KERN 'lib_tester'[1742]: net_stack: --- init_driver, built Feb 28 2002 
09:59:04
KERN 'lib_tester'[1742]: net_stack: load_driver_symbols("net_stack") 
done.
KERN 'lib_tester'[1742]: net_stack: --- find_device net/stack
KERN 'lib_tester'[1742]: net_stack: --- device_open net/stack (O_RDWR)
KERN 'lib_tester'[1742]: net_stack: --- device_control 0x0254a4a0: 
socket(1, 1, 0).
KERN 'lib_tester'[1742]: net_stack: --- device_control 0x0254a4a0: 
connect().
KERN 'lib_tester'[1742]: net_stack: --- device_select 0x0254a4a0: 1, 
16777219, 0x0299823c
KERN 'lib_tester'[1742]: net_stack: --- device_select 0x0254a4a0: 2, 
33554435, 0x0299823c
KERN 'lib_tester'[1742]: net_stack: --- device_select 0x0254a4a0: 3, 
50331651, 0x0299823c
KERN 'lib_tester'[1742]: net_stack: --- device_deselect 0x0254a4a0: 1, 
0x0299823c
KERN 'lib_tester'[1742]: net_stack: --- device_deselect 0x0254a4a0: 2, 
0x0299823c
KERN 'lib_tester'[1742]: net_stack: --- device_deselect 0x0254a4a0: 3, 
0x0299823c
KERN 'lib_tester'[1742]: net_stack: --- device_close 0x0254a4a0
KERN 'lib_tester'[1742]: net_stack: --- device_free 0x0254a4a0
KERN 'lib_tester'[1742]: net_stack: --- uninit_driver                  

Unfortunatly, I don't have a *original* BeOS R5.0.3 kernel near me to test 
against it this morning, so if one of you coult report back, it would be great!

Based on V2/#36 BeNewsletter 
(http://www.befaqs.com/mirror/classic-be/aboutbe/benewsletter/volume_II/Issue36.html#Insight),
 select() drivers support should works since R4 yet! So, I'm confident...
Weird enough, KernelExport.h still don't declare notify_select_event() kernel 
call.

Latest code:
http://philippe.houdoin.free.fr/phil/beos/openbeos/net_kit.zip
(Yep, same url, maybe I should commit it to CVS?)

I've implemented device_select() and device_deselect() hooks in 
net_stack_driver, plus add a test-only ioctl to *trigger* one select event.
In lib_tester.c, I now spawn a thread who, after 4 seconds, use this test-only 
ioctl to ask the driver to raise a select event (1= B_SELECT_READ, 2 = 
B_SELECT_WRITE, 3 = B_SELECT_EXCEPTION).
In the main thread, I simply wait on select(sock, &read_set, &write_set, 
&error_set, 0)...

Obvioulsy, the asynchronous select event notification should be launched from 
the stack in the future (relayed by the driver), not simulated like now.

But... to resume, it works!

-Philippe.

Other related posts: