xorp

route_table_reader.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_reader.hh,v 1.15 2008/10/02 21:56:21 bms Exp $
00021 
00022 #ifndef __BGP_ROUTE_TABLE_READER_HH__
00023 #define __BGP_ROUTE_TABLE_READER_HH__
00024 
00025 #include "libxorp/xorp.h"
00026 #include "libxorp/ipnet.hh"
00027 
00028 
00029 
00030 #include "bgp_trie.hh"
00031 
00032 
00033 template <class A>
00034 class RibInTable;
00035 
00036 template <class A>
00037 class ReaderIxTuple {
00038 public:
00039     typedef typename BgpTrie<A>::iterator trie_iterator;
00040     ReaderIxTuple(const IPv4& peer_id,
00041           trie_iterator route_iter, 
00042           const RibInTable<A>* _ribin);
00043     const A& masked_addr() const {return _net.masked_addr();}
00044     uint32_t prefix_len() const {return _net.prefix_len();}
00045     IPNet<A> net() const {return _net;}
00046     bool is_consistent() const;
00047     const IPv4& peer_id() const {return _peer_id;}
00048     const RibInTable<A>* ribin() const {return _ribin;}
00049     bool operator<(const ReaderIxTuple& them) const;
00050     trie_iterator& route_iterator()
00051     {
00052     return _route_iter;
00053     }
00054 private:
00055     IPNet<A> _net;
00056     IPv4 _peer_id;
00057     trie_iterator _route_iter;
00058     const RibInTable<A>* _ribin;
00059 };
00060 
00061 template <class A>
00062 class RouteTableReader {
00063 public:
00064     typedef typename BgpTrie<A>::iterator trie_iterator;
00065     RouteTableReader(const list <RibInTable<A>*>& ribins,
00066              const IPNet<A>& prefix);
00067     bool get_next(const SubnetRoute<A>*& route, IPv4& peer_id);
00068 private:
00069     set <ReaderIxTuple<A>*> _peer_readers;
00070 };
00071 
00072 #endif // __BGP_ROUTE_TABLE_READER_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations