我正在尝试编译一个名为 ngrep 的程序,当我运行 configure 时,一切似乎都很顺利,但是当我运行 make 时,我得到:
ngrep.c: In function ‘process’:
ngrep.c:544: error: ‘struct udphdr’ has no member named ‘source’
ngrep.c:545: error: ‘struct udphdr’ has no member named ‘dest’
make: *** [ngrep.o] Error 1
这是什么意思,我该如何解决?没有更早的警告或错误表明问题的根源。
最佳答案
发现问题:
#ifdef HAVE_DUMB_UDPHDR
printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->source));
printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->dest));
#else
printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->uh_sport));
printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->uh_dport));
#endif
显然,configure 在这个测试中有一个错误,它认为我的系统有“愚蠢的”udphdr,即使它没有。将第一行更改为“#if 0”可解决问题。
关于c - "error: ' struct udphdr ' has no member named ' source '"...嗯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/213950/