xorp

xrl_rib_notifier.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/rip/xrl_rib_notifier.hh,v 1.12 2008/10/02 21:58:19 bms Exp $
00021 
00022 #ifndef __RIP_XRL_RIB_NOTIFIER_HH__
00023 #define __RIP_XRL_RIB_NOTIFIER_HH__
00024 
00025 
00026 #include "libxorp/ipnet.hh"
00027 #include "libxorp/service.hh"
00028 
00029 #include "rib_notifier_base.hh"
00030 
00031 class XrlSender;
00032 class XrlRouter;
00033 
00053 template <typename A>
00054 class XrlRibNotifier : public RibNotifierBase<A>, public ServiceBase
00055 {
00056 public:
00057     typedef RibNotifierBase<A> Super;
00058 
00059     static const uint32_t DEFAULT_INFLIGHT = 20;
00060 
00061 public:
00065     XrlRibNotifier(EventLoop&       e,
00066            UpdateQueue<A>&  uq,
00067            XrlRouter&       xr,
00068            uint32_t     max_inflight = DEFAULT_INFLIGHT,
00069            uint32_t     poll_ms = Super::DEFAULT_POLL_MS);
00070 
00077     XrlRibNotifier(EventLoop&       e,
00078            UpdateQueue<A>&  uq,
00079            XrlSender&       xs,
00080            const string&    class_name,
00081            const string&    intance_name,
00082            uint32_t     max_inflight = DEFAULT_INFLIGHT,
00083            uint32_t     poll_ms = Super::DEFAULT_POLL_MS);
00084 
00085     ~XrlRibNotifier();
00086 
00093     int startup();
00094 
00101     int shutdown();
00102 
00106     uint32_t xrls_inflight() const;
00107 
00111     uint32_t max_xrls_inflight() const;
00112 
00113 protected:
00114     void updates_available();
00115 
00116 private:
00117     void add_igp_cb(const XrlError& e);
00118     void delete_igp_cb(const XrlError& e);
00119 
00120     void send_add_route(const RouteEntry<A>& re);
00121     void send_delete_route(const RouteEntry<A>& re);
00122     void send_route_cb(const XrlError& e);
00123 
00124     void incr_inflight();
00125     void decr_inflight();
00126 
00127 protected:
00128     XrlSender&      _xs;
00129     string      _cname;
00130     string      _iname;
00131     const uint32_t  _max_inflight;
00132     uint32_t        _inflight;
00133 
00134     set<IPNet<A> >  _ribnets;   // XXX hack
00135 };
00136 
00137 // ----------------------------------------------------------------------------
00138 // Public inline method definitions
00139 
00140 template <typename A>
00141 inline uint32_t
00142 XrlRibNotifier<A>::xrls_inflight() const
00143 {
00144     return _inflight;
00145 }
00146 
00147 template <typename A>
00148 inline uint32_t
00149 XrlRibNotifier<A>::max_xrls_inflight() const
00150 {
00151     return _max_inflight;
00152 }
00153 
00154 #endif // __RIP_XRL_RIB_NOTIFIER_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations