From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Greg Troxel Newsgroups: gmane.lisp.guile.user Subject: Re: multicast? [patch] Date: 30 Nov 2004 16:03:32 -0500 Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1101848630 28918 80.91.229.6 (30 Nov 2004 21:03:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 30 Nov 2004 21:03:50 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Nov 30 22:03:41 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CZF9x-0008Vv-00 for ; Tue, 30 Nov 2004 22:03:41 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CZFJP-00012A-9V for guile-user@m.gmane.org; Tue, 30 Nov 2004 16:13:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CZFJK-00011m-On for guile-user@gnu.org; Tue, 30 Nov 2004 16:13:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CZFJJ-00011N-SI for guile-user@gnu.org; Tue, 30 Nov 2004 16:13:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CZFJJ-00011K-Ns for guile-user@gnu.org; Tue, 30 Nov 2004 16:13:21 -0500 Original-Received: from [192.1.100.210] (helo=fnord.ir.bbn.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CZF9p-0000j3-1y for guile-user@gnu.org; Tue, 30 Nov 2004 16:03:33 -0500 Original-Received: by fnord.ir.bbn.com (Postfix, from userid 10853) id 680E4203F; Tue, 30 Nov 2004 16:03:32 -0500 (EST) Original-To: guile-user@gnu.org In-Reply-To: Original-Lines: 66 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:3803 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:3803 I have created a socket, bound it to a port and connected it to a mcast destination address and port. Sending works fine. Looking in libguile/socket.c, I can't find support for joining multicast groups. This is via setsockopt with struct mreq. --- libguile/socket.c.orig 2004-08-26 22:16:38.000000000 -0400 +++ libguile/socket.c @@ -563,12 +563,18 @@ SCM_DEFINE (scm_setsockopt, "setsockopt" { int fd; int optlen = -1; + /* size of optval is the largest supported option. */ + union bigopt { + size_t a; #ifdef HAVE_STRUCT_LINGER - char optval[sizeof (struct linger)]; -#else - char optval[sizeof (size_t)]; + struct linger l; #endif + struct ip_mreq m; + }; + /* XXX: why not just use the union? */ + char optval[sizeof (union bigopt) + 20]; + int ilevel, ioptname; sock = SCM_COERCE_OUTPORT (sock); @@ -630,6 +636,21 @@ SCM_DEFINE (scm_setsockopt, "setsockopt" (*(size_t *) optval) = (size_t) lv; } } + + if (ilevel == IPPROTO_IP && + (ioptname == IP_ADD_MEMBERSHIP || ioptname == IP_DROP_MEMBERSHIP)) + { + struct ip_mreq mreq; + + /* Fourth argument must be a pair of addresses. */ + SCM_ASSERT (SCM_CONSP (value), value, SCM_ARG4, FUNC_NAME); + mreq.imr_multiaddr.s_addr = htonl(SCM_NUM2ULONG (4, SCM_CAR (value))); + mreq.imr_interface.s_addr = htonl(SCM_NUM2ULONG (4, SCM_CDR (value))); + + memcpy(optval, &mreq, sizeof(mreq)); + optlen = sizeof(mreq); + } + if (optlen == -1) { /* Most options take an int. */ @@ -1393,6 +1414,11 @@ scm_init_socket () scm_c_define ("MSG_DONTROUTE", SCM_MAKINUM (MSG_DONTROUTE)); #endif +#ifdef IP_ADD_MEMBERSHIP + scm_c_define ("IP_ADD_MEMBERSHIP", SCM_MAKINUM (IP_ADD_MEMBERSHIP)); + scm_c_define ("IP_DROP_MEMBERSHIP", SCM_MAKINUM (IP_DROP_MEMBERSHIP)); +#endif + scm_add_feature ("socket"); #include "libguile/socket.x" -- Greg Troxel _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user