xorp

constants.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/constants.hh,v 1.23 2008/10/02 21:58:16 bms Exp $
00021 
00022 #ifndef __RIP_CONSTANTS_HH__
00023 #define __RIP_CONSTANTS_HH__
00024 
00025 #include "libxorp/ipv4.hh"
00026 #include "libxorp/ipv4net.hh"
00027 #include "libxorp/ipv6.hh"
00028 #include "libxorp/ipv6net.hh"
00029 
00030 static const uint32_t DEFAULT_UPDATE_INTERVAL = 30;
00031 static const uint32_t DEFAULT_UPDATE_JITTER = 16;
00032 
00033 static const uint32_t DEFAULT_EXPIRY_SECS = 180;
00034 static const uint32_t DEFAULT_DELETION_SECS = 120;
00035 
00036 static const uint32_t DEFAULT_TRIGGERED_UPDATE_DELAY = 3;
00037 static const uint32_t DEFAULT_TRIGGERED_UPDATE_JITTER = 66;
00038 
00039 static const uint32_t DEFAULT_TABLE_REQUEST_SECS = 1;
00040 
00041 static const uint32_t RIPv2_ROUTES_PER_PACKET = 25;
00042 
00048 static const uint32_t DEFAULT_INTERPACKET_DELAY_MS = 50;
00049 
00054 static const uint32_t MAXIMUM_INTERPACKET_DELAY_MS = 250;
00055 
00060 static const uint32_t DEFAULT_INTERQUERY_GAP_MS = 250;
00061 
00066 static const uint32_t RIP_INFINITY = 16;
00067 
00072 static const uint32_t RIP_MAX_COST = 0xffff;
00073 
00077 static const uint32_t RIP_TTL = 1;
00078 
00082 static const uint32_t RIP_NG_HOP_COUNT = 255;
00083 
00087 static const uint16_t RIP_PORT = 520;
00088 
00092 static const uint16_t RIP_NG_PORT = 521;
00093 
00094 static const IPv4Net IPv4_DEFAULT_ROUTE = IPv4Net(IPv4::ZERO(), 0);
00095 static const IPv6Net IPv6_DEFAULT_ROUTE = IPv6Net(IPv6::ZERO(), 0);
00096 
00100 template <typename A>
00101 struct RIP_AF_CONSTANTS;
00102 
00103 template <>
00104 struct RIP_AF_CONSTANTS<IPv4>
00105 {
00106     static const IPv4       IP_GROUP() { return IPv4::RIP2_ROUTERS(); }
00107     static const uint16_t   IP_PORT = RIP_PORT;
00108     static const IPv4Net&   DEFAULT_ROUTE() { return IPv4_DEFAULT_ROUTE; }
00109     static const uint8_t    PACKET_VERSION = 2;
00110 };
00111 
00112 template <>
00113 struct RIP_AF_CONSTANTS<IPv6>
00114 {
00115     static const IPv6&      IP_GROUP() { return IPv6::RIP2_ROUTERS(); }
00116     static const uint16_t   IP_PORT = RIP_NG_PORT;
00117     static const IPv6Net&   DEFAULT_ROUTE() { return IPv6_DEFAULT_ROUTE; }
00118     static const uint8_t     PACKET_VERSION = 1;
00119 };
00120 
00124 enum RipHorizon {
00125     // No filtering
00126     NONE         = 0,
00127     // Don't a route origin its own routes.
00128     SPLIT        = 1,
00129     // Show a route origin its own routes but with cost of infinity.
00130     SPLIT_POISON_REVERSE = 2
00131 };
00132 
00133 inline static const char*
00134 rip_horizon_name(RipHorizon h)
00135 {
00136     switch (h) {
00137     case SPLIT_POISON_REVERSE:
00138     return "split-horizon-poison-reverse";
00139     case SPLIT:
00140     return "split-horizon";
00141     case NONE:
00142     break;
00143     }
00144     return "none";
00145 };
00146 
00147 #endif // __RIP_CONSTANTS_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations