netdev
[Top] [All Lists]

Re: sk_buffs in netif_rx()

To: "netdev@xxxxxxxxxxx" <netdev@xxxxxxxxxxx>
Subject: Re: sk_buffs in netif_rx()
From: Laurence <laudney@xxxxxxxx>
Date: Fri, 15 Feb 2002 23:22:35 +0800
Organization: SJTU
Reply-to: laudney@xxxxxxxx
Sender: owner-netdev@xxxxxxxxxxx
>I am trying to printk the destination and source address of a packet 
>in netif_rx() just before it is added to the backlog queue. 
>
>I have done this successfully in Eth.c to read out skb->data[26], 
>skb->data[27], up to skb->data[33] which gives the correct information 
>for the source address. 
>
>However, skb->data[26] does not point to the right place when I read 
>it from a packet in the netif_rx() function. 
>
>How do I work out where to look in skb->data to find the information 
>(I would also like to read the timestamp and tcp sequence number) - 
>are the ip addresses and timestamps now in the "actual" data section 
>of the packet, pointed to by  skb->head?  I assume it has changed position
>because of the ethernet header having been stripped by the time it gets to
>netif_rx().

Yes, you can do that.

First, as for address, you mean IP address?? If so, they are in the IP header.
You can access IP header in skb as follow:

struct iphdr *iph = skb->nh.iph

It's a pointer to struct iphdr. You can find its definition in 
include/linux/ip.h

to access addresses:

__u32 sa = skb->nh.iph.saddr
__u32 da = skb->nh.iph.daddr


Second, to access timestamp:

sk_buff
{
..
struct timeval stamp;
..
}

Third, to access TCP sequence number:

tcp sequnce number is located in tcphdr{} in include/linux/tcp.h
so, 
struct tcphdr *th = skb->h.th;
__u32 seq = th.seq;

>
>I would also like to be able to read it in netbh() when a packet is 
>taken from the queue - will the information be at the same point in 
>the packet here? 

what queue?? sk->receive_queue?? Linux uses tcp_recvmsg (net/ipv4/tcp.c)
to take packets from there. Look at the source codes to find more
information



-- Laudney



<Prev in Thread] Current Thread [Next in Thread>