\hypertarget{classAsNum}{
\section{AsNum Class Reference}
\label{classAsNum}\index{AsNum@{AsNum}}
}


A class for storing an AS number used by protocols such as BGP.  




{\ttfamily \#include $<$asnum.hh$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classAsNum_a6ec97c6ced78aaf3184fc94da8374d7f}{AsNum} (const uint32\_\-t value)
\begin{DoxyCompactList}\small\item\em Constructor. \item\end{DoxyCompactList}\item 
\hypertarget{classAsNum_a5fce9c1522d32ae622b686b7f11ae88c}{
{\bfseries AsNum} (const uint16\_\-t value)}
\label{classAsNum_a5fce9c1522d32ae622b686b7f11ae88c}

\item 
\hypertarget{classAsNum_afc4a90444fe2d8c8694db4b345cb56c3}{
{\bfseries AsNum} (int value)}
\label{classAsNum_afc4a90444fe2d8c8694db4b345cb56c3}

\item 
\hypertarget{classAsNum_a7396f6330941230fb44180570f67a0d6}{
\hyperlink{classAsNum_a7396f6330941230fb44180570f67a0d6}{AsNum} (const uint8\_\-t $\ast$d)}
\label{classAsNum_a7396f6330941230fb44180570f67a0d6}

\begin{DoxyCompactList}\small\item\em construct from a 2-\/byte buffer in memory \item\end{DoxyCompactList}\item 
\hyperlink{classAsNum_a049e35db721e549bd82e4bc8a4849ce8}{AsNum} (const uint8\_\-t $\ast$d, bool fourbyte)
\begin{DoxyCompactList}\small\item\em construct from a 2-\/byte buffer in memory or a 4 byte buffer (in net byte order). \item\end{DoxyCompactList}\item 
\hypertarget{classAsNum_af778b7f0e986fdcd40fa336a147335f6}{
\hyperlink{classAsNum_af778b7f0e986fdcd40fa336a147335f6}{AsNum} (const string \&as\_\-str)  throw (InvalidString)}
\label{classAsNum_af778b7f0e986fdcd40fa336a147335f6}

\begin{DoxyCompactList}\small\item\em construct from a string, either as a decimal number in \hyperlink{protocolthe-p}{the} range 1-\/65535, or as two decimal numbers x.y, where x and y are in \hyperlink{protocolthe-p}{the} range 0-\/65535 \item\end{DoxyCompactList}\item 
uint16\_\-t \hyperlink{classAsNum_a342673910462ae98caacb6f2fe2ef0ae}{as} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} non-\/extended AS number value. \item\end{DoxyCompactList}\item 
uint32\_\-t \hyperlink{classAsNum_a4eda79d063c88ae086aa784d87e644f9}{as4} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} extended AS number value. \item\end{DoxyCompactList}\item 
\hypertarget{classAsNum_a30b47776a1fade131b94303fe84d8f1f}{
void \hyperlink{classAsNum_a30b47776a1fade131b94303fe84d8f1f}{copy\_\-out} (uint8\_\-t $\ast$d) const }
\label{classAsNum_a30b47776a1fade131b94303fe84d8f1f}

\begin{DoxyCompactList}\small\item\em copy \hyperlink{protocolthe-p}{the} 16-\/bit value into a 2-\/byte memory buffer \item\end{DoxyCompactList}\item 
\hypertarget{classAsNum_ae7000d4243bb85e3df74a58be9d295f4}{
void \hyperlink{classAsNum_ae7000d4243bb85e3df74a58be9d295f4}{copy\_\-out4} (uint8\_\-t $\ast$d) const }
\label{classAsNum_ae7000d4243bb85e3df74a58be9d295f4}

\begin{DoxyCompactList}\small\item\em copy \hyperlink{protocolthe-p}{the} 32-\/bit value into a 4-\/byte network byte order memory buffer \item\end{DoxyCompactList}\item 
bool \hyperlink{classAsNum_a479c6fe648ec6baab368af5f04d97de9}{extended} () const 
\begin{DoxyCompactList}\small\item\em Test if this is an extended AS number. \item\end{DoxyCompactList}\item 
bool \hyperlink{classAsNum_ac01b451291e53fbb5637a08f6460b301}{operator==} (const \hyperlink{classAsNum}{AsNum} \&x) const 
\begin{DoxyCompactList}\small\item\em Equality Operator. \item\end{DoxyCompactList}\item 
bool \hyperlink{classAsNum_a23f4a9db0de96302ffea24fa33f63880}{operator$<$} (const \hyperlink{classAsNum}{AsNum} \&x) const 
\begin{DoxyCompactList}\small\item\em Less-\/Than Operator. \item\end{DoxyCompactList}\item 
string \hyperlink{classAsNum_ac22c2e6b7b1a8923ed85e187bade792d}{str} () const 
\begin{DoxyCompactList}\small\item\em Convert this AS number from binary form to presentation format. \item\end{DoxyCompactList}\item 
\hypertarget{classAsNum_a3784b05bf42f3a46a1e4d5e34e55bb29}{
string {\bfseries short\_\-str} () const }
\label{classAsNum_a3784b05bf42f3a46a1e4d5e34e55bb29}

