libipset(3)
β¨ libipset β the library for using ipset β¨
okay bestie, sit down, hydrate, because this is the libipset(3) manual page and it is lowkey iconic π
it's the C library side of ipset(8), and yes it lives in section 3 of the manual, and yes you're gonna slay it.
πΈ NAME πΈ
libipset β a library for using ipset π«Ά
π SYNOPSIS π
#include <libipset/ipset.h>
void ipset_load_types(void)
struct ipset * ipset_init(void)
int ipset_parse_argv(struct ipset *ipset, int argc, char *argv[])
int ipset_parse_line(struct ipset *ipset, char *line)
int ipset_parse_stream(struct ipset *ipset, FILE *f)
int ipset_fini(struct ipset *ipset)
int ipset_custom_printf(struct ipset *ipset,
ipset_custom_errorfn custom_error,
ipset_standard_errorfn standard_error,
ipset_print_outfn outfn,
void *p)
struct ipset_session * ipset_session(struct ipset *ipset)
int ipset_session_full_io(struct ipset_session *session,
const char *filename,
enum ipset_io_type what)
int ipset_session_normal_io(struct ipset_session *session,
const char *filename,
enum ipset_io_type what)
FILE * ipset_session_io_stream(struct ipset_session *session,
enum ipset_io_type what)
int ipset_session_io_close(struct ipset_session *session,
enum ipset_io_type what)
π DESCRIPTION π
So, libipset hands you a library interface to ipset(8). That's the whole vibe. π
And here's the thing you gotta internalize: the functions that return an integer return 0 when everything's cute and slay, and a negative value when it's giving failure. π no cap.
π ipset_load_types π
Loads in the supported ipset types into the library and makes them available for the ipset interface. it's literally the "get the squad in the group chat" step β¨
π ipset_init π
Initializes the ipset interface: allocates and initializes the required internal structures, and opens up the netlink channel. The function returns the library interface structure of type struct ipset *, or NULL on failure. π
π ipset_parse_argv π
Parses the argc length of array of strings argv with the already initialized ipset library structure. If the command is successfully parsed, it is then submitted to the kernel to execute. In the case of error, the textual error message is printed and a negative number is returned. π
π ipset_parse_line π
Parses the string line with the already initialized ipset library structure. The line is supposed to contain a single ipset command in restore format. If the command is successfully parsed, it is then submitted to the kernel to execute. In the case of error, the textual error message is printed and a negative number is returned. π
π ipset_parse_stream π
Parses the stream f with the already initialized ipset library structure. The stream may contain multiple newline separated ipset commands in restore format. The commands are parsed and then submitted to the kernel in batches for efficiecy. In the case of error, the textual error message is printed and a negative number is returned. π₯
π ipset_fini π
Closes the netlink channel, closes opened streams and releases allocated structures holding by the ipset library structure. it's the graceful exit, the goodbye hug, the "text me when you get home" π«Ά
π customizing the interface π
The following functions makes possible to customize the interface.
πΈ ipset_custom_printf πΈ
Sets or resets the print functions for the ipset library structure, where custom_error is the custom error print function for the internal library errors, standard_error is the print function for the netlink/kernel related errors and outfn is the output function to print the result of list/save commands. The p pointer makes possible to pass arbitrary structure to the custom print functions. If NULL is passed instead of a function pointer, the default print function is set for the given task. If any of the print functions is non-default, then the version, help, interactive ipset commands are ignored. π (yes, ignored. periodt.)
πΈ ipset_session πΈ
The function returns the session structure of the ipset library structure, in order to manipulate the IO parameters.
πΈ ipset_session_full_io πΈ
You can control the full IO, i.e. input (restore) and output (save) separatedly by the function. The session parameter is the session structure of the library interface, filename is the filename you want to use for input or output and what tells the function you want to set input or output file. If there's an already opened file for the given IO mode, it is closed. The function returns an error if normal mode is in use. If NULL is passed instead of a filename, already opened file is closed and the normal stream is set for the given IO mode (stdin for input, stdout for output). Input/output files can be set separatedly. β¨
πΈ ipset_session_normal_io πΈ
You can control the normal IO, which corresponds to the interface provided by ipset(8) itself. session parameter is the session structure of the library interface, filename is the filename you want to use for input or output and what tells the function you want to set input or output file. If there's an already opened file for input/output, it is closed. The function returns an error if full mode is in use. If NULL is passed instead of a filename, already opened file is closed and the normal stream is set for the given IO mode (stdin for input, stdout for output). Input/output files cannot be set separatedly. π
πΈ ipset_session_io_stream πΈ
The function returns the stream set for the session where what tells the function you want to get the input or the output stream.
πΈ ipset_session_io_close πΈ
The function closes the stream for the session where what tells the function you want to close the input or the output stream. After closing, the standard streams are set: stdin for input, stdout for output. π
π little heads up bestie:fullmode andnormalmode are giving "pick one" energy β each of these functions returns an error if the other mode is in use. iykyk.
π AUTHORS π
ipset/libipset was designed and written by Jozsef Kadlecsik. the main character, fr fr π
π₯ SEE ALSO π₯
ipset(8)/usr/include/libipset/ipset.h/usr/include/libipset/session.h
and that's the whole page, bestie π¦ this was the libipset(3) manual, brought to you by Jozsef Kadlecsik, dated Oct 16, 2018, and sourced from the libipset(3) page itself. go forth and link against it, you absolute legend πβ¨π
π¦ where this page comes from
- alpine 3.22: ipset-doc 7.24-r0 Β· GPL-2.0-only
- alpine 3.23: ipset-doc 7.24-r0 Β· GPL-2.0-only
- alpine 3.24: ipset-doc 7.24-r0 Β· GPL-2.0-only
- arch rolling: ipset 7.24-1 Β· GPL-2.0-only
- centos-stream 10: ipset-devel 7.22-13.el10 Β· GPL-2.0-only
- centos-stream 9: ipset-devel 7.11-11.el9 Β· GPLv2
- centos-stream 9: ipset-devel 7.11-11.el9 Β· GPLv2
- debian bookworm: libipset-dev 7.17-1 Β· GPL-2.0-or-later
- debian trixie: libipset-dev 7.22-1+b1 Β· GPL-2.0-or-later
- fedora 43: ipset-devel 7.24-2.fc43 Β· GPL-2.0-only
- fedora 43: ipset-devel 7.24-2.fc43 Β· GPL-2.0-only
- fedora 44: ipset-devel 7.24-3.fc44 Β· GPL-2.0-only
- fedora 44: ipset-devel 7.24-3.fc44 Β· GPL-2.0-only
- nixos 26.05: ipset 7.24
- nixpkgs unstable: ipset 7.24
- opensuse-leap 16.0: ipset 7.23-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: ipset 7.23-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: ipset 7.23-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: ipset 7.23-160000.2.2 Β· GPL-2.0-only
- ubuntu jammy: libipset-dev 7.15-1build1 Β· GPL-2.0-or-later
- ubuntu noble: libipset-dev 7.19-1ubuntu2 Β· GPL-2.0-or-later
- ubuntu questing: libipset-dev 7.19-1ubuntu2
- ubuntu resolute: libipset-dev 7.19-1ubuntu3 Β· GPL-2.0-or-later
- ubuntu stonking: libipset-dev 7.19-1ubuntu3 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms