\hypertarget{classMergedTable}{
\section{MergedTable$<$ A $>$ Class Template Reference}
\label{classMergedTable}\index{MergedTable@{MergedTable}}
}


Make two route RouteTables behave like one.  




{\ttfamily \#include $<$rt\_\-tab\_\-merged.hh$>$}

Inheritance diagram for MergedTable$<$ A $>$:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classMergedTable}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classMergedTable_a3b7f9b4acb2bf779fea608daf1f95289}{MergedTable} (\hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$table\_\-a, \hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$table\_\-b)
\begin{DoxyCompactList}\small\item\em \hyperlink{classMergedTable}{MergedTable} Constructor. \item\end{DoxyCompactList}\item 
int \hyperlink{classMergedTable_ac1545304355a5ddccb1ac69eeeafbf48}{add\_\-route} (const \hyperlink{classIPRouteEntry}{IPRouteEntry}$<$ A $>$ \&route, \hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$caller)
\begin{DoxyCompactList}\small\item\em An add\_\-route request from a parent table causes a lookup on \hyperlink{protocolthe-p}{the} other parent table. \item\end{DoxyCompactList}\item 
int \hyperlink{classMergedTable_ac768d0cc7197ace71b06f199aa6919fc}{delete\_\-route} (const \hyperlink{classIPRouteEntry}{IPRouteEntry}$<$ A $>$ $\ast$route, \hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$caller)
\begin{DoxyCompactList}\small\item\em An delete\_\-route request from a parent table also causes a lookup on \hyperlink{protocolthe-p}{the} other parent table. \item\end{DoxyCompactList}\item 
const \hyperlink{classIPRouteEntry}{IPRouteEntry}$<$ A $>$ $\ast$ \hyperlink{classMergedTable_a28395ad6c23deb50d8b67844eacba576}{lookup\_\-route} (const \hyperlink{classIPNet}{IPNet}$<$ A $>$ \&net) const 
\begin{DoxyCompactList}\small\item\em Lookup a specific subnet. \item\end{DoxyCompactList}\item 
const \hyperlink{classIPRouteEntry}{IPRouteEntry}$<$ A $>$ $\ast$ \hyperlink{classMergedTable_a2ca22b3e8d08e3a03d8777c740524865}{lookup\_\-route} (const A \&addr) const 
\begin{DoxyCompactList}\small\item\em Lookup an IP address to get \hyperlink{protocolthe-p}{the} most specific (longest prefix length) route that matches this address. \item\end{DoxyCompactList}\item 
\hyperlink{classRouteRange}{RouteRange}$<$ A $>$ $\ast$ \hyperlink{classMergedTable_a5d132afba864f186bc807ed5ac277164}{lookup\_\-route\_\-range} (const A \&addr) const 
\begin{DoxyCompactList}\small\item\em Lookup an IP address to get \hyperlink{protocolthe-p}{the} most specific (longest prefix length) route that matches this address, along with \hyperlink{protocolthe-p}{the} \hyperlink{classRouteRange}{RouteRange} information for this address and route. \item\end{DoxyCompactList}\item 
TableType \hyperlink{classMergedTable_af05d7ac91f1614b4996833c20f402dd7}{type} () const 
\item 
void \hyperlink{classMergedTable_a1da65fd91f0d438cfc34f4d25f808450}{replumb} (\hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$old\_\-parent, \hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$new\_\-parent)
\begin{DoxyCompactList}\small\item\em replumb \hyperlink{protocolthe-p}{the} parent tables, so that new\_\-parent replaces old\_\-parent. \item\end{DoxyCompactList}\item 
\hypertarget{classMergedTable_a87f16b84678c59c3365229e0684de452}{
string \hyperlink{classMergedTable_a87f16b84678c59c3365229e0684de452}{str} () const }
\label{classMergedTable_a87f16b84678c59c3365229e0684de452}

\begin{DoxyCompactList}\small\item\em Render this \hyperlink{classMergedTable}{MergedTable} as a string for debugging purposes. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classMergedTable_a4f504677f6b3569e1f8ccb605bd9f2cd}{
\hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$ {\bfseries \_\-table\_\-a}}
\label{classMergedTable_a4f504677f6b3569e1f8ccb605bd9f2cd}

\item 
\hypertarget{classMergedTable_ace2f4773bb08d20e440bc20b171935fb}{
\hyperlink{classRouteTable}{RouteTable}$<$ A $>$ $\ast$ {\bfseries \_\-table\_\-b}}
\label{classMergedTable_ace2f4773bb08d20e440bc20b171935fb}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$class A$>$ class MergedTable$<$ A $>$}

Make two route RouteTables behave like one. \hyperlink{classMergedTable}{MergedTable} takes two routing tables and combines them together to form a single table, where routes for \hyperlink{protocolthe-p}{the} same subnet with a lower admin distance override those with a higher admin distance.

The two parent tables are not actually merged.

An add\_\-route request from a parent tables causes a lookup on \hyperlink{protocolthe-p}{the} other parent table. If \hyperlink{protocolthe-p}{the} route is better than \hyperlink{protocolthe-p}{the} one from \hyperlink{protocolthe-p}{the} other table, or no route exists in \hyperlink{protocolthe-p}{the} other table, then \hyperlink{protocolthe-p}{the} new route is passed downstream.

An delete\_\-route request from a parent table also causes a lookup on \hyperlink{protocolthe-p}{the} other parent table. The delete\_\-route is propagated downstream. If an alternative route is found, then that is then propagated downsteam as an add\_\-route to replace \hyperlink{protocolthe-p}{the} deleted route.

Lookups from downsteam cause lookups on both parent tables. The better response is given. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classMergedTable_a3b7f9b4acb2bf779fea608daf1f95289}{
\index{MergedTable@{MergedTable}!MergedTable@{MergedTable}}
\index{MergedTable@{MergedTable}!MergedTable@{MergedTable}}
\subsubsection[{MergedTable}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ {\bf MergedTable}$<$ A $>$::{\bf MergedTable} (
\begin{DoxyParamCaption}
\item[{{\bf RouteTable}$<$ A $>$ $\ast$}]{table\_\-a, }
\item[{{\bf RouteTable}$<$ A $>$ $\ast$}]{table\_\-b}
\end{DoxyParamCaption}
)}}
\label{classMergedTable_a3b7f9b4acb2bf779fea608daf1f95289}


\hyperlink{classMergedTable}{MergedTable} Constructor. 


\begin{DoxyParams}{Parameters}
{\em table\_\-a} & one of two parent RouteTables. \\
\hline
{\em table\_\-b} & one of two parent RouteTables. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\hypertarget{classMergedTable_ac1545304355a5ddccb1ac69eeeafbf48}{
\index{MergedTable@{MergedTable}!add\_\-route@{add\_\-route}}
\index{add\_\-route@{add\_\-route}!MergedTable@{MergedTable}}
\subsubsection[{add\_\-route}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ int {\bf MergedTable}$<$ A $>$::add\_\-route (
\begin{DoxyParamCaption}
\item[{const {\bf IPRouteEntry}$<$ A $>$ \&}]{route, }
\item[{{\bf RouteTable}$<$ A $>$ $\ast$}]{caller}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classMergedTable_ac1545304355a5ddccb1ac69eeeafbf48}


An add\_\-route request from a parent table causes a lookup on \hyperlink{protocolthe-p}{the} other parent table. 

If \hyperlink{protocolthe-p}{the} route is better than \hyperlink{protocolthe-p}{the} one from \hyperlink{protocolthe-p}{the} other table, or no route exists in \hyperlink{protocolthe-p}{the} other table then it is passed downstream.


\begin{DoxyParams}{Parameters}
{\em route} & \hyperlink{protocolthe-p}{the} new route. \\
\hline
{\em caller} & \hyperlink{protocolthe-p}{the} parent table sending \hyperlink{protocolthe-p}{the} new route. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
XORP\_\-OK on success, otherwise XORP\_\-ERROR. 
\end{DoxyReturn}


Implements \hyperlink{classRouteTable}{RouteTable$<$ A $>$}.

\hypertarget{classMergedTable_ac768d0cc7197ace71b06f199aa6919fc}{
\index{MergedTable@{MergedTable}!delete\_\-route@{delete\_\-route}}
\index{delete\_\-route@{delete\_\-route}!MergedTable@{MergedTable}}
\subsubsection[{delete\_\-route}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ int {\bf MergedTable}$<$ A $>$::delete\_\-route (
\begin{DoxyParamCaption}
\item[{const {\bf IPRouteEntry}$<$ A $>$ $\ast$}]{route, }
\item[{{\bf RouteTable}$<$ A $>$ $\ast$}]{caller}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classMergedTable_ac768d0cc7197ace71b06f199aa6919fc}


An delete\_\-route request from a parent table also causes a lookup on \hyperlink{protocolthe-p}{the} other parent table. 

The delete\_\-route is propagated downstream. If an alternative route is found, then that is then propagated downsteam as an add\_\-route to replace \hyperlink{protocolthe-p}{the} deleted route.


\begin{DoxyParams}{Parameters}
{\em route} & \hyperlink{protocolthe-p}{the} route to be deleted. \\
\hline
{\em caller} & \hyperlink{protocolthe-p}{the} parent table sending \hyperlink{protocolthe-p}{the} delete\_\-route. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
XORP\_\-OK on success, otherwise XORP\_\-ERROR. 
\end{DoxyReturn}


Implements \hyperlink{classRouteTable}{RouteTable$<$ A $>$}.

\hypertarget{classMergedTable_a2ca22b3e8d08e3a03d8777c740524865}{
\index{MergedTable@{MergedTable}!lookup\_\-route@{lookup\_\-route}}
\index{lookup\_\-route@{lookup\_\-route}!MergedTable@{MergedTable}}
\subsubsection[{lookup\_\-route}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ const {\bf IPRouteEntry}$<$ A $>$ $\ast$ {\bf MergedTable}$<$ A $>$::lookup\_\-route (
\begin{DoxyParamCaption}
\item[{const A \&}]{addr}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classMergedTable_a2ca22b3e8d08e3a03d8777c740524865}


Lookup an IP address to get \hyperlink{protocolthe-p}{the} most specific (longest prefix length) route that matches this address. 

The lookup will be sent to both parent tables. If both give an answer, then \hyperlink{protocolthe-p}{the} more specific route is returned. If both routes have \hyperlink{protocolthe-p}{the} same prefix length, then \hyperlink{protocolthe-p}{the} route with \hyperlink{protocolthe-p}{the} better admin\_\-distance is returned.


\begin{DoxyParams}{Parameters}
{\em addr} & \hyperlink{protocolthe-p}{the} IP address to look up.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to \hyperlink{protocolthe-p}{the} best most specific route entry if any entry matches, NULL otherwise. 
\end{DoxyReturn}


Implements \hyperlink{classRouteTable}{RouteTable$<$ A $>$}.

\hypertarget{classMergedTable_a28395ad6c23deb50d8b67844eacba576}{
\index{MergedTable@{MergedTable}!lookup\_\-route@{lookup\_\-route}}
\index{lookup\_\-route@{lookup\_\-route}!MergedTable@{MergedTable}}
\subsubsection[{lookup\_\-route}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ const {\bf IPRouteEntry}$<$ A $>$ $\ast$ {\bf MergedTable}$<$ A $>$::lookup\_\-route (
\begin{DoxyParamCaption}
\item[{const {\bf IPNet}$<$ A $>$ \&}]{net}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classMergedTable_a28395ad6c23deb50d8b67844eacba576}


Lookup a specific subnet. 

The lookup will be sent to both parent tables. If both give an answer, then \hyperlink{protocolthe-p}{the} route with \hyperlink{protocolthe-p}{the} better admin\_\-distance is returned.


\begin{DoxyParams}{Parameters}
{\em net} & \hyperlink{protocolthe-p}{the} subnet to look up. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to \hyperlink{protocolthe-p}{the} route entry if it exists, NULL otherwise. 
\end{DoxyReturn}


Implements \hyperlink{classRouteTable}{RouteTable$<$ A $>$}.

\hypertarget{classMergedTable_a5d132afba864f186bc807ed5ac277164}{
\index{MergedTable@{MergedTable}!lookup\_\-route\_\-range@{lookup\_\-route\_\-range}}
\index{lookup\_\-route\_\-range@{lookup\_\-route\_\-range}!MergedTable@{MergedTable}}
\subsubsection[{lookup\_\-route\_\-range}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ {\bf RouteRange}$<$ A $>$ $\ast$ {\bf MergedTable}$<$ A $>$::lookup\_\-route\_\-range (
\begin{DoxyParamCaption}
\item[{const A \&}]{addr}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classMergedTable_a5d132afba864f186bc807ed5ac277164}


Lookup an IP address to get \hyperlink{protocolthe-p}{the} most specific (longest prefix length) route that matches this address, along with \hyperlink{protocolthe-p}{the} \hyperlink{classRouteRange}{RouteRange} information for this address and route. 

As with lookup\_\-route, this involves querying both parent tables. The best, most specific route is returned, and \hyperlink{protocolthe-p}{the} tightest bounds on \hyperlink{protocolthe-p}{the} answer are returned.

\begin{DoxySeeAlso}{See also}
\hyperlink{classRouteRange}{RouteRange} 
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em addr} & \hyperlink{protocolthe-p}{the} IP address to look up. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to a \hyperlink{classRouteRange}{RouteRange} class instance containing \hyperlink{protocolthe-p}{the} relevant answer. It is up to \hyperlink{protocolthe-p}{the} recipient of this pointer to free \hyperlink{protocolthe-p}{the} associated memory. 
\end{DoxyReturn}


Implements \hyperlink{classRouteTable}{RouteTable$<$ A $>$}.

\hypertarget{classMergedTable_a1da65fd91f0d438cfc34f4d25f808450}{
\index{MergedTable@{MergedTable}!replumb@{replumb}}
\index{replumb@{replumb}!MergedTable@{MergedTable}}
\subsubsection[{replumb}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ void {\bf MergedTable}$<$ A $>$::replumb (
\begin{DoxyParamCaption}
\item[{{\bf RouteTable}$<$ A $>$ $\ast$}]{old\_\-parent, }
\item[{{\bf RouteTable}$<$ A $>$ $\ast$}]{new\_\-parent}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classMergedTable_a1da65fd91f0d438cfc34f4d25f808450}


replumb \hyperlink{protocolthe-p}{the} parent tables, so that new\_\-parent replaces old\_\-parent. 


\begin{DoxyParams}{Parameters}
{\em old\_\-parent} & \hyperlink{protocolthe-p}{the} old parent table. \\
\hline
{\em new\_\-parent} & \hyperlink{protocolthe-p}{the} new parent table. \\
\hline
\end{DoxyParams}


Implements \hyperlink{classRouteTable}{RouteTable$<$ A $>$}.

\hypertarget{classMergedTable_af05d7ac91f1614b4996833c20f402dd7}{
\index{MergedTable@{MergedTable}!type@{type}}
\index{type@{type}!MergedTable@{MergedTable}}
\subsubsection[{type}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class A $>$ TableType {\bf MergedTable}$<$ A $>$::type (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline, virtual\mbox{]}}}}
\label{classMergedTable_af05d7ac91f1614b4996833c20f402dd7}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} table type (TableType). 
\end{DoxyReturn}


Implements \hyperlink{classRouteTable}{RouteTable$<$ A $>$}.



The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/rib/rt\_\-tab\_\-merged.hh\item 
/home/greearb/git/xorp.ct.github/xorp/rib/rt\_\-tab\_\-merged.cc\end{DoxyCompactItemize}
