Skip to contentSkip to conversation

Injecting a brand new packet.

DISCUSSION Emmanuel Guiton 1 participant 1 message Jan 21, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi!

I'd like some advices on the following as I would not like to do it wrong and be obliged to started it again and again from scratch.

In my framework, upon reception of a certain message, the host running netfilter needs to inject a TCP packet in the network on behalf of another machine.

I started to implement this from scratch by building my own TCP packet that I was thinking to send with the ip_build_and_send_pkt (it seems to fit my needs as I can specify the source and destination IP addresses). So far, I filled my TCP header except the checksum (I guess I'll find a function to do so), I initialized a socket, and I have now to initialize the struct sk_buff, which I don't know yet how to do.

Now two questions haunt my mind:
- is there something alike in any part of the netfilter code? It would avoid me to reinvent the wheel.
- if not, do you think I choose the good way? Particularly because I'm not totally sure about the exact functionality of this ip_build_and_send_pkt function.

If you have a good advice on that, I appreciate your help a lot.

Emmanuel