1 #ifndef __UDEBUG_SERVER_H
2 #define __UDEBUG_SERVER_H
4 #include <libubox/list.h>
5 #include <libubox/uloop.h>
6 #include <libubox/avl.h>
7 #include <libubox/blobmsg.h>
8 #include <libubox/udebug.h>
9 #include <libubox/udebug-proto.h>
11 extern int debug_level
;
13 #define D(level, format, ...) \
15 if (debug_level >= level) \
16 fprintf(stderr, "DEBUG: %s(%d) " format "\n", \
17 __func__, __LINE__, ##__VA_ARGS__); \
20 #define DC(level, cl, format, ...) \
21 D(level, "[%s(%d)] " format, cl->proc_name, cl->pid, ##__VA_ARGS__)
24 struct list_head list
;
25 struct list_head bufs
;
36 struct udebug_client_msg msg
;
38 struct blob_attr data
;
41 } __attribute__((packed
,aligned(4))) rx_buf
;
45 struct list_head list
;
51 uint32_t ring_size
, data_size
;
53 struct blob_attr
*flags
;
56 extern struct avl_tree rings
;
58 void client_alloc(int fd
);
59 struct client_ring
*client_ring_alloc(struct client
*cl
);
60 struct client_ring
*client_ring_get_by_id(struct client
*cl
, uint32_t id
);
61 void client_ring_free(struct client_ring
*r
);
63 static inline uint32_t ring_id(struct client_ring
*r
)
65 return (uint32_t)(uintptr_t)r
->node
.key
;
68 static inline struct client_ring
*ring_get_by_id(uint32_t id
)
70 struct client_ring
*r
;
71 void *key
= (void *)(uintptr_t)id
;
73 return avl_find_element(&rings
, key
, r
, node
);
76 void udebug_ubus_init(void);
77 void udebug_ubus_ring_notify(struct client_ring
*r
, bool add
);
78 void udebug_ubus_free(void);