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>
9 extern int debug_level
;
11 #define D(level, format, ...) \
13 if (debug_level >= level) \
14 fprintf(stderr, "DEBUG: %s(%d) " format "\n", \
15 __func__, __LINE__, ##__VA_ARGS__); \
18 #define DC(level, cl, format, ...) \
19 D(level, "[%s(%d)] " format, cl->proc_name, cl->pid, ##__VA_ARGS__)
22 struct list_head list
;
23 struct list_head bufs
;
34 struct udebug_client_msg msg
;
36 struct blob_attr data
;
39 } __attribute__((packed
,aligned(4))) rx_buf
;
43 struct list_head list
;
49 uint32_t ring_size
, data_size
;
51 struct blob_attr
*flags
;
54 extern struct avl_tree rings
;
56 void client_alloc(int fd
);
57 struct client_ring
*client_ring_alloc(struct client
*cl
);
58 struct client_ring
*client_ring_get_by_id(struct client
*cl
, uint32_t id
);
59 void client_ring_free(struct client_ring
*r
);
61 static inline uint32_t ring_id(struct client_ring
*r
)
63 return (uint32_t)(uintptr_t)r
->node
.key
;
66 static inline struct client_ring
*ring_get_by_id(uint32_t id
)
68 struct client_ring
*r
;
69 void *key
= (void *)(uintptr_t)id
;
71 return avl_find_element(&rings
, key
, r
, node
);
74 void udebug_ubus_init(void);
75 void udebug_ubus_ring_notify(struct client_ring
*r
, bool add
);
76 void udebug_ubus_free(void);