Açıklama Yok

class_sniffer.tex 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. \hypertarget{class_sniffer}{}\section{Referencia de la Clase Sniffer}
  2. \label{class_sniffer}\index{Sniffer@{Sniffer}}
  3. 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).
  4. {\ttfamily \#include $<$sniffer.\+h$>$}
  5. Diagrama de herencias de Sniffer\begin{figure}[H]
  6. \begin{center}
  7. \leavevmode
  8. \includegraphics[height=2.000000cm]{class_sniffer}
  9. \end{center}
  10. \end{figure}
  11. \subsection*{Slots públicos}
  12. \begin{DoxyCompactItemize}
  13. \item
  14. \hypertarget{class_sniffer_a6fc78b66d2f4dce0cc3662dacf171514}{}void \hyperlink{class_sniffer_a6fc78b66d2f4dce0cc3662dacf171514}{process} ()\label{class_sniffer_a6fc78b66d2f4dce0cc3662dacf171514}
  15. \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}
  16. \subsection*{Señales}
  17. \begin{DoxyCompactItemize}
  18. \item
  19. \hypertarget{class_sniffer_a7d0fd40379b7e5f49aff18ac20cb1c45}{}void {\bfseries result\+Ready} (unsigned long index)\label{class_sniffer_a7d0fd40379b7e5f49aff18ac20cb1c45}
  20. \end{DoxyCompactItemize}
  21. \subsection*{Métodos públicos}
  22. \begin{DoxyCompactItemize}
  23. \item
  24. \hypertarget{class_sniffer_a8039cbd5f487a357321d57337a664d3d}{}\hyperlink{class_sniffer_a8039cbd5f487a357321d57337a664d3d}{Sniffer} ()\label{class_sniffer_a8039cbd5f487a357321d57337a664d3d}
  25. \begin{DoxyCompactList}\small\item\em Constructor, no hace nada. \end{DoxyCompactList}\item
  26. \hyperlink{class_sniffer_a8e5f1474f756be527b4c39a3e9a83893}{Sniffer} (Q\+Wait\+Condition $\ast$pw, Q\+Mutex $\ast$mx, int $\ast$ps)
  27. \begin{DoxyCompactList}\small\item\em Ajusta los mutexes para la inter comunicacion entre el sniffer y el G\+U\+I. \end{DoxyCompactList}\item
  28. \hypertarget{class_sniffer_a8ad3b97292e2cc274f31d87701f92be2}{}\hyperlink{class_sniffer_a8ad3b97292e2cc274f31d87701f92be2}{$\sim$\+Sniffer} ()\label{class_sniffer_a8ad3b97292e2cc274f31d87701f92be2}
  29. \begin{DoxyCompactList}\small\item\em Destructor, no hace nada. \end{DoxyCompactList}\item
  30. vector$<$ \hyperlink{classip__packet}{ip\+\_\+packet} $>$ $\ast$ \hyperlink{class_sniffer_a791027d276cfcc5e6849132ecf8e80b6}{get\+Packet\+List} ()
  31. \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
  32. string \hyperlink{class_sniffer_a3dd95c60c5b8554e1bedc22b36ae488c}{format\+\_\+payload} (const char $\ast$payload, int len)
  33. \begin{DoxyCompactList}\small\item\em Formatea la carga de un torrente de bytes a un cadena de caracteres ascii. \end{DoxyCompactList}\item
  34. string \hyperlink{class_sniffer_a02101b56a75804d1ed39a1c04ba36ab2}{format\+\_\+hex\+\_\+ascii\+\_\+line} (const char $\ast$payload, int len, int offset)
  35. \begin{DoxyCompactList}\small\item\em Devuelve una cadena de caracteres con los bytes de una linea de la carga en ascii. \end{DoxyCompactList}\item
  36. void \hyperlink{class_sniffer_a94d7cd87d0f181c3cf2e5ec851e370b6}{find\+\_\+devices} (vector$<$ string $>$ \&)
  37. \begin{DoxyCompactList}\small\item\em Encuentra los dispositivos de red en la computadora, y los almacena en el vector devs. \end{DoxyCompactList}\item
  38. void \hyperlink{class_sniffer_ab706811aa2b285e4c0f55491703c105a}{set\+Device} (string)
  39. \begin{DoxyCompactList}\small\item\em Ajusta el dispositivo para caputurar paquetes a dev. \end{DoxyCompactList}\end{DoxyCompactItemize}
  40. \subsection*{Métodos privados}
  41. \begin{DoxyCompactItemize}
  42. \item
  43. void \hyperlink{class_sniffer_ac05f935a6ec2830d6bf42b607f071910}{print\+\_\+payload} (const u\+\_\+char $\ast$payload, int len)
  44. \begin{DoxyCompactList}\small\item\em Imprime la carga en ascii. \end{DoxyCompactList}\item
  45. void \hyperlink{class_sniffer_a70598d5001a30cc8e801f1262770cdf6}{print\+\_\+hex\+\_\+ascii\+\_\+line} (const u\+\_\+char $\ast$payload, int len, int offset)
  46. \begin{DoxyCompactList}\small\item\em Imprime la carga en ascii a std output. \end{DoxyCompactList}\item
  47. void \hyperlink{class_sniffer_a0179e32fee6a0f7c2a13f37d64a7fae0}{got\+\_\+packet} (const struct pcap\+\_\+pkthdr $\ast$header, const u\+\_\+char $\ast$packet)
  48. \begin{DoxyCompactList}\small\item\em Secciona el paquete recibido. Extrae la informacion necesaria. \end{DoxyCompactList}\end{DoxyCompactItemize}
  49. \subsection*{Atributos privados}
  50. \begin{DoxyCompactItemize}
  51. \item
  52. \hypertarget{class_sniffer_ad3ad83091913a50effd7468d8d7ca590}{}vector$<$ \hyperlink{classip__packet}{ip\+\_\+packet} $>$ {\bfseries packet\+\_\+list}\label{class_sniffer_ad3ad83091913a50effd7468d8d7ca590}
  53. \item
  54. \hypertarget{class_sniffer_a36e1964fbc960b60a09b425a7cd1c0f6}{}Q\+Wait\+Condition $\ast$ {\bfseries wait\+\_\+pause}\label{class_sniffer_a36e1964fbc960b60a09b425a7cd1c0f6}
  55. \item
  56. \hypertarget{class_sniffer_ae0d6a92d2224a8c927afe861d45ab182}{}Q\+Mutex $\ast$ {\bfseries mutex}\label{class_sniffer_ae0d6a92d2224a8c927afe861d45ab182}
  57. \item
  58. \hypertarget{class_sniffer_ac35f2e04e7f7668243a75bd9b9b44028}{}string {\bfseries device}\label{class_sniffer_ac35f2e04e7f7668243a75bd9b9b44028}
  59. \item
  60. \hypertarget{class_sniffer_abb7dd6858499a14bcf002ba86e2d3f7f}{}string {\bfseries filter}\label{class_sniffer_abb7dd6858499a14bcf002ba86e2d3f7f}
  61. \item
  62. \hypertarget{class_sniffer_a2fde6ba65f629b1c74b1fcd1b8d2c022}{}int $\ast$ {\bfseries pause}\label{class_sniffer_a2fde6ba65f629b1c74b1fcd1b8d2c022}
  63. \end{DoxyCompactItemize}
  64. \subsection{Descripción detallada}
  65. 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).
  66. \subsection{Documentación del constructor y destructor}
  67. \hypertarget{class_sniffer_a8e5f1474f756be527b4c39a3e9a83893}{}\index{Sniffer@{Sniffer}!Sniffer@{Sniffer}}
  68. \index{Sniffer@{Sniffer}!Sniffer@{Sniffer}}
  69. \subsubsection[{Sniffer}]{\setlength{\rightskip}{0pt plus 5cm}Sniffer\+::\+Sniffer (
  70. \begin{DoxyParamCaption}
  71. \item[{Q\+Wait\+Condition $\ast$}]{pw, }
  72. \item[{Q\+Mutex $\ast$}]{mx, }
  73. \item[{int $\ast$}]{ps}
  74. \end{DoxyParamCaption}
  75. )}\label{class_sniffer_a8e5f1474f756be527b4c39a3e9a83893}
  76. Ajusta los mutexes para la inter comunicacion entre el sniffer y el G\+U\+I.
  77. \begin{DoxyParams}{Parámetros}
  78. {\em pw} & se usa para pausar la captura de paquetes \\
  79. \hline
  80. {\em mx} & usado para proteger la region critica \\
  81. \hline
  82. {\em ps} & bandera para pausar la captura de paquetes \\
  83. \hline
  84. \end{DoxyParams}
  85. \subsection{Documentación de las funciones miembro}
  86. \hypertarget{class_sniffer_a94d7cd87d0f181c3cf2e5ec851e370b6}{}\index{Sniffer@{Sniffer}!find\+\_\+devices@{find\+\_\+devices}}
  87. \index{find\+\_\+devices@{find\+\_\+devices}!Sniffer@{Sniffer}}
  88. \subsubsection[{find\+\_\+devices}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::find\+\_\+devices (
  89. \begin{DoxyParamCaption}
  90. \item[{vector$<$ string $>$ \&}]{devs}
  91. \end{DoxyParamCaption}
  92. )}\label{class_sniffer_a94d7cd87d0f181c3cf2e5ec851e370b6}
  93. Encuentra los dispositivos de red en la computadora, y los almacena en el vector devs.
  94. \begin{DoxyParams}{Parámetros}
  95. {\em devs} & vector de cadenas de caracteres para los nombres \\
  96. \hline
  97. \end{DoxyParams}
  98. \hypertarget{class_sniffer_a02101b56a75804d1ed39a1c04ba36ab2}{}\index{Sniffer@{Sniffer}!format\+\_\+hex\+\_\+ascii\+\_\+line@{format\+\_\+hex\+\_\+ascii\+\_\+line}}
  99. \index{format\+\_\+hex\+\_\+ascii\+\_\+line@{format\+\_\+hex\+\_\+ascii\+\_\+line}!Sniffer@{Sniffer}}
  100. \subsubsection[{format\+\_\+hex\+\_\+ascii\+\_\+line}]{\setlength{\rightskip}{0pt plus 5cm}string Sniffer\+::format\+\_\+hex\+\_\+ascii\+\_\+line (
  101. \begin{DoxyParamCaption}
  102. \item[{const char $\ast$}]{payload, }
  103. \item[{int}]{len, }
  104. \item[{int}]{offset}
  105. \end{DoxyParamCaption}
  106. )}\label{class_sniffer_a02101b56a75804d1ed39a1c04ba36ab2}
  107. Devuelve una cadena de caracteres con los bytes de una linea de la carga en ascii.
  108. \begin{DoxyParams}{Parámetros}
  109. {\em payload} & carga del paquete \\
  110. \hline
  111. {\em len} & largo del paquete \\
  112. \hline
  113. {\em offset} & distancia del paquete \\
  114. \hline
  115. \end{DoxyParams}
  116. \begin{DoxyReturn}{Devuelve}
  117. a string with the bytes of a payload line in ascii
  118. \end{DoxyReturn}
  119. \hypertarget{class_sniffer_a3dd95c60c5b8554e1bedc22b36ae488c}{}\index{Sniffer@{Sniffer}!format\+\_\+payload@{format\+\_\+payload}}
  120. \index{format\+\_\+payload@{format\+\_\+payload}!Sniffer@{Sniffer}}
  121. \subsubsection[{format\+\_\+payload}]{\setlength{\rightskip}{0pt plus 5cm}string Sniffer\+::format\+\_\+payload (
  122. \begin{DoxyParamCaption}
  123. \item[{const char $\ast$}]{payload, }
  124. \item[{int}]{len}
  125. \end{DoxyParamCaption}
  126. )}\label{class_sniffer_a3dd95c60c5b8554e1bedc22b36ae488c}
  127. Formatea la carga de un torrente de bytes a un cadena de caracteres ascii.
  128. \begin{DoxyParams}{Parámetros}
  129. {\em payload} & carga del paquete \\
  130. \hline
  131. {\em len} & largo del paquete \\
  132. \hline
  133. \end{DoxyParams}
  134. \begin{DoxyReturn}{Devuelve}
  135. la carga en una cadena de caracteres ascii
  136. \end{DoxyReturn}
  137. \hypertarget{class_sniffer_a791027d276cfcc5e6849132ecf8e80b6}{}\index{Sniffer@{Sniffer}!get\+Packet\+List@{get\+Packet\+List}}
  138. \index{get\+Packet\+List@{get\+Packet\+List}!Sniffer@{Sniffer}}
  139. \subsubsection[{get\+Packet\+List}]{\setlength{\rightskip}{0pt plus 5cm}vector$<$ {\bf ip\+\_\+packet} $>$ $\ast$ Sniffer\+::get\+Packet\+List (
  140. \begin{DoxyParamCaption}
  141. {}
  142. \end{DoxyParamCaption}
  143. )}\label{class_sniffer_a791027d276cfcc5e6849132ecf8e80b6}
  144. Devuelve la lista de paquetes que contiene los paquetes que son Ethernet -\/$>$ I\+P -\/$>$ (T\+C\+P$\vert$\+U\+D\+P)
  145. \begin{DoxyReturn}{Devuelve}
  146. vector de paquetes
  147. \end{DoxyReturn}
  148. \hypertarget{class_sniffer_a0179e32fee6a0f7c2a13f37d64a7fae0}{}\index{Sniffer@{Sniffer}!got\+\_\+packet@{got\+\_\+packet}}
  149. \index{got\+\_\+packet@{got\+\_\+packet}!Sniffer@{Sniffer}}
  150. \subsubsection[{got\+\_\+packet}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::got\+\_\+packet (
  151. \begin{DoxyParamCaption}
  152. \item[{const struct pcap\+\_\+pkthdr $\ast$}]{header, }
  153. \item[{const u\+\_\+char $\ast$}]{packet}
  154. \end{DoxyParamCaption}
  155. )\hspace{0.3cm}{\ttfamily [private]}}\label{class_sniffer_a0179e32fee6a0f7c2a13f37d64a7fae0}
  156. Secciona el paquete recibido. Extrae la informacion necesaria.
  157. \begin{DoxyParams}{Parámetros}
  158. {\em pcap\+\_\+pkthdr} & encabezado del paquete de pcap \\
  159. \hline
  160. {\em packet} & paquete recibido \\
  161. \hline
  162. \end{DoxyParams}
  163. \hypertarget{class_sniffer_a70598d5001a30cc8e801f1262770cdf6}{}\index{Sniffer@{Sniffer}!print\+\_\+hex\+\_\+ascii\+\_\+line@{print\+\_\+hex\+\_\+ascii\+\_\+line}}
  164. \index{print\+\_\+hex\+\_\+ascii\+\_\+line@{print\+\_\+hex\+\_\+ascii\+\_\+line}!Sniffer@{Sniffer}}
  165. \subsubsection[{print\+\_\+hex\+\_\+ascii\+\_\+line}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::print\+\_\+hex\+\_\+ascii\+\_\+line (
  166. \begin{DoxyParamCaption}
  167. \item[{const u\+\_\+char $\ast$}]{payload, }
  168. \item[{int}]{len, }
  169. \item[{int}]{offset}
  170. \end{DoxyParamCaption}
  171. )\hspace{0.3cm}{\ttfamily [private]}}\label{class_sniffer_a70598d5001a30cc8e801f1262770cdf6}
  172. Imprime la carga en ascii a std output.
  173. \begin{DoxyParams}{Parámetros}
  174. {\em payload} & carga del paquete \\
  175. \hline
  176. {\em len} & largo de la carga \\
  177. \hline
  178. {\em offset} & distancia \\
  179. \hline
  180. \end{DoxyParams}
  181. \hypertarget{class_sniffer_ac05f935a6ec2830d6bf42b607f071910}{}\index{Sniffer@{Sniffer}!print\+\_\+payload@{print\+\_\+payload}}
  182. \index{print\+\_\+payload@{print\+\_\+payload}!Sniffer@{Sniffer}}
  183. \subsubsection[{print\+\_\+payload}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::print\+\_\+payload (
  184. \begin{DoxyParamCaption}
  185. \item[{const u\+\_\+char $\ast$}]{payload, }
  186. \item[{int}]{len}
  187. \end{DoxyParamCaption}
  188. )\hspace{0.3cm}{\ttfamily [private]}}\label{class_sniffer_ac05f935a6ec2830d6bf42b607f071910}
  189. Imprime la carga en ascii.
  190. \begin{DoxyParams}{Parámetros}
  191. {\em payload} & carga del paquete \\
  192. \hline
  193. {\em len} & largo de la carga \\
  194. \hline
  195. \end{DoxyParams}
  196. \hypertarget{class_sniffer_ab706811aa2b285e4c0f55491703c105a}{}\index{Sniffer@{Sniffer}!set\+Device@{set\+Device}}
  197. \index{set\+Device@{set\+Device}!Sniffer@{Sniffer}}
  198. \subsubsection[{set\+Device}]{\setlength{\rightskip}{0pt plus 5cm}void Sniffer\+::set\+Device (
  199. \begin{DoxyParamCaption}
  200. \item[{string}]{dev}
  201. \end{DoxyParamCaption}
  202. )}\label{class_sniffer_ab706811aa2b285e4c0f55491703c105a}
  203. Ajusta el dispositivo para caputurar paquetes a dev.
  204. \begin{DoxyParams}{Parámetros}
  205. {\em dev} & nombre del dispositivo \\
  206. \hline
  207. \end{DoxyParams}
  208. La documentación para esta clase fue generada a partir de los siguientes ficheros\+:\begin{DoxyCompactItemize}
  209. \item
  210. sniffer.\+h\item
  211. sniffer.\+cpp\end{DoxyCompactItemize}