Pushing a stray sk_buff to the NIC
Subsystems (2)
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
On Thu, 9 Jan 2003, Joshua Stewart wrote:
Hi,
Quoted 4 lines
I'm trying to take "hand-built"
sk_buffswith little more than some data and a dev member and push them to the NIC for transmission. I would like to simply give them todev_queue_xmit. Does anybody know what state I should have them in before handing them todev_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.
Quoted 1 line
Should
skb->datapoint to the start of a MAC header or an IP header?
MAC
Quoted 2 lines
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...
Quoted 3 lines
J
Rui
Quoted 6 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/