Reputation: 150
In 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 */
if I passed in sk_buff to ip_hdr and 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 and ip_hdr_trans->saddr point to the same thing? I tried it on code. It doesn't. It seems that only ip_hdr_net->saddr point to source IP address.
So questions:
(1) what is differences between ip_hdr and ipip_hdr? Why we have them? No documentation whatever to figure it out.
(2) should I use ntohX function to convert ip_hdr member data when accessing them? eg, ip_hdr_net->saddr.
Upvotes: 0
Views: 541
Reputation: 189
ipip is ip over ip tunneling protocol.
Detail Info about the protocol is here:
http://lartc.org/howto/lartc.tunnel.ip-ip.html
You can browse the source code about its Linux implementation here:
ip over ip tunnel code xref in kernel
Upvotes: 1