xorp

fibconfig_table_set.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2011 XORP, Inc and Others
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 // $XORP: xorp/fea/fibconfig_table_set.hh,v 1.16 2008/10/02 21:56:46 bms Exp $
00021 
00022 #ifndef __FEA_FIBCONFIG_TABLE_SET_HH__
00023 #define __FEA_FIBCONFIG_TABLE_SET_HH__
00024 
00025 
00026 
00027 #include "fte.hh"
00028 #include "iftree.hh"
00029 #include "fea_data_plane_manager.hh"
00030 
00031 class FibConfig;
00032 
00033 
00034 class FibConfigTableSet {
00035 public:
00042     FibConfigTableSet(FeaDataPlaneManager& fea_data_plane_manager)
00043     : _is_running(false),
00044       _fibconfig(fea_data_plane_manager.fibconfig()),
00045       _fea_data_plane_manager(fea_data_plane_manager),
00046       _in_configuration(false)
00047     {}
00048 
00052     virtual ~FibConfigTableSet() {}
00053 
00059     FibConfig&  fibconfig() { return _fibconfig; }
00060 
00066     FeaDataPlaneManager& fea_data_plane_manager() { return _fea_data_plane_manager; }
00067 
00073     virtual bool is_running() const { return _is_running; }
00074 
00081     virtual int start(string& error_msg) = 0;
00082     
00089     virtual int stop(string& error_msg) = 0;
00090     
00103     virtual int start_configuration(string& error_msg) {
00104     // Nothing particular to do, just label start.
00105     return mark_configuration_start(error_msg);
00106     }
00107 
00118     virtual int end_configuration(string& error_msg) {
00119     // Nothing particular to do, just label start.
00120     return mark_configuration_end(error_msg);
00121     }
00122 
00130     virtual int set_table4(const list<Fte4>& fte_list) = 0;
00131 
00139     virtual int delete_all_entries4() = 0;
00140 
00148     virtual int set_table6(const list<Fte6>& fte_list) = 0;
00149     
00157     virtual int delete_all_entries6() = 0;
00158 
00162     virtual int notify_table_id_change(uint32_t new_tbl) = 0;
00163 
00164 protected:
00171     int mark_configuration_start(string& error_msg) {
00172     if (_in_configuration != true) {
00173         _in_configuration = true;
00174         return (XORP_OK);
00175     }
00176     error_msg = c_format("Cannot start configuration: "
00177                  "configuration in progress");
00178     return (XORP_ERROR);
00179     }
00180 
00187     int mark_configuration_end(string& error_msg) {
00188     if (_in_configuration != false) {
00189         _in_configuration = false;
00190         return (XORP_OK);
00191     }
00192     error_msg = c_format("Cannot end configuration: "
00193                  "configuration not in progress");
00194     return (XORP_ERROR);
00195     }
00196     
00197     bool in_configuration() const { return _in_configuration; }
00198 
00199     // Misc other state
00200     bool    _is_running;
00201 
00202 private:
00203     FibConfig&      _fibconfig;
00204     FeaDataPlaneManager& _fea_data_plane_manager;
00205     bool        _in_configuration;
00206 };
00207 
00208 #endif // __FEA_FIBCONFIG_TABLE_SET_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations