hi
i can get the ip package buffer through libpacp or SOCK_RAW , now i
want to build a package with my own ethernet header.
i try this$B!$(Bbut it seems don't work
int scok=scoket(PF_INET,SCOK_RAW,IPPROTO_TCP);
char buf[4096];
strcut ethhdr *ethh=(struct ethhdr *)buf;
struct iphdr *iph=(struct iphdr *)(buf+sizeof(struct ethhdr);
struct tcphdr *tcph=(struct tcphdr *)(buf+ sizeof(struct ethhdr)
+sizeof(struct iphdr));
then set the data for above three struct.
use sendto function to send the buf.
but it seems don't work. how can i do so i can build a package with
my own ethernet header.
or if i recv a package, i change the ethernet header , how can i send
this package.
thanks very much!!!
|