libvirt: Module libvirt-nwfilter from libvirt
Description: libvirt, virtualization, virtualization API

# Module libvirt-nwfilter from libvirt

Provides APIs for the management of nwfilters Copyright (C) 2006-2014 Red Hat, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.

## Table of Contents

### Types

    typedef struct _virNWFilter virNWFilter
    typedef struct _virNWFilterBinding virNWFilterBinding
    typedef enum virNWFilterBindingCreateFlags
    typedef virNWFilterBinding * virNWFilterBindingPtr
    typedef enum virNWFilterDefineFlags
    typedef virNWFilter * virNWFilterPtr

### Functions

    int	virConnectListAllNWFilterBindings	(virConnectPtr conn,
    						 virNWFilterBindingPtr ** bindings,
    						 unsigned int flags)
    int	virConnectListAllNWFilters	(virConnectPtr conn,
    					 virNWFilterPtr ** filters,
    					 unsigned int flags)
    int	virConnectListNWFilters		(virConnectPtr conn,
    					 char ** const names,
    					 int maxnames)
    int	virConnectNumOfNWFilters	(virConnectPtr conn)
    virNWFilterBindingPtr	virNWFilterBindingCreateXML	(virConnectPtr conn,
    							 const char * xml,
    							 unsigned int flags)
    int	virNWFilterBindingDelete	(virNWFilterBindingPtr binding)
    int	virNWFilterBindingFree		(virNWFilterBindingPtr binding)
    const char *	virNWFilterBindingGetFilterName	(virNWFilterBindingPtr binding)
    const char *	virNWFilterBindingGetPortDev	(virNWFilterBindingPtr binding)
    char *	virNWFilterBindingGetXMLDesc	(virNWFilterBindingPtr binding,
    					 unsigned int flags)
    virNWFilterBindingPtr	virNWFilterBindingLookupByPortDev	(virConnectPtr conn,
    							 const char * portdev)
    int	virNWFilterBindingRef		(virNWFilterBindingPtr binding)
    virNWFilterPtr	virNWFilterDefineXML	(virConnectPtr conn,
    					 const char * xmlDesc)
    virNWFilterPtr	virNWFilterDefineXMLFlags	(virConnectPtr conn,
    						 const char * xmlDesc,
    						 unsigned int flags)
    int	virNWFilterFree			(virNWFilterPtr nwfilter)
    const char *	virNWFilterGetName	(virNWFilterPtr nwfilter)
    int	virNWFilterGetUUID		(virNWFilterPtr nwfilter,
    					 unsigned char * uuid)
    int	virNWFilterGetUUIDString	(virNWFilterPtr nwfilter,
    					 char * buf)
    char *	virNWFilterGetXMLDesc		(virNWFilterPtr nwfilter,
    					 unsigned int flags)
    virNWFilterPtr	virNWFilterLookupByName	(virConnectPtr conn,
    					 const char * name)
    virNWFilterPtr	virNWFilterLookupByUUID	(virConnectPtr conn,
    					 const unsigned char * uuid)
    virNWFilterPtr	virNWFilterLookupByUUIDString	(virConnectPtr conn,
    						 const char * uuidstr)
    int	virNWFilterRef			(virNWFilterPtr nwfilter)
    int	virNWFilterUndefine		(virNWFilterPtr nwfilter)

## Description

### Types

### `virNWFilter`

    struct virNWFilter {

The content of this structure is not made public by the API

    }

### `virNWFilterBinding`

    struct virNWFilterBinding {

The content of this structure is not made public by the API

    }

### `virNWFilterBindingCreateFlags`

    enum virNWFilterBindingCreateFlags {

VIR_NWFILTER_BINDING_CREATE_VALIDATE | = | 1 (0x1; 1 << 0) | Validate the XML document against schema

    }

### `virNWFilterDefineFlags`

    enum virNWFilterDefineFlags {

VIR_NWFILTER_DEFINE_VALIDATE | = | 1 (0x1; 1 << 0) | Validate the XML document against schema

    }

### Functions

### `virConnectListAllNWFilterBindings`

    int	virConnectListAllNWFilterBindings	(virConnectPtr conn,
    						 virNWFilterBindingPtr ** bindings,
    						 unsigned int flags)

Collect the list of network filters, and allocate an array to store those objects.

conn
  Pointer to the hypervisor connection.
bindings
  Pointer to a variable to store the array containing the network filter objects or NULL if the list is not required (just returns number of network filters).
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  the number of network filters found or -1 and sets `filters` to NULL in case of error. On success, the array stored into `filters` is guaranteed to have an extra allocated element set to NULL but not included in the return count, to make iteration easier. The caller is responsible for calling virNWFilterFree() on each array element, then calling free() on `filters`.

### `virConnectListAllNWFilters`

    int	virConnectListAllNWFilters	(virConnectPtr conn,
    					 virNWFilterPtr ** filters,
    					 unsigned int flags)

Collect the list of network filters, and allocate an array to store those objects.

conn
  Pointer to the hypervisor connection.
filters
  Pointer to a variable to store the array containing the network filter objects or NULL if the list is not required (just returns number of network filters).
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  the number of network filters found or -1 and sets `filters` to NULL in case of error. On success, the array stored into `filters` is guaranteed to have an extra allocated element set to NULL but not included in the return count, to make iteration easier. The caller is responsible for calling virNWFilterFree() on each array element, then calling free() on `filters`.

### `virConnectListNWFilters`

    int	virConnectListNWFilters		(virConnectPtr conn,
    					 char ** const names,
    					 int maxnames)

Collect the list of network filters, and store their names in `names`

The use of this function is discouraged. Instead, use virConnectListAllNWFilters().

conn
  pointer to the hypervisor connection
names
  array to collect the list of names of network filters
maxnames
  size of `names`
Returns
  the number of network filters found or -1 in case of error

### `virConnectNumOfNWFilters`

    int	virConnectNumOfNWFilters	(virConnectPtr conn)

Provides the number of nwfilters.

conn
  pointer to the hypervisor connection
Returns
  the number of nwfilters found or -1 in case of error

### `virNWFilterBindingCreateXML`

    virNWFilterBindingPtr	virNWFilterBindingCreateXML	(virConnectPtr conn,
    							 const char * xml,
    							 unsigned int flags)

Define a new network filter, based on an XML description similar to the one returned by virNWFilterGetXMLDesc(). This API may be used to associate a filter with a currently running guest that does not have a filter defined for a specific network port. Since the bindings are generally automatically managed by the hypervisor, using this command to define a filter for a network port and then starting the guest afterwards may prevent the guest from starting if it attempts to use the network port and finds a filter already defined.

virNWFilterFree should be used to free the resources after the binding object is no longer needed.

conn
  pointer to the hypervisor connection
xml
  an XML description of the binding
flags
  bitwise-OR of virNWFilterBindingCreateFlags
Returns
  a new binding object or NULL in case of failure

### `virNWFilterBindingDelete`

    int	virNWFilterBindingDelete	(virNWFilterBindingPtr binding)

Delete the binding object. This does not free the associated virNWFilterBindingPtr object. This API may be used to remove the network port binding filter currently in use for the guest while the guest is running without needing to restart the guest. Restoring the network port binding filter for the running guest would be accomplished by using virNWFilterBindingCreateXML.

binding
  a binding object
Returns
  0 in case of success and -1 in case of failure.

### `virNWFilterBindingFree`

    int	virNWFilterBindingFree		(virNWFilterBindingPtr binding)

Free the binding object. The running instance is kept alive. The data structure is freed and should not be used thereafter.

binding
  a binding object
Returns
  0 in case of success and -1 in case of failure.

### `virNWFilterBindingGetFilterName`

    const char *	virNWFilterBindingGetFilterName	(virNWFilterBindingPtr binding)

Get the filter name for the network filter binding

binding
  a binding object
Returns
  a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the binding object.

### `virNWFilterBindingGetPortDev`

    const char *	virNWFilterBindingGetPortDev	(virNWFilterBindingPtr binding)

Get the port dev name for the network filter binding

binding
  a binding object
Returns
  a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the binding object.

### `virNWFilterBindingGetXMLDesc`

    char *	virNWFilterBindingGetXMLDesc	(virNWFilterBindingPtr binding,
    					 unsigned int flags)

Provide an XML description of the network filter. The description may be reused later to redefine the network filter with virNWFilterCreateXML().

binding
  a binding object
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. The caller must free() the returned value.

### `virNWFilterBindingLookupByPortDev`

    virNWFilterBindingPtr	virNWFilterBindingLookupByPortDev	(virConnectPtr conn,
    							 const char * portdev)

Try to lookup a network filter binding on the given hypervisor based on network port device name.

virNWFilterBindingFree should be used to free the resources after the binding object is no longer needed.

conn
  pointer to the hypervisor connection
portdev
  name for the network port device
Returns
  a new binding object or NULL in case of failure. If the network filter cannot be found, then VIR_ERR_NO_NWFILTER_BINDING error is raised.

### `virNWFilterBindingRef`

    int	virNWFilterBindingRef		(virNWFilterBindingPtr binding)

Increment the reference count on the binding. For each additional call to this method, there shall be a corresponding call to virNWFilterFree to release the reference count, once the caller no longer needs the reference to this object.

This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using an binding would increment the reference count.

binding
  the binding to hold a reference on
Returns
  0 in case of success, -1 in case of failure.

### `virNWFilterDefineXML`

    virNWFilterPtr	virNWFilterDefineXML	(virConnectPtr conn,
    					 const char * xmlDesc)

Define a new network filter, based on an XML description similar to the one returned by virNWFilterGetXMLDesc()

virNWFilterFree should be used to free the resources after the nwfilter object is no longer needed.

conn
  pointer to the hypervisor connection
xmlDesc
  an XML description of the nwfilter
Returns
  a new nwfilter object or NULL in case of failure

### `virNWFilterDefineXMLFlags`

    virNWFilterPtr	virNWFilterDefineXMLFlags	(virConnectPtr conn,
    						 const char * xmlDesc,
    						 unsigned int flags)

Define a new network filter, based on an XML description similar to the one returned by virNWFilterGetXMLDesc()

virNWFilterFree should be used to free the resources after the nwfilter object is no longer needed.

conn
  pointer to the hypervisor connection
xmlDesc
  an XML description of the nwfilter
flags
  bitwise-OR of virNWFilterDefineFlags
Returns
  a new nwfilter object or NULL in case of failure

### `virNWFilterFree`

    int	virNWFilterFree			(virNWFilterPtr nwfilter)

Free the nwfilter object. The running instance is kept alive. The data structure is freed and should not be used thereafter.

nwfilter
  a nwfilter object
Returns
  0 in case of success and -1 in case of failure.

### `virNWFilterGetName`

    const char *	virNWFilterGetName	(virNWFilterPtr nwfilter)

Get the public name for the network filter

nwfilter
  a nwfilter object
Returns
  a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the nwfilter object.

### `virNWFilterGetUUID`

    int	virNWFilterGetUUID		(virNWFilterPtr nwfilter,
    					 unsigned char * uuid)

Get the UUID for a network filter

nwfilter
  a nwfilter object
uuid
  pointer to a VIR_UUID_BUFLEN bytes array
Returns
  -1 in case of error, 0 in case of success

### `virNWFilterGetUUIDString`

    int	virNWFilterGetUUIDString	(virNWFilterPtr nwfilter,
    					 char * buf)

Get the UUID for a network filter as string. For more information about UUID see RFC4122.

nwfilter
  a nwfilter object
buf
  pointer to a VIR_UUID_STRING_BUFLEN bytes array
Returns
  -1 in case of error, 0 in case of success

### `virNWFilterGetXMLDesc`

    char *	virNWFilterGetXMLDesc		(virNWFilterPtr nwfilter,
    					 unsigned int flags)

Provide an XML description of the network filter. The description may be reused later to redefine the network filter with virNWFilterCreateXML().

nwfilter
  a nwfilter object
flags
  extra flags; not used yet, so callers should always pass 0
Returns
  a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. The caller must free() the returned value.

### `virNWFilterLookupByName`

    virNWFilterPtr	virNWFilterLookupByName	(virConnectPtr conn,
    					 const char * name)

Try to lookup a network filter on the given hypervisor based on its name.

virNWFilterFree should be used to free the resources after the nwfilter object is no longer needed.

conn
  pointer to the hypervisor connection
name
  name for the network filter
Returns
  a new nwfilter object or NULL in case of failure. If the network filter cannot be found, then VIR_ERR_NO_NWFILTER error is raised.

### `virNWFilterLookupByUUID`

    virNWFilterPtr	virNWFilterLookupByUUID	(virConnectPtr conn,
    					 const unsigned char * uuid)

Try to lookup a network filter on the given hypervisor based on its UUID.

virNWFilterFree should be used to free the resources after the nwfilter object is no longer needed.

conn
  pointer to the hypervisor connection
uuid
  the raw UUID for the network filter
Returns
  a new nwfilter object or NULL in case of failure. If the nwfdilter cannot be found, then VIR_ERR_NO_NWFILTER error is raised.

### `virNWFilterLookupByUUIDString`

    virNWFilterPtr	virNWFilterLookupByUUIDString	(virConnectPtr conn,
    						 const char * uuidstr)

Try to lookup an nwfilter on the given hypervisor based on its UUID.

virNWFilterFree should be used to free the resources after the nwfilter object is no longer needed.

conn
  pointer to the hypervisor connection
uuidstr
  the string UUID for the nwfilter
Returns
  a new nwfilter object or NULL in case of failure. If the nwfilter cannot be found, then VIR_ERR_NO_NWFILTER error is raised.

### `virNWFilterRef`

    int	virNWFilterRef			(virNWFilterPtr nwfilter)

Increment the reference count on the nwfilter. For each additional call to this method, there shall be a corresponding call to virNWFilterFree to release the reference count, once the caller no longer needs the reference to this object.

This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using an nwfilter would increment the reference count.

nwfilter
  the nwfilter to hold a reference on
Returns
  0 in case of success, -1 in case of failure.

### `virNWFilterUndefine`

    int	virNWFilterUndefine		(virNWFilterPtr nwfilter)

Undefine the nwfilter object. This call will not succeed if a running VM is referencing the filter. This does not free the associated virNWFilterPtr object.

nwfilter
  a nwfilter object
Returns
  0 in case of success and -1 in case of failure.