我在C linux中实现原始套接字。 下面的函数为'inet_ntoa'的参数1提供错误不兼容的类型 早些时候它运行良好。但现在这个错误即将到来。为什么这样? -
//packet is received from socket using recvfrom call.
char* ParseIPHeader(unsigned char *packet,int len)
{
struct ethhdr *ethernet_header;
struct iphdr *ip_header;
ethernet_header=(struct ethhdr *)packet;
if(ntohs(ethernet_header->h_proto)==ETH_P_IP)
{
if(len>=(sizeof(struct ethhdr)+sizeof(struct iphdr)))
{
ip_header=(struct iphdr*)(packet+sizeof(struct ethhdr));
printf("Dest IP address: %s \n",inet_ntoa(ip_header->daddr)); //error here
printf("Source IP address: %s \n",inet_ntoa(ip_header->saddr)); //error here
}
}
}