Reputation: 591
I was reading through the network device driver code.My driver follows the driver-model.REF:kernel/Documentation/driver-model. Reading through the interface.txt: { Device interfaces are the logical interfaces of device classes that correlate directly to userspace interfaces, like device nodes. Each interface is given a directory in the directory of the device class it belongs to. }
Havent been able to pinpoint the exact interface yet.So after going through the struct net_device and the Programming interface in the interface.txt file (kernel./Documentation/driver-model) I again come to the conclusion that its the net_device these people are talking about. Now what I want to know is the TCP/IP stack the physical and the link layer is the network driver.I want to give the interface my network driver provides to my tcp/ip stack.Question is How ? How can I give the net_device struct to the TCP/ip stack. Does anyone know about this. Regards Sraddha
.
Upvotes: 1
Views: 1876
Reputation: 16076
The hierarchy is as follows
struct inet_protosw (internet protocols) has a pointer to a struct member proto (protocol)
struct sock has a pointer to a struct member proto (protocol)
struct sock has member to a struct member sk_buff_head
struct sk_buff_head has two pointer to struct members to sk_buff (one called next, one called prev)
struct sk_buff has a pointer to struct member net_device.
I don't believe you register the net_device with inet_protosw directly.
First inet_init
registers the built in network protocols by calling proto_register
, then it calls inet_register_protosw
to initialise the protocols, then it initialises the various inet modules (ip,tcp,icmp,etc).
The interface responsible with linking the protocols and the device later has the register_netdevice
and unregister_netdevice
, which do what the sound like and register and unregister network devices with kernel. To send a packet from a protocol through a device use dev_queue_xmit
and netif_rx
receives a packet passes from the device layer to the network layer, it then calls netif_rx_schedule
to schedule the packet for further processing.
Resources and documentation on the organisation / workflow include:
Upvotes: 5