xorp

internal_message.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2009 XORP, Inc.
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/bgp/internal_message.hh,v 1.14 2008/11/08 06:14:36 mjh Exp $
00021 
00022 #ifndef __BGP_INTERNAL_MESSAGES_HH__
00023 #define __BGP_INTERNAL_MESSAGES_HH__
00024 
00025 #include "libxorp/xorp.h"
00026 #include "libxorp/ref_ptr.hh"
00027 #include "subnet_route.hh"
00028 #include "path_attribute.hh"
00029 class PeerHandler;
00030 
00031 #define GENID_UNKNOWN 0
00032 
00047 template<class A>
00048 class InternalMessage
00049 {
00050 public:
00051     InternalMessage(const SubnetRoute<A> *route,
00052             const PeerHandler *origin_peer,
00053             uint32_t genid);
00054     InternalMessage(const SubnetRoute<A> *route,
00055             FPAListRef pa_list,
00056             const PeerHandler *origin_peer,
00057             uint32_t genid);
00058     ~InternalMessage();
00059     const IPNet<A>& net() const;
00060     const SubnetRoute<A> *route() const { return _subnet_route; }
00061     const PeerHandler* origin_peer() const { return _origin_peer; }
00062     const A& nexthop() const { return _attributes->nexthop(); }
00063     FPAListRef& attributes() {return _attributes;}
00064     const FPAListRef& const_attributes() const {return _attributes;}
00065 
00066     bool changed() const { return _changed; }
00067     void set_changed() { _changed = true; }
00068     void clear_changed() const { _changed = false; }
00069 
00070     bool copied() const { return _copied; }
00071     void set_copied() { _copied = true; }
00072     void clear_copied() const { _copied = false; }
00073 
00074     bool push() const { return _push; }
00075     void set_push() { _push = true; }
00076     void clear_push() { _push = false; }
00077 
00078     bool from_previous_peering() const { return _from_previous_peering; }
00079     void set_from_previous_peering() { _from_previous_peering = true; }
00080 
00081     uint32_t genid() const { return _genid; }
00082 
00083 #if 0
00084     // This is a hack to override const in DecisionTable.
00085     void force_clear_push() const { _push = false; }
00086 #endif
00087 
00088     // this should only be called if the msg had been copied
00089     void inactivate() const {
00090     if (_copied) {
00091         _subnet_route->unref();
00092         _subnet_route = NULL;
00093     }
00094     }
00095 
00096     string str() const;
00097 protected:
00098 private:
00102     mutable const SubnetRoute<A> *_subnet_route;
00103 
00109     FPAListRef _attributes;
00110 
00115     const PeerHandler *_origin_peer;
00116 
00122     mutable bool _changed;
00123 
00128     mutable bool _copied;
00129 
00134     uint32_t _genid;
00135 
00140     mutable bool _push;
00141 
00146     bool _from_previous_peering;
00147 };
00148 
00149 #endif // __BGP_INTERNAL_MESSAGES_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations