Raw Socket Linux send/receive a packet

后端 未结 2 716
谎友^
谎友^ 2020-12-30 11:51

Have some problems in receiving packets. I can receive and read incoming packets, but I think i do not get a handshake with any host. I only want to send a packet to a remot

2条回答
  •  忘掉有多难
    2020-12-30 12:04

    ip = (struct iphdr*) buffer;
    tcp = (struct tcphdr*) (buffer + sizeof(struct tcphdr)); //This is wrong
    

    Here to get array index of tcp header in buffer, you need to add sizeof(struct iphdr) to buffer like mentioned below.

    ip = (struct iphdr*) buffer;
    tcp = (struct tcphdr*) (buffer + sizeof(struct iphdr)); //This is correct
    

提交回复
热议问题