No Description

packet.cpp 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. #include "packet.h"
  2. /// \fn Packet::Packet()
  3. /// \~English
  4. /// \brief Default constructor. The properties of the packet are set as follows:
  5. /// * src_addr: set to the empty string.
  6. /// * dst_addr: set to the empty string.
  7. /// * src_port: set to 0.
  8. /// * dst_port: set to 0.
  9. /// * octects: set to 0.
  10. /// * packets: set to 0.
  11. /// * enabled: set to false.
  12. /// \~Spanish
  13. /// \brief Constructor por defecto. Las propiedades de el paquete se ajustan como sigue:
  14. /// * src_addr: a una cadena vacia.
  15. /// * dst_addr: a una cadena vacia.
  16. /// * src_port: a 0.
  17. /// * dst_port: a 0.
  18. /// * octects: a 0.
  19. /// * packets: a 0.
  20. /// * enabled: a falso.
  21. Packet::Packet(){
  22. src_addr = "" ;
  23. dst_addr = "" ;
  24. src_port = 0 ;
  25. dst_port = 0 ;
  26. octects = 0 ;
  27. packets = 0 ;
  28. enabled = false ;
  29. }
  30. /// \fn Packet::Packet(string sa, string da, int sp, int dp, int oct, int pkt)
  31. /// \~English
  32. /// \brief Constructor which accepts specification for sa(src_addr),
  33. /// da(dst_addr), sp(src_port), dp(dst_port), oct(octects) and
  34. /// pkt(packets)
  35. /// \param sa source address
  36. /// \param da destination address
  37. /// \param sp source port
  38. /// \param dp destination port
  39. /// \param oct octects
  40. /// \param pkt packets
  41. /// \~Spanish
  42. /// \brief Constructor que acepta especificaciones para sa(src_addr),
  43. /// da(dst_addr), sp(src_port), dp(dst_port), oct(octects) y
  44. /// pkt(packets)
  45. /// \param sa direccion fuente
  46. /// \param da direccion destino
  47. /// \param sp puerto fuente
  48. /// \param dp puerto destino
  49. /// \param oct octetos
  50. /// \param pkt paquetes
  51. Packet::Packet(string sa, string da, int sp, int dp, int oct, int pkt){
  52. src_addr = sa ;
  53. dst_addr = da ;
  54. src_port = sp ;
  55. dst_port = dp ;
  56. octects = oct ;
  57. packets = pkt ;
  58. enabled = true ;
  59. }
  60. /// \fn string Packet::getSrcAddr()
  61. /// \~English
  62. /// \brief Getter for the source addr
  63. /// \return src address
  64. /// \~Spanish
  65. /// \brief Devuelve la direccion fuente
  66. /// \return direccion fuente
  67. string Packet::getSrcAddr(){
  68. return src_addr ;
  69. }
  70. /// \fn string Packet::getDstAddr()
  71. /// \~English
  72. /// \brief Getter for the destination addr
  73. /// \return dst address
  74. /// \~Spanish
  75. /// \brief Devuelve la direccion destino
  76. /// \return direccion destino
  77. string Packet::getDstAddr(){
  78. return dst_addr ;
  79. }
  80. /// \fn string Packet::getSrcPort()
  81. /// \~English
  82. /// \brief Getter for the source port
  83. /// \return src port
  84. /// \~Spanish
  85. /// \brief Devuelve el puerto fuente
  86. /// \return puerto fuente
  87. int Packet::getSrcPort(){
  88. return src_port ;
  89. }
  90. /// \fn string Packet::getDstPort()
  91. /// \~English
  92. /// \brief Getter for the destination port
  93. /// \return dst port
  94. /// \~Spanish
  95. /// \brief Devuelve la puerto destino
  96. /// \return puerto destino
  97. int Packet::getDstPort(){
  98. return dst_port ;
  99. }
  100. /// \fn string Packet::getOctets()
  101. /// \~English
  102. /// \brief Getter for the octets
  103. /// \return octets
  104. /// \~Spanish
  105. /// \brief Devuelve los octetos
  106. /// \return octetos
  107. int Packet::getOctects(){
  108. return octects ;
  109. }
  110. /// \fn string Packet::getPackets()
  111. /// \~English
  112. /// \brief Getter for the packets
  113. /// \return packets
  114. /// \~Spanish
  115. /// \brief Devuelve los paquetes
  116. /// \return paquetes
  117. int Packet::getPackets(){
  118. return packets ;
  119. }
  120. /// \fn void Packet::setSrcAddr(string addr){
  121. /// \~English
  122. /// \brief Setter for the src_addr
  123. /// \param addr source address
  124. /// \~Spanish
  125. /// \brief Ajusta la direccion fuente
  126. /// \param addr direccion fuente
  127. void Packet::setSrcAddr(string addr){
  128. src_addr = addr ;
  129. }
  130. /// \fn void Packet::setDstAddr(string addr){
  131. /// \~English
  132. /// \brief Setter for the destination addr
  133. /// \param addr destination address
  134. /// \~Spanish
  135. /// \brief Ajusta la direccion destino
  136. /// \param addr direccion destino
  137. void Packet::setDstAddr(string addr){
  138. dst_addr = addr ;
  139. }
  140. /// \fn void Packet::setSrcPort(int port){
  141. /// \~English
  142. /// \brief Setter for the source port
  143. /// \param port source port
  144. /// \~Spanish
  145. /// \brief Ajusta el puerto fuente
  146. /// \param port puerto fuente
  147. void Packet::setSrcPort(int port){
  148. src_port = port ;
  149. }
  150. /// \fn void Packet::setDstPort(int port){
  151. /// \~English
  152. /// \brief Setter for the destination port
  153. /// \param port destination port
  154. /// \~Spanish
  155. /// \brief Ajusta el puerto destino
  156. /// \param port puerto destino
  157. void Packet::setDstPort(int port){
  158. if(port < 0)
  159. port = 0 ;
  160. else
  161. dst_port = port ;
  162. }
  163. /// \fn void Packet::setOctetes(int val){
  164. /// \~English
  165. /// \brief Setter for the octects value
  166. /// \param val octects
  167. /// \~Spanish
  168. /// \brief Ajusta el valor de los octetos
  169. /// \param val octetos
  170. void Packet::setOctects(int val){
  171. if(val < 0)
  172. octects = 0 ;
  173. else
  174. octects = val ;
  175. }
  176. /// \fn void Packet::setPackets(int val){
  177. /// \~English
  178. /// \brief Setter for the packets value
  179. /// \param val packets
  180. /// \~Spanish
  181. /// \brief Ajusta el valor de los paquetes
  182. /// \param val paquetes
  183. void Packet::setPackets(int val){
  184. if(val < 0)
  185. packets = 0 ;
  186. else
  187. packets = val ;
  188. }
  189. /// \fn void Packet::enable(){
  190. /// \~English
  191. /// \brief Sets that the packet is enabled to be displayed in GUI
  192. /// \~Spanish
  193. /// \brief Ajusta que el paquete esta disponible para ser desplegado en la inter
  194. /// fase de usuario
  195. void Packet::enable(){
  196. enabled = true ;
  197. }
  198. /// \fn void Packet::disable(){
  199. /// \~English
  200. /// \brief Sets that the packet is disabled to be displayed in GUI
  201. /// \~Spanish
  202. /// \brief Ajusta que el paquete no esta disponible para ser desplegado en la inter
  203. /// fase de usuario
  204. void Packet::disable(){
  205. enabled = false ;
  206. }
  207. /// \fn void Packet::isEnable(){
  208. /// \~English
  209. /// \brief Returns true if the packet is enabled, false otherwise
  210. /// \return true (enable) or false
  211. /// \~Spanish
  212. /// \brief Devuelve cierto si el paquete esta disponible, falso de lo contrario
  213. bool Packet::isEnabled(){
  214. return enabled ;
  215. }