linux/if.h和net/if.h有什么区别? [英] What is the difference between linux/if.h and net/if.h?
问题描述
评论说, net/if.h
是GNU C库的一部分,而 linux/if.h
则说它是"TCP/IP的实现.LINUX操作系统的协议套件."
The comments say that net/if.h
is part of the GNU C Library and linux/if.h
says it is "An implementation of the TCP/IP protocol suite for the LINUX operating system."
但是为什么有两个?每个都有什么用?
But why are there two of them and what is the use of each one?
推荐答案
最初,两者都提供数据结构来管理网络接口. linux/if.h
与与Linux内核网络的交互特别相关.接口.实际上,它是在文件开头声明的:
Initially, both provide data structures to manage network interfaces.linux/if.h
is specifically more related to interact with Linux kernel's network interfaces. Actually, it states so at the beginning of the file:
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Global definitions for the INET interface module.
*/
net/if.h
是glibc出于相同目的的文件,最初主要是用户空间
.
net/if.h
is glibc's file for same purpose and is initially more user space
focused.
重要的是要注意,如果您要同时使用两者(它们共享一些结构,但不是全部),则包含顺序非常重要,建议在大多数情况下建议包含 linux/if.h
在 net/if.h
之前.
Is important to note that, if you're going to use both (they share some structures but not all), include order is quite important, suggesting, in most cases, to include linux/if.h
before net/if.h
.
这篇关于linux/if.h和net/if.h有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!