mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 14:11:29 +00:00
Add an n parameter to ServiceProbe::testMatch to enable getting all of
the available matches.
This commit is contained in:
@@ -1175,7 +1175,7 @@ void AllProbes::service_scan_free(void)
|
||||
|
||||
|
||||
// If the buf (of length buflen) matches one of the regexes in this
|
||||
// ServiceProbe, returns the details of the match (service name,
|
||||
// ServiceProbe, returns the details of nth match (service name,
|
||||
// version number if applicable, and whether this is a "soft" match.
|
||||
// If the buf doesn't match, the serviceName field in the structure
|
||||
// will be NULL. The MatchDetails returned is only valid until the
|
||||
@@ -1183,14 +1183,17 @@ void AllProbes::service_scan_free(void)
|
||||
// serviceName field can be saved throughought program execution. If
|
||||
// no version matched, that field will be NULL. This function may
|
||||
// return NULL if there are no match lines at all in this probe.
|
||||
const struct MatchDetails *ServiceProbe::testMatch(const u8 *buf, int buflen) {
|
||||
const struct MatchDetails *ServiceProbe::testMatch(const u8 *buf, int buflen, int n = 0) {
|
||||
vector<ServiceProbeMatch *>::iterator vi;
|
||||
const struct MatchDetails *MD;
|
||||
|
||||
for(vi = matches.begin(); vi != matches.end(); vi++) {
|
||||
MD = (*vi)->testMatch(buf, buflen);
|
||||
if (MD->serviceName)
|
||||
if (MD->serviceName) {
|
||||
if (n == 0)
|
||||
return MD;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -279,7 +279,7 @@ class ServiceProbe {
|
||||
void addMatch(const char *match, int lineno);
|
||||
|
||||
// If the buf (of length buflen) matches one of the regexes in this
|
||||
// ServiceProbe, returns the details of the match (service name,
|
||||
// ServiceProbe, returns the details of the nth match (service name,
|
||||
// version number if applicable, and whether this is a "soft" match.
|
||||
// If the buf doesn't match, the serviceName field in the structure
|
||||
// will be NULL. The MatchDetails returned is only valid until the
|
||||
@@ -287,7 +287,7 @@ class ServiceProbe {
|
||||
// serviceName field can be saved throughought program execution. If
|
||||
// no version matched, that field will be NULL. This function may
|
||||
// return NULL if there are no match lines at all in this probe.
|
||||
const struct MatchDetails *testMatch(const u8 *buf, int buflen);
|
||||
const struct MatchDetails *testMatch(const u8 *buf, int buflen, int n);
|
||||
|
||||
char *fallbackStr;
|
||||
ServiceProbe *fallbacks[MAXFALLBACKS+1];
|
||||
|
||||
Reference in New Issue
Block a user