msg/msg_types: add a default_type param to entity_addr_t::parse()

so it can be used in more places.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2021-04-05 10:49:22 +08:00
parent 7fb0569ec3
commit b9e72ffe3a
3 changed files with 4 additions and 4 deletions

View File

@ -660,7 +660,7 @@ int MonMap::init_with_config_file(const ConfigProxy& conf,
// there on a weird port is a v1 address, and do not handle
// addrvecs.
entity_addr_t addr;
if (!addr.parse(val.c_str(), nullptr, entity_addr_t::TYPE_LEGACY)) {
if (!addr.parse(val, entity_addr_t::TYPE_LEGACY)) {
errout << "unable to parse address for mon." << mon_name
<< ": addr='" << val << "'" << std::endl;
continue;

View File

@ -96,11 +96,11 @@ void entity_inst_t::generate_test_instances(std::list<entity_inst_t*>& o)
o.push_back(a);
}
bool entity_addr_t::parse(const std::string_view s)
bool entity_addr_t::parse(const std::string_view s, int default_type)
{
const char* start = s.data();
const char* end = nullptr;
bool got = parse(start, &end);
bool got = parse(start, &end, default_type);
return got && end == start + s.size();
}

View File

@ -407,7 +407,7 @@ struct entity_addr_t {
return ss.str();
}
bool parse(const std::string_view s);
bool parse(const std::string_view s, int default_type=TYPE_DEFAULT);
bool parse(const char *s, const char **end = 0, int type=0);
void decode_legacy_addr_after_marker(ceph::buffer::list::const_iterator& bl)