Source: ../../rib/vifmanager.hh
|
|
|
|
// -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
// Copyright (c) 2001,2002 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/rib/vifmanager.hh,v 1.1.1.1 2002/12/11 23:56:14 hodson Exp $
#ifndef __RIB_VIFMANAGER_HH__
#define __RIB_VIFMANAGER_HH__
#include <map>
#include "libxorp/vif.hh"
#include "xrl/interfaces/fea_ifmgr_xif.hh"
#define IF_EVENT_CREATED 1
#define IF_EVENT_DELETED 2
#define IF_EVENT_CHANGED 3
class RibManager;
/**
* @short VifManager keeps track of the VIFs currently enabled in the FEA
*
* The RIB process has a single VifManager instance, which registers
* with the FEA process to discover the VIFs on this router and their
* IP addresses and prefixes. When the VIFs or their configuration in
* the FEA change, the VifManager will be notified, and it will update
* the RIBs appropriately. The RIBs need to know about VIFs and VIF
* addresses to decide which routes have nexthops that are on directly
* connected subnets, and which are nexthops that need to be resolved
* using other routes to figure out where next to send the packet.
* Only routes with nexthops that are on directly connected subnets
* can be sent to the FEA
*/
class VifManager {
public:
/**
* The state of the VifManager. It it hasn't yet successfully
* registered with the FEA, it will be in INITIALIZING state. If
* it has permanently failed to register with the FEA it will be
* in FAILED state. Otherwise it should be in READY state.
*/
enum State { INITIALIZING, READY, FAILED };
/**
* VifManager constructor
*
* @param xrl_rtr this process's XRL router.
* @param eventloop this process's EventLoop.
* @param rib_manager this class contains the actual RIBs for IPv4
* and IPv4, unicast and multicast.
*/
VifManager(XrlRouter& xrl_rtr, EventLoop& eventloop,
RibManager *rib_manager);
/**
* VifManager destructor
*/
~VifManager();
/**
* Start the process of registering with the FEA, etc
*/
void start();
/**
* @returns the state of the VifManager.
* @see VifManager::State
*/
State state() const { return _state; }
/**
* interface_update is called when receiving an XRL from the FEA
* indicating that a physical interface on the router has been added,
* deleted, or reconfigured
*
* @param ifname the name of the physical interface that changed.
* @param event the event that occured. One of IF_EVENT_CREATED,
* IF_EVENT_DELETED, or IF_EVENT_CHANGED
*/
void interface_update(const string& ifname,
const uint32_t& event);
/**
* vif_update is called when receiving an XRL from the FEA
* indicating that a virtual interface on the router has been added,
* deleted, or reconfigured
*
* @param ifname the name of the physical interface on which the
* virtual interface resides.
* @param vifname the name of the virtual interface that changed.
* @param event the event that occured. One of IF_EVENT_CREATED,
* IF_EVENT_DELETED, or IF_EVENT_CHANGED
*/
void vif_update(const string& ifname,
const string& vifname, const uint32_t& event);
/**
* vifaddr4_update is called when receiving an XRL from the FEA
* indicating that a virtual interface has undergone an address
* change. An IPv4 address (and associated prefix length) has
* been added, deleted, or reconfigured on this VIF.
*
* @param ifname the name of the interface containing the VIF
* @param vifname the name of the VIF on which the address change occured.
* @param addr the address that was added or deleted.
* @param event the event that occured. One of IF_EVENT_CREATED or
* IF_EVENT_DELETED
*/
void vifaddr4_update(const string& ifname,
const string& vifname,
const IPv4& addr,
const uint32_t& event);
/**
* vifaddr6_update is called when receiving an XRL from the FEA
* indicating that a virtual interface has undergone an address
* change. An IPv6 address (and associated prefix length) has
* been added, deleted, or reconfigured on this VIF.
*
* @param ifname the name of the interface containing the VIF
* @param vifname the name of the VIF on which the address change occured.
* @param addr the address that was added or deleted.
* @param event the event that occured. One of IF_EVENT_CREATED or
* IF_EVENT_DELETED
*/
void vifaddr6_update(const string& ifname,
const string& vifname,
const IPv6& addr,
const uint32_t& event);
private:
void clean_out_old_state();
void clean_out_old_state_done(const XrlError& e);
void register_if_spy();
void register_if_spy_done(const XrlError& e);
void interface_names_done(const XrlError& e, const XrlAtomList* alist);
void vif_names_done(const XrlError& e, const XrlAtomList* alist,
string ifname);
void get_all_vifaddr4_done(const XrlError& e, const XrlAtomList* alist,
string ifname, string vifname);
void interface_deleted(const string& ifname);
void vif_deleted(const string& ifname, const string& vifname);
void vif_created(const string& ifname, const string& vifname);
void vifaddr4_created(const string& ifname, const string& vifname,
const IPv4& addr);
void vifaddr4_done(const XrlError& e, const uint32_t* prefix_len,
string ifname, string vifname,
IPv4 addr);
void vifaddr6_created(const string& ifname, const string& vifname,
const IPv6& addr);
void vifaddr6_done(const XrlError& e, const uint32_t* prefix_len,
string ifname, string vifname,
IPv6 addr);
void vifaddr4_deleted(const string& ifname, const string& vifname,
const IPv4& addr);
void vifaddr6_deleted(const string& ifname, const string& vifname,
const IPv6& addr);
XrlRouter &_xrl_rtr;
EventLoop &_eventloop;
RibManager *_rib_manager;
XrlIfmgrV0p1Client _ifmgr_client;
XorpTimer _register_retry_timer;
State _state;
int _register_retry_counter;
/* the following variables keep track of how many answers we're
still expecting from various pipelined queries to the FEA */
int _interfaces_remaining;
int _vifs_remaining;
int _addrs_remaining;
map <string, Vif*> _vifs_by_name;
multimap <string, Vif*> _vifs_by_interface;
};
#endif // __RIB_VIFMANAGER_HH__
Generated by: pavlin on possum.icir.org on Wed Dec 11 16:51:00 2002, using kdoc 2.0a54+XORP. |