+struct client {
+ struct list_head list;
+
+ struct ustream_fd s;
+ int fd;
+};
+
+static void
+client_close(struct ustream *s)
+{
+ struct client *cl = container_of(s, struct client, s.stream);
+
+ list_del(&cl->list);
+ ustream_free(s);
+ close(cl->fd);
+ free(cl);
+}
+
+static void client_notify_state(struct ustream *s)
+{
+ client_close(s);
+}
+
+static void client_notify_write(struct ustream *s, int bytes)
+{
+ if (ustream_pending_data(s, true))
+ return;
+
+ client_close(s);
+}
+
+static void
+log_fill_msg(struct blob_buf *b, struct log_head *l)
+{
+ blobmsg_add_string(b, "msg", l->data);
+ blobmsg_add_u32(b, "id", l->id);
+ blobmsg_add_u32(b, "priority", l->priority);
+ blobmsg_add_u32(b, "source", l->source);
+ blobmsg_add_u64(b, "time", (((__u64) l->ts.tv_sec) * 1000) + (l->ts.tv_nsec / 1000000));
+}
+