免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1578 | 回复: 9
打印 上一主题 下一主题

about a code of libipq application ,mistakens?? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-04-18 20:45 |只看该作者 |倒序浏览
The following is an example of a simple application which receives packets and issues NF_ACCEPT verdicts on each packet.

#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\n",
                                        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!\n";
                                break;
                }
        } while (1);        
        ipq_destroy_handle(h);
        return 0;
}

论坛徽章:
0
2 [报告]
发表于 2003-04-18 20:47 |只看该作者

about a code of libipq application ,mistakens??

when gcc ,the mistakens are followings:
/tmp/cceyASBq.o: In function `die':
/tmp/cceyASBq.o(.text+0xf): undefined reference to `ipq_perror'
/tmp/cceyASBq.o(.text+0x1d): undefined reference to `ipq_destroy_handle'
/tmp/cceyASBq.o: In function `main':
/tmp/cceyASBq.o(.text+0x49): undefined reference to `ipq_create_handle'
/tmp/cceyASBq.o(.text+0x81): undefined reference to `ipq_set_mode'
/tmp/cceyASBq.o(.text+0xb: undefined reference to `ipq_read'
/tmp/cceyASBq.o(.text+0xe4): undefined reference to `ipq_message_type'/tmp/cceyASBq.o(.text+0x116): undefined reference to `ipq_get_msgerr'
/tmp/cceyASBq.o(.text+0x141): undefined reference to `ipq_get_packet'
/tmp/cceyASBq.o(.text+0x166): undefined reference to `ipq_set_verdict'

论坛徽章:
0
3 [报告]
发表于 2003-04-18 20:47 |只看该作者

about a code of libipq application ,mistakens??

why these mistakes happen??
help!

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2003-04-18 21:28 |只看该作者

about a code of libipq application ,mistakens??

gcc带上 -lipq

论坛徽章:
0
5 [报告]
发表于 2003-04-18 22:19 |只看该作者

about a code of libipq application ,mistakens??

gcc -lipq *.c??

mistake:
/usr/bin/ld: cannot find -lipq


??

论坛徽章:
0
6 [报告]
发表于 2003-04-19 09:37 |只看该作者

about a code of libipq application ,mistakens??

what path should we install iptables?and then?

论坛徽章:
0
7 [报告]
发表于 2003-04-19 10:05 |只看该作者

about a code of libipq application ,mistakens??

这段代码的目的是:receives the packets and issues NF_ACCEPT verdicts on each packet
这是libipq的一个简单应用

iptables装到/usr/src/linux-2.4/net/core下行吗?
我这个错误和这个路径有关吗?
还有,gcc test.c出现这些错误,但是gcc -c test.c就不出现,直接生成了目标代码test.o,是不是就说明编译没有问题,而链接有错误?   (此代码起名叫test.c)
为什么不能使这段代码生效??

论坛徽章:
0
8 [报告]
发表于 2003-04-20 08:48 |只看该作者

about a code of libipq application ,mistakens??

顶!!
在线等,先谢谢了!

论坛徽章:
0
9 [报告]
发表于 2003-04-21 11:25 |只看该作者

about a code of libipq application ,mistakens??

我们把ibtables-1.1.8 make 了一下,在/usr/lib下出现了libipq.a,这个程序就只剩下一个错误了:
too many arguments to function 'ipq_create_handle'

问题到底出现在哪里??
help!!   help!!!
在线等!!

论坛徽章:
0
10 [报告]
发表于 2003-05-30 17:06 |只看该作者

about a code of libipq application ,mistakens??

$gcc -I/usr/local/include -L/usr/local/lib -o ipqtst ipqtst.c -lipq
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP