\hypertarget{class_sniffer}{}\section{Referencia de la Clase Sniffer}
\label{class_sniffer}\index{Sniffer@{Sniffer}}


The \hyperlink{class_sniffer}{Sniffer} class is the one that use the pcap library to extract the packet information. It discards any packet that is not Ethernet-\/$>$I\+P-\/$>$(T\+C\+P$\vert$\+U\+D\+P), and pass up to the G\+U\+I the packets that are Ethernet-\/$>$I\+P-\/$>$(T\+C\+P$\vert$\+U\+D\+P).  




{\ttfamily \#include $<$sniffer.\+h$>$}

Diagrama de herencias de Sniffer\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{class_sniffer}
\end{center}
\end{figure}
\subsection*{Slots públicos}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_sniffer_a6fc78b66d2f4dce0cc3662dacf171514}{}void \hyperlink{class_sniffer_a6fc78b66d2f4dce0cc3662dacf171514}{process} ()\label{class_sniffer_a6fc78b66d2f4dce0cc3662dacf171514}

\begin{DoxyCompactList}\small\item\em El sniffer se corre como un hilo por separado y la funcion process es la funcion principal de el hilo. Es el sniffer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Señales}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_sniffer_a7d0fd40379b7e5f49aff18ac20cb1c45}{}void {\bfseries result\+Ready} (unsigned long index)\label{class_sniffer_a7d0fd40379b7e5f49aff18ac20cb1c45}

\end{DoxyCompactItemize}
\subsection*{Métodos públicos}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_sniffer_a8039cbd5f487a357321d57337a664d3d}{}\hyperlink{class_sniffer_a8039cbd5f487a357321d57337a664d3d}{Sniffer} ()\label{class_sniffer_a8039cbd5f487a357321d57337a664d3d}

\begin{DoxyCompactList}\small\item\em Constructor, no hace nada. \end{DoxyCompactList}\item 
\hyperlink{class_sniffer_a8e5f1474f756be527b4c39a3e9a83893}{Sniffer} (Q\+Wait\+Condition $\ast$pw, Q\+Mutex $\ast$mx, int $\ast$ps)
\begin{DoxyCompactList}\small\item\em Ajusta los mutexes para la inter comunicacion entre el sniffer y el G\+U\+I. \end{DoxyCompactList}\item 
\hypertarget{class_sniffer_a8ad3b97292e2cc274f31d87701f92be2}{}\hyperlink{class_sniffer_a8ad3b97292e2cc274f31d87701f92be2}{$\sim$\+Sniffer} ()\label{class_sniffer_a8ad3b97292e2cc274f31d87701f92be2}

\begin{DoxyCompactList}\small\item\em Destructor, no hace nada. \end{DoxyCompactList}\item 
vector$<$ \hyperlink{classip__packet}{ip\+\_\+packet} $>$ $\ast$ \hyperlink{class_sniffer_a791027d276cfcc5e6849132ecf8e80b6}{get\+Packet\+List} ()
\begin{DoxyCompactList}\small\item\em Devuelve la lista de paquetes que contiene los paquetes que son Ethernet -\/$>$ I\+P -\/$>$ (T\+C\+P$\vert$\+U\+D\+P) \end{DoxyCompactList}\item 
string \hyperlink{class_sniffer_a3dd95c60c5b8554e1bedc22b36ae488c}{format\+\_\+payload} (const char $\ast$payload, int len)
\begin{DoxyCompactList}\small\item\em Formatea la carga de un torrente de bytes a un cadena de caracteres ascii. \end{DoxyCompactList}\item 
string \hyperlink{class_sniffer_a02101b56a75804d1ed39a1c04ba36ab2}{format\+\_\+hex\+\_\+ascii\+\_\+line} (const char $\ast$payload, int len, int offset)
\begin{DoxyCompactList}\small\item\em Devuelve una cadena de caracteres con los bytes de una linea de la carga en ascii. \end{DoxyCompactList}\item 
void \hyperlink{class_sniffer_a94d7cd87d0f181c3cf2e5ec851e370b6}{find\+\_\+devices} (vector$<$ string $>$ \&)
\begin{DoxyCompactList}\small\item\em Encuentra los dispositivos de red en la computadora, y los almacena en el vector devs. \end{DoxyCompactList}\item 
void \hyperlink{class_sniffer_ab706811aa2b285e4c0f55491703c105a}{set\+Device} (string)
\begin{DoxyCompactList}\small\item\em Ajusta el dispositivo para caputurar paquetes a dev. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Métodos privados}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{class_sniffer_ac05f935a6ec2830d6bf42b607f071910}{print\+\_\+payload} (const u\+\_\+char $\ast$payload, int len)
\begin{DoxyCompactList}\small\item\em Imprime la carga en ascii. \end{DoxyCompactList}\item 
void \hyperlink{class_sniffer_a70598d5001a30cc8e801f1262770cdf6}{print\+\_\+hex\+\_\+ascii\+\_\+line} (const u\+\_\+char $\ast$payload, int len, int offset)
\begin{DoxyCompactList}\small\item\em Imprime la carga en ascii a std output. \end{DoxyCompactList}\item 
void \hyperlink{class_sniffer_a0179e32fee6a0f7c2a13f37d64a7fae0}{got\+\_\+packet} (const struct pcap\+\_\+pkthdr $\ast$header, const u\+\_\+char $\ast$packet)
\begin{DoxyCompactList}\small\item\em Secciona el paquete recibido. Extrae la informacion necesaria. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Atributos privados}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_sniffer_ad3ad83091913a50effd7468d8d7ca590}{}vector$<$ \hyperlink{classip__packet}{ip\+\_\+packet} $>$ {\bfseries packet\+\_\+list}\label{class_sniffer_ad3ad83091913a50effd7468d8d7ca590}

\item 
\hypertarget{class_sniffer_a36e1964fbc960b60a09b425a7cd1c0f6}{}Q\+Wait\+Condition $\ast$ {\bfseries wait\+\_\+pause}\label{class_sniffer_a36e1964fbc960b60a09b425a7cd1c0f6}

\item 
\hypertarget{class_sniffer_ae0d6a92d2224a8c927afe861d45ab182}{}Q\+Mutex $\ast$ {\bfseries mutex}\label{class_sniffer_ae0d6a92d2224a8c927afe861d45ab182}

\item 
\hypertarget{class_sniffer_ac35f2e04e7f7668243a75bd9b9b44028}{}string {\bfseries device}\label{class_sniffer_ac35f2e04e7f7668243a75bd9b9b44028}

\item 
\hypertarget{class_sniffer_abb7dd6858499a14bcf002ba86e2d3f7f}{}string {\bfseries filter}\label{class_sniffer_abb7dd6858499a14bcf002ba86e2d3f7f}

\item 
\hypertarget{class_sniffer_a2fde6ba65f629b1c74b1fcd1b8d2c022}{}int $\ast$ {\bfseries pause}\label{class_sniffer_a2fde6ba65f629b1c74b1fcd1b8d2c022}

\end{DoxyCompactItemize}


\subsection{Descripción detallada}
The \hyperlink{class_sniffer}{Sniffer} class is the one that use the pcap library to extract the packet information. It discards any packet that is not Ethernet-\/$>$I\+P-\/$>$(T\+C\+P$\vert$\+U\+D\+P), and pass up to the G\+U\+I the packets that are Ethernet-\/$>$I\+P-\/$>$(T\+C\+P$\vert$\+U\+D\+P). 

\subsection{Documentación del constructor y destructor}
\hypertarget{class_sniffer_a8e5f1474f756be527b4c39a3e9a83893}{}\index{Sniffer@{Sniffer}!Sniffer@{Sniffer}}
\index{Sniffer@{Sniffer}!Sniffer@{Sniffer}}
\subsubsection[{Sniffer}]{\setlength{\rightskip}{0pt plus 5cm}Sniffer\+::\+Sniffer (
\begin{DoxyParamCaption}
\item[{Q\+Wait\+Condition $\ast$}]{pw, }
\item[{Q\+Mutex $\ast$}]{mx, }
\item[{int $\ast$}]{ps}
\end{DoxyParamCaption}
)}\label{class_sniffer_a8e5f1474f756be527b4c39a3e9a83893}


