当前位置: 技术问答>linux和unix
linux 中怎样看一个程序中的一段源代码是否被编译?tcpdump.c设置网卡混杂模式?
来源: 互联网 发布时间:2016-11-24
本文导语: 在tcpdump.c中有一段ifdef HAVE_PCAP_CREATE pd = pcap_create(device, ebuf); if (pd == NULL) error("%s", ebuf); status = pcap_set_snaplen(pd, snaplen); if (status != 0) error("%s: pcap_set_snaplen failed: %s", device, pcap_statustostr(s...
在tcpdump.c中有一段ifdef HAVE_PCAP_CREATE
pd = pcap_create(device, ebuf);
if (pd == NULL)
error("%s", ebuf);
status = pcap_set_snaplen(pd, snaplen);
if (status != 0)
error("%s: pcap_set_snaplen failed: %s",
device, pcap_statustostr(status));
status = pcap_set_promisc(pd, !pflag);
if (status != 0)
error("%s: pcap_set_promisc failed: %s",
device, pcap_statustostr(status));
if (Iflag) {
status = pcap_set_rfmon(pd, 1);
if (status != 0)
error("%s: pcap_set_rfmon failed: %s",
device, pcap_statustostr(status));
}
status = pcap_set_timeout(pd, 1000);
if (status != 0)
error("%s: pcap_set_timeout failed: %s",
device, pcap_statustostr(status));
if (Bflag != 0) {
status = pcap_set_buffer_size(pd, Bflag);
if (status != 0)
error("%s: pcap_set_buffer_size failed: %s",
device, pcap_statustostr(status));
}
status = pcap_activate(pd);
if (status 0) {
/*
* pcap_activate() succeeded, but it's warning us
* of a problem it had.
*/
cp = pcap_geterr(pd);
if (status == PCAP_WARNING)
warning("%s", cp);
else if (status == PCAP_WARNING_PROMISC_NOTSUP &&
*cp != '')
warning("%s: %sn(%s)", device,
pcap_statustostr(status), cp);
else
warning("%s: %s", device,
pcap_statustostr(status));
}
#else
*ebuf = '';
pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
if (pd == NULL)
error("%s", ebuf);
else if (*ebuf)
warning("%s", ebuf);
#endif /* HAVE_PCAP_CREATE */
/*
* Let user own process after socket has been opened.
*/
我在configure文件里面没找到HAVE_PCAP_CREATE这个,而且./configure出现pcap_create.....no,
请问各位高手,,,,,这个怎么判断,我还不懂configure文件的作用乃
pd = pcap_create(device, ebuf);
if (pd == NULL)
error("%s", ebuf);
status = pcap_set_snaplen(pd, snaplen);
if (status != 0)
error("%s: pcap_set_snaplen failed: %s",
device, pcap_statustostr(status));
status = pcap_set_promisc(pd, !pflag);
if (status != 0)
error("%s: pcap_set_promisc failed: %s",
device, pcap_statustostr(status));
if (Iflag) {
status = pcap_set_rfmon(pd, 1);
if (status != 0)
error("%s: pcap_set_rfmon failed: %s",
device, pcap_statustostr(status));
}
status = pcap_set_timeout(pd, 1000);
if (status != 0)
error("%s: pcap_set_timeout failed: %s",
device, pcap_statustostr(status));
if (Bflag != 0) {
status = pcap_set_buffer_size(pd, Bflag);
if (status != 0)
error("%s: pcap_set_buffer_size failed: %s",
device, pcap_statustostr(status));
}
status = pcap_activate(pd);
if (status 0) {
/*
* pcap_activate() succeeded, but it's warning us
* of a problem it had.
*/
cp = pcap_geterr(pd);
if (status == PCAP_WARNING)
warning("%s", cp);
else if (status == PCAP_WARNING_PROMISC_NOTSUP &&
*cp != '')
warning("%s: %sn(%s)", device,
pcap_statustostr(status), cp);
else
warning("%s: %s", device,
pcap_statustostr(status));
}
#else
*ebuf = '';
pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
if (pd == NULL)
error("%s", ebuf);
else if (*ebuf)
warning("%s", ebuf);
#endif /* HAVE_PCAP_CREATE */
/*
* Let user own process after socket has been opened.
*/
我在configure文件里面没找到HAVE_PCAP_CREATE这个,而且./configure出现pcap_create.....no,
请问各位高手,,,,,这个怎么判断,我还不懂configure文件的作用乃
|
make的时候,把编译选项打印出来,看看HAVE_PCAP_CREATE宏有没有定义
./configure出现pcap_create.....no 一般表示没有编译该功能(如果配置脚本正常的话)
./configure出现pcap_create.....no 一般表示没有编译该功能(如果配置脚本正常的话)
|
#ifdef xx
里面随便加几个字母avasdfe
编译报错就证明有定义
#endif
里面随便加几个字母avasdfe
编译报错就证明有定义
#endif