X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Fsocket2unix.c;h=12f03f56dd2654ed8fe767b17101f8b8110422c5;hb=f1c354120d8c23511e28edc0ddf0bdaefbe70e5a;hp=1f741b5f5680e9b97d0f09be17540f718523d2cd;hpb=16e3b5325c41eee1aa88ecd4e054be7b608a7810;p=socket2unix%2Fsocket2unix.git diff --git a/src/socket2unix.c b/src/socket2unix.c index 1f741b5..12f03f5 100644 --- a/src/socket2unix.c +++ b/src/socket2unix.c @@ -46,7 +46,7 @@ #define LOG_LEVEL_DEBUG 3 #define LOG_LEVEL_MASK LOG_LEVEL_DEBUG -#define LOG_LEVEL_PERROR 42 +#define LOG_LEVEL_PERROR (1 << 10) #define OPTION_PARSED (1 << 1) /* Don't intercept listen(), accept(). */ @@ -370,10 +370,10 @@ static int set_sockaddr_un(struct sockaddr_un *sockaddr, int port; if (addr->sa_family == AF_INET) { af = "v4"; - port = ntohs(((struct sockaddr_in *)addr)->sin_port); + port = ntohs(((const struct sockaddr_in *)addr)->sin_port); } else if (addr->sa_family == AF_INET6) { af = "v6"; - port = ntohs(((struct sockaddr_in6 *)addr)->sin6_port); + port = ntohs(((const struct sockaddr_in6 *)addr)->sin6_port); } else { af = "unknown"; port = 0; @@ -448,14 +448,14 @@ int close(int fd) { static int (*real_close)(int); LOAD_FUNCTION(real_close, "close"); - DBG("close(%d)\n", fd); - struct list *entry = remove_sockfd(fd); if (entry == NULL) { DBG("close(%d): sockfd not found\n", fd); return real_close(fd); } assert(fd == entry->orig_sockfd); + + DBG("close(%d)\n", fd); free(entry->orig_addr); free(entry); @@ -466,8 +466,6 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { static int (*real_bind)(int, const struct sockaddr *, socklen_t); LOAD_FUNCTION(real_bind, "bind"); - DBG("bind(%d, ..)\n", sockfd); - if (addr == NULL || addrlen < sizeof(addr->sa_family) || addr->sa_family == AF_UNIX || addr->sa_family == AF_LOCAL) { @@ -593,8 +591,6 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { return real_accept(sockfd, addr, addrlen); } - DBG("accept(%d, ..)\n", sockfd); - struct list *entry = find_sockfd(sockfd); if (!entry) { DBG("accept(%d, ..): sockfd not found\n", sockfd); @@ -647,8 +643,6 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { return real_connect(sockfd, addr, addrlen); } - DBG("connect(%d, ..)\n", sockfd); - if (addr == NULL || addrlen < sizeof(addr->sa_family) || addr->sa_family == AF_UNIX || addr->sa_family == AF_LOCAL) {