CCing the list On 7/16/14, Denis Kirjanov <kirjanov@xxxxxxxxx> wrote: > On 7/16/14, Robert Clove <cloverobert@xxxxxxxxx> wrote: > > Please don't reply privately > >> skb is the new skb >> and >> size is the size of the variable that i will push in new header >> For eg: >> struct my_head_struct { >> int a; >> }; >> unsigned int hook_func(unsigned int hooknum, >> struct sk_buff *skb, >> const struct net_device *in, >> const struct net_device *out, >> int (*okfn)(struct sk_buff *)) >> { >> >> unsigned int length,truesize; >> printk("Inside the hook function\n"); >> >> >> struct my_head_struct * my_head= NULL; >> >> struct sk_buff *newskb; >> newskb = skb_copy_expand(skb, sizeof(struct my_head_struct), 0, >> GFP_ATOMIC); >> if(newskb==NULL) >> { >> printk("Failed to allocate mem\n"); >> //return SEND_FAIL_MEMORY; >> } >> else >> { >> // /* need add check of newskb value for error control */ >> >> skb_push(newskb, sizeof(struct my_head_struct)); > > my_head = (struct my_head_struct *) skb_push(skb, sizeof (*my_head)); > my_head->a = cpu_to_be32(<your be32 value>); > >> >> // /* use network byte order */ >> my_head->a = 21; *//want to push this in new skb* >> >> } >> printk("Dropped packet on %s...\n", drop_if); >> return NF_ACCEPT; >> } else { >> return NF_ACCEPT; >> } >> } >> >> Please guide on above >> >> >> On Wed, Jul 16, 2014 at 4:57 PM, Denis Kirjanov <kirjanov@xxxxxxxxx> >> wrote: >> >>> On 7/16/14, Robert Clove <cloverobert@xxxxxxxxx> wrote: >>> > Hi All, >>> > >>> > >>> > I want to add data to the packet header. >>> > >>> > I used the skb_copy_expand to make the copy of the skb and data. >>> > Now in the headroom i want to add some data. >>> > How can i do that,please suggest . >>> >>> __skb_push(skb, <your size>) to adjust the skb->data pointer >>> >>> > >>> > Regards >>> > >>> >>> >>> -- >>> Regards, >>> Denis >>> >> > > > -- > Regards, > Denis > -- Regards, Denis _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies