* multicast? @ 2004-11-30 19:36 Greg Troxel 2004-11-30 21:03 ` multicast? [patch] Greg Troxel 0 siblings, 1 reply; 5+ messages in thread From: Greg Troxel @ 2004-11-30 19:36 UTC (permalink / raw) I'm writing a program with guile (1.6.5) and guile-gnome. 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. I don't see anything in HEAD either. Has anyone written this? -- Greg Troxel <gdt@ir.bbn.com> _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multicast? [patch] 2004-11-30 19:36 multicast? Greg Troxel @ 2004-11-30 21:03 ` Greg Troxel 2004-12-23 13:34 ` Marius Vollmer 0 siblings, 1 reply; 5+ messages in thread From: Greg Troxel @ 2004-11-30 21:03 UTC (permalink / raw) 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 <gdt@ir.bbn.com> _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multicast? [patch] 2004-11-30 21:03 ` multicast? [patch] Greg Troxel @ 2004-12-23 13:34 ` Marius Vollmer 2004-12-23 20:48 ` Greg Troxel 2005-02-27 23:58 ` Marius Vollmer 0 siblings, 2 replies; 5+ messages in thread From: Marius Vollmer @ 2004-12-23 13:34 UTC (permalink / raw) Cc: guile-user Greg Troxel <gdt@ir.bbn.com> writes: > [a nice patch] I'm not completely sure what to do with this. Adding more multicast functinoality is certainly very good and needs to happen. On the other hand, can we hope to ever cover all socket options that are out there? Maybe we should have different functions for different kinds of socket options, or maybe not. Opinions? I will install your patch anyway, but I'm afraid we need the papers... more about this in private mail. _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multicast? [patch] 2004-12-23 13:34 ` Marius Vollmer @ 2004-12-23 20:48 ` Greg Troxel 2005-02-27 23:58 ` Marius Vollmer 1 sibling, 0 replies; 5+ messages in thread From: Greg Troxel @ 2004-12-23 20:48 UTC (permalink / raw) Cc: guile-user I'm not completely sure what to do with this. Adding more multicast functinoality is certainly very good and needs to happen. This is really all that's needed - joining groups and setting TTL. As a scripting language, guile should support all the normal network operations. I don't find making setsockopt fancier a bad thing. It would be cool to have a table of commands and types, but then it's more like g-wrap. -- Greg Troxel <gdt@ir.bbn.com> _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multicast? [patch] 2004-12-23 13:34 ` Marius Vollmer 2004-12-23 20:48 ` Greg Troxel @ 2005-02-27 23:58 ` Marius Vollmer 1 sibling, 0 replies; 5+ messages in thread From: Marius Vollmer @ 2005-02-27 23:58 UTC (permalink / raw) Cc: guile-user Marius Vollmer <marius.vollmer@uni-dortmund.de> writes: > I will install your patch anyway, [...] Ok, it is in HEAD now. 2005-02-28 Marius Vollmer <mvo@zagadka.de> * socket.c (scm_setsockopt): Handle IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP options. Also, reorganized the code a bit for cleanliness. (scm_init_socket): Define IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. Thanks to Greg Troxel! -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-02-27 23:58 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-11-30 19:36 multicast? Greg Troxel 2004-11-30 21:03 ` multicast? [patch] Greg Troxel 2004-12-23 13:34 ` Marius Vollmer 2004-12-23 20:48 ` Greg Troxel 2005-02-27 23:58 ` Marius Vollmer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).