monitube-data_config.c File Reference

Relating to getting and setting the configuration data. More...

#include "monitube-data_main.h"
#include "monitube-data_config.h"
#include "monitube-data_ha.h"
#include "monitube-data_packet.h"
#include <jnx/radix.h>

Go to the source code of this file.

Data Structures

struct  address_s
struct  monitor_s
struct  mirror_s
struct  prefix_s

Defines

#define MAX_MON_NAME_LEN   256
 Application name length.

Typedefs

typedef address_s address_t
typedef monitor_s monitor_t
typedef mirror_s mirror_t
typedef prefix_s prefix_t

Functions

static void update_time (evContext ctx __unused, void *uap __unused, struct timespec due __unused, struct timespec inter __unused)
static uint8_t bit_count (uint32_t n)
static void delete_all_addresses (monitor_t *mon)
status_t init_config (evContext ctx)
void set_mastership (boolean state, in_addr_t master_addr)
void set_replication_interval (uint8_t interval)
uint8_t get_replication_interval (void)
time_t get_current_time (void)
void clear_config (void)
void clear_monitors_configuration (void)
void clear_mirrors_configuration (void)
void delete_monitor (char *name)
void delete_mirror (in_addr_t from)
void delete_address (char *name, in_addr_t addr, in_addr_t mask)
void add_address (char *name, in_addr_t addr, in_addr_t mask)
void update_monitor (char *name, uint32_t rate)
void update_mirror (in_addr_t from, in_addr_t to)
uint32_t get_monitored_rate (in_addr_t address, char **name)
in_addr_t get_mirror (in_addr_t address)

Variables

volatile boolean is_master
 mastership state of this data component
static evContext m_ctx
 event context
static patroot monitors_conf
 Pat. root for monitors config.
static patroot mirrors_conf
 Pat. root for mirrors config.
static radix_root_t mon_prefixes
 Radix tree for monitor lookups.
static uint8_t replication_interval
 replication interval
static msp_spinlock_t mir_conf_lock
 lock for mirrors_conf config
static msp_spinlock_t mon_conf_lock
 lock for mon_prefixes config
static atomic_uint_t current_time


Detailed Description

Relating to getting and setting the configuration data.

These functions will store and provide access to the configuration data which is essentially coming from the mgmt component.

Definition in file monitube-data_config.c.


Typedef Documentation

typedef struct address_s address_t

The structure we use to bundle the patricia-tree node with the data to store for each monitor's network address

typedef struct mirror_s mirror_t

The structure we use to bundle the patricia-tree node with the data to store for each mirror

typedef struct monitor_s monitor_t

The structure we use to bundle the patricia-tree node with the data to store for each monitor

typedef struct prefix_s prefix_t

The structure we use to bundle the radix-tree node with a pointer to the configuration we need depending on the tree (a monitor or mirror)


Function Documentation

void add_address ( char *  name,
in_addr_t  addr,
in_addr_t  mask 
)

Add an address prefix to a monitor's config

Parameters:
[in] name The monitor's name
[in] addr Address
[in] mask Address mask

Definition at line 515 of file monitube-data_config.c.

References address_s::address, monitor_s::addresses, bit_count(), clean_flows_in_monitored_prefix(), INSIST_ERR, LOG, address_s::mask, mon_conf_lock, mon_prefixes, prefix_s::monitor, monitors_conf, monitor_s::name, address_s::node, prefix_s::prefix, and prefix_s::rnode.

Referenced by mgmt_client_message().

static uint8_t bit_count ( uint32_t  n  )  [static]

Count the number of bits in a uint32_t / in_addr_t

Parameters:
[in] n The input (mask) that we want the number of bits for
Returns:
the number of 1 bits

Definition at line 157 of file monitube-data_config.c.

Referenced by add_address(), delete_address(), and delete_all_addresses().

void clear_config ( void   ) 

Clear the configuration data

Definition at line 320 of file monitube-data_config.c.

References clear_mirrors_configuration(), and clear_monitors_configuration().

Referenced by mgmt_client_connection(), and monitube_quit().

void clear_mirrors_configuration ( void   ) 

Delete all configured mirrors

Definition at line 355 of file monitube-data_config.c.

References clean_flows_with_any_mirror(), INSIST_ERR, LOG, mir_conf_lock, mirrors_conf, and mirror_s::node.

Referenced by clear_config(), and mgmt_client_message().

void clear_monitors_configuration ( void   ) 

Delete all configured monitors

Definition at line 331 of file monitube-data_config.c.

References monitor_s::addresses, clean_flows_with_any_monitor(), delete_all_addresses(), LOG, monitors_conf, and monitor_s::node.

Referenced by clear_config(), and mgmt_client_message().

void delete_address ( char *  name,
in_addr_t  addr,
in_addr_t  mask 
)

Delete a given address from a monitor's config

Parameters:
[in] name The monitor's name
[in] addr Address
[in] mask Address mask

Definition at line 455 of file monitube-data_config.c.

References monitor_s::addresses, bit_count(), clean_flows_in_monitored_prefix(), INSIST_ERR, LOG, mon_conf_lock, mon_prefixes, monitors_conf, and address_s::node.

Referenced by mgmt_client_message().

static void delete_all_addresses ( monitor_t mon  )  [static]

Delete all address from a monitor's configuration

Parameters:
[in] mon The monitor's configuration

Definition at line 174 of file monitube-data_config.c.

References address_s::address, monitor_s::addresses, bit_count(), INSIST_ERR, LOG, address_s::mask, mon_conf_lock, mon_prefixes, and address_s::node.

Referenced by clear_monitors_configuration(), and delete_monitor().

void delete_mirror ( in_addr_t  from  ) 

Find and delete a mirror given its from address

Parameters:
[in] from The mirror's from address

Definition at line 415 of file monitube-data_config.c.

References clean_flows_with_mirror(), INSIST_ERR, LOG, mir_conf_lock, mirrors_conf, and mirror_s::node.

Referenced by mgmt_client_message().

void delete_monitor ( char *  name  ) 

Find and delete a monitor given its name

Parameters:
[in] name The monitor's name

Definition at line 383 of file monitube-data_config.c.

References monitor_s::addresses, clean_flows_with_monitor(), delete_all_addresses(), LOG, monitors_conf, and monitor_s::node.

Referenced by mgmt_client_message().

time_t get_current_time ( void   ) 

Get the currently cached time

Returns:
Current time

Definition at line 310 of file monitube-data_config.c.

References current_time.

Referenced by aging_cleanup(), process_fragment(), and process_packet().

in_addr_t get_mirror ( in_addr_t  address  ) 

Find the redirect for a mirrored address if one exists

Parameters:
[in] address The original destination
Returns:
the address to mirror to; or 0 if none found

Definition at line 718 of file monitube-data_config.c.

References INSIST_ERR, mir_conf_lock, mirrors_conf, and mirror_s::redirect.

Referenced by process_packet().

uint32_t get_monitored_rate ( in_addr_t  address,
char **  name 
)

Find the monitoring rate for an address if one exists

Parameters:
[in] address The destination address
[out] name The monitor name associated with the rate (set if found)
Returns:
the monitoring rate; or zero if no match is found

Definition at line 676 of file monitube-data_config.c.

References INSIST_ERR, LOG, mon_conf_lock, and mon_prefixes.

Referenced by add_flow_state(), and process_packet().

uint8_t get_replication_interval ( void   ) 

Get the replication interval

Returns:
The configured replication interval

Definition at line 297 of file monitube-data_config.c.

References replication_interval.

Referenced by process_packet().

status_t init_config ( evContext  ctx  ) 

Init the data structures that will store configuration info

Parameters:
[in] ctx event context
Returns:
SUCCESS if successful; otherwise EFAIL with an error message.

Definition at line 219 of file monitube-data_config.c.

References current_time, is_master, LOG, m_ctx, MAX_MON_NAME_LEN, mir_conf_lock, mirrors_conf, mon_conf_lock, mon_prefixes, monitors_conf, replication_interval, and update_time().

Referenced by init_application().

void set_mastership ( boolean  state,
in_addr_t  master_addr 
)

Configure mastership of this data component

Parameters:
[in] state Mastership state (T=Master, F=Slave)
[in] master_addr Master address (only present if state=F/slave)

Definition at line 257 of file monitube-data_config.c.

References is_master, and m_ctx.

Referenced by mgmt_client_message().

void set_replication_interval ( uint8_t  interval  ) 

Set the replication interval

Parameters:
[in] interval Interval in second between replication data updates

Definition at line 285 of file monitube-data_config.c.

References replication_interval.

Referenced by mgmt_client_message().

void update_mirror ( in_addr_t  from,
in_addr_t  to 
)

Update or add a mirroring config

Parameters:
[in] from The mirror from address
[in] to The mirror to address

Definition at line 630 of file monitube-data_config.c.

References INSIST_ERR, LOG, mir_conf_lock, mirrors_conf, mirror_s::node, mirror_s::original, mirror_s::redirect, and redirect_flows_with_mirror().

Referenced by mgmt_client_message().

void update_monitor ( char *  name,
uint32_t  rate 
)

Update or add a monitoring config

Parameters:
[in] name The monitor name
[in] rate The monitored group's bps (media) rate

Definition at line 588 of file monitube-data_config.c.

References monitor_s::addresses, clean_flows_with_monitor(), LOG, MAX_MON_NAME_LEN, monitors_conf, monitor_s::name, monitor_s::node, and monitor_s::rate.

Referenced by mgmt_client_message().

static void update_time ( evContext ctx  __unused,
void *uap  __unused,
struct timespec due  __unused,
struct timespec inter  __unused 
) [static]

Update cached time

Parameters:
[in] ctx The event context for this application
[in] uap The user data for this callback
[in] due The absolute time when the event is due (now)
[in] inter The period; when this will next be called

Definition at line 139 of file monitube-data_config.c.

References current_time.

Referenced by init_config().


Variable Documentation

atomic_uint_t current_time [static]

The current cached time. Cache it to prevent many system time() calls by the data threads.

Definition at line 97 of file monitube-data_config.c.

Referenced by aging_cleanup(), get_current_time(), init_config(), and update_time().


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:27:02 2010 for SDK Your Net Corporation Monitube IPTV Monitoring Example: monitube-data 1.0 by Doxygen 1.5.1