OpenVAS Libraries  4.0+rc3.SVN
Data Structures | Typedefs | Enumerations | Functions
accessrules.h File Reference

Protos and data structures for Access Rules data sets. More...

#include <glib.h>

Go to the source code of this file.

Data Structures

struct  accessrule
 The structure for a Access Rule. More...

Typedefs

typedef struct accessrule accessrule_t
 The structure for a Access Rule.
typedef GHashTable accessrules_t
 A collection of information records corresponding to Access Rules.

Enumerations

enum  rule_t { ALLOW = 1, REJECT = 2 }
 The possible types of a rule. More...

Functions

accessrule_taccessrule_new (void)
 Create a new access rule structure filled with the given values.
void accessrule_free (accessrule_t *)
 Free memory of a access rules structure.
rule_t accessrule_rule (const accessrule_t *)
 Get the rule type.
gchar * accessrule_ip (const accessrule_t *)
 Get the IP string.
gchar * accessrule_comment (const accessrule_t *)
 Get the comment string.
int accessrule_set_rule (accessrule_t *, const rule_t)
int accessrule_set_ip (accessrule_t *, const gchar *)
 Set the IP of a Access Rule.
int accessrule_set_comment (accessrule_t *, const gchar *)
 Set the comment of a Access Rule.
gchar * accessrule_as_xml (const accessrule_t *)
 Create a XML representation of a Access Rule.
accessrules_taccessrules_new ()
 Make a collection of Access Rules.
void accessrules_free (accessrules_t *)
 Free a collection of Access Rules.
guint accessrules_size (accessrules_t *)
 Get the size of a collection of Access Rules.
void accessrules_add (accessrules_t *, accessrule_t *)
 Add an Access Rule to a collection of Access Rules.
guint accessrules_to_file (accessrules_t *, gchar *)
 Write the contents of a Access Rules collection to a file.
accessrules_taccessrules_from_file (gchar *)
 Read a collection of Access Rules from a file.

Detailed Description

Protos and data structures for Access Rules data sets.

This file contains the protos for accessrules.c


Typedef Documentation

typedef struct accessrule accessrule_t

The structure for a Access Rule.

The elements of this structure should never be accessed directly. Only the functions corresponding to this module should be used.


Enumeration Type Documentation

enum rule_t

The possible types of a rule.

Enumerator:
ALLOW 

allow a corresponding IP

REJECT 

reject a corresponding IP


Function Documentation

gchar* accessrule_as_xml ( const accessrule_t r)

Create a XML representation of a Access Rule.

Parameters:
rThe Access Rule structure.
Returns:
A newly allocated string with multi-line text. The string needs to be freed with g_free().
Todo:
Use g_markup_escape here
gchar* accessrule_comment ( const accessrule_t r)

Get the comment string.

Parameters:
rThe Access Rule structure of which the comment should be returned.
Returns:
The comment string. Don't free this.
void accessrule_free ( accessrule_t r)

Free memory of a access rules structure.

Parameters:
rThe structure to be freed.
gchar* accessrule_ip ( const accessrule_t r)

Get the IP string.

Parameters:
rThe Access Rule structure of which the IP should be returned.
Returns:
The IP string. Don't free this.
accessrule_t* accessrule_new ( void  )

Create a new access rule structure filled with the given values.

Returns:
NULL in case the memory could not be allocated. Else an empty accessrule structure which needs to be released using accessrule_free . The whole struct is initalized with 0's.
rule_t accessrule_rule ( const accessrule_t r)

Get the rule type.

Parameters:
rThe Access Rule structure of which the rule should be returned.
Returns:
The rule type.
int accessrule_set_comment ( accessrule_t r,
const gchar *  comment 
)

Set the comment of a Access Rule.

Parameters:
rThe Access Rule structure.
commentThe comment string to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int accessrule_set_ip ( accessrule_t r,
const gchar *  ip 
)

Set the IP of a Access Rule.

Parameters:
rThe Access Rule structure.
ipThe IP string to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
void accessrules_add ( accessrules_t rules,
accessrule_t r 
)

Add an Access Rule to a collection of Access Rules.

Parameters:
rulesThe collection of Access Rules (must have ip set).
void accessrules_free ( accessrules_t rules)

Free a collection of Access Rules.

Parameters:
rulesThe collection of Access Rules.
accessrules_t* accessrules_from_file ( gchar *  fn)

Read a collection of Access Rules from a file.

Parameters:
fnThe filename from which to read.
Returns:
NULL in case an error occured. Else a collection of access rules which might be empty e.g. if the format was incorrect.
Todo:
Create a access_rules_t* and pass as user data
Todo:
error checks, handling
guint accessrules_size ( accessrules_t rules)

Get the size of a collection of Access Rules.

Returns:
The number of entries in the collection.
guint accessrules_to_file ( accessrules_t rules,
gchar *  fn 
)

Write the contents of a Access Rules collection to a file.

Parameters:
rulesThe collection of Access Rules.
fnThe filename where to store the Access Rules.
Returns:
0 in case of success, other values mean a failure.