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:
14
protocols.cc
14
protocols.cc
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user