Ajusta los mutexes para la inter comunicacion entre el sniffer y el G\+U\+I. 


\begin{DoxyParams}{Parámetros}
{\em pw} & se usa para pausar la captura de paquetes \\
\hline
{\em mx} & usado para proteger la region critica \\
\hline
{\em ps} & bandera para pausar la captura de paquetes \\
\hline
\end{DoxyParams}


\subsection{Documentación de las funciones miembro}
\hypertarget{class_sniffer_a94d7cd87d0f181c3cf2e5ec851e370b6}{}\index{Sniffer@{Sniffer}!find\+\_\+devices@{find\+\_\+devices}}
\index{find\+\_\+devices@{find\+\_\+devices}!Sniffer@{Sniffer}}
\subsubsection[{find\+\_\+devices}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::find\+\_\+devices (
\begin{DoxyParamCaption}
\item[{vector$<$ string $>$ \&}]{devs}
\end{DoxyParamCaption}
)}\label{class_sniffer_a94d7cd87d0f181c3cf2e5ec851e370b6}


Encuentra los dispositivos de red en la computadora, y los almacena en el vector devs. 


\begin{DoxyParams}{Parámetros}
{\em devs} & vector de cadenas de caracteres para los nombres \\
\hline
\end{DoxyParams}
\hypertarget{class_sniffer_a02101b56a75804d1ed39a1c04ba36ab2}{}\index{Sniffer@{Sniffer}!format\+\_\+hex\+\_\+ascii\+\_\+line@{format\+\_\+hex\+\_\+ascii\+\_\+line}}
\index{format\+\_\+hex\+\_\+ascii\+\_\+line@{format\+\_\+hex\+\_\+ascii\+\_\+line}!Sniffer@{Sniffer}}
\subsubsection[{format\+\_\+hex\+\_\+ascii\+\_\+line}]{\setlength{\rightskip}{0pt plus 5cm}string Sniffer\+::format\+\_\+hex\+\_\+ascii\+\_\+line (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{payload, }
\item[{int}]{len, }
\item[{int}]{offset}
\end{DoxyParamCaption}
)}\label{class_sniffer_a02101b56a75804d1ed39a1c04ba36ab2}


Devuelve una cadena de caracteres con los bytes de una linea de la carga en ascii. 


\begin{DoxyParams}{Parámetros}
{\em payload} & carga del paquete \\
\hline
{\em len} & largo del paquete \\
\hline
{\em offset} & distancia del paquete \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Devuelve}
a string with the bytes of a payload line in ascii 
\end{DoxyReturn}
\hypertarget{class_sniffer_a3dd95c60c5b8554e1bedc22b36ae488c}{}\index{Sniffer@{Sniffer}!format\+\_\+payload@{format\+\_\+payload}}
\index{format\+\_\+payload@{format\+\_\+payload}!Sniffer@{Sniffer}}
\subsubsection[{format\+\_\+payload}]{\setlength{\rightskip}{0pt plus 5cm}string Sniffer\+::format\+\_\+payload (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{payload, }
\item[{int}]{len}
\end{DoxyParamCaption}
)}\label{class_sniffer_a3dd95c60c5b8554e1bedc22b36ae488c}


Formatea la carga de un torrente de bytes a un cadena de caracteres ascii. 


