8#include "daq/slc/readout/IOInfo.h"
19int IOInfo::checkTCP(
IOInfo& info)
21 std::vector<IOInfo> info_v;
22 info_v.push_back(info);
23 int ret = checkTCP(info_v);
28int IOInfo::checkTCP(std::vector<IOInfo>& info)
31 for (
size_t i = 0; i < info.size(); i++) {
33 info[i].setTXQueue(0);
34 info[i].setRXQueue(0);
39 std::string sl, local_address, rem_address, st, queue;
40 std::ifstream fin(
"/proc/net/tcp");
42 while (fin && getline(fin, line)) {
45 ss >> sl >> local_address >> rem_address >> st >> queue;
46 unsigned int addr = strtoul(local_address.substr(0, 8).c_str(), NULL, 16);
47 int port = strtoul(local_address.substr(9).c_str(), NULL, 16);
48 unsigned int raddr = strtoul(rem_address.substr(0, 8).c_str(), NULL, 16);
49 int rport = strtoul(rem_address.substr(9).c_str(), NULL, 16);
50 for (
size_t i = 0; i < info.size(); i++) {
51 if (info[i].getState() > 0)
continue;
52 int sti = strtoul(st.c_str(), NULL, 16);
54 port == info[i].getLocalPort() && sti == 1) {
55 info[i].setRemoteAddress(raddr);
56 info[i].setRemotePort(rport);
57 info[i].setState(sti);
58 info[i].setTXQueue(strtoul(queue.substr(0, 8).c_str(), NULL, 16));
59 info[i].setRXQueue(strtoul(queue.substr(9).c_str(), NULL, 16));
61 }
else if (raddr == info[i].getRemoteAddress() &&
62 rport == info[i].getRemotePort() && sti == 1) {
63 info[i].setLocalAddress(addr);
64 info[i].setLocalPort(port);
65 info[i].setState(sti);
66 info[i].setTXQueue(strtoul(queue.substr(0, 8).c_str(), NULL, 16));
67 info[i].setRXQueue(strtoul(queue.substr(9).c_str(), NULL, 16));
70 if (count == info.size())
return count;
76const char* IOInfo::getLocalIP()
const
79 addr.sin_addr.s_addr = m_local_addr;
80 return inet_ntoa(addr.sin_addr);
83const char* IOInfo::getRemoteIP()
const
86 addr.sin_addr.s_addr = m_remote_addr;
87 return inet_ntoa(addr.sin_addr);
Abstract base class for different kinds of events.