|
xorp
|
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/route_queue.hh,v 1.18 2008/11/08 06:14:37 mjh Exp $ 00021 00022 #ifndef __BGP_ROUTE_QUEUE_HH__ 00023 #define __BGP_ROUTE_QUEUE_HH__ 00024 00025 #include "subnet_route.hh" 00026 00027 class PeerHandler; 00028 00029 typedef enum ribout_queue_op { 00030 RTQUEUE_OP_ADD = 1, 00031 RTQUEUE_OP_DELETE = 2, 00032 RTQUEUE_OP_REPLACE_OLD = 3, 00033 RTQUEUE_OP_REPLACE_NEW = 4, 00034 RTQUEUE_OP_PUSH = 5 00035 } RouteQueueOp; 00036 00037 template<class A> 00038 class RouteQueueEntry { 00039 public: 00040 RouteQueueEntry(const SubnetRoute<A>* rt, FPAListRef& pa_list, 00041 RouteQueueOp op) : 00042 _route_ref(rt), _pa_list(pa_list) 00043 { 00044 // mandate that we lock the pa_list before storing it here. 00045 XLOG_ASSERT(pa_list->is_locked()); 00046 _op = op; 00047 _origin_peer = 0; 00048 _push = false; 00049 } 00050 00051 //for push only 00052 RouteQueueEntry(RouteQueueOp op, const PeerHandler *origin_peer) : 00053 _route_ref(NULL) 00054 { 00055 assert(op == RTQUEUE_OP_PUSH); 00056 _op = op; 00057 _origin_peer = origin_peer; // NULL is valid. 00058 _push = false; 00059 } 00060 00061 ~RouteQueueEntry() { 00062 } 00063 00064 const SubnetRoute<A>* route() const 00065 { 00066 return _route_ref.route(); 00067 } 00068 00069 const IPNet<A>& net() const 00070 { 00071 return _route_ref.route()->net(); 00072 } 00073 00074 FPAListRef attributes() const 00075 { 00076 // mandate that the attributes are still locked. 00077 if (!_pa_list.is_empty()) 00078 XLOG_ASSERT(_pa_list->is_locked()); 00079 return _pa_list; 00080 } 00081 RouteQueueOp op() const { return _op; } 00082 00083 void set_origin_peer(const PeerHandler *peer) {_origin_peer = peer; } 00084 const PeerHandler *origin_peer() const { return _origin_peer; } 00085 void set_genid(uint32_t genid) { _genid = genid; } 00086 uint32_t genid() const { return _genid; } 00087 void set_push(bool push) { _push = push; } 00088 bool push() const { return _push;} 00089 00090 string str() const; 00091 private: 00092 RouteQueueOp _op; 00093 00094 SubnetRouteConstRef<A> _route_ref; 00095 FPAListRef _pa_list; 00096 const PeerHandler *_origin_peer; 00097 uint32_t _genid; 00098 bool _push; 00099 }; 00100 00101 #endif // __BGP_ROUTE_QUEUE_HH__