0
我正在瀏覽數據包注入器的一段代碼。當我試圖編譯,它是示出了錯誤:爲自定義數據包創建IP標頭時出錯
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。