| 179 | } |
| 180 | |
| 181 | void SystemStateInfo::ReadProcNetDevLine( |
| 182 | const StringPiece& dev_string, NetworkValues* result) { |
| 183 | StringPiece sp(dev_string); |
| 184 | // Lines can have leading whitespace |
| 185 | StripWhiteSpace(&sp); |
| 186 | |
| 187 | // Initialize result to 0 to simplify error handling below |
| 188 | memset(result, 0, sizeof(*result)); |
| 189 | |
| 190 | // Don't include the loopback interface |
| 191 | if (sp.starts_with("lo:")) return; |
| 192 | |
| 193 | int colon_idx = sp.find_first_of(':'); |
| 194 | if (colon_idx == StringPiece::npos) { |
| 195 | KLOG_EVERY_N_SECS(WARNING, 60) << "Failed to parse interface name in line: " |
| 196 | << sp.as_string(); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | ReadIntArray(sp.substr(colon_idx + 1), NUM_NET_VALUES, result); |
| 201 | } |
| 202 | |
| 203 | void SystemStateInfo::AddNetworkValues(const NetworkValues& a, NetworkValues* b) { |
| 204 | for (int i = 0; i < NUM_NET_VALUES; ++i) (*b)[i] += a[i]; |
nothing calls this directly
no test coverage detected