// -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- // Copyright (c) 2001-2004 International Computer Science Institute // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software") // to deal in the Software without restriction, subject to the conditions // listed in the XORP LICENSE file. These conditions include: you must // preserve this copyright notice, and you cannot mention the copyright // holders in advertising related to the Software without their permission. // The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This // notice is a summary of the XORP LICENSE file; the license in that file is // legally binding. // $XORP: xorp/fea/fticonfig_table_set.hh,v 1.8 2004/06/10 22:40:51 hodson Exp $ #ifndef __FEA_FTICONFIG_TABLE_SET_HH__ #define __FEA_FTICONFIG_TABLE_SET_HH__ #include "libxorp/xorp.h" #include "libxorp/ipvx.hh" #include "fte.hh" #include "netlink_socket.hh" #include "routing_socket.hh" class FtiConfig; class FtiConfigTableSet { public: FtiConfigTableSet(FtiConfig& ftic); virtual ~FtiConfigTableSet(); FtiConfig& ftic() { return _ftic; } virtual void register_ftic(); /** * Start operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int start() = 0; /** * Stop operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int stop() = 0; /** * Start a configuration interval. All modifications to FtiConfig * state must be within a marked "configuration" interval. * * This method provides derived classes with a mechanism to perform * any actions necessary before forwarding table modifications can * be made. * * @return true if configuration successfully started. */ virtual bool start_configuration() { // Nothing particular to do, just label start. return mark_configuration_start(); } /** * End of configuration interval. * * This method provides derived classes with a mechanism to * perform any actions necessary at the end of a configuration, eg * write a file. * * @return true configuration success pushed down into forwarding table. */ virtual bool end_configuration() { // Nothing particular to do, just label start. return mark_configuration_end(); } /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table4(const list<Fte4>& fte_list) = 0; /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries4() = 0; /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table6(const list<Fte6>& fte_list) = 0; /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries6() = 0; protected: /** * Mark start of a configuration. * * @return true if configuration can be marked as started, false otherwise. */ inline bool mark_configuration_start() { if (false == _in_configuration) { _in_configuration = true; return true; } return false; } /** * Mark end of a configuration. * * @return true if configuration can be marked as ended, false otherwise. */ inline bool mark_configuration_end() { if (true == _in_configuration) { _in_configuration = false; return true; } return false; } inline bool in_configuration() const { return _in_configuration; } // Misc other state bool _is_running; private: FtiConfig& _ftic; bool _in_configuration; }; class FtiConfigTableSetDummy : public FtiConfigTableSet { public: FtiConfigTableSetDummy(FtiConfig& ftic); virtual ~FtiConfigTableSetDummy(); /** * Start operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int start(); /** * Stop operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int stop(); /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table4(const list<Fte4>& fte_list); /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries4(); /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table6(const list<Fte6>& fte_list); /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries6(); private: }; class FtiConfigTableSetRtsock : public FtiConfigTableSet { public: FtiConfigTableSetRtsock(FtiConfig& ftic); virtual ~FtiConfigTableSetRtsock(); /** * Start operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int start(); /** * Stop operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int stop(); /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table4(const list<Fte4>& fte_list); /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries4(); /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table6(const list<Fte6>& fte_list); /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries6(); private: }; class FtiConfigTableSetNetlink : public FtiConfigTableSet { public: FtiConfigTableSetNetlink(FtiConfig& ftic); virtual ~FtiConfigTableSetNetlink(); /** * Start operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int start(); /** * Stop operation. * * @return XORP_OK on success, otherwise XORP_ERROR. */ virtual int stop(); /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table4(const list<Fte4>& fte_list); /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries4(); /** * Set the unicast forwarding table. * * @param fte_list the list with all entries to install into * the unicast forwarding table. * * @return true on success, otherwise false. */ virtual bool set_table6(const list<Fte6>& fte_list); /** * Delete all entries in the routing table. Must be within a * configuration interval. * * @return true on success, otherwise false. */ virtual bool delete_all_entries6(); private: }; #endif // __FEA_FTICONFIG_TABLE_SET_HH__