view.c File Reference

This file contains functions to enable named views that can hold local zone authority service. More...

#include "config.h"
#include "services/view.h"
#include "services/localzone.h"
#include "util/config_file.h"
#include "respip/respip.h"

Functions

int view_cmp (const void *v1, const void *v2)
 Compare two view entries in rbtree.
 
struct viewsviews_create (void)
 Create views storage.
 
void view_delete (struct view *v)
 Delete one view.
 
static void delviewnode (rbnode_type *n, void *ATTR_UNUSED(arg))
 
void views_delete (struct views *v)
 Delete views storage.
 
static struct viewview_create (char *name)
 create a new view
 
static struct viewviews_enter_view_name (struct views *vs, char *name)
 enter a new view returns with WRlock
 
int views_apply_cfg (struct views *vs, struct config_file *cfg)
 Apply config settings; Takes care of locking.
 
struct viewviews_find_view (struct views *vs, const char *name, int write)
 find a view by name
 
void views_print (struct views *v)
 Debug helper.
 
size_t views_get_mem (struct views *vs)
 Calculate memory usage of views.
 
size_t view_get_mem (struct view *v)
 Calculate memory usage of view.
 
void views_swap_tree (struct views *vs, struct views *data)
 Swap internal tree with preallocated entries.
 

Detailed Description

This file contains functions to enable named views that can hold local zone authority service.

Function Documentation

◆ view_cmp()

int view_cmp ( const void *  v1,
const void *  v2 
)

Compare two view entries in rbtree.

Sort canonical.

Parameters
v1view 1
v2view 2
Returns
: negative, positive or 0 comparison value.

References view::name.

Referenced by fptr_whitelist_rbtree_cmp(), and views_create().

◆ views_create()

struct views * views_create ( void  )

◆ view_delete()

void view_delete ( struct view v)

Delete one view.

Parameters
vview to delete.

References view::local_zones, local_zones_delete(), view::lock, view::name, view::respip_set, and respip_set_delete().

Referenced by views_enter_view_name().

◆ views_delete()

void views_delete ( struct views v)

◆ views_apply_cfg()

◆ views_find_view()

◆ views_print()

void views_print ( struct views v)

Debug helper.

Print all views Takes care of locking.

Parameters
vthe views tree

◆ views_get_mem()

size_t views_get_mem ( struct views vs)

Calculate memory usage of views.

Parameters
vsthe views tree. The routine locks and unlocks the structure for reading.
Returns
memory in bytes.

References views::lock, RBTREE_FOR, view_get_mem(), and views::vtree.

Referenced by fr_printmem().

◆ view_get_mem()

size_t view_get_mem ( struct view v)

Calculate memory usage of view.

Parameters
vthe view. The routine locks and unlocks the structure for reading.
Returns
memory in bytes.

References getmem_str(), view::local_zones, local_zones_get_mem(), view::lock, view::name, view::respip_set, and respip_set_get_mem().

Referenced by views_get_mem().

◆ views_swap_tree()

void views_swap_tree ( struct views vs,
struct views data 
)

Swap internal tree with preallocated entries.

Caller should manage the locks.

Parameters
vsviews tree
datapreallocated information.

References rbtree_type::count, rbtree_type::root, and views::vtree.

Referenced by fr_reload_config().