LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   eternet header.... (https://www.linuxquestions.org/questions/linux-networking-3/eternet-header-440910/)

shrishailnk 05-02-2006 10:58 AM

eternet header....
 
hello all,

I need to add the ethernet header to the newly allocated sk_buff ,insted of copying whole ethernet
header , i need to copy the individual fields to sk_buff ( ie dst mac ,src mac ,proto)...

can anyone please tell me is the code below ,can realise the above idea....

unsigned char dmac[6]; all these have the respectiv
unsigned char smac[6]; values...
unsigned int type;

new_skb = alloc_skb(size+16 , GFP_ATOMIC);

should i allocate 16 or 14 for eth hdr...

skb_reserve(new_skb , 16);
memcpy(new_skb->data-16 , dmac , 6);
memcpy(new_skb->data-10 , smac , 6);
memcpy(new_skb->data-4 , type ,2);
skb_push(new_skb , 16);

will the above lines work?
one more doubt...
Is it necessary to use only ptrs in the memcpy arguments ... (say i have "int a" ,can i just copy it or do i have to convert it to a ptr...)

waiting for response..
thanks in advance...


All times are GMT -5. The time now is 03:36 PM.