xorp

olsr.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/olsr.hh,v 1.3 2008/10/02 21:56:35 bms Exp $
00022 
00023 #ifndef __OLSR_OLSR_HH__
00024 #define __OLSR_OLSR_HH__
00025 
00026 #include "olsr_types.hh"
00027 #include "exceptions.hh"
00028 #include "policy_varrw.hh"
00029 #include "io.hh"
00030 #include "message.hh"
00031 #include "link.hh"
00032 #include "neighbor.hh"
00033 #include "twohop.hh"
00034 #include "face.hh"
00035 #include "face_manager.hh"
00036 #include "neighborhood.hh"
00037 #include "topology.hh"
00038 #include "external.hh"
00039 
00040 #include "libxorp/trie.hh"
00041 #include "libproto/spt.hh"
00042 
00043 #include "vertex.hh"
00044 #include "route_manager.hh"
00045 
00046 #include "trace.hh"
00047 
00048 #include "libxorp/profile.hh"
00049 #include "profile_vars.hh"
00050 
00056 class Olsr {
00057   public:
00058     Olsr(EventLoop& eventloop, IO* io);
00059 
00063     inline bool running() { return _io->status() != SERVICE_SHUTDOWN; }
00064 
00071     ProcessStatus status(string& reason);
00072 
00076     void shutdown();
00077 
00085     void receive(const string& interface, const string& vif,
00086     IPv4 dst, uint16_t dport, IPv4 src, uint16_t sport,
00087     uint8_t* data, uint32_t len);
00088 
00092     bool transmit(const string& interface, const string& vif,
00093     const IPv4& dst, const uint16_t& dport,
00094     const IPv4& src, const uint16_t& sport,
00095     uint8_t* data, const uint32_t& len);
00096 
00102     inline void register_vif_status(IO::VifStatusCb cb) {
00103     _io->register_vif_status(cb);
00104     }
00105 
00111     inline void register_address_status(IO::AddressStatusCb cb) {
00112     _io->register_address_status(cb);
00113     }
00114 
00115     inline EventLoop& get_eventloop() {
00116     return _eventloop;
00117     }
00118 
00119     inline FaceManager& face_manager() {
00120     return _fm;
00121     }
00122 
00123     inline Neighborhood& neighborhood() {
00124     return _nh;
00125     }
00126 
00127     inline TopologyManager& topology_manager() {
00128     return _tm;
00129     }
00130 
00131     inline ExternalRoutes& external_routes() {
00132     return _er;
00133     }
00134 
00135     inline RouteManager& route_manager() {
00136     return _rm;
00137     }
00138 
00145     inline bool set_main_addr(const IPv4& addr) {
00146     return face_manager().set_main_addr(addr);
00147     }
00148 
00152     inline IPv4 get_main_addr() {
00153     return face_manager().get_main_addr();
00154     }
00155 
00162     inline bool set_mpr_coverage(const uint32_t mpr_coverage) {
00163     neighborhood().set_mpr_coverage(mpr_coverage);
00164     return true;
00165     }
00166 
00170     inline uint32_t get_mpr_coverage() {
00171     return neighborhood().mpr_coverage();
00172     }
00173 
00180     inline bool set_tc_redundancy(const uint32_t tc_redundancy) {
00181     neighborhood().set_tc_redundancy(tc_redundancy);
00182     return true;
00183     }
00184 
00188     inline uint32_t get_tc_redundancy() {
00189     return neighborhood().get_tc_redundancy();
00190     }
00191 
00198     inline bool set_hello_interval(const TimeVal& interval) {
00199     face_manager().set_hello_interval(interval);
00200     return true;
00201     }
00202 
00206     inline TimeVal get_hello_interval() {
00207     return face_manager().get_hello_interval();
00208     }
00209 
00216     inline bool set_mid_interval(const TimeVal& interval) {
00217     face_manager().set_mid_interval(interval);
00218     return true;
00219     }
00220 
00224     inline TimeVal get_mid_interval() {
00225     return face_manager().get_mid_interval();
00226     }
00227 
00234     inline bool set_refresh_interval(const TimeVal& interval) {
00235     neighborhood().set_refresh_interval(interval);
00236     return true;
00237     }
00238 
00242     inline TimeVal get_refresh_interval() {
00243     return neighborhood().get_refresh_interval();
00244     }
00245 
00252     inline bool set_tc_interval(TimeVal interval) {
00253     neighborhood().set_tc_interval(interval);
00254     return true;
00255     }
00256 
00260     inline TimeVal get_tc_interval() {
00261     return neighborhood().get_tc_interval();
00262     }
00263 
00270     inline bool set_willingness(const OlsrTypes::WillType willingness) {
00271     neighborhood().set_willingness(willingness);
00272     return true;
00273     }
00274 
00278     inline OlsrTypes::WillType get_willingness() {
00279     return neighborhood().willingness();
00280     }
00281 
00288     inline bool set_hna_interval(const TimeVal& interval) {
00289     external_routes().set_hna_interval(interval);
00290     return true;
00291     }
00292 
00296     inline TimeVal get_hna_interval() {
00297     return external_routes().get_hna_interval();
00298     }
00299 
00306     inline bool set_dup_hold_time(const TimeVal& interval) {
00307     face_manager().set_dup_hold_time(interval);
00308     return true;
00309     }
00310 
00314     inline TimeVal get_dup_hold_time() {
00315     return face_manager().get_dup_hold_time();
00316     }
00317 
00329     bool bind_address(const string& interface,
00330               const string& vif,
00331               const IPv4& local_addr,
00332               const uint32_t& local_port,
00333               const IPv4& all_nodes_addr,
00334               const uint32_t& all_nodes_port);
00335 
00346     bool unbind_address(const string& interface, const string& vif);
00347 
00360     bool enable_address(const string& interface, const string& vif,
00361                 const IPv4& address, const uint16_t& port,
00362             const IPv4& all_nodes_address);
00363 
00375     bool disable_address(const string& interface, const string& vif,
00376                  const IPv4& address, const uint16_t& port);
00377 
00387     bool set_interface_enabled(const string& interface, const string& vif,
00388                    const bool enabled);
00389 
00399     bool get_interface_enabled(const string& interface, const string& vif,
00400                    bool& enabled);
00401 
00410     bool get_interface_stats(const string& interface, const string& vif,
00411                  FaceCounters& stats);
00412 
00421     inline bool set_interface_cost(const string& interface,
00422     const string& vif, int cost)
00423     {
00424     OlsrTypes::FaceID faceid = face_manager().get_faceid(interface, vif);
00425     return face_manager().set_interface_cost(faceid, cost);
00426     }
00427 
00434     uint32_t get_mtu(const string& interface);
00435 
00446     bool get_broadcast_address(const string& interface, const string& vif,
00447                    const IPv4& address, IPv4& bcast_address);
00448 
00456     bool is_vif_broadcast_capable(const string& interface,
00457     const string& vif);
00458 
00466     bool is_vif_multicast_capable(const string& interface,
00467     const string& vif);
00468 
00478     bool add_route(IPv4Net net, IPv4 nexthop, uint32_t nexthop_id,
00479            uint32_t metric, const PolicyTags& policytags);
00480 
00490     bool replace_route(IPv4Net net, IPv4 nexthop, uint32_t nexthop_id,
00491                uint32_t metric, const PolicyTags& policytags);
00492 
00498     bool delete_route(IPv4Net net);
00499 
00506     void configure_filter(const uint32_t& filter, const string& conf);
00507 
00513     void reset_filter(const uint32_t& filter);
00514 
00518     void push_routes();
00519 
00529     bool originate_external_route(const IPv4Net& net,
00530                   const IPv4& nexthop,
00531                   const uint32_t& metric,
00532                   const PolicyTags& policytags);
00533 
00540     bool withdraw_external_route(const IPv4Net& net);
00541 
00545     PolicyFilters& get_policy_filters() { return _policy_filters; }
00546 
00550     Trace& trace() { return _trace; }
00551 
00555     //Profile& profile() { return _profile; }
00556 
00564     bool clear_database();
00565 
00566   private:
00567     EventLoop&      _eventloop;
00568     IO*         _io;
00569 
00570     FaceManager     _fm;
00571     Neighborhood    _nh;
00572     TopologyManager _tm;
00573     ExternalRoutes  _er;
00574     RouteManager    _rm;
00575 
00576     string      _reason;
00577     ProcessStatus   _process_status;
00578 
00579     PolicyFilters   _policy_filters;
00580 
00584     Trace       _trace;
00585 
00589     //Profile       _profile;
00590 
00591 };
00592 
00593 #endif // __OLSR_OLSR_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations