123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- #include "packet.h"
-
-
- /// \fn Packet::Packet()
- /// \~English
- /// \brief Default constructor. The properties of the packet are set as follows:
- /// * src_addr: set to the empty string.
- /// * dst_addr: set to the empty string.
- /// * src_port: set to 0.
- /// * dst_port: set to 0.
- /// * octects: set to 0.
- /// * packets: set to 0.
- /// * enabled: set to false.
- /// \~Spanish
- /// \brief Constructor por defecto. Las propiedades del paquete se ajustan como sigue:
- /// * src_addr: a una cadena vacia.
- /// * dst_addr: a una cadena vacia.
- /// * src_port: a 0.
- /// * dst_port: a 0.
- /// * octects: a 0.
- /// * packets: a 0.
- /// * enabled: a falso.
- Packet::Packet(){
- src_addr = "" ;
- dst_addr = "" ;
- src_port = 0 ;
- dst_port = 0 ;
- octects = 0 ;
- packets = 0 ;
- enabled = false ;
- }
-
- /// \fn Packet::Packet(string sa, string da, int sp, int dp, int oct, int pkt)
- /// \~English
- /// \brief Constructor which accepts specification for sa(src_addr),
- /// da(dst_addr), sp(src_port), dp(dst_port), oct(octects) and
- /// pkt(packets)
- /// \param sa source address
- /// \param da destination address
- /// \param sp source port
- /// \param dp destination port
- /// \param oct octects
- /// \param pkt packets
- /// \~Spanish
- /// \brief Constructor que acepta especificaciones para sa(src_addr),
- /// da(dst_addr), sp(src_port), dp(dst_port), oct(octects) y
- /// pkt(packets)
- /// \param sa direccion fuente
- /// \param da direccion destino
- /// \param sp puerto fuente
- /// \param dp puerto destino
- /// \param oct octetos
- /// \param pkt paquetes
- Packet::Packet(string sa, string da, int sp, int dp, int oct, int pkt){
- src_addr = sa ;
- dst_addr = da ;
- src_port = sp ;
- dst_port = dp ;
- octects = oct ;
- packets = pkt ;
- enabled = true ;
- }
-
- /// \fn string Packet::getSrcAddr()
- /// \~English
- /// \brief Getter for the source addr
- /// \return src address
- /// \~Spanish
- /// \brief Devuelve la direccion fuente
- /// \return direccion fuente
- string Packet::getSrcAddr(){
- return src_addr ;
- }
-
- /// \fn string Packet::getDstAddr()
- /// \~English
- /// \brief Getter for the destination addr
- /// \return dst address
- /// \~Spanish
- /// \brief Devuelve la direccion destino
- /// \return direccion destino
- string Packet::getDstAddr(){
- return dst_addr ;
- }
-
- /// \fn string Packet::getSrcPort()
- /// \~English
- /// \brief Getter for the source port
- /// \return src port
- /// \~Spanish
- /// \brief Devuelve el puerto fuente
- /// \return puerto fuente
- int Packet::getSrcPort(){
- return src_port ;
- }
-
- /// \fn string Packet::getDstPort()
- /// \~English
- /// \brief Getter for the destination port
- /// \return dst port
- /// \~Spanish
- /// \brief Devuelve el puerto destino
- /// \return puerto destino
- int Packet::getDstPort(){
- return dst_port ;
- }
-
- /// \fn string Packet::getOctets()
- /// \~English
- /// \brief Getter for the octets
- /// \return octets
- /// \~Spanish
- /// \brief Devuelve los octetos
- /// \return octetos
- int Packet::getOctects(){
- return octects ;
- }
-
- /// \fn string Packet::getPackets()
- /// \~English
- /// \brief Getter for the packets
- /// \return packets
- /// \~Spanish
- /// \brief Devuelve los paquetes
- /// \return paquetes
- int Packet::getPackets(){
- return packets ;
- }
-
- /// \fn void Packet::setSrcAddr(string addr){
- /// \~English
- /// \brief Setter for the src_addr
- /// \param addr source address
- /// \~Spanish
- /// \brief Ajusta la direccion fuente
- /// \param addr direccion fuente
- void Packet::setSrcAddr(string addr){
- src_addr = addr ;
- }
-
- /// \fn void Packet::setDstAddr(string addr){
- /// \~English
- /// \brief Setter for the destination addr
- /// \param addr destination address
- /// \~Spanish
- /// \brief Ajusta la direccion destino
- /// \param addr direccion destino
- void Packet::setDstAddr(string addr){
- dst_addr = addr ;
- }
-
- /// \fn void Packet::setSrcPort(int port){
- /// \~English
- /// \brief Setter for the source port
- /// \param port source port
- /// \~Spanish
- /// \brief Ajusta el puerto fuente
- /// \param port puerto fuente
- void Packet::setSrcPort(int port){
- src_port = port ;
- }
-
- /// \fn void Packet::setDstPort(int port){
- /// \~English
- /// \brief Setter for the destination port
- /// \param port destination port
- /// \~Spanish
- /// \brief Ajusta el puerto destino
- /// \param port puerto destino
- void Packet::setDstPort(int port){
- if(port < 0)
- port = 0 ;
- else
- dst_port = port ;
- }
-
- /// \fn void Packet::setOctetes(int val){
- /// \~English
- /// \brief Setter for the octects value
- /// \param val octects
- /// \~Spanish
- /// \brief Ajusta el valor de los octetos
- /// \param val octetos
- void Packet::setOctects(int val){
- if(val < 0)
- octects = 0 ;
- else
- octects = val ;
- }
-
- /// \fn void Packet::setPackets(int val){
- /// \~English
- /// \brief Setter for the packets value
- /// \param val packets
- /// \~Spanish
- /// \brief Ajusta el valor de los paquetes
- /// \param val paquetes
- void Packet::setPackets(int val){
- if(val < 0)
- packets = 0 ;
- else
- packets = val ;
- }
-
- /// \fn void Packet::enable(){
- /// \~English
- /// \brief Sets that the packet is enabled to be displayed in GUI
- /// \~Spanish
- /// \brief Ajusta que el paquete esta disponible para ser desplegado en la inter
- /// fase de usuario
- void Packet::enable(){
- enabled = true ;
- }
-
- /// \fn void Packet::disable(){
- /// \~English
- /// \brief Sets that the packet is disabled to be displayed in GUI
- /// \~Spanish
- /// \brief Ajusta que el paquete no esta disponible para ser desplegado en la inter
- /// fase de usuario
- void Packet::disable(){
- enabled = false ;
- }
-
- /// \fn void Packet::isEnable(){
- /// \~English
- /// \brief Returns true if the packet is enabled, false otherwise
- /// \return true (enable) or false
- /// \~Spanish
- /// \brief Devuelve cierto si el paquete esta disponible, falso de lo contrario
- bool Packet::isEnabled(){
- return enabled ;
- }
|