]>
git.proxmox.com Git - ceph.git/blob - ceph/src/common/address_helper.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 * Created on: Oct 27, 2013
13 #include "common/address_helper.h"
15 // decode strings like "tcp://<host>:<port>"
16 int entity_addr_from_url(entity_addr_t
*addr
/* out */, const char *url
)
18 std::regex
expr("(tcp|rdma)://([^:]*):([\\d]+)");
21 if (std::regex_match(url
, m
, expr
)) {
22 string
host(m
[2].first
, m
[2].second
);
23 string
port(m
[3].first
, m
[3].second
);
25 // FIPS zeroization audit 20191115: this memset is fine.
26 memset(&hints
, 0, sizeof(hints
));
27 hints
.ai_family
= PF_UNSPEC
;
29 if (!getaddrinfo(host
.c_str(), nullptr, &hints
, &res
)) {
30 addr
->set_sockaddr((sockaddr
*)res
->ai_addr
);
31 addr
->set_port(std::atoi(port
.c_str()));