2018-03-26 14:46:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/*! Determine number of elements in an array of static size */
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
|
2018-03-26 16:21:03 +00:00
|
|
|
#define LOG(fmt, args ...) \
|
|
|
|
fprintf(stderr, ">>> UDTRACE: " fmt, ## args)
|
|
|
|
|
2018-10-31 12:14:20 +00:00
|
|
|
typedef void (*udtrace_dissector)(int fd, bool is_out, const char *fn,
|
|
|
|
const uint8_t *data, unsigned int len);
|
|
|
|
|
|
|
|
struct sock_state {
|
|
|
|
int fd;
|
|
|
|
const char *path;
|
|
|
|
udtrace_dissector dissector;
|
|
|
|
};
|
|
|
|
|
2018-10-31 12:06:30 +00:00
|
|
|
/* find the state corresponding to a given file descriptor */
|
|
|
|
struct sock_state *udtrace_sstate_by_fd(int fd);
|
|
|
|
|
2018-03-26 14:46:52 +00:00
|
|
|
/* add a file descriptor from the list of to-be-traced ones */
|
2018-03-26 16:21:03 +00:00
|
|
|
void udtrace_add_fd(int fd);
|
2018-03-26 14:46:52 +00:00
|
|
|
|
|
|
|
/* delete a file descriptor from the list of to-be-traced ones */
|
2018-03-26 16:21:03 +00:00
|
|
|
void udtrace_del_fd(int fd);
|
|
|
|
|
|
|
|
/* set the path of a given fd */
|
|
|
|
void udtrace_fd_set_path(int fd, const char *path);
|
2018-03-26 14:46:52 +00:00
|
|
|
|
|
|
|
/* is the given file descriptor part of the to-be-traced unix domain fd's? */
|
|
|
|
bool is_unix_socket(int fd);
|
|
|
|
|
2018-03-26 16:21:03 +00:00
|
|
|
void udtrace_data(int fd, bool is_out, const char *fn, const uint8_t *data, unsigned int len);
|