| 10 | } |
| 11 | |
| 12 | int traffic_status(struct ff_traffic_args *traffic) |
| 13 | { |
| 14 | int ret; |
| 15 | struct ff_msg *msg, *retmsg = NULL; |
| 16 | |
| 17 | msg = ff_ipc_msg_alloc(); |
| 18 | if (msg == NULL) { |
| 19 | errno = ENOMEM; |
| 20 | return -1; |
| 21 | } |
| 22 | |
| 23 | msg->msg_type = FF_TRAFFIC; |
| 24 | ret = ff_ipc_send(msg); |
| 25 | if (ret < 0) { |
| 26 | errno = EPIPE; |
| 27 | ff_ipc_msg_free(msg); |
| 28 | return -1; |
| 29 | } |
| 30 | |
| 31 | do { |
| 32 | if (retmsg != NULL) { |
| 33 | ff_ipc_msg_free(retmsg); |
| 34 | } |
| 35 | |
| 36 | ret = ff_ipc_recv(&retmsg, msg->msg_type); |
| 37 | if (ret < 0) { |
| 38 | errno = EPIPE; |
| 39 | return -1; |
| 40 | } |
| 41 | } while (msg != retmsg); |
| 42 | |
| 43 | *traffic = retmsg->traffic; |
| 44 | |
| 45 | ff_ipc_msg_free(msg); |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | int main(int argc, char **argv) |
| 51 | { |
no test coverage detected