パケットインジェクターのコードを調べています。私がそれをコンパイルしようとしたとき、それはエラーを示しています:
IP-Packet-Injection.c:155: error: lvalue required as left operand of assignment
IP-Packet-Injection.c:156: error: lvalue required as left operand of assignment
その特定の部分のコードは次のとおりです。
unsigned char *CreateIPHeader(/* Customize this as an exercise */)
{
struct iphdr *ip_header;
ip_header = (struct iphdr *)malloc(sizeof(struct iphdr));
ip_header->version = 4;
ip_header->ihl = (sizeof(struct iphdr))/4 ;
ip_header->tos = 0;
ip_header->tot_len = htons(sizeof(struct iphdr));
ip_header->id = htons(111);
ip_header->frag_off = 0;
ip_header->ttl = 111;
ip_header->protocol = IPPROTO_TCP;
ip_header->check = 0; /* We will calculate the checksum later */
/*this is line 155 */ (in_addr_t)ip_header->saddr = inet_addr(SRC_IP);
/*this is line 156 */ (in_addr_t)ip_header->daddr = inet_addr(DST_IP);
/* Calculate the IP checksum now :
The IP Checksum is only over the IP header */
ip_header->check = ComputeIpChecksum((unsigned char *)ip_header, ip_header->ihl*4);
return ((unsigned char *)ip_header);
}
コードの155行目と156行目を示しました。そこには何の問題も見当たりません。誰かがエラーが何であるかを教えてもらえますか?前もって感謝します。オペレーティングシステム:Ubuntu、コンパイラ:GCC。