From owner-svn-ports-all@freebsd.org Sun Apr 10 23:10:51 2016 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 08C93B0A1D0; Sun, 10 Apr 2016 23:10:51 +0000 (UTC) (envelope-from ehaupt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D791615E4; Sun, 10 Apr 2016 23:10:50 +0000 (UTC) (envelope-from ehaupt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3ANAouZ091379; Sun, 10 Apr 2016 23:10:50 GMT (envelope-from ehaupt@FreeBSD.org) Received: (from ehaupt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3ANAnUV091377; Sun, 10 Apr 2016 23:10:49 GMT (envelope-from ehaupt@FreeBSD.org) Message-Id: <201604102310.u3ANAnUV091377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ehaupt set sender to ehaupt@FreeBSD.org using -f From: Emanuel Haupt Date: Sun, 10 Apr 2016 23:10:49 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r412989 - in head/net/mdns-repeater: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2016 23:10:51 -0000 Author: ehaupt Date: Sun Apr 10 23:10:49 2016 New Revision: 412989 URL: https://svnweb.freebsd.org/changeset/ports/412989 Log: Fix interface binding & error messages. PR: 208652 Submitted by: johan Added: head/net/mdns-repeater/files/patch-mdns-repeater.c (contents, props changed) Modified: head/net/mdns-repeater/Makefile Modified: head/net/mdns-repeater/Makefile ============================================================================== --- head/net/mdns-repeater/Makefile Sun Apr 10 22:33:00 2016 (r412988) +++ head/net/mdns-repeater/Makefile Sun Apr 10 23:10:49 2016 (r412989) @@ -3,7 +3,7 @@ PORTNAME= mdns-repeater PORTVERSION= 1.10 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net dns MASTER_SITES= LOCAL/ehaupt Added: head/net/mdns-repeater/files/patch-mdns-repeater.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/mdns-repeater/files/patch-mdns-repeater.c Sun Apr 10 23:10:49 2016 (r412989) @@ -0,0 +1,145 @@ +--- mdns-repeater.c.orig 2015-04-03 07:03:21 UTC ++++ mdns-repeater.c +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + + #define PACKAGE "mdns-repeater" + #define MDNS_ADDR "224.0.0.251" +@@ -79,7 +80,7 @@ void log_message(int loglevel, char *fmt + static int create_recv_sock() { + int sd = socket(AF_INET, SOCK_DGRAM, 0); + if (sd < 0) { +- log_message(LOG_ERR, "recv socket(): %m"); ++ log_message(LOG_ERR, "recv socket(): %s", strerror(errno)); + return sd; + } + +@@ -87,7 +88,7 @@ static int create_recv_sock() { + + int on = 1; + if ((r = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) < 0) { +- log_message(LOG_ERR, "recv setsockopt(SO_REUSEADDR): %m"); ++ log_message(LOG_ERR, "recv setsockopt(SO_REUSEADDR): %s", strerror(errno)); + return r; + } + +@@ -98,18 +99,18 @@ static int create_recv_sock() { + serveraddr.sin_port = htons(MDNS_PORT); + serveraddr.sin_addr.s_addr = htonl(INADDR_ANY); /* receive multicast */ + if ((r = bind(sd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))) < 0) { +- log_message(LOG_ERR, "recv bind(): %m"); ++ log_message(LOG_ERR, "recv bind(): %s", strerror(errno)); + } + + // enable loopback in case someone else needs the data + if ((r = setsockopt(sd, IPPROTO_IP, IP_MULTICAST_LOOP, &on, sizeof(on))) < 0) { +- log_message(LOG_ERR, "recv setsockopt(IP_MULTICAST_LOOP): %m"); ++ log_message(LOG_ERR, "recv setsockopt(IP_MULTICAST_LOOP): %s", strerror(errno)); + return r; + } + + #ifdef IP_PKTINFO + if ((r = setsockopt(sd, SOL_IP, IP_PKTINFO, &on, sizeof(on))) < 0) { +- log_message(LOG_ERR, "recv setsockopt(IP_PKTINFO): %m"); ++ log_message(LOG_ERR, "recv setsockopt(IP_PKTINFO): %s", strerror(errno)); + return r; + } + #endif +@@ -120,7 +121,7 @@ static int create_recv_sock() { + static int create_send_sock(int recv_sockfd, const char *ifname, struct if_sock *sockdata) { + int sd = socket(AF_INET, SOCK_DGRAM, 0); + if (sd < 0) { +- log_message(LOG_ERR, "send socket(): %m"); ++ log_message(LOG_ERR, "send socket(): %s", strerror(errno)); + return sd; + } + +@@ -136,7 +137,7 @@ static int create_send_sock(int recv_soc + + #ifdef SO_BINDTODEVICE + if ((r = setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(struct ifreq))) < 0) { +- log_message(LOG_ERR, "send setsockopt(SO_BINDTODEVICE): %m"); ++ log_message(LOG_ERR, "send setsockopt(SO_BINDTODEVICE): %s", strerror(errno)); + return r; + } + #endif +@@ -156,7 +157,7 @@ static int create_send_sock(int recv_soc + + int on = 1; + if ((r = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) < 0) { +- log_message(LOG_ERR, "send setsockopt(SO_REUSEADDR): %m"); ++ log_message(LOG_ERR, "send setsockopt(SO_REUSEADDR): %s", strerror(errno)); + return r; + } + +@@ -167,22 +168,28 @@ static int create_send_sock(int recv_soc + serveraddr.sin_port = htons(MDNS_PORT); + serveraddr.sin_addr.s_addr = if_addr->s_addr; + if ((r = bind(sd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))) < 0) { +- log_message(LOG_ERR, "send bind(): %m"); ++ log_message(LOG_ERR, "send bind(): %s", strerror(errno)); + } + ++#if __FreeBSD__ ++ if((r = setsockopt(sd, IPPROTO_IP, IP_MULTICAST_IF, &serveraddr.sin_addr, sizeof(serveraddr.sin_addr))) < 0) { ++ log_message(LOG_ERR, "send ip_multicast_if(): errno %d: %s", errno, strerror(errno)); ++ } ++#endif ++ + // add membership to receiving socket + struct ip_mreq mreq; + memset(&mreq, 0, sizeof(struct ip_mreq)); + mreq.imr_interface.s_addr = if_addr->s_addr; + mreq.imr_multiaddr.s_addr = inet_addr(MDNS_ADDR); + if ((r = setsockopt(recv_sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))) < 0) { +- log_message(LOG_ERR, "recv setsockopt(IP_ADD_MEMBERSHIP): %m"); ++ log_message(LOG_ERR, "recv setsockopt(IP_ADD_MEMBERSHIP): %s", strerror(errno)); + return r; + } + + // enable loopback in case someone else needs the data + if ((r = setsockopt(sd, IPPROTO_IP, IP_MULTICAST_LOOP, &on, sizeof(on))) < 0) { +- log_message(LOG_ERR, "send setsockopt(IP_MULTICAST_LOOP): %m"); ++ log_message(LOG_ERR, "send setsockopt(IP_MULTICAST_LOOP): %s", strerror(errno)); + return r; + } + +@@ -249,7 +256,7 @@ static void daemonize() { + pid_t running_pid; + pid_t pid = fork(); + if (pid < 0) { +- log_message(LOG_ERR, "fork(): %m"); ++ log_message(LOG_ERR, "fork(): %s", strerror(errno)); + exit(1); + } + +@@ -385,7 +392,7 @@ int main(int argc, char *argv[]) { + + pkt_data = malloc(PACKET_SIZE); + if (pkt_data == NULL) { +- log_message(LOG_ERR, "cannot malloc() packet buffer: %m"); ++ log_message(LOG_ERR, "cannot malloc() packet buffer: %s", strerror(errno)); + r = 1; + goto end_main; + } +@@ -409,7 +416,7 @@ int main(int argc, char *argv[]) { + ssize_t recvsize = recvfrom(server_sockfd, pkt_data, PACKET_SIZE, 0, + (struct sockaddr *) &fromaddr, &sockaddr_size); + if (recvsize < 0) { +- log_message(LOG_ERR, "recv(): %m"); ++ log_message(LOG_ERR, "recv(): %s", strerror(errno)); + } + + int j; +@@ -440,7 +447,7 @@ int main(int argc, char *argv[]) { + ssize_t sentsize = send_packet(socks[j].sockfd, pkt_data, (size_t) recvsize); + if (sentsize != recvsize) { + if (sentsize < 0) +- log_message(LOG_ERR, "send()"); ++ log_message(LOG_ERR, "send(): %s", strerror(errno)); + else + log_message(LOG_ERR, "send_packet size differs: sent=%ld actual=%ld", + recvsize, sentsize);