xorp

route_table_ribout.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/bgp/route_table_ribout.hh,v 1.21 2008/11/08 06:14:40 mjh Exp $
00021 
00022 #ifndef __BGP_ROUTE_TABLE_RIBOUT_HH__
00023 #define __BGP_ROUTE_TABLE_RIBOUT_HH__
00024 
00025 
00026 
00027 
00028 #include "bgp_module.h"
00029 #include "libxorp/xlog.h"
00030 #include "libxorp/eventloop.hh"
00031 #include "route_table_base.hh"
00032 #include "route_queue.hh"
00033 #include "parameter.hh"
00034 
00035 
00036 template<class A>
00037 class RibOutTable : public BGPRouteTable<A>  {
00038 public:
00039     RibOutTable(string tablename,
00040         Safi safi,
00041         BGPRouteTable<A> *parent,
00042         PeerHandler *peer);
00043     ~RibOutTable();
00044     void print_queue(const list<const RouteQueueEntry<A> *>& queue) const;
00045     int add_route(InternalMessage<A> &rtmsg,
00046           BGPRouteTable<A> *caller);
00047     int replace_route(InternalMessage<A> &old_rtmsg,
00048               InternalMessage<A> &new_rtmsg,
00049               BGPRouteTable<A> *caller);
00050     int delete_route(InternalMessage<A> &rtmsg, 
00051              BGPRouteTable<A> *caller);
00052 
00053     int push(BGPRouteTable<A> *caller);
00054     const SubnetRoute<A> *lookup_route(const IPNet<A> &net,
00055                        uint32_t& genid,
00056                        FPAListRef& pa_list) const;
00057 
00058     RouteTableType type() const {return RIB_OUT_TABLE;}
00059     string str() const;
00060     int dump_entire_table() { abort(); return 0; }
00061 
00062     /* mechanisms to implement flow control in the output plumbing */
00063     void wakeup();
00064     bool pull_next_route();
00065 
00066     /* output_no_longer_busy is called asynchronously by the peer
00067        handler when the state of the output queue goes from busy to
00068        non-busy.  When the output queue has been busy we will have
00069        signalled back upstream to stop further routes arriving, so we
00070        need to go and retrieve the queued routes */
00071     void output_no_longer_busy();
00072 
00073     bool get_next_message(BGPRouteTable<A> */*next_table*/) {
00074     abort();
00075     return false;
00076     }
00077 
00078     void reschedule_self();
00079 
00080     void peering_went_down(const PeerHandler *peer, uint32_t genid,
00081                BGPRouteTable<A> *caller);
00082     void peering_down_complete(const PeerHandler *peer, uint32_t genid,
00083                    BGPRouteTable<A> *caller);
00084     void peering_came_up(const PeerHandler *peer, uint32_t genid,
00085              BGPRouteTable<A> *caller);
00086 private:
00087     //the queue that builds, prior to receiving a push, so we can
00088     //send updates to our peers atomically
00089     list <const RouteQueueEntry<A> *> _queue;
00090 
00091     PeerHandler *_peer;
00092     bool _peer_busy;
00093     bool _peer_is_up;
00094     XorpTask _pull_routes_task;
00095 };
00096 
00097 #endif // __BGP_ROUTE_TABLE_RIBOUT_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations