monitube2-mgmt_config.c File Reference

Relating to loading and storing the configuration data. More...

#include <sync/common.h>
#include <ddl/dax.h>
#include <jnx/pconn.h>
#include <jnx/parse_interface.h>
#include <jnx/patricia.h>
#include <jnx/junos_kcom_pub_blob.h>
#include <jnx/ssrb_parse.h>
#include "monitube2-mgmt_config.h"
#include "monitube2-mgmt_conn.h"
#include "monitube2-mgmt_logging.h"

Go to the source code of this file.

Defines

#define MAX_FLOW_AGE   300
 max flow statistic age in seconds (5 mins)

Functions

static void delete_list (list_t *list)
static void delete_serviceset (ss_info_t *ssi)
static void delete_all_servicesets (void)
static void delete_address (rule_t *rule, in_addr_t addr)
static void delete_all_addresses (void)
static void delete_rule (rule_t *rule)
static void delete_all_rules (void)
static void ss_change (evContext ctx UNUSED, void *uap, struct timespec due UNUSED, struct timespec inter UNUSED)
static void notify_ssrb_change (junos_kcom_pub_ssrb_t *ssrb, void **data UNUSED, size_t *datalen UNUSED, junos_kcom_pub_blob_msg_opcode_t operation)
static int verify_service_interfaces (dax_walk_data_t *dwd, ddl_handle_t *dop, int action, void *data)
static int apply_rules (dax_walk_data_t *dwd, ddl_handle_t *dop, int action, void *data)
static int parse_addresses (dax_walk_data_t *dwd, ddl_handle_t *dop, int action, void *data)
static int parse_rules (dax_walk_data_t *dwd, ddl_handle_t *dop, int action, void *data)
static void age_out_flow_stat (evContext ctx UNUSED, void *uap, struct timespec due UNUSED, struct timespec inter UNUSED)
static void syncup (junos_kcom_pub_ssrb_t *s, void **d UNUSED, size_t *l UNUSED)
void init_config (evContext ctx)
void clear_config (void)
rule_tnext_rule (rule_t *data)
address_tnext_address (rule_t *rule, address_t *data)
ss_info_tnext_serviceset (ss_info_t *data)
flowstat_ss_tnext_flowstat_ss (flowstat_ss_t *data)
flowstat_tnext_flowstat (flowstat_ss_t *fss, flowstat_t *data)
void clear_stats (void)
void set_flow_stat (uint16_t fpc_slot, uint16_t pic_slot, uint16_t ssid, in_addr_t flow_addr, uint16_t flow_port, double mdi_df, uint32_t mdi_mlr)
int monitube_config_read (int check)

Variables

static patroot rules
 Pat. root for rules config.
static patroot ssets
 Pat. root for service sets config.
static patroot flow_stats
 Pat. root for flow stats.
static rule_tcurrent_rule = NULL
 current monitor set while loading configuration
static evContext m_ctx
 event context


Detailed Description

Relating to loading and storing the configuration data.

These functions will parse and load the configuration data.

Definition in file monitube2-mgmt_config.c.


Function Documentation

static void age_out_flow_stat ( evContext ctx  UNUSED,
void *  uap,
struct timespec due  UNUSED,
struct timespec inter  UNUSED 
) [static]

Delete the flow statistics because they have timed out

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 1411 of file monitube2-mgmt_config.c.

References flow_stats, m_ctx, flowstat_ss_s::node, flowstat_s::node, flowstat_s::ssi, flowstat_ss_s::stats, and flowstat_s::timer_id.

Referenced by set_flow_stat().

static int apply_rules ( dax_walk_data_t *  dwd,
ddl_handle_t *  dop,
int  action,
void *  data 
) [static]

Handler for dax_query to get the applied rules (in service sets) $ss contains the service-set name $es contain the extension name $rule contains the rule name

Parameters:
[in] dwd Opaque dax data
[in] dop DAX Object Pointer for rule object
[in] action The action on the given server object
[in] data User data passed to handler (check flag)
Returns:
DAX_WALK_OK upon success or DAX_WALK_ABORT upon failure

Definition at line 584 of file monitube2-mgmt_config.c.

References address_s::address, delete_all_servicesets(), delete_serviceset(), ss_info_s::es, ss_info_s::fpc_slot, ss_info_s::gen_num, ss_info_s::id, list_item_s::item, LOG, address_s::mask, MONITUBE2_MGMT_STRLEN, ss_info_s::name, rule_s::name, next_address(), next_serviceset(), ss_info_s::node, notify_apply_rule(), notify_config_rule(), notify_config_rule_prefix(), notify_delete_serviceset(), notify_remove_rule(), ss_info_s::pic_slot, rule_s::rate, rule_s::redirect, ss_info_s::rules, rules, rule_s::ssets, ssets, and ss_info_s::svc_id.

Referenced by monitube_config_read().

void clear_config ( void   ) 

Clear and reset the entire configuration, freeing all memory store for policy

Definition at line 1489 of file monitube2-mgmt_config.c.

References clear_stats(), delete_all_rules(), and process_notifications().

Referenced by monitube_config_read(), monitube_init(), and monitube_shutdown().

void clear_stats ( void   ) 

Clear all statistics

Definition at line 1586 of file monitube2-mgmt_config.c.

References flow_stats, m_ctx, flowstat_s::node, flowstat_ss_s::node, flowstat_ss_s::stats, and flowstat_s::timer_id.

Referenced by clear_config(), monitube_clear_stats(), monitube_init(), and monitube_shutdown().

static void delete_address ( rule_t rule,
in_addr_t  addr 
) [static]

Delete a given address from a rule's config (uses current_rule)

Parameters:
[in] rule The rule in which the address lies
[in] addr Address
[in] mask Address mask

Definition at line 203 of file monitube2-mgmt_config.c.

References rule_s::addresses, LOG, and address_s::node.

Referenced by parse_addresses().

static void delete_all_addresses ( void   )  [static]

Delete all address from a monitor's configuration

Parameters:
[in] notify Whether or not to notify the data component

Definition at line 231 of file monitube2-mgmt_config.c.

References rule_s::addresses, current_rule, LOG, and address_s::node.

Referenced by delete_rule(), and parse_addresses().

static void delete_all_rules ( void   )  [static]

Delete all configured rules and service sets as well since no service sets could refer to any rules and we only care about service sets referring to some MoniTube rule.

Definition at line 313 of file monitube2-mgmt_config.c.

References delete_all_servicesets(), delete_rule(), and rules.

Referenced by clear_config(), and parse_rules().

static void delete_all_servicesets ( void   )  [static]

Delete all service sets

Definition at line 159 of file monitube2-mgmt_config.c.

References delete_list(), list_item_s::item, LOG, ss_info_s::node, notify_delete_all_policy(), ss_info_s::rules, rule_s::ssets, and ssets.

Referenced by apply_rules(), and delete_all_rules().

static void delete_list ( list_t *  list  )  [static]

Delete all items from a list

Parameters:
[in] list The list to empty out

Definition at line 89 of file monitube2-mgmt_config.c.

Referenced by delete_all_servicesets(), delete_rule(), and delete_serviceset().

static void delete_rule ( rule_t rule  )  [static]

Delete a rule

Parameters:
[in] rule The rule

Definition at line 259 of file monitube2-mgmt_config.c.

References rule_s::addresses, current_rule, delete_all_addresses(), delete_list(), ss_info_s::fpc_slot, list_item_s::item, LOG, rule_s::name, rule_s::node, notify_delete_rule(), ss_info_s::pic_slot, ss_info_s::rules, rules, and rule_s::ssets.

Referenced by delete_all_rules(), and parse_rules().

static void delete_serviceset ( ss_info_t ssi  )  [static]

Delete a service-set

Parameters:
[in] ssi The service set info

Definition at line 107 of file monitube2-mgmt_config.c.

References delete_list(), ss_info_s::fpc_slot, ss_info_s::gen_num, ss_info_s::id, list_item_s::item, LOG, m_ctx, ss_info_s::node, notify_delete_serviceset(), ss_info_s::pic_slot, ss_info_s::rules, rule_s::ssets, ssets, ss_info_s::svc_id, and ss_info_s::timer.

Referenced by apply_rules().

void init_config ( evContext  ctx  ) 

Init the data structures that will store configuration info

Definition at line 1463 of file monitube2-mgmt_config.c.

References flow_stats, LOG, m_ctx, MONITUBE2_MGMT_STRLEN, notify_ssrb_change(), rules, ssets, and syncup().

Referenced by monitube_init().

int monitube_config_read ( int  check  ) 

Read daemon configuration from the database

Parameters:
[in] check 1 if this function being invoked because of a commit check
Returns:
SUCCESS (0) successfully loaded, EFAIL if not
Note:
Do not use ERRMSG/LOG during config check normally.

Definition at line 1752 of file monitube2-mgmt_config.c.

References apply_rules(), clear_config(), parse_rules(), process_notifications(), and verify_service_interfaces().

Referenced by main().

address_t* next_address ( rule_t rule,
address_t data 
)

Given a rule, get the next address in configuration given the previously returned data

Parameters:
[in] rule Rule's configuration
[in] data previously returned data, should be NULL first time
Returns:
pointer to an address if one more exists, o/w NULL

Definition at line 1525 of file monitube2-mgmt_config.c.

References rule_s::addresses, and address_s::node.

Referenced by apply_rules(), receive_connection(), and verify_service_interfaces().

flowstat_t* next_flowstat ( flowstat_ss_t fss,
flowstat_t data 
)

Get the next flowstat record in configuration given the previously returned data

Parameters:
[in] fss A flow stats service set
[in] data previously returned data, should be NULL first time
Returns:
pointer to a flowstat if one more exists, o/w NULL

Definition at line 1576 of file monitube2-mgmt_config.c.

References flowstat_s::node, and flowstat_ss_s::stats.

Referenced by monitube_show_stats().

flowstat_ss_t* next_flowstat_ss ( flowstat_ss_t data  ) 

Get the next flowstat service set in configuration given the previously returned data

Parameters:
[in] data previously returned data, should be NULL first time
Returns:
pointer to a flowstat if one more exists, o/w NULL

Definition at line 1557 of file monitube2-mgmt_config.c.

References flow_stats, and flowstat_ss_s::node.

Referenced by monitube_show_stats().

rule_t* next_rule ( rule_t data  ) 

Get the next rule in configuration given the previously returned data

Parameters:
[in] data previously returned data, should be NULL first time
Returns:
pointer to a rule if one more exists, o/w NULL

Definition at line 1506 of file monitube2-mgmt_config.c.

References rule_s::node, and rules.

ss_info_t* next_serviceset ( ss_info_t data  ) 

Get the next service set in configuration given the previously returned data

Parameters:
[in] data previously returned data, should be NULL first time
Returns:
pointer to a service set if one more exists, o/w NULL

Definition at line 1541 of file monitube2-mgmt_config.c.

References ss_info_s::node, and ssets.

Referenced by apply_rules(), monitube_show_stats(), and receive_connection().

static void notify_ssrb_change ( junos_kcom_pub_ssrb_t *  ssrb,
void **data  UNUSED,
size_t *datalen  UNUSED,
junos_kcom_pub_blob_msg_opcode_t  operation 
) [static]

Inform us of a change in a service set

Parameters:
[in] ssrb Service set resolution blob
[in,out] data Data to store with ssrb info
[in,out] datalen Length of data
[in] operation Operation pertaining to ssrb

Definition at line 384 of file monitube2-mgmt_config.c.

References ss_info_s::gen_num, ss_info_s::id, LOG, m_ctx, ss_change(), ssets, ss_info_s::svc_id, and ss_info_s::timer.

Referenced by init_config().

static int parse_addresses ( dax_walk_data_t *  dwd,
ddl_handle_t *  dop,
int  action,
void *  data 
) [static]

Handler for dax_walk_list to parse each configured address in a rule's "from destination-addresses"

Parameters:
[in] dwd Opaque dax data
[in] dop DAX Object Pointer for server object
[in] action The action on the given server object
[in] data User data passed to handler (check flag)
Returns:
DAX_WALK_OK upon success or DAX_WALK_ABORT upon failure

Definition at line 1001 of file monitube2-mgmt_config.c.

References address_s::address, rule_s::addresses, current_rule, delete_address(), delete_all_addresses(), ss_info_s::fpc_slot, list_item_s::item, LOG, address_s::mask, rule_s::name, address_s::node, notify_config_rule(), notify_config_rule_prefix(), notify_delete_rule(), ss_info_s::pic_slot, rule_s::rate, rule_s::redirect, and rule_s::ssets.

Referenced by parse_rules().

static int parse_rules ( dax_walk_data_t *  dwd,
ddl_handle_t *  dop,
int  action,
void *  data 
) [static]

