我正在浏览一段数据包注入器的代码。当我尝试编译它时,它显示错误:
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。