libipset(3) - phpMan

libipset(3)                                                        libipset(3)

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
       libipset  provides a library interface to ipset(8).  The integer return
       valued functions return 0 on success and a negative value on failure.
       ipset_load_types
              Loads in the supported ipset types in the library and make  them
              available for the ipset interface.

       ipset_init
              Initializes  the  ipset interface: allocates and initializes the
              required internal structures, 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 lenght of array of strings argv with the already
              initialized ipset library structure.  If the command is success-
              fully 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  nega-
              tive 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 nega-
              tive number is returned.

       ipset_fini
              Closes the netlink channel, closes opened streams  and  releases
              allocated structures holding by the ipset library structure.

       The following functions makes possible to customize the interface.
       ipset_custom_printf
              Sets  or resets the print functions for the ipset library struc-
              ture, where custom_error is the custom error print function  for
              the  internal  library errors, standard_error is the print func-
              tion for the netlink/kernel related errors and outfn is the out-
              put  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.

       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  controll  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 controll the normal IO, which corresponds to the  inter-
              face provided by ipset(8) itself.  session parameter is the ses-
              sion structure of the library interface, filename is  the  file-
              name  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 func-
              tion 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 separat-
              edly.

       ipset_session_io_stream
              The function returns the stream set for the session  where  what
              tells  the  funtion  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  funtion  you  want to close the input or the output stream.
              After closing, the standard streams are set:  stdin  for  input,
              stdout for output.

AUTHORS
       ipset/libipset was designed and written by Jozsef Kadlecsik.

SEE ALSO
       ipset(8),
       /usr/include/libipset/ipset.h /usr/include/libipset/session.h

Jozsef Kadlecsik                 Oct 16, 2018                      libipset(3)