1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-31 20:09:02 +00:00

Use const. New function nmap_getprotbyname()

This commit is contained in:
dmiller
2022-09-16 01:10:18 +00:00
parent 721912c113
commit 6c6d4e33b5
3 changed files with 17 additions and 4 deletions

View File

@@ -181,7 +181,7 @@ int addprotocolsfromservmask(char *mask, u8 *porttbl) {
}
struct nprotoent *nmap_getprotbynum(int num) {
const struct nprotoent *nmap_getprotbynum(int num) {
if (nmap_protocols_init() == -1)
return NULL;
@@ -189,3 +189,15 @@ struct nprotoent *nmap_getprotbynum(int num) {
assert(num >= 0 && num < UCHAR_MAX);
return protocol_table[num];
}
const struct nprotoent *nmap_getprotbyname(const char *name) {
if (nmap_protocols_init() == -1)
return NULL;
ProtoMap::const_iterator it = proto_map.find(name);
if (it != proto_map.end()) {
return &it->second;
}
return NULL;
}