98{
100 if (netCon) {
101 TLOG_DEBUG(45) <<
"Getting URI for network connection " << netCon->
UID();
103 if (service->get_protocol() == "tcp") {
104
105 std::string port = "*";
106 if (service->get_port() && service->get_port() != 0) {
107 port = std::to_string(service->get_port());
108 }
109 std::string ipaddr = "0.0.0.0";
110 char hostname[256];
111 if (gethostname(&hostname[0], 256) == 0) {
112 ipaddr = std::string(hostname);
113 }
114 auto iface = service->get_eth_device_name();
115 if (iface != "") {
116
117 struct ifaddrs* ifaddr;
118 getifaddrs(&ifaddr);
119 for (auto ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
120 if (ifa->ifa_addr == NULL) {
121 continue;
122 }
123 if (std::string(ifa->ifa_name) == iface) {
124 char ip[NI_MAXHOST];
126 getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), ip, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
127 if (status != 0) {
128 continue;
129 }
130 ipaddr = std::string(ip);
131 break;
132 }
133 }
134 freeifaddrs(ifaddr);
135 }
136 uri = std::string(service->get_protocol() +
"://" + ipaddr +
":" + port);
137 } else if (service->get_protocol() == "inproc") {
138 uri = std::string(service->get_protocol() +
"://" + service->get_path());
139 }
140 }
142}
const std::string & UID() const noexcept
const dunedaq::confmodel::Service * get_associated_service() const
Get "associated_service" relationship value. Service provided by this connection.
#define TLOG_DEBUG(lvl,...)
Unsupported std::string uri Execution of command std::string error Failed to create CommandFacility uri