xorp

xrl_queue.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 // vim:set sts=4 ts=8 sw=4:
00003 
00004 // Copyright (c) 2001-2009 XORP, Inc.
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License, Version 2, June
00008 // 1991 as published by the Free Software Foundation. Redistribution
00009 // and/or modification of this program under the terms of any other
00010 // version of the GNU General Public License is not permitted.
00011 // 
00012 // This program is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00015 // see the GNU General Public License, Version 2, a copy of which can be
00016 // found in the XORP LICENSE.gpl file.
00017 // 
00018 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00019 // http://xorp.net
00020 
00021 // $XORP: xorp/contrib/olsr/xrl_queue.hh,v 1.3 2008/10/02 21:56:37 bms Exp $
00022 
00023 #ifndef __OLSR_XRL_QUEUE_HH__
00024 #define __OLSR_XRL_QUEUE_HH__
00025 
00026 class XrlIO;
00027 
00031 class XrlQueue {
00032 public:
00033     XrlQueue(EventLoop& eventloop, XrlRouter& xrl_router);
00034 
00035     void set_io(XrlIO* io) { _io = io; }
00036 
00047     void queue_add_route(string ribname, const IPv4Net& net,
00048              const IPv4& nexthop, uint32_t nexthop_id,
00049              uint32_t metric, const PolicyTags& policytags);
00050 
00057     void queue_delete_route(string ribname, const IPv4Net& net);
00058 
00062     bool busy();
00063 
00064 private:
00065     struct Queued {
00066     bool add;
00067     string ribname;
00068     IPv4Net net;
00069     IPv4 nexthop;
00070     uint32_t nexthop_id;
00071     uint32_t metric;
00072     string comment;
00073     PolicyTags policytags;
00074     };
00075 
00076     static const size_t WINDOW = 100;
00077 
00078     EventLoop& eventloop() const;
00079 
00083     inline bool maximum_number_inflight() const {
00084     return _flying >= WINDOW;
00085     }
00086 
00090     void start();
00091 
00099     bool sendit_spec(Queued& q, const char *protocol);
00100 
00107     void route_command_done(const XrlError& error, const string comment);
00108 
00109 private:
00110     XrlIO*      _io;
00111     EventLoop&      _eventloop;
00112     XrlRouter&      _xrl_router;
00113     deque<Queued>   _xrl_queue;
00114 
00118     size_t      _flying;
00119 };
00120 
00121 #endif // __OLSR_XRL_QUEUE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations