📄 libxorp_overview.tex
字号:
This file provides facility for debug messages generation.More specifically, it defines the \verb=debug_msg()=, the macroresponsible for generating debug messages.It takes the same arguments as printf(3). For example:\begin{verbatim}debug_msg("The number is %d\n", 5);\end{verbatim}For more details see the comments inside that file.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{ether\_compat.h}This file contains Ethernet-related manipulation compatibilityfunctions. For example, it includes the appropriate system files,and declares functions \verb=ether_aton()= and \verb=ether_ntoa()=(implemented locally in \emph{ether\_compat.c}) if the system is missingthe corresponding \verb=ether_aton(3)= and \verb=ether_ntoa(3)=.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{eventloop.hh}This file defines \emph{class EventLoop}.It is used to co-ordinate interactions between a TimerList and aSelectorList for XORP processes. All XorpTimer and select operationsshould be co-ordinated through this interface.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{exceptions.hh}This file contains \emph{class XorpException}: a base class for XORP C++exceptions. It contains also all standard XORP C++ exceptions.An example of such exception is \emph{class InvalidFamily} which isthrown if the address family is invalid (for example, by an IPvXconstructor when invoked with an invalid address family).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{heap.hh}This file contains \emph{class Heap}. The Heap class is used by theTimerList class as it's priority queue for timers. This implementationsupports removal of arbitrary objects from the heap, even if they arenot located at the top.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{ioevents.hh}This file contains the enumerated \emph{IoEventType} codes: variousevent types supported by the I/O callback facade. The event types areused by clients when registering interest in I/O events.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{ipnet.hh, ipv4net.hh, ipv6net.hh, ipvxnet.hh}These files contain the declaration of the following classes:\emph{class IPv4Net, class IPv6Net, class IPvXNet}, which areclasses for basic subnet addresses (for IPv4, IPv6 and dual IPv4/6address family respectively). IPvXNet can be used to store a subnetaddress that has either IPv4 or IPv6 address family.Most of the implementation is contained in file \emph{ipnet.hh}, whichcontains a \emph{template class IPNet}. The IPv4Net, IPv6Net, andIPvXNet classes are derived from that template.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{ipv4.hh, ipv6.hh, ipvx.hh}These files contain the declaration for the following classes:\emph{class IPv4, class IPv6, class IPvX}, which areclasses for basic IP addresses (for IPv4, IPv6 and dual IPv4/6address family respectively). IPvX can be used to store anaddress that has either IPv4 or IPv6 address family.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{mac.hh}This file declares the following classes: \emph{class Mac, classEtherMac}. The first class is a generic container for any type of MAC.The second class is a container for Ethernet MAC address.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{nexthop.hh}This file declares a number of classes that can be used to containrouting next-hop information. For example, \emph{class NextHop}is the generic class for holding information about routingnext hops. NextHops can be of many types, including immediateneighbors, remote routers (with IBGP), discard interfaces,encapsulation endpoints, etc. NextHop itself doesn't really doanything useful, except to provide a generic handle for thespecialized subclasses. The specialized subclasses are:\begin{itemize} \item IPPeerNextHop is for next hops that are local peers. \item IPEncapsNextHop is for ``next hops'' that are non-local, and require encapsulation to reach. An example is the PIM Register Encapsulation. \item IPExternalNextHop An IP nexthop that is not an intermediate neighbor. \item DiscardNextHop is a discard interface.\end{itemize}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{popen.hh}This file contains the interface for the local implementationof \emph{popen(2)} and \emph{pclose(2)}.The corresponding local names are \emph{popen2()} and \emph{pclose2()}respectively. Unlike the system's \emph{popen(2)}, the local\emph{popen2()} implementation allows the user to specify the streamswhere the \emph{stdout} and \emph{stderr} of the command will beredirected to.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{profile.hh}This file implements the mechanism for event profiling.The developer can add profiling entries at various places of the program.Each profiling entry has a name and it can be enabled or disabled.In addition, a number of strings can be added to each profiling entry,and those strings can be read at some later stage.% TODO: add an example of using the profiling mechanism.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{random.hh}This file declares the API for the local implementation of random(3).Currently it is used if the underlying system doesn't have random(3).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{range.hh}This file implements the following classes:\emph{class U32Range, class IPv4Range, class IPv4Range}.Those classes implement linear ranges X..Y (\eg for integers oraddresses). A linear range is defined by its low and high inclusiveboundaries. It is the user's responisibility to ensure that thecondition (low $\leq$ high) always holds.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{ref\_ptr.hh}This file declares \emph{template class ref\_ptr}: reference countedpointer class.The ref\_ptr class is a strong reference class. It maintains a count ofhow many references to an object exist and releases the memory associatedwith the object when the reference count reaches zero. The referencepointer can be dereferenced like an ordinary pointer to call methodson the reference counted object.At the time of writing the only supported memory management isthrough the new and delete operators. At a future date, this classshould support the STL allocator classes or an equivalent toprovide greater flexibility.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{ref\_trie.hh}This file implements a trie to support route lookups. Theimplementation is template-based, and is based on the code intrie.hh. From deleloper's point of view, templates RefTrie, RefTrieNode,RefTriePreOrderIterator, and RefTriePostOrderIterator are the most important.Those templates should be invokedwith two classes, the basetype ``A'' for the search Key (which is asubnet, \verb=IPNet<A>=), and the Payload.RefTrie differs from Trie (and its associated classes) in that theRefTrieNode includes a reference count of how many RefTrieIteratorsare pointing at it. If a RefTrieNode is deleted, but has a non-zeroreference count, deletion will be delayed until the reference countbecomes zero. In this way, additions and deletions to the RefTriecannot cause a RefTriePreOrderIterator or RefTriePostOrderIteratorto reference invalid memory, although a deletion and subsequent addition cancause the payload data referenced by an iterator to change.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{round\_robin.hh}This file implements round-robin queue which is used by thepriority-based task implementation (see Section~\ref{sec:task_hh}).It is used internally by libxorp and shouldn't be used by the rest ofthe system.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{run\_command.hh}This file implements \emph{class RunCommand} which provides themechanism for running an external command. In addition to the commandname and its arguments, the developer can specify three callbacks:\begin{itemize} \item \emph{stdout\_cb}: the callback to call when there is data on the standard output. \item \emph{stderr\_cb}: the callback to call when there is data on the standard error. \item \emph{done\_cb}: the callback to call when the command is completed.\end{itemize}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{safe\_callback\_obj.hh}This file declares class \emph{CallbackSafeObject}.Objects that wish to be callback safe should be derived from thisclass. When a CallbackSafeObject is destructed it informs all the callbacksthat refer to it that this is the case and invalidates (sets to null)the object they point to.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{selector.hh}This file contains the I/O multiplexing interface. The particular classof interest is \emph{class SelectorList}.A SelectorList provides an entity where callbacks for pending I/Ooperations on file descriptors may be registered. The callbacksare invoked when one of the select methods is called and I/Ois pending on the particular descriptors.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{service.hh}This file declares \emph{class ServiceBase}. A service is a class thatcan be started and stopped and would typically involve some asynchronousprocessing to transition between states. The base class provides astate model and methods for transitioning between states. Mandatorytransition methods, like start and stop, are abstract in the baseclass.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{status\_codes.h}This file contains the enumerated \emph{ProcessStatus} codesthat a XORP process should report to the XORP router manager(\emph{rtrmgr})~\cite{xorp:rtrmgr}.The file itself contains a detailed explanation of the process states(valid transaction between states, triggering events, actions, etc).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{task.hh}\label{sec:task_hh}This file declares and implements class \emph{class XorpTask}.Class \emph{XorpTask} is used for priority-based tasks.Each task can have a priority between \emph{PRIORITY\_HIGHEST} and\emph{PRIORITY\_LOWEST}. A number of suggested priorities and weightsare declared inside that class:\begin{verbatim}class XorpTask {public: ... // // Task/Timer priorities. Those are suggested values. // static const int PRIORITY_HIGHEST = 0; static const int PRIORITY_XRL_KEEPALIVE = 1; static const int PRIORITY_HIGH = 2; static const int PRIORITY_DEFAULT = 4; static const int PRIORITY_BACKGROUND = 7; static const int PRIORITY_LOWEST = 9; static const int PRIORITY_INFINITY = 255; // // Task/Timer weights. Those are suggested values. // static const int WEIGHT_DEFAULT = 1; ...};\end{verbatim}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{time\_slice.hh}This file declares \emph{class TimeSlice}.This class can be used to compute whether some processing is takingtoo long time to complete. It is up to the program that usesTimeSlice to check whether the processing is taking too long,and suspend processing of that task if necessary.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{timer.hh}This file declares the XORP timer facility. The only class of interestfrom a developer's point of view is \emph{class XorpTimer}.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{timespent.hh}This files declares and implements \emph{class TimeSpent}.This class used for debugging purpose to find code that has taken too long toexecute.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{timeval.hh}This file contains implementation of \emph{class TimeVal} forstoring time values (similar to \emph{struct timeval}).\emph{TimeVal} implements the appropriate constructors and numeroushelper methods (\eg Less-Than and Addition operators, etc).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{tlv.hh}This file contains the implementation of \emph{class Tlv} for readingand writing TLV (Type-Lenght-Value) records from/to a file. The recordsare stored in network byte order format.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{token.hh}This file contains various token-related definitions. Token is asequence of symbols separated from other tokens by some pre-definedsymbols. In this implementation, the separators are the is\_space(3) and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -