| 348 | } |
| 349 | |
| 350 | static void |
| 351 | perform_command(telemetry_cb fn, const char *cmd, const char *param, int s) |
| 352 | { |
| 353 | struct rte_tel_data data = {0}; |
| 354 | |
| 355 | int ret = fn(cmd, param, &data); |
| 356 | if (ret < 0) { |
| 357 | char out_buf[MAX_CMD_LEN + 10]; |
| 358 | int used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":null}", |
| 359 | MAX_CMD_LEN, cmd ? cmd : "none"); |
| 360 | if (write(s, out_buf, used) < 0) |
| 361 | perror("Error writing to socket"); |
| 362 | return; |
| 363 | } |
| 364 | output_json(cmd, &data, s); |
| 365 | } |
| 366 | |
| 367 | static int |
| 368 | unknown_command(const char *cmd __rte_unused, const char *params __rte_unused, |
no test coverage detected