我正在尝试编译一个名为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在这个测试中有一个bug,它认为我的系统有“dumb”udphdr,尽管它没有。将第一行改为“if 0”可以解决这个问题。

08-17 03:00