1libipset(3) libipset(3)
2
3
4
6 libipset - A library for using ipset
7
9 #include <libipset/ipset.h>
10
11 void ipset_load_types(void)
12
13 struct ipset * ipset_init(void)
14 int ipset_parse_argv(struct ipset *ipset, int argc, char *argv[])
15
16 int ipset_parse_line(struct ipset *ipset, char *line)
17
18 int ipset_parse_stream(struct ipset *ipset, FILE *f)
19
20 int ipset_fini(struct ipset *ipset)
21
22 int ipset_custom_printf(struct ipset *ipset,
23 ipset_custom_errorfn custom_error,
24 ipset_standard_errorfn standard_error,
25 ipset_print_outfn outfn,
26 void *p)
27
28 struct ipset_session * ipset_session(struct ipset *ipset)
29
30 int ipset_session_full_io(struct ipset_session *session,
31 const char *filename,
32 enum ipset_io_type what)
33
34 int ipset_session_normal_io(struct ipset_session *session,
35 const char *filename,
36 enum ipset_io_type what)
37
38 FILE * ipset_session_io_stream(struct ipset_session *session,
39 enum ipset_io_type what)
40
41 int ipset_session_io_close(struct ipset_session *session,
42 enum ipset_io_type what)
43
45 libipset provides a library interface to ipset(8). The integer return
46 valued functions return 0 on success and a negative value on failure.
47
48 ipset_load_types
49 Loads in the supported ipset types in the library and make them
50 available for the ipset interface.
51
52
53 ipset_init
54 Initializes the ipset interface: allocates and initializes the
55 required internal structures, opens up the netlink channel. The
56 function returns the library interface structure of type struct
57 ipset * or NULL on failure.
58
59
60 ipset_parse_argv
61 Parses the argc length of array of strings argv with the already
62 initialized ipset library structure. If the command is success‐
63 fully parsed, it is then submitted to the kernel to execute. In
64 the case of error, the textual error message is printed and a
65 negative number is returned.
66
67
68 ipset_parse_line
69 Parses the string line with the already initialized ipset
70 library structure. The line is supposed to contain a single
71 ipset command in restore format. If the command is successfully
72 parsed, it is then submitted to the kernel to execute. In the
73 case of error, the textual error message is printed and a nega‐
74 tive number is returned.
75
76
77 ipset_parse_stream
78 Parses the stream f with the already initialized ipset library
79 structure. The stream may contain multiple newline separated
80 ipset commands in restore format. The commands are parsed and
81 then submitted to the kernel in batches for efficiecy. In the
82 case of error, the textual error message is printed and a nega‐
83 tive number is returned.
84
85
86 ipset_fini
87 Closes the netlink channel, closes opened streams and releases
88 allocated structures holding by the ipset library structure.
89
90
91 The following functions makes possible to customize the interface.
92
93 ipset_custom_printf
94 Sets or resets the print functions for the ipset library struc‐
95 ture, where custom_error is the custom error print function for
96 the internal library errors, standard_error is the print func‐
97 tion for the netlink/kernel related errors and outfn is the out‐
98 put function to print the result of list/save commands. The p
99 pointer makes possible to pass arbitrary structure to the custom
100 print functions. If NULL is passed instead of a function
101 pointer, the default print function is set for the given task.
102 If any of the print functions is non-default, then the version,
103 help, interactive ipset commands are ignored.
104
105
106 ipset_session
107 The function returns the session structure of the ipset library
108 structure, in order to manipulate the IO parameters.
109
110
111 ipset_session_full_io
112 You can control the full IO, i.e. input (restore) and output
113 (save) separatedly by the function. The session parameter is the
114 session structure of the library interface, filename is the
115 filename you want to use for input or output and what tells the
116 function you want to set input or output file. If there's an
117 already opened file for the given IO mode, it is closed. The
118 function returns an error if normal mode is in use. If NULL is
119 passed instead of a filename, already opened file is closed and
120 the normal stream is set for the given IO mode (stdin for input,
121 stdout for output). Input/output files can be set separatedly.
122
123
124 ipset_session_normal_io
125 You can control the normal IO, which corresponds to the inter‐
126 face provided by ipset(8) itself. session parameter is the ses‐
127 sion structure of the library interface, filename is the file‐
128 name you want to use for input or output and what tells the
129 function you want to set input or output file. If there's an
130 already opened file for input/output, it is closed. The func‐
131 tion returns an error if full mode is in use. If NULL is passed
132 instead of a filename, already opened file is closed and the
133 normal stream is set for the given IO mode (stdin for input,
134 stdout for output). Input/output files cannot be set separat‐
135 edly.
136
137
138 ipset_session_io_stream
139 The function returns the stream set for the session where what
140 tells the function you want to get the input or the output
141 stream.
142
143
144 ipset_session_io_close
145 The function closes the stream for the session where what tells
146 the function you want to close the input or the output stream.
147 After closing, the standard streams are set: stdin for input,
148 stdout for output.
149
150
152 ipset/libipset was designed and written by Jozsef Kadlecsik.
153
154
156 ipset(8),
157 /usr/include/libipset/ipset.h /usr/include/libipset/session.h
158
159
160
161Jozsef Kadlecsik Oct 16, 2018 libipset(3)