monitube2-data_config.c File Reference

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

#include "monitube2-data_main.h"
#include "monitube2-data_config.h"

Go to the source code of this file.

Data Structures

struct  list_item_s
struct  address_s
struct  rule_s
struct  prefix_s

Defines

#define MONITUBE2_MGMT_STRLEN   256
 Application name length.
#define RLOCK(l)   INSIST_ERR(msp_rwlock_rlock(l) == MSP_OK)
 Read lock.
#define WLOCK(l)   INSIST_ERR(msp_rwlock_wlock(l) == MSP_OK)
 Write lock.
#define RUNLOCK(l)   INSIST_ERR(msp_rwlock_runlock(l) == MSP_OK)
 Read lock.
#define WUNLOCK(l)   INSIST_ERR(msp_rwlock_wunlock(l) == MSP_OK)
 Write lock.

Typedefs

typedef list_item_s list_item_t
typedef address_s address_t
typedef rule_s rule_t
typedef prefix_s prefix_t

Functions

typedef TAILQ_HEAD (list_s, list_item_s)
static void update_time (evContext ectx UNUSED, void *uap UNUSED, struct timespec due UNUSED, struct timespec inter UNUSED)
static uint8_t bit_count (uint32_t n)
static void free_policy (evContext ectx UNUSED, void *uap, struct timespec due UNUSED, struct timespec inter UNUSED)
void init_config (void)
time_t get_current_time (void)
void clear_config (void)
void update_rule (char *name, uint32_t rate, in_addr_t redirect)
int delete_rule (char *name)
void add_address (char *name, in_addr_t addr, in_addr_t mask)
void delete_address (char *name, in_addr_t addr, in_addr_t mask)
void apply_rule (char *name, uint16_t ssid, uint32_t gennum, uint32_t svcid)
void remove_rule (char *name, uint16_t ssid, uint32_t gennum, uint32_t svcid)
void delete_serviceset (uint16_t ssid, uint32_t gennum, uint32_t svcid)
int get_monitored_rule_info (uint16_t ssid, uint32_t svcid, in_addr_t address, uint32_t *rate, uint32_t *redirect_addr)

Variables

int plugin_id
evContext * ctx
msp_policy_db_handle_t pdb_handle
void * pdb_shm_handle
 ss_info_t
static atomic_uint_t current_time
static patroot rules


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 monitube2-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 destination address/prefix

typedef struct list_item_s list_item_t

A list item

typedef struct prefix_s prefix_t

The structure we use to bundle the radix-tree node with a pointer to the rule we need. Used in the data & ctrl paths with a lock in ss_info_t

typedef struct rule_s rule_t

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

Only redirect and rate could be used in the fast path. To change these or delete the rule one should have a write lock. The rest is only touched in the ctrl path (and from one thread). In ctrl side we don't always grab the lock when reading, b/c we don't care about reading while data side is reading. We just want to block ctrl side writing while data side is reading.


Function Documentation

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

Add an address to the rule

Parameters:
[in] name rule name
[in] addr Address
[in] mask Mask to apply to addr

Definition at line 519 of file monitube2-data_config.c.

References address_s::address, rule_s::addresses, bit_count(), CLOG, list_item_s::data, INSIST_ERR, address_s::mask, address_s::node, pdb_shm_handle, prefix_s::prefix, prefix_s::rnode, prefix_s::rule, rules, ss_info_t, rule_s::ssets, WLOCK, and WUNLOCK.

Referenced by mgmt_client_message().

void apply_rule ( char *  name,
uint16_t  ssid,
uint32_t  gennum,
uint32_t  svcid 
)

Apply rule on a service set

Parameters:
[in] name rule name
[in] ssid service set id
[in] gennum Service set generation number needed for PDB
[in] svcid Service ID needed for PDB

Definition at line 667 of file monitube2-data_config.c.

References CLOG, list_item_s::data, INSIST_ERR, pdb_handle, pdb_shm_handle, plugin_id, PLUGIN_NAME, rules, ss_info_t, and rule_s::ssets.

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 195 of file monitube2-data_config.c.

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

void clear_config ( void   ) 

Clear the stored configuration data

Definition at line 288 of file monitube2-data_config.c.

References CLOG, ctx, delete_rule(), free_policy(), rule_s::name, pdb_handle, plugin_id, PLUGIN_NAME, rules, and ss_info_t.

Referenced by mgmt_client_connection(), and mgmt_client_message().

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

Delete an address from the rule

Parameters:
[in] name rule name
[in] addr Address
[in] mask Mask to apply to addr

Definition at line 591 of file monitube2-data_config.c.

References rule_s::addresses, bit_count(), CLOG, list_item_s::data, address_s::node, prefix_s::rule, rules, ss_info_t, rule_s::ssets, WLOCK, and WUNLOCK.

Referenced by mgmt_client_message().

int delete_rule ( char *  name  ) 

Delete rule

Parameters:
[in] name rule name
Returns:
0 on success; -1 o/w

Definition at line 423 of file monitube2-data_config.c.

References address_s::address, rule_s::addresses, bit_count(), CLOG, list_item_s::data, rule_s::lock, address_s::mask, rule_s::node, address_s::node, pdb_shm_handle, prefix_s::rule, rules, ss_info_t, rule_s::ssets, WLOCK, and WUNLOCK.

Referenced by clear_config(), and mgmt_client_message().

void delete_serviceset ( uint16_t  ssid,
uint32_t  gennum,
uint32_t  svcid 
)

Delete service set

Parameters:
[in] ssid service set id

Definition at line 891 of file monitube2-data_config.c.

References CLOG, ctx, list_item_s::data, free_policy(), pdb_handle, pdb_shm_handle, plugin_id, PLUGIN_NAME, ss_info_t, and rule_s::ssets.

Referenced by mgmt_client_message().

static void free_policy ( evContext ectx  UNUSED,
void *  uap,
struct timespec due  UNUSED,
struct timespec inter  UNUSED 
) [static]

Callback to free policy after some delay

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 221 of file monitube2-data_config.c.

References pdb_shm_handle, and ss_info_t.

Referenced by clear_config(), delete_serviceset(), and remove_rule().

time_t get_current_time ( void   ) 

Get the currently cached time

Returns:
Current time

Definition at line 278 of file monitube2-data_config.c.

References current_time.

Referenced by process_packet().

int get_monitored_rule_info ( uint16_t  ssid,
uint32_t  svcid,
in_addr_t  address,
uint32_t *  rate,
uint32_t *  redirect_addr 
)

Find the monitoring rate and redirect address a rule-match happen one exists. This will be run in the fast path.

Parameters:
[in] ssid The service set id
[in] svcid The service id
[in] address The destination address
[out] rate If null on input, this is ignored. The monitoring rate; 0 if no rate
[out] redirect_addr If null on input, this is ignored. The mirror addr; 0 if no mirroring
Returns:
0 if found a valid rule; or -1 if no match is found

Definition at line 994 of file monitube2-data_config.c.

References DLOG, rule_s::lock, pdb_handle, plugin_id, PLUGIN_NAME, rule_s::rate, rule_s::redirect, RLOCK, prefix_s::rule, RUNLOCK, and ss_info_t.

Referenced by monitube_data_hdlr().

void init_config ( void   ) 

Init the data structures that will store configuration info

Should only be called on startup (one time)

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

References CLOG, ctx, current_time, MONITUBE2_MGMT_STRLEN, rules, and update_time().

Referenced by retry_attach_fdb().

void remove_rule ( char *  name,
uint16_t  ssid,
uint32_t  gennum,
uint32_t  svcid 
)

Remove a rule from a service set

Parameters:
[in] name rule name
[in] ssid service set id
[in] gennum Service set generation number needed for PDB
[in] svcid Service ID needed for PDB

Definition at line 787 of file monitube2-data_config.c.

References CLOG, ctx, list_item_s::data, free_policy(), pdb_handle, pdb_shm_handle, plugin_id, PLUGIN_NAME, rules, ss_info_t, and rule_s::ssets.

Referenced by mgmt_client_message().

typedef TAILQ_HEAD ( list_s  ,
list_item_s   
)

The structure we use to bundle service-set info

We don't need the prefixes_lock during the delayed delete

< service set id number

< service id

< generation number

< Radix tree for monitor lookups in data path

< Lock while using prefixes or its contents

< list of rules (only used in ctrl path)

Definition at line 70 of file monitube2-data_config.c.

References rules.

void update_rule ( char *  name,
uint32_t  rate,
in_addr_t  redirect 
)

Update/create a rule

Parameters:
[in] name rule name
[in] rate monitoring rate
[in] redirect address for mirroring

Definition at line 377 of file monitube2-data_config.c.

References rule_s::addresses, CLOG, INSIST_ERR, rule_s::lock, rule_s::name, rule_s::node, pdb_shm_handle, rule_s::rate, rule_s::redirect, rules, rule_s::ssets, WLOCK, and WUNLOCK.

Referenced by mgmt_client_message().

static void update_time ( evContext ectx  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 177 of file monitube2-data_config.c.

References current_time.

Referenced by init_config().


Variable Documentation

evContext* ctx

The main evContext on the ctrl plane side

Definition at line 578 of file monitube2-data_main.c.

Referenced by clear_config(), connect_mgmt(), delete_serviceset(), init_config(), init_connections(), mgmt_client_connection(), monitube_ctrl_hdlr(), process_notifications(), remove_rule(), and retry_attach_fdb().

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 136 of file monitube2-data_config.c.

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

msp_policy_db_handle_t pdb_handle

The policy database handle

Definition at line 583 of file monitube2-data_main.c.

Referenced by apply_rule(), clear_config(), delete_serviceset(), get_monitored_rule_info(), monitube_ctrl_hdlr(), and remove_rule().

void* pdb_shm_handle

The shared mem handle for the PDB

Definition at line 588 of file monitube2-data_main.c.

Referenced by add_address(), apply_rule(), delete_rule(), delete_serviceset(), free_policy(), monitube_ctrl_hdlr(), remove_rule(), and update_rule().

int plugin_id

The id assigned by mspmand unique over all plugins

Definition at line 573 of file monitube2-data_main.c.

Referenced by apply_rule(), clear_config(), delete_serviceset(), get_monitored_rule_info(), monitube2_entry(), monitube_ctrl_hdlr(), monitube_data_hdlr(), and remove_rule().

patroot rules [static]

The PATRICIA tree root for rules configuration. Only used in the ctrl path

Definition at line 142 of file monitube2-data_config.c.

Referenced by add_address(), apply_rule(), clear_config(), delete_address(), delete_rule(), init_config(), remove_rule(), TAILQ_HEAD(), and update_rule().


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