about write() function!!

HiAll

I use the open() function to open the ethernet device en0.

cpc = open("/dev/io-net/en0", O_WRONLY);

The return value cpc is 3 . I think the device is opened correctly.

Then I use the write() function.

len_written=write(cpc,…,…) ;

The return value len_written is -1.While I get the error info,It shows

that “Function is not implemented”.

Then I use the ifconfig command , I can see the en0 device .

Could someone tell me how to solve it ? Thanks a lot.

You don’t write to /dev/io-net/en0 directly. Take a look at the source to BSD’s ifconfig. It is all done by using the socket API in libsocket(). The only thing you can do to /dev/io-net/en0 is the NICINFO devctl.