LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-23-2005, 09:55 PM   #1
cstrask
LQ Newbie
 
Registered: Oct 2005
Location: California
Distribution: FC3
Posts: 6

Rep: Reputation: 0
Help with sk_buff


I am writing a custom network device driver. It is essentially IP over ppp. I am having difficulty
understanding how to properly form the link layer header. I need to makeup a fake/static link layer header b/c the real header is removed by the hardware.

My code is below any suggestions would be helpful. I am not sure what to do in dev->hard_header
and dev->rebuild_header.

Code:
void sonet_init(struct net_device *dev)
{
	struct sonet_priv *priv;
	//ether_setup(dev); /* assign some of the fields */
	dev->open                   = sonet_open;
	dev->stop                    = sonet_release;
	dev->set_config           = sonet_config;
	dev->hard_start_xmit  = sonet_tx;
	dev->do_ioctl               = sonet_ioctl;
	dev->get_stats            = sonet_stats;
	dev->change_mtu       = sonet_change_mtu;  
	dev->rebuild_header    = sonet_rebuild_header;
	dev->hard_header       = sonet_header;
	dev->tx_timeout         = sonet_tx_timeout;
	dev->watchdog_timeo = timeout;
	dev->type		       = ARPHRD_PPP;
	dev->hard_header_len = 2;
	dev->mtu		= 1500;
	dev->addr_len		= 1;
	dev->tx_queue_len	= 1000;	
	dev->flags           |= IFF_NOARP;
	dev->features        |= NETIF_F_NO_CSUM;
	dev->hard_header_cache = NULL;      /* Disable caching */
	priv = netdev_priv(dev);
	memset(priv, 0, sizeof(struct sonet_priv));
}
void sonet_rx(struct net_device *dev)
{
	printk(KERN_ALERT "SONET RX Function\n");
	//static packet used for debugging

       char data[] = {
              0x45, 0x00, 0x00, 0x54, 0xbc, 0xe7, 0x40, 0x00, 0x80, 0x01, 0xb9, 0x71, 0xc0, 0xa8,
              0x01, 0x02, 0xc0, 0xa8, 0x01, 0x01, 0x00, 0x00, 0x51, 0x96, 0xf7, 0x6b, 0x00, 0x04,   0xf8, 0xe9,
              0x80, 0x43, 0x44, 0xc9, 0x0e, 0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 
              0x12, 0x13,0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 
              0x22, 0x23,  0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 
              0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37};
   
	int length = 84;

	struct sk_buff *skb;
	struct sonet_priv *priv = netdev_priv(dev);
	skb = dev_alloc_skb(length);
	memcpy(skb_put(skb, length), data, length);
	skb->dev = dev;

	//I am trying to set a static header
       skb->mac.raw = 0x00;
	skb->pkt_type=PACKET_OTHERHOST;
	skb->protocol=ETH_P_IP;
       skb->data = data;
	skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */
	priv->stats.rx_packets++;
	priv->stats.rx_bytes += length;
	netif_rx(skb);
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve an sk_buff from libipq netfunk Linux - Networking 2 03-20-2006 04:16 AM
how to use sk_buff wangjinyi Programming 0 10-27-2005 02:28 AM
kernel APIs related to sk_buff seong moon Linux - Networking 0 08-27-2002 04:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration