libxorp_overview.tex
来自「BCAST Implementation for NS2」· TEX 代码 · 共 743 行 · 第 1/2 页
TEX
743 行
%% $XORP: xorp/docs/libxorp/libxorp_overview.tex,v 1.13 2003/11/06 20:34:57 hodson Exp $%\documentclass[11pt]{article}%\usepackage[dvips]{changebar}\usepackage{subfigure}\usepackage{fullpage}\usepackage{setspace}\usepackage{times}\usepackage{latexsym}\usepackage{psfig}\usepackage{graphicx}\usepackage{xspace}\usepackage{color}\usepackage{amsmath}%\usepackage[dvipdf]{graphics}%\usepackage[dvips]{graphicx}%\usepackage{xorp}\definecolor{gray}{rgb}{0.5,0.5,0.5}\newcommand{\etc}{\emph{etc.}\xspace}\newcommand{\ie}{\emph{i.e.,}\xspace}\newcommand{\eg}{\emph{e.g.,}\xspace}%\newcommand{\comment}[1]{{\color{gray}[\textsf{#1}]}}\newcommand{\comment}[1]{}% Changebar stuff% \newenvironment{colorcode}{\color{blue}}{}% \renewcommand{\cbstart}{\begin{colorcode}}% \renewcommand{\cbend}{\end{colorcode}}% \pagestyle{empty}\begin{document}\title{XORP Libxorp Library Overview \\\vspace{1ex}Version 0.5}\author{ XORP Project \\ International Computer Science Institute \\ Berkeley, CA 94704, USA \\ {\it feedback@xorp.org}}\date{November 6, 2003}\maketitle\thispagestyle{empty}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{Introduction}The \emph{libxorp} library contains a set of classes for basicXORP functionality such as IP addresses and subnets, timers, eventloops, etc. It is used by virtually every other XORP component, andits main purpose is to simplify the implementation of those components.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{Overview}Currently, the libxorp library contains the following classes andcomponents (in alphabetical order):\begin{itemize} \item \emph{asnum.hh: class AsNum}: A class for storing an AS number used by protocols such as BGP. \item \emph{asyncio.hh: class AsyncFileReader, class AsyncFileWriter}: Asynchronous file transfer classes. \item \emph{buffer.hh: class Buffer}: A class for storing buffered data. \item \emph{c\_format.hh: c\_format()}: A macro that creates a C++ string from a C-style printf(3)-formatted string. \item \emph{callback.hh:} Callback mechanism. \item \emph{config\_param.hh: template class ConfigParam}: A class for storing a configuration parameter. \item \emph{debug.h}: Provides facility for generating debug messages. \item \emph{ether\_compat.h}: Ethernet manipulation compatibility functions. \item \emph{eventloop.hh: class EventLoop}: Event loop class for coordinated operations between timers and I/O operations on file descriptors. \item \emph{exceptions.hh}: Standard XORP C++ exceptions. \item \emph{heap.hh: class Heap}: Provides Heap data structure. \item \emph{ipnet.hh, ipv4net.hh, ipv6net.hh, ipvxnet.hh: class IPv4Net, class IPv6Net, class IPvXNet}: Implementation of classes for basic subnet addresses (for IPv4, IPv6 and dual IPv4/6 address family respectively). \item \emph{ipv4.hh, ipv6.hh, ipvx.hh: class IPv4, class IPv6, class IPvX}: Implementation of classes for basic IP addresses (for IPv4, IPv6 and dual IPv4/6 address family respectively). \item \emph{mac.hh: class Mac, class EtherMac}: Containers for MAC types. \item \emph{nexthop.hh}: Classes that contain routing next-hop information. \item \emph{ref\_ptr.hh: template class ref\_ptr}: Reference counted pointer class. \item \emph{ref\_trie.hh}: Implementation of a trie to support route lookups. Based on trie.hh, but with reference-counted storage supporting delayed deletion. \item \emph{selector.hh}: I/O multiplexing interface. \item \emph{service.hh}: Provides base for asynchronous service classes. \item \emph{status\_codes.h}: Process states status codes used by processes when reporting their operational status to the router manager. \item \emph{time\_slice.hh: class TimeSlice}: A class for computing whether some processing is taking too long. \item \emph{timer.hh, class XorpTimer}: XORP timer facility. \item \emph{timeval.hh: class TimeVal}: A class for storing time values (similar to \emph{struct timeval}). \item \emph{token.hh}: Token related definitions. \item \emph{transactions.hh}: Facility for transaction operations. \item \emph{trie.hh}: Implementation of a trie to support route lookups. \item \emph{utility.h}: Contains various mini-utilities (mostly compiler-related helpers). \item \emph{utils.hh}: Contains various utilities (\eg to delete a list or array of pointers and the objects pointed to). \item \emph{vif.hh: class Vif, class VifAddr}: Virtual interface and virtual interface address classes. \item \emph{xlog.h}: Provides facility for log messages generation. \item \emph{xorp.h}: The XORP main include file that should be included by all XORP C and C++ files.\end{itemize}Each of the components is described inSection~\ref{sec:components_description}.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{Components Description}\label{sec:components_description}This section contains a brief description of each of the components ofthe \emph{libxorp} library. This description is for informativepurpose only. The source code for each component is the ultimate sourcefor programming reference, and implementation details.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{asnum.hh}This file contains \emph{class AsNum}: a class for storing an AS numberused by protocols such as BGP.This class can be used to store an AS number that can be either16 or 32 bits. Originally, the AS numbers were defined as 16-bitunsigned numbers. Later the ``extended'' AS numbers were introduced,which are unsigned 32-bit numbers.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{asyncio.hh}This file containsasynchronous file transfer classes. These utilize XORP EventLoopand its SelectorList to read or write files asynchronously. Theuser creates an AsyncFile\{Reader,Writer\} and adds a buffer forreading or writing with add\_buffer(). A callback provided witheach buffer is called every time I/O happens on the buffer.Reading or writing only begins when start() is called, and normallycontinues until there are no buffers left.From the developer's point of view, the following classes are ofinterest: \emph{class AsyncFileReader, class AsyncFileWriter}.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{buffer.hh}This file contains \emph{class Buffer}: a class for conveniently storingand accessing buffered data.Currently it has limited applicability.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{c\_format.hh}This file contains \emph{c\_format()}: a macro that creates a C++ stringfrom a C-style printf(3)-formatted string.It takes the same arguments as printf(3), but \%n is illegal andwill cause abort to be called.In practice c\_format() is a nasty macro, but by doing this we can checkthe compile time arguments are sane and the run time arguments.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{callback.hh}This file contains an implementation of a callback mechanism.XORP is an asynchronous programming environment and as a result thereare many places where callbacks are useful. Callbacks are typicallyinvoked to signify the completion or advancement of an asynchronousoperation.XORP provides a generic and flexible callback interface that utilizesoverloaded templatized functions for generating callbacks inconjunction with many small templatized classes. Whilst this makes thesyntax a little unpleasant, it provides a great deal of flexibility.XorpCallback objects are objects created by the callback()function which returns a reference pointer to a newly createdcallback object. The callback is invoked by calling the dispatch()method on that object.For more details on the callback mechanism, and for usage examples, seethe beginning of \emph{callback.hh}.Note that this file is auto-generated by callback-gen.py (a Python script),therefore it should never be edited.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{config\_param.hh}This file contains the implementation of \emph{template classConfigParam}: a class for storing a configuration parameter.This class can be used to store the value of a configuration parameter.Such parameter has a current and a default value.The \emph{ConfigParam} class has the facility to add a callback that isinvoked whenever the value of the configuration parameter is changed.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{debug.h}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{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{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.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?