xorp

proto_state.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 Lesser General Public License, Version
00008 // 2.1, June 1999 as published by the Free Software Foundation.
00009 // Redistribution and/or modification of this program under the terms of
00010 // any other version of the GNU Lesser General Public License is not
00011 // permitted.
00012 // 
00013 // This program is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00016 // see the GNU Lesser General Public License, Version 2.1, a copy of
00017 // which can be found in the XORP LICENSE.lgpl file.
00018 // 
00019 // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00020 // http://xorp.net
00021 
00022 
00023 #ifndef __LIBPROTO_PROTO_STATE_HH__
00024 #define __LIBPROTO_PROTO_STATE_HH__
00025 
00026 
00027 #include "libxorp/xorp.h"
00028 #include "libxorp/service.hh"
00029 
00030 
00031 //
00032 // Protocol state generic functionality
00033 //
00034 
00038 class ProtoState : public ServiceBase {
00039 public:
00043     ProtoState();
00044     
00048     virtual ~ProtoState();
00049     
00057     int     start();
00058     
00066     int     stop();
00067     
00079     int     pending_start();
00080     
00091     int     pending_stop();
00092     
00098     void    enable()    { _flags |= XORP_ENABLED;   }
00099     
00106     void    disable();
00107     
00113     bool    is_up() const;
00114     
00120     bool    is_down() const;
00121 
00127     bool    is_pending_up() const;
00128 
00134     bool    is_pending_down() const;
00135     
00141     bool    is_enabled()    const   { return (_flags & XORP_ENABLED); }
00142     
00148     bool    is_disabled()   const   { return (! is_enabled());  }
00149     
00155     bool    is_debug()  const   { return (_debug_flag);     }
00156     
00162     void    set_debug(bool v)   { _debug_flag = v;      }
00163     
00172     string  state_str() const;
00173     
00174 private:
00180     int startup();
00181 
00187     int shutdown();
00188 
00194     int reset();
00195 
00196     enum {
00197     XORP_ENABLED    = 1 << 0    // Entity is enabled.
00198     };
00199     uint32_t    _flags;         // Misc. flags: XORP_ENABLED, etc
00200                     // (see above).
00201     bool    _debug_flag;        // Enable/Disable debug messages.
00202 };
00203 
00204 //
00205 // Global variables
00206 //
00207 
00208 //
00209 // Global functions prototypes
00210 //
00211 
00212 #endif // __LIBPROTO_PROTO_STATE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations