No Description

mainwindow.h 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <QtGui>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <QComboBox>
  8. #include <QMenuBar>
  9. #include <QLabel>
  10. #include <QTableWidget>
  11. #include <QCheckBox>
  12. #include <QLineEdit>
  13. #include <QFileDialog>
  14. #include <QMessageBox>
  15. #include <QApplication>
  16. #include "packet.h"
  17. using namespace std;
  18. namespace Ui {
  19. class MainWindow;
  20. }
  21. /// \fn bool ReadFile(string fname, vector<Packet> & netdata)
  22. /// \~English
  23. /// \brief Function that reads a file and return a boolean
  24. /// that determines if the file was succesfully opened and read or not.
  25. /// \param fname String that contains the filename of the file.
  26. /// \param netdata Vector of packets.
  27. /// \return true if successfuly read a file, false otherwise
  28. /// \~Spanish
  29. /// \brief Funcion que lee un archivo y devuelve un booleano que determina
  30. /// si el archivo abrio y se leyo con exito o no.
  31. /// \param fname Cadena de caracteres que contiene el nombre del archivo.
  32. /// \param netdata Vector de paquetes.
  33. /// \return cierto si leyo el archivo con exito, false de lo contrario
  34. bool ReadFile(string, vector<Packet> &) ;
  35. /// \fn bool SaveFile(string fname, vector<Packet> & netdata)
  36. /// \~English
  37. /// \brief Function that saves a file to the computer.
  38. /// It returns true when the file was succesfully saved and false
  39. /// if an error occurred.
  40. /// \param fname String that contains the filename of the file.
  41. /// \param netdata Vector of packets.
  42. /// \return true if successfuly read a file, false otherwise
  43. /// \~Spanish
  44. /// \brief Funcion que guarda un archivo en la computadora.
  45. /// Devuelve cierto cuando el archivo se guardo con exito y falso si
  46. /// ocurre error
  47. /// \param fname Cadena de caracteres que contiene el nombre del archivo.
  48. /// \param netdata Vector de paquetes.
  49. /// \return cierto si guardo el archivo con exito, false de lo contrario
  50. bool SaveFile(string, vector<Packet>) ;
  51. /// \fn void FilterBySrcAddr(vector<Packet> &netdata, string address)
  52. /// \~English
  53. /// Function that filters the packets in the netflow by the source address
  54. /// \param netdata packets vector
  55. /// \param address key address to filter
  56. /// \~Spanish
  57. /// Funcion que filtra los paquetes en el flujo de red por la direccion fuente
  58. /// \param netdata vector de paquetes
  59. /// \param address direccion llave para el fitro
  60. void FilterBySrcAddr(vector<Packet> &, string );
  61. /// \fn void FilterByDstAddr(vector<Packet> &netdata, string address)
  62. /// \~English
  63. /// Function that filters the packets in the netflow by the destination address
  64. /// \param netdata packets vector
  65. /// \param address key address to filter
  66. /// \~Spanish
  67. /// Funcion que filtra los paquetes en el flujo de red por la direccion destino
  68. /// \param netdata vector de paquetes
  69. /// \param address direccion llave para el fitro
  70. void FilterByDstAddr(vector<Packet> &, string );
  71. /// \fn void FilterBySrcPort(vector<Packet> &netdata, string port)
  72. /// \~English
  73. /// Function that filters the packets in the netflow by the source port
  74. /// \param netdata packets vector
  75. /// \param port key port to filter
  76. /// \~Spanish
  77. /// Funcion que filtra los paquetes en el flujo de red por el puerto fuente
  78. /// \param netdata vector de paquetes
  79. /// \param port puerto llave para el fitro
  80. void FilterBySrcPort(vector<Packet> &, int) ;
  81. /// \fn void FilterByDstPort(vector<Packet> &netdata, string port)
  82. /// \~English
  83. /// Function that filters the packets in the netflow by the destination port
  84. /// \param netdata packets vector
  85. /// \param port key port to filter
  86. /// \~Spanish
  87. /// Funcion que filtra los paquetes en el flujo de red por el puerto destino
  88. /// \param netdata vector de paquetes
  89. /// \param port puerto llave para el fitro
  90. void FilterByDstPort(vector<Packet> &, int) ;
  91. /// \fn void SortBySrcAddr(vector<Packet> &netdata)
  92. /// \~English
  93. /// \brief Function that sorts by source address
  94. /// the packets in the netflow file using the Bubble sort algorithm.
  95. /// \param netdata Packet vector that will be sorted.
  96. /// \~Spanish
  97. /// \brief Function que ordena por direccion fuente
  98. /// los paquetes en el archivo de netflows usando el algoritmo de Bubble sort (Burbuja).
  99. /// \param netdata Vector de paquetes a ser ordenado.
  100. void SortBySrcAddr(vector<Packet> &) ;
  101. /// \fn void SortByDstAddr(vector<Packet> &netdata)
  102. /// \~English
  103. /// \brief Function that sorts by destination address
  104. /// the packets in the netflow file using the Selection sort algorithm.
  105. /// \param netdata Packet vector that will be sorted.
  106. /// \~Spanish
  107. /// \brief Function que ordena por direccion destino
  108. /// los paquetes en el archivo de netflows usando el algoritmo de Selection sort (Seleccion).
  109. /// \param netdata Vector de paquetes a ser ordenado.
  110. void SortByDstAddr(vector<Packet> &) ;
  111. /// \fn void SortBySrcPort(vector<Packet> &netdata)
  112. /// \~English
  113. /// \brief Function that sorts by source port
  114. /// the packets in the netflow file using the Bubble sort algorithm.
  115. /// \param netdata Packet vector that will be sorted.
  116. /// \~Spanish
  117. /// \brief Function que ordena por puerto fuente
  118. /// los paquetes en el archivo de netflows usando el algoritmo de Selection sort (Burbuja).
  119. /// \param netdata Vector de paquetes a ser ordenado.
  120. void SortBySrcPort(vector<Packet> &) ;
  121. /// \fn void SortByDstPort(vector<Packet> &netdata)
  122. /// \~English
  123. /// \brief Function that sorts by destination port
  124. /// the packets in the netflow file using the Bubble sort algorithm.
  125. /// \param netdata Packet vector that will be sorted.
  126. /// \~Spanish
  127. /// \brief Function que ordena por puerto destino
  128. /// los paquetes en el archivo de netflows usando el algoritmo de Bubble sort (Burbuja).
  129. /// \param netdata Vector de paquetes a ser ordenado.
  130. void SortByDstPort(vector<Packet> &) ;
  131. class MainWindow : public QMainWindow
  132. {
  133. Q_OBJECT
  134. private:
  135. int numPackets, numOctects;
  136. int filterMethod;
  137. vector< Packet > netdata; // Used to store the data from the network file
  138. QTableWidgetItem *item; //This pointer is used to create table entries and add them to the table
  139. public:
  140. /// \fn MainWindow::MainWindow()
  141. /// \~English
  142. /// \brief Constructor
  143. /// \~Spanish
  144. /// \brief Constructor
  145. explicit MainWindow(QWidget *parent = 0);
  146. /// \fn MainWindow::~MainWindow()
  147. /// \~English
  148. /// \brief Destructor
  149. /// \~Spanish
  150. /// \brief Destructor
  151. ~MainWindow();
  152. private slots:
  153. /// \fn void MainWindow::on_Filter_Box_currentIndexChanged(int index)
  154. /// \~English
  155. /// \brief Changes the ID of the filtering function chosen by the user
  156. /// \~Spanish
  157. /// \brief Cambia el ID de la funcion de filtro escogida por el usaurio
  158. void on_Filter_Box_currentIndexChanged(int index); //
  159. /// \fn void MainWindow::on_actionLoad_Network_Data_triggered()
  160. /// \~English
  161. /// \brief Loads a network flow file into the GUI.
  162. /// \~Spanish
  163. /// \brief Carga un archivo de fluidos de red a la inteface de usuario.
  164. void on_actionLoad_Network_Data_triggered(); //
  165. /// \fn void MainWindow::on_actionAbout_triggered()
  166. /// \~English
  167. /// \brief Displays a short about of the app
  168. /// \~Spanish
  169. /// \brief Despliega un sobre corto de la aplicacion
  170. void on_actionAbout_triggered(); //
  171. /// \fn void MainWindow::on_actionExit_triggered()
  172. /// \~English
  173. /// \brief Exits the app
  174. /// \~Spanish
  175. /// \brief Sale de la aplicacion
  176. void on_actionExit_triggered();
  177. /// \fn void MainWindow::FillTable()
  178. /// \~English
  179. /// \brief Refresh the GUI packet list.
  180. /// \~Spanish
  181. /// \brief Rellena la lista de paquetes de la interface de usuarios.
  182. void FillTable();
  183. /// \fn void MainWindow::on_runFilter_clicked()
  184. /// \~English
  185. /// \brief Invokes a filtering funtion that filter by the field chosen by the user.
  186. /// \~Spanish
  187. /// \brief Invoca una funcion de filtrar por el campo escogido por el usuario.
  188. void on_runFilter_clicked();
  189. /// \fn void MainWindow::on_sortButton_clicked()
  190. /// \~English
  191. /// \brief Invokes a sorting funtion that sorts by the field chosen by the user.
  192. /// \~Spanish
  193. /// \brief Invoca una funcion de ordenar por el campo escogido por el usuario.
  194. void on_sortButton_clicked();
  195. /// \fn void MainWindow::on_openFile_clicked()
  196. /// \~English
  197. /// \brief Open a file network flow packets.
  198. /// \~Spanish
  199. /// \brief Abre un archivo con paquetes de fluidos de red.
  200. void on_openFile_clicked();
  201. /// \fn void MainWindow::on_saveFile_clicked()
  202. /// \~English
  203. /// \brief Saves the network packets as appears in the window.
  204. /// \~Spanish
  205. /// \brief Guarda los paquetes de network como aparecen en la pantalla.
  206. void on_saveFile_clicked();
  207. /// \fn void MainWindow::on_clearButton_clicked()
  208. /// \~English
  209. /// \brief Removes any applied filter to the list of packets.
  210. /// \~Spanish
  211. /// \brief Remueve cualquier filtro aplicado a la lista de paquetes.
  212. void on_clearButton_clicked();
  213. private:
  214. Ui::MainWindow *ui;
  215. };
  216. #endif // MAINWINDOW_H