xorp

policy_target.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 // vim:set sts=4 ts=8:
00003 
00004 // Copyright (c) 2001-2011 XORP, Inc and Others
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License, Version 2, June
00008 // 1991 as published by the Free Software Foundation. Redistribution
00009 // and/or modification of this program under the terms of any other
00010 // version of the GNU General Public License is not permitted.
00011 // 
00012 // This program is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00015 // see the GNU General Public License, Version 2, a copy of which can be
00016 // found in the XORP LICENSE.gpl file.
00017 // 
00018 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00019 // http://xorp.net
00020 
00021 // $XORP: xorp/policy/policy_target.hh,v 1.19 2008/10/02 21:57:59 bms Exp $
00022 
00023 #ifndef __POLICY_POLICY_TARGET_HH__
00024 #define __POLICY_POLICY_TARGET_HH__
00025 
00026 
00027 
00028 #include "libxipc/xrl_std_router.hh"
00029 #include "process_watch.hh"
00030 #include "configuration.hh"
00031 #include "filter_manager.hh"
00032 #include "policy/common/varrw.hh"
00033 
00040 class PolicyTarget {
00041 public:
00042     static string policy_target_name;
00043 
00047     PolicyTarget(XrlStdRouter& rtr);
00048 
00052     bool running();
00053     
00057     void shutdown();
00058 
00070     void create_term(const string& policy, const ConfigNodeId& order,
00071              const string& term);
00072 
00081     void delete_term(const string& policy, const string& term);
00082 
00094     void update_term_block(const string& policy,
00095                const string& term,
00096                const uint32_t& block,
00097                const ConfigNodeId& order,
00098                const string& statement);
00099     
00107     void create_policy(const string& policy);
00108 
00109 
00117     void delete_policy(const string& policy);
00118 
00126     void create_set(const string& name);
00127     
00137     void update_set(const string& type, const string& name, 
00138             const string& elements);
00139 
00147     void delete_set(const string& name);
00148 
00158     void add_to_set(const string& type, const string& name, 
00159             const string& element);
00160 
00170     void delete_from_set(const string& type, const string& name, 
00171              const string& element);
00172 
00180     void update_import(const string& protocol, const string& policies,
00181                const string& modifier);
00182 
00190     void update_export(const string& protocol, const string& policies,
00191                const string& modifier);
00192 
00193     /* 
00194      * Configure the variable map used for semantic checking.
00195      * This should be initialized only once at startup.
00196      *
00197      * Dynamic configuration may easily be implemented by invalidiating policies
00198      * in the configuration class.
00199      *
00200      * Dynamic addition of variables should be safe. It is the removal and
00201      * update which needs to trigger a policy to be flagged as modified.
00202      *
00203      * @param protocol the protocol for which the variable is available.
00204      * @param variable the name of the variable.
00205      * @param type the type of the variable.
00206      * @param access the permissions on the variable (r/rw).
00207      * @param id the varrw interface id.
00208      */
00209     void add_varmap(const string& protocol, const string& variable,
00210             const string& type, const string& access,
00211             const VarRW::Id& id);
00212 
00219     void commit(uint32_t msec);
00220 
00227     string dump_state(uint32_t id); 
00228 
00235     void birth(const string& tclass, const string& tinstance);
00236 
00243     void death(const string& tclass, const string& tinstance);
00244 
00251     void set_proto_target(const string& protocol, const string& target);
00252 
00253     string cli_command(const string& command);
00254     string test_policy(const string& arg);
00255     string show(const string& arg);
00256     void   show(const string& type, const string& name, RESOURCES& res);
00257     bool   test_policy(const string& policy, const string& prefix,
00258                const string& attributes, string& mods);
00259     bool   test_policy(const string& policy, const RATTR& attrs, RATTR& mods);
00260 
00261 private:
00262     void parse_attributes(const string& attr, RATTR& out);
00263 
00264     bool        _running;
00265     uint32_t        _commit_delay;
00266     ProtocolMap     _pmap;
00267     ProcessWatch    _process_watch;
00268     Configuration   _conf;
00269     FilterManager   _filter_manager;
00270 };
00271 
00272 #endif // __POLICY_POLICY_TARGET_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations