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

int nfq_get_indev_name ( struct nlif_handle *  nlif_handle,
struct nfq_data *  nfad,
char *  name 

nfq_get_indev_name - get the name of the interface the packet was received through

nlif_handle pointer to a nlif interface resolving handle
nfad Netlink packet data handle passed to callback function
name pointer that will be set to the interface name string
-1 in case of error, >0 if it succeed.
The name variable will point to the name of the input interface.

To use a nlif_handle, You need first to call nlif_open() and to open an handler. Don't forget to store the result as it will be used during all your program life:

	h = nlif_open();
 	if (h == NULL) {
Once the handler is open, you need to fetch the interface table at a whole via a call to nlif_query.
libnfnetlink is able to update the interface mapping when a new interface appears. To do so, you need to call nlif_catch() on the handler after each interface related event. The simplest way to get and treat event is to run a select() or poll() against the nlif file descriptor. To get this file descriptor, you need to use nlif_fd:
 	if_fd = nlif_fd(h);
Don't forget to close the handler when you don't need the feature anymore:

Definition at line 862 of file libnetfilter_queue.c.

References nfq_get_indev().

      u_int32_t ifindex = nfq_get_indev(nfad);
      return nlif_index2name(nlif_handle, ifindex, name);

Generated by  Doxygen 1.6.0   Back to index