Pushing a stray sk_buff to the NIC

2 messages, 2 authors, 2003-01-10 · open the first message on its own page

Pushing a stray sk_buff to the NIC

From: Joshua Stewart <hidden>
Date: 2003-01-10 01:06:16

I'm trying to take "hand-built" sk_buffs with little more than some data
and a dev member and push them to the NIC for transmission.  I would
like to simply give them to dev_queue_xmit.  Does anybody know what
state I should have them in before handing them to dev_queue_xmit? 
Should skb->data point to the start of a MAC header or an IP header?

Also, given an IP address in skb->nh.iph->daddr, what's the easiest way
to get the appropriate MAC address?

J

Re: Pushing a stray sk_buff to the NIC

From: Rui Sousa <hidden>
Date: 2003-01-10 14:25:52

On Thu, 9 Jan 2003, Joshua Stewart wrote:

Hi,
I'm trying to take "hand-built" sk_buffs with little more than some data
and a dev member and push them to the NIC for transmission.  I would
like to simply give them to dev_queue_xmit.  Does anybody know what
state I should have them in before handing them to dev_queue_xmit? 
In a driver I wrote I setup (for a newly allocated skb and a 2.4 kernel):

	some_header = (struct some_header *) skb_push(skb, sizeof(struct some_header));

	skb->nh.raw = (unsigned char *) some_header;

	this_eth_hdr = (struct ethhdr *) skb_push(skb, ETH_HLEN);

	this_eth_hdr->h_proto = __constant_htons(ETH_P_SOME_HEADER);
	memcpy(this_eth_hdr->h_source, dev->dev_addr, ETH_ALEN);

	skb->dev = dev;
        skb->protocol = __constant_htons(ETH_P_CSM_ENCAPS);

	dev_queue_xmit(skb);

where some_header for you is probably an IP header and dev is the "struct 
net_device" of the device you are using to send the packet out on the 
wire.
Should skb->data point to the start of a MAC header or an IP header?
MAC
 
Also, given an IP address in skb->nh.iph->daddr, what's the easiest way
to get the appropriate MAC address?
First you need to get the device, then the MAC address is easy. This 
should be what normal IP routing code does...
J
Rui
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help