c - "error: ' struct udphdr ' has no member named ' source '"...嗯?

标签 c linux unix ngrep

我正在尝试编译一个名为 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/

相关文章:

c++ - 无法使用#define作为传递给原型(prototype)的值,无效代码

linux - shell 脚本: error during comparison (Linux)

windows - linux下maven-jetty-plugin无法绑定(bind)地址

linux - 在 Linux 上修复几千个文件名

java - 如何使用java在没有密码的情况下ssh到主机

c - 如何将数组地址存储在另一个数组的索引中?

c++ - C/C++ 动态链接如何在不同平台上工作?

c - 在不安装的情况下构建嵌套的 Autotools 包

Linux 堆栈驻留内存在堆栈展开后未回收

c - 为什么这个 C 程序执行在通过 scanf() 输入时停止工作?