c - 为什么 sk_buff 在 h union 中有一个 ip 头指针(ipiphdr),在 nh union 中有一个常规 ip 头指针(iphdr)?

标签 c sockets networking linux-kernel

这更多的是一个好奇心问题。我一直在查看 Linux 网络内核,并注意到 sk_buff 在不同的 union 中有两个指向 ipv4 header 的指针。这背后的原因是什么?是否存在数据包可能具有多个 ip header 的情况?

编辑 这是我看到它的地方的链接。我在其他地方也看到过这个。 sk_buff

00202         union {
00203                 struct tcphdr   *th;
00204                 struct udphdr   *uh;
00205                 struct icmphdr  *icmph;
00206                 struct igmphdr  *igmph;
00207                 struct iphdr    *ipiph;
00208                 struct ipv6hdr  *ipv6h;
00209                 unsigned char   *raw;
00210         } h;
00211 
00212         union {
00213                 struct iphdr    *iph;
00214                 struct ipv6hdr  *ipv6h;
00215                 struct arphdr   *arph;
00216                 unsigned char   *raw;
00217         } nh;

提前致谢

最佳答案

h 是传输层的 header 。 nh 是网络层的 header 。

但是在原始套接字中,没有传输协议(protocol),因此 header 是网络层 header 。

关于c - 为什么 sk_buff 在 h union 中有一个 ip 头指针(ipiphdr),在 nh union 中有一个常规 ip 头指针(iphdr)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42170382/

相关文章:

c - 未定义对 "only some math.h"函数的引用

c# - 套接字流不包含整个响应

客户端服务器套接字编程c-linux

c++ - 通过 Berkeley 套接字使用线程通知

ios - System.Net.NetworkInformation IPv4Mask 在 MonoTouch 中不起作用?

linux - linux中如何获取服务器的ip地址?

c - 使用 calloc 初始化 void* 缓冲区

c - C中的密码复杂度

c - 代码未优化时的段错误——SQLite

linux - C# 资源暂时不可用,在 linux 上的 dotnet core 上阻塞套接字