Source: ../../bgp/internal_message.hh
|
|
|
|
// -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
// Copyright (c) 2001-2003 International Computer Science Institute
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software")
// to deal in the Software without restriction, subject to the conditions
// listed in the XORP LICENSE file. These conditions include: you must
// preserve this copyright notice, and you cannot mention the copyright
// holders in advertising related to the Software without their permission.
// The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
// notice is a summary of the XORP LICENSE file; the license in that file is
// legally binding.
// $XORP: xorp/bgp/internal_message.hh,v 1.4 2003/03/10 23:19:58 hodson Exp $
#ifndef __BGP_INTERNAL_MESSAGES_HH__
#define __BGP_INTERNAL_MESSAGES_HH__
#include "libxorp/xorp.h"
#include "subnet_route.hh"
class PeerHandler;
#define GENID_UNKNOWN 0
template<class A>
class InternalMessage
{
public:
InternalMessage(const SubnetRoute<A> *route,
const PeerHandler *origin_peer,
uint32_t genid);
~InternalMessage();
const IPNet<A>& net() const;
const SubnetRoute<A> *route() const { return _subnet_route; }
const PeerHandler* origin_peer() const { return _origin_peer; }
const A& nexthop() const { return _subnet_route->nexthop(); }
bool changed() const { return _changed; }
void set_changed() { _changed = true; }
void clear_changed() const { _changed = false; }
bool push() const { return _push; }
void set_push() { _push = true; }
void clear_push() { _push = false; }
bool from_previous_peering() const { return _from_previous_peering; }
void set_from_previous_peering() { _from_previous_peering = true; }
uint32_t genid() const { return _genid; }
inline bool has_igp_metric() const {return _has_igp_metric;}
inline uint32_t igp_metric() const {return _igp_metric;}
inline void set_igp_metric(uint32_t metric) const
{
_igp_metric = metric;
_has_igp_metric = true;
}
inline void clone_igp_metric(const InternalMessage<A>& them)
{
if (them.has_igp_metric()) {
set_igp_metric(them.igp_metric());
}
}
// This is a hack to override const in DecisionTable.
void force_clear_push() const { _push = false; }
void inactivate() const {
_subnet_route->unref();
_subnet_route = NULL;
}
string str() const;
protected:
private:
/**
* the actual route data.
*/
mutable const SubnetRoute<A> *_subnet_route;
/**
* we need origin_peer to make sure we don't send a route back to
* the peer it came from, or send an IBGP route to an IBGP peer.
*/
const PeerHandler *_origin_peer;
/**
* changed indicates that the route data has been modified since
* the route was last stored (and so needs storing by a
* CacheTable).
*/
mutable bool _changed;
/**
* genid is the generation ID from the RibIn, if known, or zero if
* it's not known.
*/
uint32_t _genid;
/**
* push indicates that this is the last route in a batch, so the
* push to peers is implicit.
*/
mutable bool _push;
/**
* from_previous_peering is set on messages where the deleted route
* originates from a previous peering that has now gone down.
*/
bool _from_previous_peering;
/**
* igp_metric is added by the DecisionTable so that downsteam
* tables can know what metric DecisionTable used.
*/
mutable uint32_t _igp_metric;
mutable bool _has_igp_metric;
};
#endif // __BGP_INTERNAL_MESSAGES_HH__
Generated by: pavlin on possum.icir.org on Mon Mar 10 19:34:59 2003, using kdoc 2.0a54+XORP. |