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);
Do 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, which make sense. Because network layer has IP but not on transport 
layer.

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.
_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to