class IfTree

Container class for FEA Interface objects in a system. More...

 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

Public Types

Public Methods

Protected Methods

Protected Members


Detailed Description

Container class for FEA Interface objects in a system.

typedef map<const string, IfTreeInterface*> IfMap

IfMap

typedef map<uint32_t, IfTreeInterface*> IfIndexMap

IfIndexMap

typedef multimap<uint32_t, IfTreeVif*> VifIndexMap

VifIndexMap

 IfTree ()

IfTree

Default constructor.

 IfTree (const IfTree& other)

IfTree

Constructor from another IfTree.

Parameters:

otherthe other IfTree.
 ~IfTree ()

~IfTree

Destructor.

IfTree&  operator= (const IfTree& other)

operator=

Assignment operator.

Parameters:

otherthe other IfTree.
void  clear ()

clear

Remove all interface state from the interface tree.

void  add_recursive_interface (const IfTreeInterface& other_iface, bool mark_state)

add_recursive_interface

Add recursively a new interface.

Parameters:

other_ifacethe interface to add recursively.
mark_stateif true, then mark the state same as the state from the other interface, otherwise the state will be CREATED.
int  add_interface (const string& ifname)

add_interface

Create a new interface.

Parameters:

ifnamethe interface name.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  remove_interface (const string& ifname)

remove_interface

Label interface as ready for deletion. Deletion does not occur until finalize_state() is called.

Parameters:

ifnamethe name of the interface to be labelled.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  update_interface (const IfTreeInterface& other_iface)

update_interface

Recursively create a new interface or update its state if it already exists.

Parameters:

other_ifacethe interface with the state to copy from.

Returns: XORP_OK on success, otherwise XORP_ERROR.

IfTreeInterface*  find_interface (const string& ifname)

find_interface

Find an interface.

Parameters:

ifnamethe interface name to search for.

Returns: a pointer to the interface (IfTreeInterface) or NULL if not found.

const IfTreeInterface*  find_interface (const string& ifname)

find_interface

[const]

Find a const interface.

Parameters:

ifnamethe interface name to search for.

Returns: a const pointer to the interface (IfTreeInterface) or NULL if not found.

IfTreeInterface*  find_interface (uint32_t pif_index)

find_interface

Find an interface for a given physical index.

Parameters:

pif_indexthe physical interface index to search for.

Returns: a pointer to the interface (IfTreeInterface) or NULL if not found.

const IfTreeInterface*  find_interface (uint32_t pif_index)

find_interface

[const]

Find a const interface for a given physical index.

Parameters:

pif_indexthe physical interface index to search for.

Returns: a const pointer to the interface (IfTreeInterface) or NULL if not found.

IfTreeVif*  find_vif (const string& ifname, const string& vifname)

find_vif

Find a vif.

Parameters:

ifnamethe interface name to search for.
vifnamethe vif name to search for.

Returns: a pointer to the vif (IfTreeVif) or NULL if not found.

const IfTreeVif*  find_vif (const string& ifname, const string& vifname)

find_vif

[const]

Find a const vif.

Parameters:

ifnamethe interface name to search for.
vifnamethe vif name to search for.

Returns: a const pointer to the vif (IfTreeVif) or NULL if not found.

IfTreeVif*  find_vif (uint32_t pif_index)

find_vif

Find a vif for a given physical index.

Parameters:

pif_indexthe physical interface index to search for.

Returns: a pointer to the vif (IfTreeVif) or NULL if not found.

const IfTreeVif*  find_vif (uint32_t pif_index)

find_vif

[const]

Find a const vif for a given physical index.

Parameters:

pif_indexthe physical interface index to search for.

Returns: a const pointer to the vif (IfTreeVif) or NULL if not found.

IfTreeAddr4*  find_addr (const string& ifname, const string& vifname, const IPv4& addr)

find_addr

Find an IPv4 address.

Parameters:

ifnamethe interface name to search for.
vifnamethe vif name to search for.
addrthe address to search for.

Returns: a pointer to the vif (IfTreeAddr4) or NULL if not found.

const IfTreeAddr4*  find_addr (const string& ifname, const string& vifname, const IPv4& addr)

