免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 766 | 回复: 0
打印 上一主题 下一主题

net_device [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-03 16:41 |只看该作者 |倒序浏览






  • init() is used to search and initialize network devices. This method is responsible for finding and initializing a network adapter of the present type. Primarily, a net_device structure has to be created and filled with the driver-specific data of the network device or network driver. Subsequently, the network device is registered by register_netdevice(). (See
    Section 5.3.1
    .)

  • uninit() is called when a network device is unregistered (unregister_netdevice()). This method can be used to execute driver-specific functions, which may be necessary when a network device is removed. The uninit() has been introduced to the net_device structure since version 2.4 and is currently not used by any driver.

  • destructor() is also new in the net_device structure. This function is called when the last reference to a network device was removed (dev->refcnt) (i.e., when no protocol instances or other components in the Linux kernel point to the net_device structure). This means that you can use the destructor() function to do cleanup work (e.g., free memory or similar things). The destructor() function is currently not used by any driver.

  • open() opens (activates) a named network device. During the activation, the required system resources are requested and assigned. Note that this method can open only network devices that were previously registered. Normally, dev->open() is used in the dev_open() method which, in turn, is called by the ifconfig command. Upon successful execution of open(), the network device can be used.

  • stop() terminates the activity of a network adapter and frees the system resources it has used. The network device is then no longer active, but it remains in the list of registered network devices (net_devs).

  • hard_start_xmit() uses a packet (in the form of a socket buffer) over the network device. If successful (i.e., the packet was delivered to the adapter), then hard_start_xmit() returns with the return value 0; otherwise, 1.

  • get_stats() gets statistics and information about the network device and its activities. This information is returned in the form of a net_device_stats structure. The elements of this structure will be introduced in the course of this chapter.

  • get_wireless_stats() returns additional information for wireless network adapters. This information is forwarded in a structure of the type iw_statistics. The tool iwconfig can be used to display this specific information.

  • set_multicast_list() passed the list with multicast MAC addresses to the network adapter, so that the adapter can receive packets with these addresses. This list is called either when the multicast receipt for the network device is activated (IFF_MULTICAST flag) or when the list of group MAC addresses to be received has changed. (See also
    Section 17.4.1
    .)

  • watchdog_timeo() deals with problems during the transmission of a packet across the network adapter (not when the socket buffer is passed to the network adapter). If no acknowledgment for the packet is received after dev->tx_timeout, then the kernel calls the method watchdog_timeo() to solve the problem.

  • do_ioctl(): This method is generally not used by higher protocols, because they have no generic functions. It is normally used to pass adapter-specific ioctl() commands to the network driver.

  • set_config() is used to change the configuration of a network adapter at runtime. The method lets you change system parameters, such as the interrupt or the memory location of the network adapter.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/79820/showart_1358464.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP