DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::utilities Namespace Reference

Classes

class  Named
 A Named is a DAQ object (Queue or DAQModule) which has an instance name. More...
 
class  NamedObject
 Implements the Named interface. More...
 
class  ReusableThread
 
class  TimestampEstimatorBase
 TimestampEstimatorBase is the base class for timestamp-based logic in test systems where the current timestamp must be estimated somehow (eg, because there is no hardware timing system). More...
 
class  TimestampEstimatorSystem
 TimestampEstimatorSystem is an implementation of TimestampEstimatorBase that uses the system clock to give the current timestamp. More...
 
class  TimestampEstimatorTimeSync
 TimestampEstimatorTimeSync is an implementation of TimestampEstimatorBase that uses TimeSync messages from an input queue to estimate the current timestamp. More...
 
struct  ZmqUri
 

Enumerations

enum  { TLVL_TIME_SYNC_PROPERTIES = 17 , TLVL_TIME_SYNC_NOTES = 18 , TLVL_TIME_SYNC_NEW_ESTIMATE = 19 }
 

Functions

std::vector< std::string > get_ips_from_hostname (std::string hostname)
 
std::vector< std::string > resolve_uri_hostname (std::string connection_string)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TLVL_TIME_SYNC_PROPERTIES 
TLVL_TIME_SYNC_NOTES 
TLVL_TIME_SYNC_NEW_ESTIMATE 

Definition at line 24 of file TimestampEstimatorTimeSync.hpp.

Function Documentation

◆ get_ips_from_hostname()

std::vector< std::string > dunedaq::utilities::get_ips_from_hostname ( std::string hostname)

Definition at line 16 of file Resolver.cpp.

17{
18 std::vector<std::string> output;
19
20 TLOG_DEBUG(12) << "Name is " << hostname;
21
22 struct addrinfo* addrinfo = nullptr;
23 auto s = getaddrinfo(hostname.c_str(), nullptr, nullptr, &addrinfo);
24
25 if (s != 0) {
26 ers::error(NameNotFound(ERS_HERE, hostname, std::string(gai_strerror(s))));
27 return output;
28 }
29
30 for (auto rp = addrinfo; rp != nullptr; rp = rp->ai_next) {
31 char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; // NOLINT
32
33 // Let's skip all the IPv6 here
34 if (rp->ai_family == AF_INET6)
35 continue;
36
37 getnameinfo(rp->ai_addr, rp->ai_addrlen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
38 auto ipaddr = std::string(hbuf);
39 bool duplicate = false;
40 for (auto& ip : output) {
41 if (ip == ipaddr) {
42 duplicate = true;
43 break;
44 }
45 }
46 if (!duplicate) {
47 TLOG_DEBUG(13) << "Found address " << ipaddr << " for hostname " << hostname;
48 output.push_back(ipaddr);
49 }
50 }
51
52 freeaddrinfo(addrinfo);
53
54 return output;
55}
#define ERS_HERE
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
NameNotFound
Definition Issues.hpp:24
void error(const Issue &issue)
Definition ers.hpp:81

◆ resolve_uri_hostname()

std::vector< std::string > dunedaq::utilities::resolve_uri_hostname ( std::string connection_string)

Definition at line 58 of file Resolver.cpp.

59{
60 ZmqUri uri(connection_string);
61
62 if (uri.scheme == "tcp") {
63 auto output = get_ips_from_hostname(uri.host);
64
65 for (size_t ii = 0; ii < output.size(); ++ii) {
66 output[ii] = "tcp://" + output[ii] + ":" + uri.port;
67 }
68 return output;
69 } else {
70 return { connection_string };
71 }
72}
std::vector< std::string > get_ips_from_hostname(std::string hostname)
Definition Resolver.cpp:16
Unsupported std::string uri Execution of command std::string error Failed to create CommandFacility uri
Definition Issues.hpp:77