Logo Search packages:      
Sourcecode: libnetfilter-queue version File versions  Download package

struct nfq_q_handle* nfq_create_queue ( struct nfq_handle h,
u_int16_t  num,
nfq_callback *  cb,
void *  data 
) [read]

nfq_create_queue - create a new queue handle and return it.

Parameters:
hNetfilter queue connection handle obtained via call to nfq_open()
numthe number of the queue to bind to
cbcallback function to call for each queued packet
datacustom data to pass to the callback function
Returns:
a nfq_q_handle pointing to the newly created queue

Creates a new queue handle, and returns it. The new queue is identified by num, and the callback specified by cb will be called for each enqueued packet. The data argument will be passed unchanged to the callback. If a queue entry with id num already exists, this function will return failure and the existing entry is unchanged.

The nfq_callback type is defined in libnetfilter_queue.h as:

typedef int nfq_callback(struct nfq_q_handle *qh,
		    	 struct nfgenmsg *nfmsg,
			 struct nfq_data *nfad, void *data);

Parameters:

  • qh The queue handle returned by nfq_create_queue
  • nfmsg message objetc that contains the packet
  • nfad Netlink packet data handle
  • data the value passed to the data parameter of nfq_create_queue

The callback should return < 0 to stop processing.

Definition at line 467 of file libnetfilter_queue.c.

{
      int ret;
      struct nfq_q_handle *qh;

      if (find_qh(h, num))
            return NULL;

      qh = malloc(sizeof(*qh));

      memset(qh, 0, sizeof(*qh));
      qh->h = h;
      qh->id = num;
      qh->cb = cb;
      qh->data = data;

      ret = __build_send_cfg_msg(h, NFQNL_CFG_CMD_BIND, num, 0);
      if (ret < 0) {
            nfq_errno = ret;
            free(qh);
            return NULL;
      }

      add_qh(qh);
      return qh;
}

Generated by  Doxygen 1.6.0   Back to index