netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Pushing a stray sk_buff to the NIC
@ 2003-01-10  1:10 Joshua Stewart
  2003-01-10 14:34 ` Rui Sousa
  0 siblings, 1 reply; 2+ messages in thread
From: Joshua Stewart @ 2003-01-10  1:10 UTC (permalink / raw)
  To: Linux Kernel Mailing List, Linux network development

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Pushing a stray sk_buff to the NIC
  2003-01-10  1:10 Pushing a stray sk_buff to the NIC Joshua Stewart
@ 2003-01-10 14:34 ` Rui Sousa
  0 siblings, 0 replies; 2+ messages in thread
From: Rui Sousa @ 2003-01-10 14:34 UTC (permalink / raw)
  To: Joshua Stewart; +Cc: Linux Kernel Mailing List, Linux network development

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/
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-10 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-10  1:10 Pushing a stray sk_buff to the NIC Joshua Stewart
2003-01-10 14:34 ` Rui Sousa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).