xorp

debug_io.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/debug_io.hh,v 1.4 2008/10/02 21:56:33 bms Exp $
00022 
00023 #ifndef __OLSR_DEBUG_IO_HH__
00024 #define __OLSR_DEBUG_IO_HH__
00025 
00031 class DebugIO : public IO {
00032   public:
00033     DebugIO(TestInfo& info, EventLoop& eventloop);
00034 
00035     virtual ~DebugIO();
00036 
00040     void pp(const string& which, int level,
00041     const string& interface, const string& vif,
00042     IPv4 dst, uint16_t dport, IPv4 src, uint16_t sport,
00043     uint8_t* data, uint32_t len);
00044 
00045     int startup();
00046     int shutdown();
00047 
00052     bool enable_address(const string& interface, const string& vif,
00053     const IPv4& address, const uint16_t& port,
00054     const IPv4& all_nodes_address);
00055 
00060     bool disable_address(const string& interface, const string& vif,
00061     const IPv4& address, const uint16_t& port);
00062 
00068     bool is_interface_enabled(const string& interface) const;
00069 
00075     bool is_vif_enabled(const string & interface, const string & vif) const;
00076 
00080     bool is_vif_broadcast_capable(const string& interface, const string& vif);
00081 
00085     bool is_vif_multicast_capable(const string& interface, const string& vif);
00086 
00090     bool is_vif_loopback(const string& interface, const string& vif);
00091 
00097     bool is_address_enabled(const string& interface, const string& vif,
00098     const IPv4& address) const;
00099 
00109     bool get_addresses(const string& interface, const string& vif,
00110     list<IPv4>& addresses) const;
00111 
00122     bool get_broadcast_address(const string& interface,
00123                    const string& vif,
00124                    const IPv4& address,
00125                    IPv4& bcast_address) const;
00126 
00130     bool get_interface_id(const string& interface, uint32_t& interface_id);
00131 
00135     uint32_t get_mtu(const string& interface);
00136 
00140     inline int packets() const { return _packets; }
00141 
00146     bool send(const string& interface, const string& vif,
00147     const IPv4 & src, const uint16_t & sport,
00148     const IPv4 & dst, const uint16_t & dport,
00149     uint8_t* data, const uint32_t & len);
00150 
00154     void receive(const string& interface, const string& vif,
00155     const IPv4 & dst, const uint16_t& dport,
00156     const IPv4 & src, const uint16_t& sport,
00157     uint8_t* data, const uint32_t & len);
00158 
00162     bool register_forward(const string& interface, const string& vif,
00163               IO::ReceiveCallback cb);
00164 
00169     void unregister_forward(const string& interface, const string& vif);
00170 
00171     bool add_route(IPv4Net net, IPv4 nexthop, uint32_t nexthop_id,
00172         uint32_t metric, const PolicyTags& policytags);
00173 
00174     bool replace_route(IPv4Net net, IPv4 nexthop,
00175         uint32_t nexthop_id, uint32_t metric,
00176         const PolicyTags & policytags);
00177 
00178     bool delete_route(IPv4Net net);
00179 
00180     void routing_table_empty();
00181 
00182     uint32_t routing_table_size();
00183 
00187     bool routing_table_verify(IPv4Net net, IPv4 nexthop, uint32_t metric);
00188 
00193     void routing_table_dump(ostream& o);
00194 
00195   private:
00196     TestInfo&       _info;
00197     EventLoop&      _eventloop;
00198     int         _packets;
00199 
00200     uint32_t            _next_interface_id;
00201     map<string, uint32_t>   _interface_ids;
00202 
00203     MessageDecoder  _md;
00204 
00210     map<pair<string, string>, IO::ReceiveCallback>  _forward_cbs;
00211 
00212     struct DebugRouteEntry {
00213         IPv4        _nexthop;
00214         uint32_t    _metric;
00215     PolicyTags  _policytags;
00216     };
00217 
00218     map<IPv4Net, DebugRouteEntry>   _routing_table;
00219 };
00220 
00221 #endif // __OLSR_DEBUG_IO_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations