|
|
|
|
 关于libipq API 的疑问,求助!!! - goodness4960 [ 2005-05-25 12:00 | 2,753 byte(s)]
 Re: 关于libipq API 的疑问,求助!!! - hoyt [ 2005-05-27 08:42 | 134 byte(s)]
 Re: 关于libipq API 的疑问,求助!!! - goodness4960 [ 2005-05-28 15:53 | 10 byte(s)]
 Re: 关于libipq API 的疑问,求助!!! - goodness4960 [ 2005-05-25 12:08 | 181 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
我在redhat9(linux-2.4.20-8)环境下通过gcc libitest.c 编译以下的关于libipq程序(libitest.c).但是错误说libipq.h文件不存在。我想问两个问题:1、我写的gcc编译的格式是对的吗?如果不对,那么应该怎样编译了?
2、错误说libipq.h文件不存在,是不是需要下载和libipq.h有关的补丁或者还是内核哪一项需要配置,或者还是其他原因,请高手指点! 谢谢!
# modprobe iptable_filter
# modprobe ip_queue
# iptables -A OUTPUT -p icmp -j QUEUE
#include <linux/netfilter.h>
#include <libipq.h>
#include <stdio.h>
#define BUFSIZE 2048
static void die(struct ipq_handle *h)
{
ipq_perror("passer");
ipq_destroy_handle(h);
exit(1);
}
int main(int argc, char **argv)
{
int status;
unsigned char buf[BUFSIZE];
struct ipq_handle *h;
h = ipq_create_handle(0, PF_INET);
if (!h)
die(h);
status = ipq_set_mode(h, IPQ_COPY_PACKET, BUFSIZE);
if (status < 0)
die(h);
do{
status = ipq_read(h, buf, BUFSIZE, 0);
if (status < 0)
die(h);
switch (ipq_message_type(buf)) {
case NLMSG_ERROR:
fprintf(stderr, "Received error message %d
",
ipq_get_msgerr(buf));
break;
case IPQM_PACKET: {
ipq_packet_msg_t *m = ipq_get_packet(buf);
status = ipq_set_verdict(h, m->packet_id,
NF_ACCEPT, 0, NULL);
if (status < 0)
die(h);
break;
}
default:
fprintf(stderr, "Unknown message type!
");
break;}
} while (1);
ipq_destroy_handle(h);
return 0;
}
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
不知道libipq.h这个头文件是放在那个目录下啊?我找了很多地方都找不到 ,包括/usr/local/include ,
/usr/include/linux ,和/usr/src/linux-2.4/include/linux ,都找过了,但是都没有
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
|
这个库是iptables的一个工具库,你去下载一个iptables的源代码,然后编译一下,就会生成一个.a文件和一个头文件,把这个文件拷贝出来就可以了。
|
|
|
----
|
|
[Original]
[Print]
[Top]
|
|
|