lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::JungfrauIdLookup Class Reference

Finds the MAC address of a host: first in /proc/net/arp, then by logging in to the device with telnet and reading the eth0 HWaddr from its ifconfig output. More...

#include <JungfrauDetectorId.hh>

Public Member Functions

 JungfrauIdLookup ()
 Construct with an empty cache.
 
 ~JungfrauIdLookup ()
 Does nothing; empty body.
 
bool has (const std::string &hostname)
 Return true if a MAC address is known for the IP address of hostname.
 
const std::string & operator[] (const std::string &hostname)
 Return the cached MAC address for the IP address of hostname; a missing entry is inserted as an empty string.
 

Static Public Member Functions

static std::string host_to_ip (const std::string &hostname)
 Resolve hostname with gethostbyname() and return its first address as a dotted IPv4 string.
 
static uint64_t mac_to_hex (std::string mac)
 Remove the colons from mac and parse the remaining text as a hexadecimal number with strtoul().
 

Detailed Description

Finds the MAC address of a host: first in /proc/net/arp, then by logging in to the device with telnet and reading the eth0 HWaddr from its ifconfig output.

Constructor & Destructor Documentation

◆ JungfrauIdLookup()

Drp::JungfrauIdLookup::JungfrauIdLookup ( )

Construct with an empty cache.

◆ ~JungfrauIdLookup()

Drp::JungfrauIdLookup::~JungfrauIdLookup ( )

Does nothing; empty body.

Member Function Documentation

◆ has()

bool Drp::JungfrauIdLookup::has ( const std::string &  hostname)

Return true if a MAC address is known for the IP address of hostname.

If it is not cached, /proc/net/arp is reloaded, and if still missing the device is queried over telnet (port 23).

◆ host_to_ip()

static std::string Drp::JungfrauIdLookup::host_to_ip ( const std::string &  hostname)
static

Resolve hostname with gethostbyname() and return its first address as a dotted IPv4 string.

A failed lookup is not checked (null pointer dereference).

◆ mac_to_hex()

static uint64_t Drp::JungfrauIdLookup::mac_to_hex ( std::string  mac)
static

Remove the colons from mac and parse the remaining text as a hexadecimal number with strtoul().

◆ operator[]()

const std::string & Drp::JungfrauIdLookup::operator[] ( const std::string &  hostname)

Return the cached MAC address for the IP address of hostname; a missing entry is inserted as an empty string.


The documentation for this class was generated from the following file: