- 论坛徽章:
- 0
|
我觉得还有个简单点的方法.
skb中有个成员叫h,就是表示header的.
下面这段来自LDD3 CHAPTER 17 PAGE 529
SKB data structure:
union { /* ... */ } h;
union { /* ... */ } nh;
union { /*... */} mac;
Pointers to the various levels of headers contained within the packet. Each field
of the union is a pointer to a different type of data structure. h hosts pointers to
transport layer headers (for example, struct tcphdr *th); nh includes network
layer headers (such as struct iphdr *iph); and mac collects pointers to link-layer
headers (such as struct ethdr *ethernet).
If your driver needs to look at the source and destination addresses of a TCP
packet, it can find them in skb->h.th. See the header file for the full set of header
types that can be accessed in this way. |
|