1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2021 Felix Fietkau <nbd@nbd.name> */
3 #ifndef __MINSTREL_RCD_H
4 #define __MINSTREL_RCD_H
6 #include <libubox/list.h>
7 #include <libubox/vlist.h>
8 #include <libubox/uloop.h>
9 #include <libubox/ustream.h>
10 #include <libubox/utils.h>
18 #define RCD_PORT 0x5243
21 struct vlist_node node
;
23 struct uloop_fd event_fd
;
28 struct list_head list
;
29 struct ustream_fd sfd
;
34 struct list_head list
;
39 static inline const char *phy_name(struct phy
*phy
)
41 return phy
->node
.avl
.key
;
44 extern struct vlist_tree phy_list
;
46 void rcd_server_add(const char *addr
);
47 void rcd_server_init(void);
49 void rcd_client_accept(int fd
);
50 void rcd_client_phy_event(struct phy
*phy
, const char *str
);
51 void rcd_client_set_phy_state(struct client
*cl
, struct phy
*phy
, bool add
);
53 void rcd_phy_init(void);
54 void rcd_phy_init_client(struct client
*cl
);
55 void rcd_phy_dump(struct client
*cl
, struct phy
*phy
);
56 void rcd_phy_control(struct client
*cl
, char *data
);
58 #define client_printf(cl, ...) ustream_printf(&(cl)->sfd.stream, __VA_ARGS__)
59 #define client_phy_printf(cl, phy, fmt, ...) client_printf(cl, "%s;" fmt, phy_name(phy), ## __VA_ARGS__)