From 4645d2fa200841c6834def4dae72bd34fc4567a0 Mon Sep 17 00:00:00 2001 From: Luke De Mouy Date: Mon, 11 Jan 2016 19:38:42 -0700 Subject: [PATCH] rename PortType to Type, and simply the argument names from functions from portType and portNumber to type and number respectively --- src/library/sysadm-firewall.cpp | 20 ++++++++++---------- src/library/sysadm-firewall.h | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/library/sysadm-firewall.cpp b/src/library/sysadm-firewall.cpp index e1a2213..c519193 100644 --- a/src/library/sysadm-firewall.cpp +++ b/src/library/sysadm-firewall.cpp @@ -10,10 +10,10 @@ #include using namespace sysadm; -PortInfo Firewall::LookUpPort(int portNumber, QString portType) +PortInfo Firewall::LookUpPort(int port, QString type) { //Make sure that the port is valid - if (portNumber < 0 || portNumber > 65535) + if (port < 0 || port > 65535) { PortInfo returnValue; returnValue.Port = -1; @@ -28,19 +28,19 @@ PortInfo Firewall::LookUpPort(int portNumber, QString portType) PortInfo returnValue; //the port number is valid so set it - returnValue.Port = portNumber; + returnValue.Port = port; //make sure that the portType is cased in lower to match the service file and //then store it in the returnValue, since there isn't a huge point in checking //the validitiy of the type since /etc/services lists more than udp/tcp - portType = portType.toLower(); - returnValue.PortType = portType; + type = type.toLower(); + returnValue.Type = type; //Check to see if it's a recommended port returnValue.Recommended = false; for(int i = 0; i < recommendedPortsSize; i++) { - if (portNumber == recommendedPorts[i]) + if (port == recommendedPorts[i]) { returnValue.Recommended = true; } @@ -49,12 +49,12 @@ PortInfo Firewall::LookUpPort(int portNumber, QString portType) //Check to see if the port number is listed. The format in the file // is portname/portType. ex.: 22/tcp - QStringList port = portStrings->filter(QString::number(portNumber) + "/" + portType); - if(port.size() > 0) + QStringList portList = portStrings->filter(QString::number(port) + "/" + type); + if(portList.size() > 0) { //grab the first one, there may be duplicates due to colliding ports in the /etc/services file //but those are listed after the declaration for what the port officially should be used for - QString line = port.at(0); + QString line = portList.at(0); //Split across spaces since it's whitespace delimited QStringList lineList = line.split(' '); @@ -196,7 +196,7 @@ void Firewall::SaveOpenPorts() QStringList fileout; for(int i=0; i(const PortInfo lhs, const PortInfo rhs) { return rhs < lhs;} friend bool operator==(const PortInfo lhs, const PortInfo rhs) { - return lhs.Port == rhs.Port && lhs.PortType == rhs.PortType; + return lhs.Port == rhs.Port && lhs.Type == rhs.Type; } friend bool operator !=(const PortInfo lhs, const PortInfo rhs) { return !(lhs == rhs);} @@ -40,25 +40,25 @@ public: * including its port type, keyword, description, and whether it's a * recommended port * - * @param portNumber a port number between 0 and 2^16 - 1 - * @param portType specify whether the port is tdp, udp, etc + * @param number a port number between 0 and 2^16 - 1 + * @param type specify whether the port is tdp, udp, etc * * @ErrorConditions Port Number is set to -1 and a description of the error is stored in the description variable */ - PortInfo LookUpPort(int portNumber, QString portType); + PortInfo LookUpPort(int number, QString type); /** * @brief Opens a port - * @param portNumber a port number between 0 and 2^16 -1 - * @param portType specify whether the port is tdp, udp, etc + * @param number a port number between 0 and 2^16 -1 + * @param type specify whether the port is tdp, udp, etc */ - void OpenPort(int portNumber, QString portType); + void OpenPort(int number, QString type); /** * @brief ClosePort closes a port - * @param portNumber a port number between 0 and 2^16 -1 - * @param portType specify whether the port is tdp, udp, etc + * @param number a port number between 0 and 2^16 -1 + * @param type specify whether the port is tdp, udp, etc */ - void ClosePort(int portNumber, QString portType); + void ClosePort(int number, QString type); /** * @brief finds a list of ports that are open gets the info about them