Katoch
Katoch

Reputation: 2777

linux network drivers --- net_device_ops

so far i have only used file operational structure in device driver. Using system call open & read , write.

How to open device driver & transmit data using net_device_ops ? Is there reference example on net for the user program to interact with it ?

http://lnxpps.de/rpie/mcp2515_mod.c

Upvotes: 2

Views: 6968

Answers (1)

jhd1013
jhd1013

Reputation: 98

I'm not sure I understand the question, so let me know if my answer doesn't make sense.

I see you have defined functions for .ndo_open, .ndo_stop, and .ndo_start_xmit. .ndo_open is called by the kernel when you configure the interface using ifconfig up or use ifconfig to assign an address to the interface. .ndo_stop is called by the kernel when you remove the module or if you shutdown the interface using ifconfig down.

ifconfig is described here: http://linux.die.net/man/8/ifconfig

.ndo_start_xmit is called by the kernel network stack when a socket is used to transmit a packet. So, to transmit data using .ndo_start_xmit you'll need to create a socket, assign an appropriate destination address, and send the data via the socket. If you're using IP, there are tools you can use send packets easily, such as netperf or iperf.

Upvotes: 5

Related Questions