\item 
\hypertarget{classAsNum_a7bb53da2b6f2b9dd367cbb78d926bfff}{
string {\bfseries fourbyte\_\-str} () const }
\label{classAsNum_a7bb53da2b6f2b9dd367cbb78d926bfff}

\end{DoxyCompactItemize}
\subsection*{Static Public Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classAsNum_a2a54e3884e8237dd9719d8410511961c}{
static const uint16\_\-t {\bfseries AS\_\-INVALID} = 0}
\label{classAsNum_a2a54e3884e8237dd9719d8410511961c}

\item 
\hypertarget{classAsNum_a46ded79d1df11f5bcba4c27fdcd7fd30}{
static const uint16\_\-t {\bfseries AS\_\-TRAN} = 23456}
\label{classAsNum_a46ded79d1df11f5bcba4c27fdcd7fd30}

\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classAsNum_a4d0383dc48e4ff1a032a7c8d0a522b05}{
uint32\_\-t {\bfseries \_\-as}}
\label{classAsNum_a4d0383dc48e4ff1a032a7c8d0a522b05}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
A class for storing an AS number used by protocols such as BGP. This class can be used to store an AS number that can be either 16 or 32 bits. Originally, \hyperlink{protocolthe-p}{the} AS numbers were defined as 16-\/bit unsigned numbers. Later \hyperlink{protocolthe-p}{the} \char`\"{}extended\char`\"{} AS numbers were introduced, which are unsigned 32-\/bit numbers. Conventional terminology refers to \hyperlink{protocolthe-p}{the} 32-\/bit version as 4-\/byte AS numbers rather than 32-\/bit AS numbers, so we'll try and stick with that where it makes sense.

2-\/byte numbers are expanded to 32-\/bits by extending them with 0's in front. 4-\/byte numbers are represented in a 2-\/byte AS path, by a special 16-\/bit value, AS\_\-TRAN, which will be allocated by IANA. Together with any AsPath containing AS\_\-TRAN, we will always see a AS4\_\-PATH attribute which contains \hyperlink{protocolthe-p}{the} full 32-\/bit representation of \hyperlink{protocolthe-p}{the} path. So there is no loss of information.

IANA refers to NEW\_\-AS\_\-PATH, but \hyperlink{protocolthe-p}{the} latest internet drafts refer to AS4\_\-PATH. They're \hyperlink{protocolthe-p}{the} same thing, but I \hyperlink{protocolthe-p}{the} latter is preferred so we'll use that.

The internal representation of an \hyperlink{classAsNum}{AsNum} is 32-\/bit in host order.

The canonical string form of a 4-\/byte AS number is $<$high$>$.$<$low$>$, so decimal 65536 ends up being printed as \char`\"{}1.0\char`\"{}.

An \hyperlink{classAsNum}{AsNum} must always be initialized, so \hyperlink{protocolthe-p}{the} default constructor is never called. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classAsNum_a6ec97c6ced78aaf3184fc94da8374d7f}{
\index{AsNum@{AsNum}!AsNum@{AsNum}}
\index{AsNum@{AsNum}!AsNum@{AsNum}}
\subsubsection[{AsNum}]{\setlength{\rightskip}{0pt plus 5cm}AsNum::AsNum (
\begin{DoxyParamCaption}
\item[{const uint32\_\-t}]{value}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline, explicit\mbox{]}}}}
\label{classAsNum_a6ec97c6ced78aaf3184fc94da8374d7f}


Constructor. 


\begin{DoxyParams}{Parameters}
{\em value} & \hyperlink{protocolthe-p}{the} value to assign to this AS number. \\
\hline
\end{DoxyParams}
\hypertarget{classAsNum_a049e35db721e549bd82e4bc8a4849ce8}{
\index{AsNum@{AsNum}!AsNum@{AsNum}}
\index{AsNum@{AsNum}!AsNum@{AsNum}}
\subsubsection[{AsNum}]{\setlength{\rightskip}{0pt plus 5cm}AsNum::AsNum (
\begin{DoxyParamCaption}
\item[{const uint8\_\-t $\ast$}]{d, }
\item[{bool}]{fourbyte}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline, explicit\mbox{]}}}}
\label{classAsNum_a049e35db721e549bd82e4bc8a4849ce8}


construct from a 2-\/byte buffer in memory or a 4 byte buffer (in net byte order). 

The 4byte parameter is mostly to distinguish this from \hyperlink{protocolthe-p}{the} 2-\/byte constructor above. 

\subsection{Member Function Documentation}
\hypertarget{classAsNum_a342673910462ae98caacb6f2fe2ef0ae}{
\index{AsNum@{AsNum}!as@{as}}
\index{as@{as}!AsNum@{AsNum}}
\subsubsection[{as}]{\setlength{\rightskip}{0pt plus 5cm}uint16\_\-t AsNum::as (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsNum_a342673910462ae98caacb6f2fe2ef0ae}


Get \hyperlink{protocolthe-p}{the} non-\/extended AS number value. 

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} non-\/extended AS number value. 
\end{DoxyReturn}
\hypertarget{classAsNum_a4eda79d063c88ae086aa784d87e644f9}{
\index{AsNum@{AsNum}!as4@{as4}}
\index{as4@{as4}!AsNum@{AsNum}}
\subsubsection[{as4}]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t AsNum::as4 (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsNum_a4eda79d063c88ae086aa784d87e644f9}


Get \hyperlink{protocolthe-p}{the} extended AS number value. 

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} extended AS number value. 
\end{DoxyReturn}
\hypertarget{classAsNum_a479c6fe648ec6baab368af5f04d97de9}{
\index{AsNum@{AsNum}!extended@{extended}}
\index{extended@{extended}!AsNum@{AsNum}}
\subsubsection[{extended}]{\setlength{\rightskip}{0pt plus 5cm}bool AsNum::extended (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsNum_a479c6fe648ec6baab368af5f04d97de9}


Test if this is an extended AS number. 

\begin{DoxyReturn}{Returns}
true if this is an extended AS number. 
\end{DoxyReturn}
\hypertarget{classAsNum_a23f4a9db0de96302ffea24fa33f63880}{
\index{AsNum@{AsNum}!operator$<$@{operator$<$}}
\index{operator$<$@{operator$<$}!AsNum@{AsNum}}
\subsubsection[{operator$<$}]{\setlength{\rightskip}{0pt plus 5cm}bool AsNum::operator$<$ (
\begin{DoxyParamCaption}
\item[{const {\bf AsNum} \&}]{x}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsNum_a23f4a9db0de96302ffea24fa33f63880}


Less-\/Than Operator. 

\begin{DoxyReturn}{Returns}
true if \hyperlink{protocolthe-p}{the} left-\/hand operand is numerically smaller than \hyperlink{protocolthe-p}{the} right-\/hand operand. 
\end{DoxyReturn}
\hypertarget{classAsNum_ac01b451291e53fbb5637a08f6460b301}{
\index{AsNum@{AsNum}!operator==@{operator==}}
\index{operator==@{operator==}!AsNum@{AsNum}}
\subsubsection[{operator==}]{\setlength{\rightskip}{0pt plus 5cm}bool AsNum::operator== (
\begin{DoxyParamCaption}
\item[{const {\bf AsNum} \&}]{x}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsNum_ac01b451291e53fbb5637a08f6460b301}


Equality Operator. 


\begin{DoxyParams}{Parameters}
{\em other} & \hyperlink{protocolthe-p}{the} right-\/hand operand to compare against. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if \hyperlink{protocolthe-p}{the} left-\/hand operand is numerically same as \hyperlink{protocolthe-p}{the} right-\/hand operand. 
\end{DoxyReturn}
\hypertarget{classAsNum_ac22c2e6b7b1a8923ed85e187bade792d}{
\index{AsNum@{AsNum}!str@{str}}
\index{str@{str}!AsNum@{AsNum}}
\subsubsection[{str}]{\setlength{\rightskip}{0pt plus 5cm}string AsNum::str (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsNum_ac22c2e6b7b1a8923ed85e187bade792d}


Convert this AS number from binary form to presentation format. 

\begin{DoxyReturn}{Returns}
C++ string with \hyperlink{protocolthe-p}{the} human-\/readable ASCII representation of \hyperlink{protocolthe-p}{the} AS number. 
\end{DoxyReturn}


The documentation for this class was generated from the following file:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/asnum.hh\end{DoxyCompactItemize}
