All of lore.kernel.org
 help / color / mirror / Atom feed
* Just starting with libipq
@ 2005-05-05 14:11 Duncan Godfrey
  2005-05-06 12:50 ` Jonas Berlin
  0 siblings, 1 reply; 3+ messages in thread
From: Duncan Godfrey @ 2005-05-05 14:11 UTC (permalink / raw)
  To: netfilter-devel

Hello,

I was wondering if someone would be able to help me, Im just starting 
out with some libipq development and Im trying to compile some example 
source code from a tutorial site (I have compiled the source on the man 
page an it worked fine).

Everytime I compile it with gcc -o quick quick.c -libpq, I get the 
following errors:

quick.c:56: error: dereferencing pointer to incomplete type
quick.c:58: error: dereferencing pointer to incomplete type

Has anyone else had a similar experience? Thanks in advance for any help.

Duncan

The code is:

#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);

      struct iphdr *ip = (struct iphdr*) m->payload;

      struct tcphdr *tcp = (struct tcphdr*) (m->payload + (4 * ip->ihl));
                                 
      int port = htons(tcp->dest);       
                              
      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;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-06 12:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-05 14:11 Just starting with libipq Duncan Godfrey
2005-05-06 12:50 ` Jonas Berlin
2005-05-06 12:54   ` Jonas Berlin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.