LibrarySetup(3)

πŸ’– LibrarySetup(3) πŸ’–

ok so bestie, welcome to LibrarySetup, a page from the Library Functions Manual for libnetfilter_queue. she's giving legacy energy ngl β€” this whole thing is [DEPRECATED] and we're gonna talk about it πŸ’…


✨ NAME ✨

LibrarySetup β€” Library setup [DEPRECATED]


πŸ¦‹ SYNOPSIS πŸ¦‹

Functions

  • struct nfq_handle * nfq_open (void)
  • int nfq_close (struct nfq_handle *h)
  • int nfq_bind_pf (struct nfq_handle *h, uint16_t pf)
  • int nfq_unbind_pf (struct nfq_handle *h, uint16_t pf)

🌸 Detailed Description 🌸

ok so library initialisation happens in two steps, no more no less, she's a two-step girlie πŸŽ€

First step is to call nfq_open() to open a NFQUEUE handler.

Second step is to tell the kernel that userspace queueing is handle by NFQUEUE for the selected protocol. This is made by calling nfq_unbind_pf() and nfq_bind_pf() with protocol information. The idea behind this is to enable simultaneously loaded modules to be used for queuing. iykyk πŸ’œ

Here's a little code snippet that bind with AF_INET:

h = nfq_open();
if (!h) {
        fprintf(stderr, 'error during nfq_open()\n');
        exit(1);
}

printf('unbinding existing nf_queue handler for AF_INET (if any)\n');
if (nfq_unbind_pf(h, AF_INET) < 0) {
        fprintf(stderr, 'error during nfq_unbind_pf()\n');
        exit(1);
}

printf('binding nfnetlink_queue as nf_queue handler for AF_INET\n');
if (nfq_bind_pf(h, AF_INET) < 0) {
        fprintf(stderr, 'error during nfq_bind_pf()\n');
        exit(1);
}

Once this is done, you can setup and use a Queue. ✨

When the program has finished with libnetfilter_queue, it has to call the nfq_close() function to free all associated resources. clean up after yourself bestie, it's giving main character energy 🌈


πŸ‘‘ Function Documentation πŸ‘‘

int nfq_bind_pf (struct nfq_handle * h, uint16_t pf)

nfq_bind_pf β€” bind a nfqueue handler to a given protocol family 🫢

Parameters

  • h β€” Netfilter queue connection handle obtained via call to nfq_open()
  • pf β€” protocol family to bind to nfqueue handler obtained from nfq_open()

Binds the given queue connection handle to process packets belonging to the given protocol family (ie. PF_INET, PF_INET6, etc). This call is obsolete, Linux kernels from 3.8 onwards ignore it. πŸ’€ like she's literally being ignored by the kernel, that's so real of her

Returns

  • integer inferior to 0 in case of failure
Definition at line 474 of file libnetfilter_queue.c.

int nfq_close (struct nfq_handle * h)

nfq_close β€” close a nfqueue handler 🌸

Parameters

  • h β€” Netfilter queue connection handle obtained via call to nfq_open()

This function closes the nfqueue handler and free associated resources. closure is self-care fr fr 🧚

Returns

  • 0 on success, non-zero on failure.
Definition at line 452 of file libnetfilter_queue.c.

struct nfq_handle * nfq_open (void)

nfq_open β€” open a nfqueue handler ✨

This function obtains a netfilter queue connection handle. When you are finished with the handle returned by this function, you should destroy it by calling nfq_close(). A new netlink connection is obtained internally and associated with the queue connection handle returned. she's out here making connections, networking queen πŸ’…

Returns

  • a pointer to a new queue handle or NULL on failure.
Definition at line 363 of file libnetfilter_queue.c.

int nfq_unbind_pf (struct nfq_handle * h, uint16_t pf)

nfq_unbind_pf β€” unbind nfqueue handler from a protocol family πŸ¦‹

Parameters

  • h β€” Netfilter queue connection handle obtained via call to nfq_open()
  • pf β€” protocol family to unbind family from

Unbinds the given queue connection handle from processing packets belonging to the given protocol family.

This call is obsolete, Linux kernels from 3.8 onwards ignore it. πŸ“ not the kernel ghosting her too 😭

Definition at line 490 of file libnetfilter_queue.c.

πŸ’œ Author πŸ’œ

Generated automatically by Doxygen for libnetfilter_queue from the source code. yes bestie the robots wrote this one, we're just vibing with it πŸ€–βœ¨


ok that's the whole page!! this came from libnetfilter_queue Version 1.0.5, and she's the LibrarySetup(3) girlie through and through. go forth and set up your library, bestie β€” and remember to nfq_close() when you're done πŸ’–πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from