log_(LOG_LEVEL_ERROR, __FILE__, __LINE__, __VA_ARGS__)
#define WARN(...) \
log_(LOG_LEVEL_WARNING, __FILE__, __LINE__, __VA_ARGS__)
-#define DEBUG(...) \
+#define DBG(...) \
log_(LOG_LEVEL_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
#define DIE(...) \
return real_socket(domain, type, protocol);
}
- DEBUG("socket(%s, %s, %d)\n",
- af_to_name(domain), sock_to_name(type), protocol);
+ DBG("socket(%s, %s, %d)\n",
+ af_to_name(domain), sock_to_name(type), protocol);
/* We must return the replacement socket in case the program uses select()
* or similar on it. */
static int (*real_close)(int);
LOAD_FUNCTION(real_close, "close");
- DEBUG("close(%d)\n", fd);
+ DBG("close(%d)\n", fd);
struct list *entry = remove_sockfd(fd);
if (entry == NULL) {
- DEBUG("close(%d): sockfd not found\n", fd);
+ DBG("close(%d): sockfd not found\n", fd);
return real_close(fd);
}
assert(fd == entry->unix_sockfd);
static int (*real_bind)(int, const struct sockaddr *, socklen_t);
LOAD_FUNCTION(real_bind, "bind");
- DEBUG("bind(%d, ..)\n", sockfd);
+ DBG("bind(%d, ..)\n", sockfd);
if (addr == NULL || addrlen < sizeof(addr->sa_family)
|| addr->sa_family == AF_UNIX
struct list *entry = find_sockfd(sockfd);
if (!entry) {
- DEBUG("bind(%d, ..): sockfd not found\n", sockfd);
+ DBG("bind(%d, ..): sockfd not found\n", sockfd);
return real_bind(sockfd, addr, addrlen);
}
assert(sockfd == entry->unix_sockfd);
- DEBUG("bind(%d, ..): %s %s\n",
- sockfd,
- af_to_name(entry->orig_domain),
- sock_to_name(entry->orig_type));
+ DBG("bind(%d, ..): %s %s\n",
+ sockfd,
+ af_to_name(entry->orig_domain), sock_to_name(entry->orig_type));
struct sockaddr_un sockaddr;
if (set_sockaddr_un(&sockaddr, addr, addrlen) != 0) {
ERROR("connect(%d, ..) failed\n", sockfd);
}
- DEBUG("bind(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path);
+ DBG("bind(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path);
int attempts = 0;
while (attempts < 10) {
static int (*real_listen)(int, int);
LOAD_FUNCTION(real_listen, "listen");
- DEBUG("listen(%d, %d)\n", sockfd, backlog);
+ DBG("listen(%d, %d)\n", sockfd, backlog);
struct list *entry = find_sockfd(sockfd);
if (!entry) {
- DEBUG("listen(%d, %d): sockfd not found\n", sockfd, backlog);
+ DBG("listen(%d, %d): sockfd not found\n", sockfd, backlog);
return real_listen(sockfd, backlog);
}
assert(sockfd == entry->unix_sockfd);
- DEBUG("listen(%d, %d): %s %s\n",
- sockfd, backlog,
- af_to_name(entry->orig_domain),
- sock_to_name(entry->orig_type));
+ DBG("listen(%d, %d): %s %s\n",
+ sockfd, backlog,
+ af_to_name(entry->orig_domain), sock_to_name(entry->orig_type));
if (real_listen(entry->unix_sockfd, backlog) != 0) {
DIE("listen(): failed to listen");
static int (*real_accept)(int, struct sockaddr *, socklen_t *);
LOAD_FUNCTION(real_accept, "accept");
- DEBUG("accept(%d, ..)\n", sockfd);
+ DBG("accept(%d, ..)\n", sockfd);
struct list *entry = find_sockfd(sockfd);
if (!entry) {
- DEBUG("accept(%d, ..): sockfd not found\n", sockfd);
+ DBG("accept(%d, ..): sockfd not found\n", sockfd);
return real_accept(sockfd, addr, addrlen);
}
assert(sockfd == entry->unix_sockfd);
- DEBUG("accept(%d, ..): %s %s\n",
- sockfd,
- af_to_name(entry->orig_domain),
- sock_to_name(entry->orig_type));
+ DBG("accept(%d, ..): %s %s\n",
+ sockfd,
+ af_to_name(entry->orig_domain), sock_to_name(entry->orig_type));
struct sockaddr_un sockaddr;
socklen_t size = sizeof(sockaddr);
if (addr == NULL || addrlen == NULL) {
return sock;
}
- DEBUG("accept(%d, ..): caller requested sockaddr\n", sockfd);
+ DBG("accept(%d, ..): caller requested sockaddr\n", sockfd);
if (*addrlen < size) {
WARN("accept(%d, ..): invalid addrlen from program", sockfd);
static int (*real_connect)(int, const struct sockaddr *, socklen_t);
LOAD_FUNCTION(real_connect, "connect");
- DEBUG("connect(%d, ..)\n", sockfd);
+ DBG("connect(%d, ..)\n", sockfd);
if (addr == NULL || addrlen < sizeof(addr->sa_family)
|| addr->sa_family == AF_UNIX
struct list *entry = find_sockfd(sockfd);
if (!entry) {
- DEBUG("connect(%d, ..): sockfd not found\n", sockfd);
+ DBG("connect(%d, ..): sockfd not found\n", sockfd);
return real_connect(sockfd, addr, addrlen);
}
assert(sockfd == entry->unix_sockfd);
- DEBUG("connect(%d, ..): %s %s\n",
- sockfd,
- af_to_name(entry->orig_domain),
- sock_to_name(entry->orig_type));
+ DBG("connect(%d, ..): %s %s\n",
+ sockfd,
+ af_to_name(entry->orig_domain), sock_to_name(entry->orig_type));
struct sockaddr_un sockaddr;
if (set_sockaddr_un(&sockaddr, addr, addrlen) != 0) {
ERROR("connect(%d, ..) failed\n", sockfd);
}
- DEBUG("connect(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path);
+ DBG("connect(%d, ..): using path '%s'\n", sockfd, sockaddr.sun_path);
if (real_connect(entry->unix_sockfd, (struct sockaddr *)&sockaddr,
sizeof(sockaddr)) != 0) {
static int (*real_getsockname)(int, struct sockaddr *, socklen_t *);
LOAD_FUNCTION(real_getsockname, "getsockname");
- DEBUG("getsockname(%d, ..)\n", sockfd);
+ DBG("getsockname(%d, ..)\n", sockfd);
return real_getsockname(sockfd, addr, addrlen);
}
static int (*real_getpeername)(int, struct sockaddr *, socklen_t *);
LOAD_FUNCTION(real_getpeername, "getpeername");
- DEBUG("getpeername(%d, ..)\n", sockfd);
+ DBG("getpeername(%d, ..)\n", sockfd);
return real_getpeername(sockfd, addr, addrlen);
}
static int (*real_getsockopt)(int, int, int, void *, socklen_t *);
LOAD_FUNCTION(real_getsockopt, "getsockopt");
- DEBUG("getsockopt(%d, %d %s, %d, ..)\n",
- sockfd,
- level, level_to_name(level),
- optname);
+ DBG("getsockopt(%d, %d %s, %d, ..)\n",
+ sockfd, level, level_to_name(level), optname);
return real_getsockopt(sockfd, level, optname, optval, optlen);
}
static int (*real_setsockopt)(int, int, int, const void *, socklen_t);
LOAD_FUNCTION(real_setsockopt, "setsockopt");
- DEBUG("setsockopt(%d, %d %s, %d, ..)\n",
- sockfd,
- level, level_to_name(level),
- optname);
+ DBG("setsockopt(%d, %d %s, %d, ..)\n",
+ sockfd, level, level_to_name(level), optname);
return real_setsockopt(sockfd, level, optname, optval, optlen);
}