From 5cc11be9e678db693c0e084d105b44277da88d6e Mon Sep 17 00:00:00 2001 From: Luke De Mouy Date: Thu, 7 Jan 2016 16:55:04 -0700 Subject: [PATCH] add the port type to the PortInfo struct --- src/library/portlookup.cpp | 8 +++++++- src/library/portlookup.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/library/portlookup.cpp b/src/library/portlookup.cpp index ecc2b37..b091e65 100644 --- a/src/library/portlookup.cpp +++ b/src/library/portlookup.cpp @@ -22,6 +22,12 @@ PortLookUp::PortInfo PortLookUp::LookUpPort(int portNumber, QString portType) //the port number is valid so set it returnValue.Port = portNumber; + //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; + //Check to see if it's a recommended port returnValue.Recommended = false; for(int i = 0; i < recommendedPortsSize; i++) @@ -35,7 +41,7 @@ PortLookUp::PortInfo PortLookUp::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(QRegExp("/\\b("+QString::number(portNumber)+"\\/"+portType.toLower()+")/g")); + QStringList port = portStrings->filter(QRegExp("/\\b("+QString::number(portNumber)+"\\/"+portType+")/g")); if(port.size() > 0) { diff --git a/src/library/portlookup.h b/src/library/portlookup.h index 91b5d31..b3ebdab 100644 --- a/src/library/portlookup.h +++ b/src/library/portlookup.h @@ -15,6 +15,7 @@ class PortLookUp { struct PortInfo{ int Port; + QString PortType; QString Keyword; QString Description; bool Recommended;