SeregASM
SeregASM

Reputation: 85

Send packet to network device from char* buf in kernel with sk_buff

I have collected char * buffer from sk_buff (hook packet and went through skb->head to skb_>end), transmitted this buffer to another PC. And now i want to resend this packet to network from a new PC. How can I send it? With using dev_queue_xmit() I had to reconstruct sk_buff structure from char* and data length. It is possible? Or can I use raw socket to resend my data?

Upvotes: 1

Views: 790

Answers (1)

Jan Hudec
Jan Hudec

Reputation: 76236

I believe you have to construct sk_buff, not reconstruct. Plus I don't think it's a reasonable idea to ever collect the char* from it.

The sk_buff simply represents a stream of bytes composed of separate pieces so they don't have to be copied all over the place when composing the packet. You should not collect a single buffer from sk_buff, but if you have single buffer, just fill in new sk_buff with one part pointing to the buffer and you are done.

Upvotes: 1

Related Questions