Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Aug 2000 05:30:00 +0200
From:      Bjoern Fischer <bfischer@Techfak.Uni-Bielefeld.DE>
To:        Vinod Mukkamala <vmukkama@gmu.edu>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: socket option IP_MULTICAST_LOOP has no effect?
Message-ID:  <20000830052959.C873@frolic.no-support.loc>
In-Reply-To: <Pine.OSF.4.21.0008291552210.5932-100000@osf1.gmu.edu>; from vmukkama@gmu.edu on Tue, Aug 29, 2000 at 03:56:25PM -0400
References:  <Pine.OSF.4.21.0008291552210.5932-100000@osf1.gmu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 29, 2000 at 03:56:25PM -0400, Vinod Mukkamala wrote:
>     For some reason setsockopt function takes in the a address of a char
> as the 4th argument only.
[code example typos corrected]
>=20
> int tmp =3D 0;  // to disable loop back
>  setsockopt(s,
>       IPPROTO_IP,
>       IP_MULTICAST_LOOP,
>       (char *)&tmp,
>       sizeof(tmp));
>=20
> and it didn't work...=20
>=20
> but=20
>=20
> char tmp =3D 0; // to disable loop back
>  setsockopt(s,
>       IPPROTO_IP,
>       IP_MULTICAST_LOOP,
>       (char *)&tmp,
>       sizeof(tmp));
>=20
> works perfectly fine.=20

Thank you a lot for your help, I will try this as soon as possible,
but there's something weird:

  case IP_MULTICAST_LOOP:
      /*
       * Set the loopback flag for outgoing multicast packets.
       * Must be zero or one.  The original multicast API required a
       * char argument, which is inconsistent with the rest
       * of the socket API.  We allow either a char or an int.
       */
      if (sopt->sopt_valsize =3D=3D 1) {
              u_char loop;
              error =3D sooptcopyin(sopt, &loop, 1, 1);
              if (error)
                      break;
              imo->imo_multicast_loop =3D !!loop;
      } else {
              u_int loop;
              error =3D sooptcopyin(sopt, &loop, sizeof loop,
                                  sizeof loop);
              if (error)
                      break;
              imo->imo_multicast_loop =3D !!loop;
      }
      break;

This piece of code is out of FreeBSD 4-STABLE's kernel source.
As you see it should deal with both: ints *and* chars. The
code seems to be correct, so I wonder why it's not working
with ints.

  Bj=F6rn Fischer

--=20
-----BEGIN GEEK CODE BLOCK-----
GCS d--(+) s++: a- C+++(-) UB++++OSI++++$ P+++(-) L---(++) !E W- N+ o>+
K- !w !O !M !V  PS++  PE-  PGP++  t+++  !5 X++ tv- b+++ D++ G e+ h-- y+=20
------END GEEK CODE BLOCK------


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000830052959.C873>