- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我读了源代码,但它确实让我困惑。例如函数 sib_mac_header 函数,它是下面代码中的第三个函数,sib -> head 是指向分配的缓冲区头的指针,sib -> mac_header 是指向该缓冲区中 mac_header 地址的指针。为什么两个地址相加的结果是指向MAC以太结构的指针?
skbuff.h中的源代码如下:
1609 static inline void skb_reset_network_header(struct sk_buff *skb)
1610 {
1611 skb->network_header = skb->data - skb->head;
1612 }
1613
1614 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
1615 {
1616 skb_reset_network_header(skb);
1617 skb->network_header += offset;
1618 }
1619
1620 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
1621 {
1622 return skb->head + skb->mac_header;
1623 }
最佳答案
您误读了代码。 skb->mac_header
不是一个直接指针...它存储 mac 头相对于 skb->head 的偏移量。事实上,在 64 位架构上,sk_buff_data_t 是 unsigned int,并且 struct sk_buff 的许多成员都是显式偏移的(此技巧用于通过将信息存储在 4 字节字段而不是 8 字节指针中来节省内存) .
关于c - linux 内核中 skbuff.h 中的 mac 相关函数如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22795527/
我正在尝试编写一个内核模块,它是USB驱动程序和网络驱动程序的组合,现在每当USB驱动程序接收到数据时,它都会在struct urb中,但是网络所需的数据驱动程序是sk_buff,现在我如何将urb转
使用 Netfilter 的钩子(Hook)(NF_INET_PRE_ROUTING 和 NF_INET_POST_ROUTING)我实现了一个内核模块来监控给定主机的所有传入和传出数据包。通过查看
我有一个程序需要从结构“skbuff”中获取源地址,在以前的内核版本中,我可以使用以下行获取“saddr”: static __u32 get_src_ip(const struct sk_buff
我正在开发一个应用程序,它通过监视系统的端口来猜测您的应用程序是否受到攻击。为此我决定直播sk_buff通过内核模块的变量。 但目前我遇到了以下问题: 无法访问 skbuff.h 头文件。当我做的时候
我在很多书上看到skbuff.h的路径是usr/include/linux。我在 Ubuntu、fedora 和 backtrack 中搜索,但找不到头文件。谁能帮我找到这个文件?提前致谢。 最佳答案
sk_buff 有两个地方可以存储下一个碎片数据: skb_shinfo(head)->frag_list skb_shinfo(head)->frags[] 这两种处理碎片的方式有什么区别? 最佳答
我读了源代码,但它确实让我困惑。例如函数 sib_mac_header 函数,它是下面代码中的第三个函数,sib -> head 是指向分配的缓冲区头的指针,sib -> mac_header 是指向
我是一名优秀的程序员,十分优秀!