find_addr

[const]

Find a const IPv4 address.

Parameters:

ifnamethe interface name to search for.
vifnamethe vif name to search for.
addrthe address to search for.

Returns: a const pointer to the vif (IfTreeAddr4) or NULL if not found.

IfTreeAddr6*  find_addr (const string& ifname, const string& vifname, const IPv6& addr)

find_addr

Find an IPv6 address.

Parameters:

ifnamethe interface name to search for.
vifnamethe vif name to search for.
addrthe address to search for.

Returns: a pointer to the vif (IfTreeAddr6) or NULL if not found.

const IfTreeAddr6*  find_addr (const string& ifname, const string& vifname, const IPv6& addr)

find_addr

[const]

Find a const IPv6 address.

Parameters:

ifnamethe interface name to search for.
vifnamethe vif name to search for.
addrthe address to search for.

Returns: a pointer to the vif (IfTreeAddr6) or NULL if not found.

bool  find_interface_vif_by_addr (const IPvX& addr, const IfTreeInterface*& ifp, const IfTreeVif*& vifp)

find_interface_vif_by_addr

[const]

Find an interface and a vif by an address that belongs to that interface and vif.

Parameters:

addrthe address.
ifpreturn-by-reference a pointer to the interface.
vifpreturn-by-reference a pointer to the vif.

Returns: true if a match is found, otherwise false.

bool  find_interface_vif_same_subnet_or_p2p (const IPvX& addr, const IfTreeInterface*& ifp, const IfTreeVif*& vifp)

find_interface_vif_same_subnet_or_p2p

[const]

Find an interface and a vif by an address that shares the same subnet or p2p address.

Parameters:

addrthe address.
ifpreturn-by-reference a pointer to the interface.
vifpreturn-by-reference a pointer to the vif.

Returns: true if a match is found, otherwise false.

IfMap&  interfaces ()

interfaces

Get the map with the stored interfaces.

Returns: the map with the stored interfaces.

const IfMap&  interfaces ()

interfaces

[const]

Get the const map with the stored interfaces.

Returns: the const map with the stored interfaces.

IfTree&  align_with_pulled_changes (const IfTree& other, const IfTree& user_config)

align_with_pulled_changes

Align system-user merged configuration with the pulled changes in the system configuration.

Inside the FEA there may be multiple configuration representations, typically one the user modifies, one that mirrors the hardware, and one that merges those two (e.g., some of the merged information comes from the user configuration while other might come from the underlying system). Errors may occur pushing the user config down onto the hardware and we need a method to update the merged config from the h/w config that exists after the config push. We can't just copy the h/w config since the user config is restricted to configuration set by the user.

The alignment works as follows: 1. If an interface in the local tree is marked as "soft", its state is not modified and the rest of the processing is ignored. 2. If an interface in the local tree is marked as "default_system_config", the rest of the processing is not applied, and the following rules are used instead: (a) If the interface is not in the other tree, it is marked as "disabled" and its vifs are marked for deletion. (b) Otherwise, its state (and the subtree below it) is copied as-is from the other tree. 3. If an item in the local tree is not in the other tree, it is marked as "disabled" in the local tree. 4. If an item in the local tree is in the other tree, and its state is different in the local and the other tree, the state is copied from the other tree to the local tree. Also, if the item is disabled in the user config tree, it is marked as "disabled" in the local tree.

Parameters:

otherthe configuration tree to align state with.
user_configthe user configuration tree to reference during the alignment.

Returns: modified configuration structure.

IfTree&  align_with_observed_changes (const IfTree& other, const IfTree& user_config)

align_with_observed_changes

Align system-user merged configuration with the observed changes in the system configuration.

Inside the FEA there may be multiple configuration representations, typically one the user modifies, one that mirrors the hardware, and one that merges those two (e.g., some of the merged information comes from the user configuration while other might come from the underlying system). On certain systems there could be asynchronous updates originated by the system that are captured by the FEA interface observer (e.g., a cable is unplugged, a tunnel interface is added/deleted, etc).

This method is used to align those updates with the merged configuration.