Handler for dax_walk_list to parse each configured rule

Parameters:
[in] dwd Opaque dax data
[in] dop DAX Object Pointer for application object
[in] action The action on the given application object
[in] data User data passed to handler (check flag)
Returns:
DAX_WALK_OK upon success or DAX_WALK_ABORT upon failure

Definition at line 1192 of file monitube2-mgmt_config.c.

References rule_s::addresses, current_rule, delete_all_rules(), delete_rule(), ss_info_s::fpc_slot, list_item_s::item, LOG, MONITUBE2_MGMT_STRLEN, rule_s::name, rule_s::node, notify_config_rule(), parse_addresses(), ss_info_s::pic_slot, rule_s::rate, rule_s::redirect, rules, and rule_s::ssets.

Referenced by monitube_config_read().

void set_flow_stat ( uint16_t  fpc_slot,
uint16_t  pic_slot,
uint16_t  ssid,
in_addr_t  flow_addr,
uint16_t  flow_port,
double  mdi_df,
uint32_t  mdi_mlr 
)

Given a monitor's name and flow address add or update its statistics record

Parameters:
[in] fpc_slot FPC slot #
[in] pic_slot PIC slot #
[in] ssid Service set id
[in] flow_addr flow address (ID)
[in] flow_port flow port (ID)
[in] mdi_df MDI delay factor
[in] mdi_mlr MDI media loss rate

Definition at line 1637 of file monitube2-mgmt_config.c.

References age_out_flow_stat(), flowstat_s::flow_addr, flowstat_s::flow_port, flow_stats, flowstat_s::fpc_slot, flowstat_s::last_mdi_df, flowstat_s::last_mdi_mlr, LOG, m_ctx, MAX_FLOW_AGE, flowstat_ss_s::node, flowstat_s::node, flowstat_s::pic_slot, flowstat_s::reports, flowstat_s::ssi, flowstat_ss_s::ssid, flowstat_ss_s::stats, STATS_BASE_WINDOW, flowstat_s::timer_id, and flowstat_s::window_position.

Referenced by receive_message().

static void ss_change ( evContext ctx  UNUSED,
void *  uap,
struct timespec due  UNUSED,
struct timespec inter  UNUSED 
) [static]

A change has happened to this service set and we need to notify the PIC

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 345 of file monitube2-mgmt_config.c.

References ss_info_s::fpc_slot, ss_info_s::gen_num, ss_info_s::id, list_item_s::item, rule_s::name, ss_info_s::name, notify_apply_rule(), ss_info_s::pic_slot, ss_info_s::rules, and ss_info_s::svc_id.

Referenced by notify_ssrb_change().

static void syncup ( junos_kcom_pub_ssrb_t *  s,
void **d  UNUSED,
size_t *l  UNUSED 
) [static]

SYNC up the SSRB database

Parameters:
[in] s The SSRB info
[in] d The user data for this callback
[in] l The user data size

Definition at line 1449 of file monitube2-mgmt_config.c.

References LOG.

Referenced by init_config().

static int verify_service_interfaces ( dax_walk_data_t *  dwd,
ddl_handle_t *  dop,
int  action,
void *  data 
) [static]

Handler for dax_query to get the changed service interfaces (in service sets) $ss contains the service-set name

Parameters:
[in] dwd Opaque dax data
[in] dop DAX Object Pointer for sampling-service object
[in] action The action on the given server object
[in] data User data passed to handler (check flag)
Returns:
DAX_WALK_OK upon success or DAX_WALK_ABORT upon failure

Definition at line 475 of file monitube2-mgmt_config.c.

References address_s::address, ss_info_s::fpc_slot, ss_info_s::gen_num, ss_info_s::id, list_item_s::item, address_s::mask, MONITUBE2_MGMT_STRLEN, rule_s::name, next_address(), notify_apply_rule(), notify_config_rule(), notify_config_rule_prefix(), notify_delete_serviceset(), ss_info_s::pic_slot, rule_s::rate, rule_s::redirect, ss_info_s::rules, ssets, and ss_info_s::svc_id.

Referenced by monitube_config_read().


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:04 2010 for SDK Your Net Corporation Monitube2 IPTV Monitoring Example: monitube2-mgmt 1.0 by Doxygen 1.5.1