Group: comp.os.linux.development.system


Subject: Why no nodes for network devices?
From: phil-news-nospam@ipal.net
Date: 12/21/2007 2:22:38 AM
On Wed, 19 Dec 2007 09:45:13 -0800 (PST) David Schwartz <davids@webmaster.com> wrote: | On Dec 19, 1:53 am, MAx <mahesh1...@gmail.com> wrote: | |> Why are there no nodes for network devices as they are for char and |> block devices? | | The file metaphor didn't work as well, so it wasn't used. However, for direct device access by a userland program, for example to read or write on an ethernet port, the device metaphor is fine. You could open /dev/eth0 (if there is not existing conflict such as the interface already activated to the network stack) then each write() would send out a raw datagram, and each read() would get the next to arrive. Programs that configure interfaces could select which one to configure by opening the device node and doing appropriate calls with the descriptor. This is already done with serial ports to activate a PPP session after the dialup sequence is complete. |> An application calls open on a char file in /dev directory to operate |> on the device, how does it happen in case of network devices? | | You create a socket and then you can perform 'ioctl' operations on | that socket. You can 'read' and 'write' on the socket if you want, but | you can also use 'send', 'recv', and the versions of those functions | that take/give address information, 'sendto', 'recvfrom'. | | There are also other socket operations like 'shutdown', 'connect', | 'bind', and so on. Function like 'getsockopt'/'setsockopt' are used to | set and get socket options. Once there is a working network stack, the device node metaphor does have its problem. Still, it could have been done by mounting a pseudo filesystem with filenames that represent the socket parameters, and the descriptor you get is the socket. Then you could cause programs to end up with a socket by just the name you pass as the "file". This would not preclude all those extra function calls networking needs (which may or may not be implemented at the kernel ABI layer as ioctl() calls or real syscalls, or overload one syscall for them all). -- |---------------------------------------/----------------------------------| | Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below | | first name lower case at ipal.net / spamtrap-2007-12-20-2014@ipal.net | |------------------------------------/-------------------------------------|