1. If an interface in the other tree is not in the local tree, it is tested whether is in the user configuration tree. If not, the rest of the processing is not applied and the interface is ignored. Otherwise it is created, its state is merged from the user config and other tree, and is marked as "CREATED". 2. If an interface in the local tree is marked as "soft", its state is not modified and the rest of the processing is ignored. 3. If an interface in the local tree is marked as "default_system_config", the rest of the processing is not applied, and its state (and the subtree below it) is copied as-is from the other tree. 4. If an item in the other tree is not in the local tree, it is tested whether is in the user configuration tree. If not, the rest of the processing is not applied and the item is ignored. Otherwise it is created, its state is merged from the user config and the other tree, and is marked as "CREATED". 5. If an item in the other tree is marked as: (a) "NO_CHANGE": The state of the entry in the other tree is not propagated to the local tree, but its subtree entries are processed. (b) "DELETED": The item in the local tree is disabled, and the subtree entries are ignored. (c) "CREATED" or "CHANGED": If the state of the entry is different in the other and the local tree, it is copied to the local tree, and the item in the local tree is marked as "CREATED" or "CHANGED". unless it was marked earlier as "CREATED". Also, if the item is disabled in the user config tree, it is marked as "disabled" in the local tree.

Parameters:

otherthe configuration tree to align state with.
user_configthe user configuration tree to reference during the alignment.

Returns: modified configuration structure.

IfTree&  align_with_user_config (const IfTree& other)

align_with_user_config

Align system-user merged configuration with the user configuration changes.

Inside the FEA there may be multiple configuration representations, typically one the user modifies, one that mirrors the hardware, and one that merges those two (e.g., some of the merged information comes from the user configuration while other might come from the underlying system).

This method is used to align the user configuration changes with the merged configuration.

The alignment works as follows: 1. If an item in the other tree is not in the local tree, it is created in the local tree and its state (and the subtree below it) is copied as-is from the other tree, and the rest of the processing is ignored. 2. If an item in the other tree is marked as: (a) "DELETED": The item in the local tree is marked as "DELETED", and the subtree entries are ignored. (b) All other: If the state of the item is different in the other and the local tree, it is copied to the local tree. Note that we compare the state even for "NO_CHANGE" items in case a previous change to a parent item in the merged tree has affected the entry (e.g., disabled interface would disable the vifs and addresses as well).

Parameters:

otherthe configuration tree to align state with.

Returns: modified configuration structure.

IfTree&  prepare_replacement_state (const IfTree& other)

prepare_replacement_state

Prepare configuration for pushing and replacing previous configuration.

If the previous configuration is to be replaced with new configuration, we need to prepare the state that will delete, update, and add the new state as appropriate. The preparation works as follows: - All items in the local tree are preserved and marked as created. - All items in the other tree that are not in the local tree are added to the local tree and are marked as deleted.

Parameters:

otherthe configuration tree to be used to prepare the replacement state.

Returns: modified configuration structure.

IfTree&  prune_bogus_deleted_state (const IfTree& old_iftree)

prune_bogus_deleted_state

Prune bogus deleted state.

If an item in the local tree is marked as deleted, but is not in the other tree, then it is removed.

Parameters:

old_iftreethe old tree with the state that is used as reference.

Returns: the modified configuration tree.

void  finalize_state ()

finalize_state

Delete interfaces labelled as ready for deletion, call finalize_state() on remaining interfaces, and set state to NO_CHANGE.

Reimplemented from IfTreeItem.

string  str ()

str

[const]

Returns: string representation of IfTree.

Reimplemented from IfTreeItem.

friend class IfTreeInterface

IfTreeInterface

[protected]

friend class IfTreeVif

IfTreeVif

[protected]

void  insert_ifindex (IfTreeInterface* ifp)

insert_ifindex

[protected]

void  erase_ifindex (IfTreeInterface* ifp)

erase_ifindex

[protected]

void  insert_vifindex (IfTreeVif* vifp)

insert_vifindex

[protected]

void  erase_vifindex (IfTreeVif* vifp)

erase_vifindex

[protected]


Generated by: pavlin on kobe.xorp.net on Wed Jan 7 19:10:56 2009, using kdoc 2.0a54+XORP.