Skip to contentSkip to conversation

A libipq program error . It seems link error,

DISCUSSION cyberyam 1 participant 1 message May 16, 2003 netfilter

lore
Share & tools
lore

cyberyam

author
#0 lore raw

I have update the iptables from 1.2.6a to 1.2.8
use the next command

       make  jxvf iptables1.2.8.tar.tar
       make  install KERNEL_DIR=/usr/src/linux
       make  install-devel KERNEL_DIR=/usr/src/linux 

i use the command iptables ,it appears it has been updated to 1.2.8

But i use a program test libipq ,it is occored the next error ,Who can tell me the reasons.

ot@zhaopeng test]# gcc testLIbipq.c
/tmp/ccwmXAsQ.o: In function `die':
/tmp/ccwmXAsQ.o(.text+0xf): undefined reference to ipq_perror' /tmp/ccwmXAsQ.o(.text+0x1d): undefined reference to ipq_destroy_handle' /tmp/ccwmXAsQ.o: In function `main':
/tmp/ccwmXAsQ.o(.text+0x49): undefined reference to ipq_create_handle' /tmp/ccwmXAsQ.o(.text+0x81): undefined reference to ipq_set_mode' /tmp/ccwmXAsQ.o(.text+0xb8): undefined reference to ipq_read' /tmp/ccwmXAsQ.o(.text+0xe4): undefined reference to ipq_message_type' /tmp/ccwmXAsQ.o(.text+0x116): undefined reference to ipq_get_msgerr' /tmp/ccwmXAsQ.o(.text+0x141): undefined reference to ipq_get_packet' /tmp/ccwmXAsQ.o(.text+0x166): undefined reference to `ipq_set_verdict'
collect2: ld returned 1 exit status

The source is
----------------------------------------------------------------------
/*
* This code is GPL.
*/
#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;
}