【问题标题】:how does the tcp/ip stack get the net_device interface in linuxlinux中tcp/ip栈如何获取net_device接口
【发布时间】:2012-02-16 23:01:22
【问题描述】:

我正在阅读网络设备驱动程序代码。我的驱动程序遵循 driver-model.REF:kernel/Documentation/driver-model。 通读interface.txt: { 设备接口是相关的设备类的逻辑接口 直接连接到用户空间接口,如设备节点。 每个接口在设备的目录下都给了一个目录 它所属的类。 }

还不能确定确切的接口。所以在通过interface.txt文件(kernel./Documentation/driver-model)中的struct net_device和编程接口之后 我再次得出结论,即这些人正在谈论的 net_device。 现在我想知道的是物理的 TCP/IP 堆栈,链路层是网络驱动程序。我想将我的网络驱动程序提供的接口提供给我的 tcp/ip 堆栈。问题是如何?如何将 net_device 结构提供给 TCP/ip 堆栈。有谁知道这件事。 问候 斯拉达

.

【问题讨论】:

    标签: networking network-protocols linux-device-driver


    【解决方案1】:

    层次结构如下

    struct inet_protosw(互联网协议)有一个指向结构成员proto(协议)的指针

    struct sock 有一个指向 struct 成员 proto(协议)的指针

    struct sock 有一个 struct 成员 sk_buff_head 的成员

    struct sk_buff_head 有两个指向 sk_buff 的结构成员的指针(一个称为 next,一个称为 prev)

    struct sk_buff 有一个指向结构成员 net_device 的指针。

    我不相信你直接用 inet_protosw 注册 net_device。

    首先inet_init通过调用proto_register注册内置网络协议,然后调用inet_register_protosw初始化协议,然后初始化各种inet模块(ip、tcp、icmp等)。

    负责连接协议和设备的接口有register_netdeviceunregister_netdevice,它们的功能听起来像是向内核注册和注销网络设备。要通过设备从协议发送数据包,请使用dev_queue_xmitnetif_rx 接收从设备层传递到网络层的数据包,然后调用netif_rx_schedule 来安排数据包以进行进一步处理。

    有关组织/工作流程的资源和文档包括:

    【讨论】:

      猜你喜欢
      • 2016-01-05
      • 2012-02-09
      • 1970-01-01
      • 1970-01-01
      • 2018-02-05
      • 1970-01-01
      • 2011-01-18
      • 2013-07-28
      • 2012-03-15
      相关资源
      最近更新 更多