C code to change destination address field in a packet

view full story

http://stackoverflow.com – I have a C program to capture packets transmitted on an interface. It prints the various fields of the captured packet like the protocol, destination address etc. Now, I need to change the destination address of all these packets, so as to give it a different route for transmission. I am working on Linux OS and thus using libpcap for packet-capturing. So, a C function/code to do serve this purpose is what I am looking for. Tcprewrite is a command which does this; but I need to code this in C instead of using the command. Any help would be highly appreciated. (HowTos)