You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Paul Querna <ch...@force-elite.com> on 2004/12/31 01:35:50 UTC
[PATCH] Multicast Support
Attached is the implemented APR Multicast API.
It has support for both IPv4 and IPv6.
The attached version works on FreeBSD and OS X, the two platforms I
mostly care about. There is work that must done for Win32, Linux and
Netware to support all features.
No one commented on the base name of the API... I have left it as
apr_mcast for now, as that is the shortest. Alternatives include
apr_multicast, apr_socket_mcast or apr_socket_multicast.
Also attached are a simple send/recv program using this API and a
Makefile I used to compile them.
I hope to commit the patch this weekend... I would love comments on any
part of it.
Thanks,
-Paul Querna
Re: [PATCH] Multicast Support
Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Thu, Dec 30, 2004 at 07:46:55PM -0800, Paul Querna wrote:
> I haven't done anything with SSM, but I agree it would be nice to have a
> single API if this is a feature that will be widely used.
It's already in wide use in some spheres, it's the only form of
multicast that has realistic DoS prevention (with ASM, arbitrary
multicast users can trivially join and flood a group id). I'll have at
least on APR-based SSM implementation ready in a few months anyway, for
widescale virus signature updating.
> >Passing "iface" as a sockaddr is not going to be portable, the API's on
> >some systems (Win32 and Linux, using IPv6) for example prefer interface
> >names as the references. Using a string might be better, as it's
> >possible to convert strings to interface numbers ( if_nametoindex() ) and
> >sockaddr's ( inet_addr() ).
>
> I made is a sockaddr, because I believed that to be the most portable.
Same here, and then I ran into problems ...
> Interface names are per-OS. (eg win32, linux, freebsd, and solaris are
> all different). This means if I want cross platform or even cross
> machine configuration, it must not use the interface name, but a network
> address. (Cross Machine: eg, some machines have Intel Cards, others have
> Broadcom, in FreeBSD these have different interface names.)
>
> I welcome a better solution... :)
I resorted to user specifying either something like "eth0" or "1.1.1.1"
depending on their platform. One very ugly solution, but about all that
is portable. Even this isn't foolproof, there is no self-consistent way
between IPv4 and IPv6 to do this on win32.
For the *nix's, some consistency can be got by abandoning the ip_mreq
API and using the group_req one instead - but this is flaky, on *BSD you
need to running a bleeding-edge KAME stack and on Linux you need to
manually define the structures and defines, because the system headers
are broken (oh and you need to be running a pretty recent 2.6 kernel).
But ultimately, the group_req API is far superiour technically.
> I thought that for any OS that prefers the interface name/number, we can
> always map the sockaddr to that interface pretty easily.
Win32 with IPv6 was my stumbling block with that approach :/ But it's
probably best ignored for these purposes.
I've tested on Linux anyway, the send/recv apps work fine in IPv6, recv
works fine in IPv4, there's a kink in my system for sending IPv4
- but I havn't had a chance to look at it yet, I doubt it's anything in
the multicast code though, since sending packets should be identical
for unicast and multicast.
I'll be back in my dev environment on Tuesday, where I can subject it to
the full rigours of our multicast test-lab and feed-back more, I'll
submit some group_req-based SSM code at some point too (unless someone
beats me to it).
--
Colm MacCárthaigh Public Key: colm+pgp@stdlib.net
Re: [PATCH] Multicast Support
Posted by Paul Querna <ch...@force-elite.com>.
Colm MacCarthaigh wrote:
> On Thu, Dec 30, 2004 at 04:35:50PM -0800, Paul Querna wrote:
>
>>+static apr_status_t do_mcast_opt(int type, apr_socket_t *sock,
>>+ apr_byte_t value)
>>I hope to commit the patch this weekend... I would love comments on any
>>part of it.
>
>
> It might be useful to abstract to a slightly higher level and include
> support for Source-Specific Multicast (SSM) in the API now, even if an
> implementation is premature. All this boils down to is adding a
>
> "apr_sockaddr_t * source"
>
> argument to the API calls, for now it can be a mandatory NULL, with a
> NOTIMP return if it's defined. But later when SSM is implemented (I'll
> submit a patch ;) this means the same API can be used. This is where
> Multicast is supposed to be headed anyway :)
>
I haven't done anything with SSM, but I agree it would be nice to have a
single API if this is a feature that will be widely used.
> Passing "iface" as a sockaddr is not going to be portable, the API's on
> some systems (Win32 and Linux, using IPv6) for example prefer interface
> names as the references. Using a string might be better, as it's
> possible to convert strings to interface numbers ( if_nametoindex() ) and
> sockaddr's ( inet_addr() ).
I made is a sockaddr, because I believed that to be the most portable.
Interface names are per-OS. (eg win32, linux, freebsd, and solaris are
all different). This means if I want cross platform or even cross
machine configuration, it must not use the interface name, but a network
address. (Cross Machine: eg, some machines have Intel Cards, others have
Broadcom, in FreeBSD these have different interface names.)
I welcome a better solution... :)
I thought that for any OS that prefers the interface name/number, we can
always map the sockaddr to that interface pretty easily.
>>+static int sock_is_ipv4(apr_socket_t* sock)
>>+{
>>+ if (sock->local_addr->family == APR_INET)
>>+ return 1;
>>+ return 0;
>>+}
>>+
>>+#if APR_HAVE_IPV6
>>+static int sock_is_ipv6(apr_socket_t* sock)
>>+{
>>+ if (sock->local_addr->family == APR_INET6)
>>+ return 1;
>>+ return 0;
>>+}
>
>
> These functions are not specific to multicast and might be better placed
> non-static in sockaddr.c or sockets.c ? They look useful :) Otherwise
> why not make them macros ?
>
No disagreement here, I just made them for myself for pure convenience.
>
>>+/**
>>+ * Join a Multicast Group
>>+ * @param sock The socket to join a multicast group
>>+ * @param join The address of the multicast group to join
>>+ * @param iface Address of the interface to use. If NULL is passed, the
>>+ * defautl multicast interface will be used. (OS Dependent)
>>+ */
>
>
> Default is mis-spelled a few times :)
>
Opps. Copy and Paste got me into trouble again.
Thanks for feedback, everything helps.
-Paul
Re: [PATCH] Multicast Support
Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Thu, Dec 30, 2004 at 04:35:50PM -0800, Paul Querna wrote:
> +static apr_status_t do_mcast_opt(int type, apr_socket_t *sock,
> + apr_byte_t value)
> I hope to commit the patch this weekend... I would love comments on any
> part of it.
It might be useful to abstract to a slightly higher level and include
support for Source-Specific Multicast (SSM) in the API now, even if an
implementation is premature. All this boils down to is adding a
"apr_sockaddr_t * source"
argument to the API calls, for now it can be a mandatory NULL, with a
NOTIMP return if it's defined. But later when SSM is implemented (I'll
submit a patch ;) this means the same API can be used. This is where
Multicast is supposed to be headed anyway :)
Passing "iface" as a sockaddr is not going to be portable, the API's on
some systems (Win32 and Linux, using IPv6) for example prefer interface
names as the references. Using a string might be better, as it's
possible to convert strings to interface numbers ( if_nametoindex() ) and
sockaddr's ( inet_addr() ).
See mnc_multicast.c in
http://people.heanet.ie/~colmmacc/mnc/mnc-1.3.tar.gz
for my last stab at an IPv6/IPv6 ASM/SSM *nix/Win32 portable Multicast
abstraction.
> +static int sock_is_ipv4(apr_socket_t* sock)
> +{
> + if (sock->local_addr->family == APR_INET)
> + return 1;
> + return 0;
> +}
> +
> +#if APR_HAVE_IPV6
> +static int sock_is_ipv6(apr_socket_t* sock)
> +{
> + if (sock->local_addr->family == APR_INET6)
> + return 1;
> + return 0;
> +}
These functions are not specific to multicast and might be better placed
non-static in sockaddr.c or sockets.c ? They look useful :) Otherwise
why not make them macros ?
> +/**
> + * Join a Multicast Group
> + * @param sock The socket to join a multicast group
> + * @param join The address of the multicast group to join
> + * @param iface Address of the interface to use. If NULL is passed, the
> + * defautl multicast interface will be used. (OS Dependent)
> + */
Default is mis-spelled a few times :)
I havn't had a chance to compile it yet (just battling with subversion
now), might be back with Linux hackery.
--
Colm MacCárthaigh Public Key: colm+pgp@stdlib.net