xorp

port_vars.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2009 XORP, Inc.
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/port_vars.hh,v 1.16 2008/10/02 21:58:17 bms Exp $
00021 
00022 #ifndef __RIP_PORT_VARS_HH__
00023 #define __RIP_PORT_VARS_HH__
00024 
00025 #include "constants.hh"
00026 
00030 struct PortCounters {
00031 public:
00032     PortCounters() : _packets_recv(0), _requests_recv(0), _updates_recv(0),
00033              _bad_routes(0), _bad_packets(0),
00034              _bad_auth_packets(0), _tr_sent(0), _tr_recv(),
00035              _triggered_updates(0), _unsol_updates(0), _nr_req_recv(0),
00036              _nr_updates(0)
00037     {}
00038 
00042     uint32_t packets_recv() const   { return _packets_recv; }
00043 
00047     void incr_packets_recv()        { _packets_recv++; }
00048 
00052     uint32_t update_packets_recv() const { return _updates_recv; }
00053 
00057     void incr_update_packets_recv() { _updates_recv++; }
00058 
00063     uint32_t bad_routes() const     { return _bad_routes; }
00064 
00068     void incr_bad_routes()      { _bad_routes++; }
00069 
00073     uint32_t bad_packets() const    { return _bad_packets; }
00074 
00078     void incr_bad_packets()     { _bad_packets++; }
00079 
00083     uint32_t bad_auth_packets() const   { return _bad_auth_packets; }
00084 
00088     void incr_bad_auth_packets()    { _bad_auth_packets++; }
00089 
00093     uint32_t triggered_updates() const  { return _triggered_updates; }
00094 
00098     void incr_triggered_updates()   { _triggered_updates++; }
00099 
00103     uint32_t unsolicited_updates() const    { return _unsol_updates; }
00104 
00108     void incr_unsolicited_updates()     { _unsol_updates++; }
00109 
00113     uint32_t table_requests_sent() const    { return _tr_sent; }
00114 
00118     void incr_table_requests_sent()     { _tr_sent++; }
00119 
00123     uint32_t table_requests_recv() const    { return _tr_recv; }
00124 
00128     void incr_table_requests_recv()     { _tr_recv++; }
00129 
00133     uint32_t non_rip_requests_recv() const  { return _nr_req_recv; }
00134 
00138     void incr_non_rip_requests_recv()       { _nr_req_recv++; }
00139 
00143     uint32_t non_rip_updates_sent() const   { return _nr_updates; }
00144 
00148     void incr_non_rip_updates_sent()        { _nr_updates++; }
00149 
00150 protected:
00151     uint32_t _packets_recv;
00152     uint32_t _requests_recv;
00153     uint32_t _updates_recv;
00154     uint32_t _bad_routes;
00155     uint32_t _bad_packets;
00156     uint32_t _bad_auth_packets;
00157     uint32_t _tr_sent;
00158     uint32_t _tr_recv;
00159     uint32_t _triggered_updates;
00160     uint32_t _unsol_updates;
00161     uint32_t _nr_req_recv;
00162     uint32_t _nr_updates;
00163 };
00164 
00165 
00169 class PortTimerConstants {
00170 public:
00175     PortTimerConstants();
00176 
00182     bool set_expiry_secs(uint32_t t);
00183 
00188     uint32_t expiry_secs() const;
00189 
00195     bool set_deletion_secs(uint32_t t);
00196 
00201     uint32_t deletion_secs() const;
00202 
00209     bool set_table_request_period_secs(uint32_t t);
00210 
00215     uint32_t table_request_period_secs() const;
00216 
00222     bool set_update_interval(uint32_t t_secs);
00223 
00228     uint32_t update_interval();
00229 
00236     bool set_update_jitter(uint32_t t_jitter);
00237 
00243     uint32_t update_jitter();
00244 
00250     bool set_triggered_update_delay(uint32_t t_secs);
00251 
00256     uint32_t triggered_update_delay() const;
00257 
00264     bool set_triggered_update_jitter(uint32_t t_jitter);
00265 
00270     uint32_t triggered_update_jitter() const;
00271 
00279     bool set_interpacket_delay_ms(uint32_t t);
00280 
00284     uint32_t interpacket_delay_ms() const;
00285 
00293     bool set_interquery_delay_ms(uint32_t t);
00294 
00301     uint32_t interquery_delay_ms() const;
00302 
00303 protected:
00304     uint32_t _expiry_secs;
00305     uint32_t _deletion_secs;
00306     uint32_t _table_request_secs;
00307     uint32_t _update_interval;
00308     uint32_t _update_jitter;
00309     uint32_t _triggered_update_delay;
00310     uint32_t _triggered_update_jitter;
00311     uint32_t _interpacket_msecs;
00312     uint32_t _interquery_msecs;
00313 };
00314 
00315 
00316 // ----------------------------------------------------------------------------
00317 // Inline PortTimerConstants accessor and modifiers.
00318 
00319 inline
00320 PortTimerConstants::PortTimerConstants()
00321     : _expiry_secs(DEFAULT_EXPIRY_SECS),
00322       _deletion_secs(DEFAULT_DELETION_SECS),
00323       _table_request_secs(DEFAULT_TABLE_REQUEST_SECS),
00324       _update_interval(DEFAULT_UPDATE_INTERVAL),
00325       _update_jitter(DEFAULT_UPDATE_JITTER),
00326       _triggered_update_delay(DEFAULT_TRIGGERED_UPDATE_DELAY),
00327       _triggered_update_jitter(DEFAULT_TRIGGERED_UPDATE_JITTER),
00328       _interpacket_msecs(DEFAULT_INTERPACKET_DELAY_MS),
00329       _interquery_msecs(DEFAULT_INTERQUERY_GAP_MS)
00330 {
00331 }
00332 
00333 inline bool
00334 PortTimerConstants::set_expiry_secs(uint32_t t)
00335 {
00336     if (t == 0)
00337     return false;
00338     _expiry_secs = t;
00339     return true;
00340 }
00341 
00342 inline uint32_t
00343 PortTimerConstants::expiry_secs() const
00344 {
00345     return _expiry_secs;
00346 }
00347 
00348 inline bool
00349 PortTimerConstants::set_deletion_secs(uint32_t t)
00350 {
00351     if (t == 0)
00352     return false;
00353     _deletion_secs = t;
00354     return true;
00355 }
00356 
00357 inline uint32_t
00358 PortTimerConstants::deletion_secs() const
00359 {
00360     return _deletion_secs;
00361 }
00362 
00363 inline bool
00364 PortTimerConstants::set_update_interval(uint32_t t_secs)
00365 {
00366     _update_interval = t_secs;
00367     return true;
00368 }
00369 
00370 inline uint32_t
00371 PortTimerConstants::update_interval()
00372 {
00373     return _update_interval;
00374 }
00375 
00376 inline bool
00377 PortTimerConstants::set_update_jitter(uint32_t t_jitter)
00378 {
00379     if (t_jitter > 100)
00380     return false;
00381     _update_jitter = t_jitter;
00382     return true;
00383 }
00384 
00385 inline uint32_t
00386 PortTimerConstants::update_jitter()
00387 {
00388     return _update_jitter;
00389 }
00390 
00391 inline bool
00392 PortTimerConstants::set_table_request_period_secs(uint32_t t)
00393 {
00394     //
00395     // XXX: value of 0 is accepted because it is used to disable the
00396     // periodic request messages.
00397     //
00398     _table_request_secs = t;
00399     return true;
00400 }
00401 
00402 inline uint32_t
00403 PortTimerConstants::table_request_period_secs() const
00404 {
00405     return _table_request_secs;
00406 }
00407 
00408 inline bool
00409 PortTimerConstants::set_triggered_update_delay(uint32_t t_secs)
00410 {
00411     _triggered_update_delay = t_secs;
00412     return true;
00413 }
00414 
00415 inline uint32_t
00416 PortTimerConstants::triggered_update_delay() const
00417 {
00418     return _triggered_update_delay;
00419 }
00420 
00421 inline bool
00422 PortTimerConstants::set_triggered_update_jitter(uint32_t t_jitter)
00423 {
00424     if (t_jitter > 100)
00425     return false;
00426     _triggered_update_jitter = t_jitter;
00427     return true;
00428 }
00429 
00430 inline uint32_t
00431 PortTimerConstants::triggered_update_jitter() const
00432 {
00433     return _triggered_update_jitter;
00434 }
00435 
00436 inline bool
00437 PortTimerConstants::set_interpacket_delay_ms(uint32_t t)
00438 {
00439     if (t > MAXIMUM_INTERPACKET_DELAY_MS)
00440     return false;
00441     _interpacket_msecs = t;
00442     return true;
00443 }
00444 
00445 inline uint32_t
00446 PortTimerConstants::interpacket_delay_ms() const
00447 {
00448     return _interpacket_msecs;
00449 }
00450 
00451 inline bool
00452 PortTimerConstants::set_interquery_delay_ms(uint32_t t)
00453 {
00454     _interquery_msecs = t;
00455     return true;
00456 }
00457 
00458 inline uint32_t
00459 PortTimerConstants::interquery_delay_ms() const
00460 {
00461     return _interquery_msecs;
00462 }
00463 
00464 #endif // __RIP_PORT_VARS_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations