[mpls-linux-general] regarding sk_buff structure....
Status: Beta
Brought to you by:
jleu
From: <vvk...@hs...> - 2002-01-08 18:35:34
|
Hi Experts ! I have come across with one problem that , i want to get the packet and send it to an application , running in user space .......... My objective is to get the SHIM ,src,dest address and packet data ........ I am following style.......................of code. #define MPLS_MAX_BUFF_SIZE 1500 #define MPLS_MAX_DATA_SIZE 1500 - 4* sizeof ( unsigned long ) -1 int mpls_get_packet_data( struct sk_buff *skb, unsigned long shim, int type ) { char *fname="mpls_get_packet_data"; mpls_info_t *buff=NULL; printk(KERN_ALERT"%s : entering .....\n",fname); buff=(mpls_info_t *)kmalloc(sizeof(mpls_info_t), GFP_KERNEL); if ( buff == NULL ) { printk(KERN_ALERT"%s: kmalloc error",fname); return -ENOMEM; } if ( skb == NULL ) { printk(KERN_ALERT"%s: skb NULL argument error",fname); kfree(buff); return -EINVAL; } /* Now get the "src", "fec ..i.e dest address", * "data" from sk_buff structure ......... * Fill it in the "mpls_info_t" structure... * and place the msg in the queue ....... */ buff->type = type; /* Label Type ...IN or OUT Label */ buff->shim = shim; /* fill the SHIM info .......*/ buff->src = skb->nh.iph->saddr; /* src address from sk_buff */ buff->fec = skb->nh.iph->daddr; /* dest address from sk_buff */ memset(buff->data, 0, MPLS_MAX_DATA_SIZE-1); if ( skb->data != NULL ) { printk(KERN_ALERT"%s: skb data length [%d]\n",fname,skb->len); memcpy(buff->data, skb->data, skb->len); } return mpls_sendmsg(buff, MPLS_MAX_BUFF_SIZE); } This function i am calling in the "mpls_output2" function in the file : " mpls_output.c" file of mpls src for kinux............ here problem is ......... after some time kernel panic msg arriving and system is hanging up .... no response ............ Error is : invalid operand : 00000 Is the way i am following is correct or not ? Can you please guide me , how to retrieve the data............from "sk_buff" structure ...............? Please guide me in this .............. I am following the Linux Device Drivers book by oerilly .. by alessandro rubini............ Thanks in advance........ Regards,Ramki kvv. Hughes Software Systems |