Skip to contentSkip to conversation

Required resources on network driver programming

DISCUSSION linux lover 3 participants 3 messages Dec 20, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,
I am newbie to Linux kernel
programming. I want to write my own virtual network device driver that take every packets from IP layer just print the contents of packet(header part with its starting addresses only) and send it to actual device driver for packet transmission and at receiving end receive packet from NIC card again print the header addresses and send it to upper layer for normal packet processing.
I require help about where can i get
resources or any book for writing virtual network driver with SAMPLE EXAMPLES?
regards,
linux_lover

__________________________________
Do you Yahoo!?
Send holiday email and support a worthy cause. Do good.
http://celebrity.mail.yahoo.com

#1 lore raw

Hi.

Quoted 3 lines · linux lover

I require help about where can i get
resources or any book for writing virtual network driver with SAMPLE EXAMPLES?

I think the following resources might be useful for your task - also there might be alternatives for the implementation (tcpdump/tethereal-like programs that capture the information you need from a packet socket):

Linux Device Drivers, 2nd Edition
http://www.xml.com/ldd/chapter/book/index.html

The Linux Kernel Module Programming Guide
http://en.tldp.org/LDP/lkmpg/

Virtual Network Interfaces
http://www.linux.it/~rubini/docs/vinter/vinter.html

Linux Kernel Module Programming Guide
http://oopweb.com/OS/Documents/LKMPG/VolumeFrames.html?/OS/Documents/LKMPG/Volume/node11.html

The Linux Kernel API
http://kernelnewbies.org/documents/kdoc/kernel-api/linuxkernelapi.html

Generally it's also a good idea to have a look at http://www.kernelnewbies.org/ and visit the IRC-channel #kernelnewbies at oftc.net.

Bye, Mike

#2 lore raw
In reply to linux lover
Quoted 14 lines · linux lover

Hi all,
I am newbie to Linux kernel
programming. I want to write my own virtual network device driver that take every packets from IP layer just print the contents of packet(header part with its starting addresses only) and send it to actual device driver for packet transmission and at receiving end receive packet from NIC card again print the header addresses and send it to upper layer for normal packet processing.
I require help about where can i get
resources or any book for writing virtual network driver with SAMPLE EXAMPLES?

Another mail gave you pointers to driver programming.
Here are links to TUN/TAP, a virtual ethernet (or point-to-point) device driver in the Linux kernel.

With TAP you have a virtual ethernet device, where the device driver is replaced with a userspace application (that you write) that receives all data sent to the tap device (for instance tap0) from the linux kernel network stack. This data contains ethernet header + all other payload (like IP-header + IP data with either TCP/UDP or arp-packets)..

Your userspace app may also send data to a tap-device and this data will be sent to the linux network stack like it came from a real ethernet device.

So your userspace app may do whatever it want with the data, it may print out the contents of the IP layer and forward the data to another PC using the real ethernet device (eth0, or another network medium). The other PC may do the opposite, i.e. receive the data from the ethernet device and send then to the tap device.

Your application may even encapsulate the data send between the two PC in any protocol you may like (you got tunneling).

If you wanted to do all in kernel mode this is not what you want, but tun/tap code may give you some tips on how to create a virtual ethernet device..

See these links:
http://lxr.linux.no/source/drivers/net/tun.c?v=2.6.8.1
http://vtun.sourceforge.net/tun/
http://vtun.sourceforge.net/tun/faq.html

Signature · 1 line
Roar B. Rotvik