\begin{DoxyParams}{Parámetros}
{\em payload} & carga del paquete \\
\hline
{\em len} & largo del paquete \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Devuelve}
la carga en una cadena de caracteres ascii 
\end{DoxyReturn}
\hypertarget{class_sniffer_a791027d276cfcc5e6849132ecf8e80b6}{}\index{Sniffer@{Sniffer}!get\+Packet\+List@{get\+Packet\+List}}
\index{get\+Packet\+List@{get\+Packet\+List}!Sniffer@{Sniffer}}
\subsubsection[{get\+Packet\+List}]{\setlength{\rightskip}{0pt plus 5cm}vector$<$ {\bf ip\+\_\+packet} $>$ $\ast$ Sniffer\+::get\+Packet\+List (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{class_sniffer_a791027d276cfcc5e6849132ecf8e80b6}


Devuelve la lista de paquetes que contiene los paquetes que son Ethernet -\/$>$ I\+P -\/$>$ (T\+C\+P$\vert$\+U\+D\+P) 

\begin{DoxyReturn}{Devuelve}
vector de paquetes 
\end{DoxyReturn}
\hypertarget{class_sniffer_a0179e32fee6a0f7c2a13f37d64a7fae0}{}\index{Sniffer@{Sniffer}!got\+\_\+packet@{got\+\_\+packet}}
\index{got\+\_\+packet@{got\+\_\+packet}!Sniffer@{Sniffer}}
\subsubsection[{got\+\_\+packet}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::got\+\_\+packet (
\begin{DoxyParamCaption}
\item[{const struct pcap\+\_\+pkthdr $\ast$}]{header, }
\item[{const u\+\_\+char $\ast$}]{packet}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [private]}}\label{class_sniffer_a0179e32fee6a0f7c2a13f37d64a7fae0}


Secciona el paquete recibido. Extrae la informacion necesaria. 


\begin{DoxyParams}{Parámetros}
{\em pcap\+\_\+pkthdr} & encabezado del paquete de pcap \\
\hline
{\em packet} & paquete recibido \\
\hline
\end{DoxyParams}
\hypertarget{class_sniffer_a70598d5001a30cc8e801f1262770cdf6}{}\index{Sniffer@{Sniffer}!print\+\_\+hex\+\_\+ascii\+\_\+line@{print\+\_\+hex\+\_\+ascii\+\_\+line}}
\index{print\+\_\+hex\+\_\+ascii\+\_\+line@{print\+\_\+hex\+\_\+ascii\+\_\+line}!Sniffer@{Sniffer}}
\subsubsection[{print\+\_\+hex\+\_\+ascii\+\_\+line}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::print\+\_\+hex\+\_\+ascii\+\_\+line (
\begin{DoxyParamCaption}
\item[{const u\+\_\+char $\ast$}]{payload, }
\item[{int}]{len, }
\item[{int}]{offset}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [private]}}\label{class_sniffer_a70598d5001a30cc8e801f1262770cdf6}


Imprime la carga en ascii a std output. 


\begin{DoxyParams}{Parámetros}
{\em payload} & carga del paquete \\
\hline
{\em len} & largo de la carga \\
\hline
{\em offset} & distancia \\
\hline
\end{DoxyParams}
\hypertarget{class_sniffer_ac05f935a6ec2830d6bf42b607f071910}{}\index{Sniffer@{Sniffer}!print\+\_\+payload@{print\+\_\+payload}}
\index{print\+\_\+payload@{print\+\_\+payload}!Sniffer@{Sniffer}}
\subsubsection[{print\+\_\+payload}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::print\+\_\+payload (
\begin{DoxyParamCaption}
\item[{const u\+\_\+char $\ast$}]{payload, }
\item[{int}]{len}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [private]}}\label{class_sniffer_ac05f935a6ec2830d6bf42b607f071910}


Imprime la carga en ascii. 


\begin{DoxyParams}{Parámetros}
{\em payload} & carga del paquete \\
\hline
{\em len} & largo de la carga \\
\hline
\end{DoxyParams}
\hypertarget{class_sniffer_ab706811aa2b285e4c0f55491703c105a}{}\index{Sniffer@{Sniffer}!set\+Device@{set\+Device}}
\index{set\+Device@{set\+Device}!Sniffer@{Sniffer}}
\subsubsection[{set\+Device}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::set\+Device (
\begin{DoxyParamCaption}
\item[{string}]{dev}
\end{DoxyParamCaption}
)}\label{class_sniffer_ab706811aa2b285e4c0f55491703c105a}


Ajusta el dispositivo para caputurar paquetes a dev. 


\begin{DoxyParams}{Parámetros}
{\em dev} & nombre del dispositivo \\
\hline
\end{DoxyParams}


La documentación para esta clase fue generada a partir de los siguientes ficheros\+:\begin{DoxyCompactItemize}
\item 
sniffer.\+h\item 
sniffer.\+cpp\end{DoxyCompactItemize}
