在include/linux/ip.h中,
23 static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
24 {
25 return (struct iphdr *)skb_network_header(skb);
26 }
27
28 static inline struct iphdr *inner_ip_hdr(const struct sk_buff *skb)
29 {
30 return (struct iphdr *)skb_inner_network_header(skb);
31 }
32
33 static inline struct iphdr *ipip_hdr(const struct sk_buff *skb)
34 {
35 return (struct iphdr *)skb_transport_header(skb);
36 }
37 #endif /* _LINUX_IP_H */
如果我将sk_buff传递给ip_hdr和ipip_hdr
struct iphdr *ip_hdr ip_hdr_net = ip_hdr(skb);
struct iphdr *ip_hdr ip_hdr_trans = ipip_hdr(skb);
ip_hdr_net->saddr和ip_hdr_trans>saddr指向同一事物?我在代码上试过了。似乎只有ip_hdr_net->saddr指向源IP地址。
所以问题是:
(1) ip_hdr和ipip_hdr有什么区别?为什么我们有他们?没有任何文档可以解决这个问题。
(2)访问ip_hdr成员数据时,是否应该使用ntohX函数进行转换?例如,ip_hdr_net->saddr。
发布于 2016-08-21 02:40:11
ipip是ip over ip隧道协议。
协议的详细信息如下:
http://lartc.org/howto/lartc.tunnel.ip-ip.html
你可以在这里浏览它的Linux实现的源代码:
ip over ip tunnel code xref in kernel
https://stackoverflow.com/questions/39013454
复制相似问题